Commit db5c6adc authored by Simon Marlow's avatar Simon Marlow
Browse files

Load the PIC base register on every entry point

(fixes dyn tests with -fnew-codegen on x86)
parent 111edd85
...@@ -65,6 +65,7 @@ import Reg ...@@ -65,6 +65,7 @@ import Reg
import NCGMonad import NCGMonad
import Hoopl
import OldCmm import OldCmm
import CLabel ( CLabel, ForeignLabelSource(..), pprCLabel, import CLabel ( CLabel, ForeignLabelSource(..), pprCLabel,
mkDynamicLinkerLabel, DynamicLinkerLabelInfo(..), mkDynamicLinkerLabel, DynamicLinkerLabelInfo(..),
...@@ -752,18 +753,37 @@ initializePicBase_x86 ...@@ -752,18 +753,37 @@ initializePicBase_x86
-> NatM [NatCmmDecl (Alignment, CmmStatics) X86.Instr] -> NatM [NatCmmDecl (Alignment, CmmStatics) X86.Instr]
initializePicBase_x86 ArchX86 os picReg initializePicBase_x86 ArchX86 os picReg
(CmmProc info lab (ListGraph blocks) : statics) (CmmProc info lab (ListGraph blocks) : statics)
| osElfTarget os | osElfTarget os
= return (CmmProc info lab (ListGraph (b':tail blocks)) : statics) = return (CmmProc info lab (ListGraph blocks') : statics)
where BasicBlock bID insns = head blocks where blocks' = case blocks of
b' = BasicBlock bID (X86.FETCHGOT picReg : insns) [] -> []
(b:bs) -> fetchGOT b : map maybeFetchGOT bs
-- we want to add a FETCHGOT instruction to the beginning of
-- every block that is an entry point, which corresponds to
-- the blocks that have entries in the info-table mapping.
maybeFetchGOT b@(BasicBlock bID _)
| bID `mapMember` info = fetchGOT b
| otherwise = b
fetchGOT (BasicBlock bID insns) =
BasicBlock bID (X86.FETCHGOT picReg : insns)
initializePicBase_x86 ArchX86 OSDarwin picReg initializePicBase_x86 ArchX86 OSDarwin picReg
(CmmProc info lab (ListGraph blocks) : statics) (CmmProc info lab (ListGraph blocks) : statics)
= return (CmmProc info lab (ListGraph (b':tail blocks)) : statics) = return (CmmProc info lab (ListGraph blocks') : statics)
where BasicBlock bID insns = head blocks where blocks' = case blocks of
b' = BasicBlock bID (X86.FETCHPC picReg : insns) [] -> []
(b:bs) -> fetchPC b : map maybeFetchPC bs
maybeFetchPC b@(BasicBlock bID _)
| bID `mapMember` info = fetchPC b
| otherwise = b
fetchPC (BasicBlock bID insns) =
BasicBlock bID (X86.FETCHPC picReg : insns)
initializePicBase_x86 _ _ _ _ initializePicBase_x86 _ _ _ _
= panic "initializePicBase_x86: not needed" = panic "initializePicBase_x86: not needed"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment