Extend the GHC API with breakpoints and breakpoint handlers
[ghc-hetmet.git] / compiler / cmm / CmmOpt.hs
index a23a46f..a3de41c 100644 (file)
@@ -15,22 +15,21 @@ module CmmOpt (
 #include "HsVersions.h"
 
 import Cmm
-import CmmUtils        ( hasNoGlobalRegs )
-import CLabel  ( entryLblToInfoLbl )
+import CmmUtils
+import CLabel
 import MachOp
-import SMRep   ( tablesNextToCode )
+import SMRep
+import StaticFlags
 
 import UniqFM
-import Unique  ( Unique )
-import Panic   ( panic )
+import Unique
 
 import Outputable
 
-import Bits
-import Word
-import Int
-import GLAEXTS
-
+import Data.Bits
+import Data.Word
+import Data.Int
+import GHC.Exts
 
 -- -----------------------------------------------------------------------------
 -- The mini-inliner
@@ -313,8 +312,12 @@ cmmMachOpFold op [x@(CmmLit _), y]
 -- put arg1 on the left of the rearranged expression, we'll get into a
 -- loop:  (x1+x2)+x3 => x1+(x2+x3)  => (x2+x3)+x1 => x2+(x3+x1) ...
 --
+-- Also don't do it if arg1 is PicBaseReg, so that we don't separate the
+-- PicBaseReg from the corresponding label (or label difference).
+--
 cmmMachOpFold mop1 [CmmMachOp mop2 [arg1,arg2], arg3]
-   | mop1 == mop2 && isAssociativeMachOp mop1 && not (isLit arg1)
+   | mop1 == mop2 && isAssociativeMachOp mop1
+     && not (isLit arg1) && not (isPicReg arg1)
    = cmmMachOpFold mop1 [arg1, cmmMachOpFold mop2 [arg2,arg3]]
 
 -- Make a RegOff if we can
@@ -528,3 +531,6 @@ maybeInvertConditionalExpr :: CmmExpr -> Maybe CmmExpr
 maybeInvertConditionalExpr (CmmMachOp op args) 
   | Just op' <- maybeInvertComparison op = Just (CmmMachOp op' args)
 maybeInvertConditionalExpr _ = Nothing
+
+isPicReg (CmmReg (CmmGlobal PicBaseReg)) = True
+isPicReg _ = False
\ No newline at end of file