Commit 3cedbfb4 authored by PHO's avatar PHO

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 {
ncg_x86fp_kludge :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr],
ncgExpandTop :: [NatCmmDecl statics instr] -> [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
,ncg_x86fp_kludge = id
,ncgAllocMoreStack = X86.Instr.allocMoreStack platform
,ncgExpandTop = id
,ncgMakeFarBranches = id
,ncgMakeFarBranches = const id
}
where platform = targetPlatform dflags
......@@ -228,7 +228,7 @@ sparcNcgImpl dflags
,ncg_x86fp_kludge = id
,ncgAllocMoreStack = noAllocMoreStack
,ncgExpandTop = map SPARC.CodeGen.Expand.expandTop
,ncgMakeFarBranches = id
,ncgMakeFarBranches = const id
}
--
......@@ -661,7 +661,7 @@ sequenceTop
sequenceTop _ top@(CmmData _ _) = top
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 blocks where there is an edge from one block to another iff the
......
......@@ -32,6 +32,7 @@ import CodeGen.Platform
import BlockId
import DynFlags
import Cmm
import CmmInfo
import FastString
import CLabel
import Outputable
......@@ -515,9 +516,10 @@ ppc_takeRegRegMoveInstr _ = Nothing
-- big, we have to work around this limitation.
makeFarBranches
:: [NatBasicBlock Instr]
:: BlockEnv CmmStatics
-> [NatBasicBlock Instr]
makeFarBranches blocks
-> [NatBasicBlock Instr]
makeFarBranches info_env blocks
| last blockAddresses < nearLimit = blocks
| otherwise = zipWith handleBlock blockAddresses blocks
where
......@@ -536,10 +538,10 @@ makeFarBranches blocks
where Just targetAddr = lookupUFM blockAddressMap tgt
makeFar _ other = other
nearLimit = 7000 -- 8192 instructions are allowed; let's keep some
-- distance, as we have a few pseudo-insns that are
-- pretty-printed as multiple instructions,
-- and it's just not worth the effort to calculate
-- things exactly
-- 8192 instructions are allowed; let's keep some distance, as
-- we have a few pseudo-insns that are pretty-printed as
-- multiple instructions, and it's just not worth the effort
-- to calculate things exactly
nearLimit = 7000 - mapSize info_env * maxRetInfoTableSizeW
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