No need to map over all blocks, setting up PIC.
authorGabor Greif <ggreif@gmail.com>
Thu, 11 Apr 2013 22:20:55 +0000 (00:20 +0200)
committerGabor Greif <ggreif@gmail.com>
Fri, 12 Apr 2013 22:11:51 +0000 (00:11 +0200)
Darwin x86 has inconsistent PIC base register, so splitting (which happened before)
ensures that each cmm procedure only has one entry point (namely the first block).

compiler/nativeGen/PIC.hs

index 5fff8cb..e46a823 100644 (file)
@@ -771,19 +771,11 @@ initializePicBase_x86 ArchX86 os picReg
              BasicBlock bID (X86.FETCHGOT picReg : insns)
 
 initializePicBase_x86 ArchX86 OSDarwin picReg
-        (CmmProc info lab live (ListGraph blocks) : statics)
-        = return (CmmProc info lab live (ListGraph blocks') : statics)
-
-    where blocks' = case blocks of
-                     [] -> []
-                     (b:bs) -> fetchPC b : map maybeFetchPC bs
-
-          maybeFetchPC b@(BasicBlock bID _)
-            | bID `mapMember` info = fetchPC b
-            | otherwise            = b
+        (CmmProc info lab live (ListGraph (entry:blocks)) : statics)
+        = return (CmmProc info lab live (ListGraph (block':blocks)) : statics)
 
-          fetchPC (BasicBlock bID insns) =
-             BasicBlock bID (X86.FETCHPC picReg : insns)
+    where BasicBlock bID insns = entry
+          block' = BasicBlock bID (X86.FETCHPC picReg : insns)
 
 initializePicBase_x86 _ _ _ _
         = panic "initializePicBase_x86: not needed"