Skip to content

Commit

Permalink
No need to map over all blocks, setting up PIC.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ggreif committed Apr 12, 2013
1 parent bad5783 commit 52efb2c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions compiler/nativeGen/PIC.hs
Expand Up @@ -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"
Expand Down

0 comments on commit 52efb2c

Please sign in to comment.