Commit 3cedbfb4 authored by PHO's avatar PHO
Browse files

AsmCodeGen.NcgImpl.ncgMakeFarBranches should take account of info tables (#709)

We have to reduce the maximum number of instructions to jump over depending on the number of info tables in a proc.
parent aa1d7d35
...@@ -147,7 +147,7 @@ data NcgImpl statics instr jumpDest = NcgImpl { ...@@ -147,7 +147,7 @@ data NcgImpl statics instr jumpDest = NcgImpl {
ncg_x86fp_kludge :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr], ncg_x86fp_kludge :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr],
ncgExpandTop :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr], ncgExpandTop :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr],
ncgAllocMoreStack :: Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr), ncgAllocMoreStack :: Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr),
ncgMakeFarBranches :: [NatBasicBlock instr] -> [NatBasicBlock instr] ncgMakeFarBranches :: BlockEnv CmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]
} }
-------------------- --------------------
...@@ -190,7 +190,7 @@ x86_64NcgImpl dflags ...@@ -190,7 +190,7 @@ x86_64NcgImpl dflags
,ncg_x86fp_kludge = id ,ncg_x86fp_kludge = id
,ncgAllocMoreStack = X86.Instr.allocMoreStack platform ,ncgAllocMoreStack = X86.Instr.allocMoreStack platform
,ncgExpandTop = id ,ncgExpandTop = id
,ncgMakeFarBranches = id ,ncgMakeFarBranches = const id
} }
where platform = targetPlatform dflags where platform = targetPlatform dflags
...@@ -228,7 +228,7 @@ sparcNcgImpl dflags ...@@ -228,7 +228,7 @@ sparcNcgImpl dflags
,ncg_x86fp_kludge = id ,ncg_x86fp_kludge = id
,ncgAllocMoreStack = noAllocMoreStack ,ncgAllocMoreStack = noAllocMoreStack
,ncgExpandTop = map SPARC.CodeGen.Expand.expandTop ,ncgExpandTop = map SPARC.CodeGen.Expand.expandTop
,ncgMakeFarBranches = id ,ncgMakeFarBranches = const id
} }
-- --
...@@ -661,7 +661,7 @@ sequenceTop ...@@ -661,7 +661,7 @@ sequenceTop
sequenceTop _ top@(CmmData _ _) = top sequenceTop _ top@(CmmData _ _) = top
sequenceTop ncgImpl (CmmProc info lbl live (ListGraph blocks)) = sequenceTop ncgImpl (CmmProc info lbl live (ListGraph blocks)) =
CmmProc info lbl live (ListGraph $ ncgMakeFarBranches ncgImpl $ sequenceBlocks info blocks) CmmProc info lbl live (ListGraph $ ncgMakeFarBranches ncgImpl info $ sequenceBlocks info blocks)
-- The algorithm is very simple (and stupid): we make a graph out of -- The algorithm is very simple (and stupid): we make a graph out of
-- the blocks where there is an edge from one block to another iff the -- the blocks where there is an edge from one block to another iff the
......
...@@ -32,6 +32,7 @@ import CodeGen.Platform ...@@ -32,6 +32,7 @@ import CodeGen.Platform
import BlockId import BlockId
import DynFlags import DynFlags
import Cmm import Cmm
import CmmInfo
import FastString import FastString
import CLabel import CLabel
import Outputable import Outputable
...@@ -515,9 +516,10 @@ ppc_takeRegRegMoveInstr _ = Nothing ...@@ -515,9 +516,10 @@ ppc_takeRegRegMoveInstr _ = Nothing
-- big, we have to work around this limitation. -- big, we have to work around this limitation.
makeFarBranches makeFarBranches
:: [NatBasicBlock Instr] :: BlockEnv CmmStatics
-> [NatBasicBlock Instr] -> [NatBasicBlock Instr]
makeFarBranches blocks -> [NatBasicBlock Instr]
makeFarBranches info_env blocks
| last blockAddresses < nearLimit = blocks | last blockAddresses < nearLimit = blocks
| otherwise = zipWith handleBlock blockAddresses blocks | otherwise = zipWith handleBlock blockAddresses blocks
where where
...@@ -536,10 +538,10 @@ makeFarBranches blocks ...@@ -536,10 +538,10 @@ makeFarBranches blocks
where Just targetAddr = lookupUFM blockAddressMap tgt where Just targetAddr = lookupUFM blockAddressMap tgt
makeFar _ other = other makeFar _ other = other
nearLimit = 7000 -- 8192 instructions are allowed; let's keep some -- 8192 instructions are allowed; let's keep some distance, as
-- distance, as we have a few pseudo-insns that are -- we have a few pseudo-insns that are pretty-printed as
-- pretty-printed as multiple instructions, -- multiple instructions, and it's just not worth the effort
-- and it's just not worth the effort to calculate -- to calculate things exactly
-- things exactly nearLimit = 7000 - mapSize info_env * maxRetInfoTableSizeW
blockAddressMap = listToUFM $ zip (map blockId blocks) blockAddresses blockAddressMap = listToUFM $ zip (map blockId blocks) blockAddresses
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