diff options
author | Bartosz Nitka <niteria@gmail.com> | 2016-07-07 03:07:20 -0700 |
---|---|---|
committer | Bartosz Nitka <niteria@gmail.com> | 2016-07-07 03:57:44 -0700 |
commit | 6ed7c4793fe1acd491646a8312afbbda6be1fd0b (patch) | |
tree | 206c1a844201486bfdbfdf9cdca7efe9f2ab7d52 /compiler/nativeGen | |
parent | bedd62037f588321312feaf16923fa04d443e3d8 (diff) | |
download | haskell-6ed7c4793fe1acd491646a8312afbbda6be1fd0b.tar.gz |
Document some codegen nondeterminism
Bit-for-bit reproducible binaries are not a goal for now,
so this is just marking places that could be a problem.
Doing this will allow eltsUFM to be removed and will
leave only nonDetEltsUFM.
GHC Trac: #4012
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r-- | compiler/nativeGen/AsmCodeGen.hs | 4 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/Main.hs | 3 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/Spill.hs | 5 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/SpillCost.hs | 6 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/Stats.hs | 14 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs | 3 | ||||
-rw-r--r-- | compiler/nativeGen/RegAlloc/Linear/Stats.hs | 3 |
7 files changed, 23 insertions, 15 deletions
diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs index 094a9085be..46c6fa4763 100644 --- a/compiler/nativeGen/AsmCodeGen.hs +++ b/compiler/nativeGen/AsmCodeGen.hs @@ -432,7 +432,9 @@ cmmNativeGens dflags this_mod modLoc ncgImpl h dbgMap us -- Generate .file directives for every new file that has been -- used. Note that it is important that we generate these in -- ascending order, as Clang's 3.6 assembler complains. - let newFileIds = sortBy (comparing snd) $ eltsUFM $ fileIds' `minusUFM` fileIds + let newFileIds = sortBy (comparing snd) $ + nonDetEltsUFM $ fileIds' `minusUFM` fileIds + -- See Note [Unique Determinism and code generation] pprDecl (f,n) = text "\t.file " <> ppr n <+> doubleQuotes (ftext f) diff --git a/compiler/nativeGen/RegAlloc/Graph/Main.hs b/compiler/nativeGen/RegAlloc/Graph/Main.hs index f7b3d0179d..0b10f3c1e3 100644 --- a/compiler/nativeGen/RegAlloc/Graph/Main.hs +++ b/compiler/nativeGen/RegAlloc/Graph/Main.hs @@ -401,7 +401,8 @@ patchRegsFromGraph platform graph code -- We need to deepSeq the whole graph before trying to colour it to avoid -- space leaks. seqGraph :: Color.Graph VirtualReg RegClass RealReg -> () -seqGraph graph = seqNodes (eltsUFM (Color.graphMap graph)) +seqGraph graph = seqNodes (nonDetEltsUFM (Color.graphMap graph)) + -- See Note [Unique Determinism and code generation] seqNodes :: [Color.Node VirtualReg RegClass RealReg] -> () seqNodes ns diff --git a/compiler/nativeGen/RegAlloc/Graph/Spill.hs b/compiler/nativeGen/RegAlloc/Graph/Spill.hs index 9c3ccae315..a1d46cbc1b 100644 --- a/compiler/nativeGen/RegAlloc/Graph/Spill.hs +++ b/compiler/nativeGen/RegAlloc/Graph/Spill.hs @@ -376,6 +376,5 @@ makeSpillStats s instance Outputable SpillStats where ppr stats - = (vcat $ map (\(r, s, l) -> ppr r <+> int s <+> int l) - $ eltsUFM (spillStoreLoad stats)) - + = pprUFM (spillStoreLoad stats) + (vcat . map (\(r, s, l) -> ppr r <+> int s <+> int l)) diff --git a/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs b/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs index beffde97bb..198be622e1 100644 --- a/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs +++ b/compiler/nativeGen/RegAlloc/Graph/SpillCost.hs @@ -153,7 +153,8 @@ chooseSpill chooseSpill info graph = let cost = spillCost_length info graph node = minimumBy (\n1 n2 -> compare (cost $ nodeId n1) (cost $ nodeId n2)) - $ eltsUFM $ graphMap graph + $ nonDetEltsUFM $ graphMap graph + -- See Note [Unique Determinism and code generation] in nodeId node @@ -241,7 +242,8 @@ lifeMapFromSpillCostInfo :: SpillCostInfo -> UniqFM (VirtualReg, Int) lifeMapFromSpillCostInfo info = listToUFM $ map (\(r, _, _, life) -> (r, (r, life))) - $ eltsUFM info + $ nonDetEltsUFM info + -- See Note [Unique Determinism and code generation] -- | Determine the degree (number of neighbors) of this node which diff --git a/compiler/nativeGen/RegAlloc/Graph/Stats.hs b/compiler/nativeGen/RegAlloc/Graph/Stats.hs index cfd8f83122..9a8d0068ff 100644 --- a/compiler/nativeGen/RegAlloc/Graph/Stats.hs +++ b/compiler/nativeGen/RegAlloc/Graph/Stats.hs @@ -129,7 +129,7 @@ instance (Outputable statics, Outputable instr) $$ (if (not $ isNullUFM $ raCoalesced s) then text "# Registers coalesced." - $$ (pprUFMWithKeys (raCoalesced s) (vcat . map ppr)) + $$ pprUFMWithKeys (raCoalesced s) (vcat . map ppr) $$ text "" else empty) @@ -160,7 +160,7 @@ instance (Outputable statics, Outputable instr) $$ (if (not $ isNullUFM $ raCoalesced s) then text "# Registers coalesced." - $$ (pprUFMWithKeys (raCoalesced s) (vcat . map ppr)) + $$ pprUFMWithKeys (raCoalesced s) (vcat . map ppr) $$ text "" else empty) @@ -232,7 +232,7 @@ pprStatsLifetimes stats in ( text "-- vreg-population-lifetimes" $$ text "-- (instruction_count, number_of_vregs_that_lived_that_long)" - $$ (vcat $ map ppr $ eltsUFM lifeBins) + $$ pprUFM lifeBins (vcat . map ppr) $$ text "\n") @@ -240,7 +240,8 @@ binLifetimeCount :: UniqFM (VirtualReg, Int) -> UniqFM (Int, Int) binLifetimeCount fm = let lifes = map (\l -> (l, (l, 1))) $ map snd - $ eltsUFM fm + $ nonDetEltsUFM fm + -- See Note [Unique Determinism and code generation] in addListToUFM_C (\(l1, c1) (_, c2) -> (l1, c1 + c2)) @@ -260,7 +261,7 @@ pprStatsConflict stats in ( text "-- vreg-conflicts" $$ text "-- (conflict_count, number_of_vregs_that_had_that_many_conflicts)" - $$ (vcat $ map ppr $ eltsUFM confMap) + $$ pprUFM confMap (vcat . map ppr) $$ text "\n") @@ -285,7 +286,8 @@ pprStatsLifeConflict stats graph , ppr $ sizeUniqSet (Color.nodeConflicts node) , ppr $ lifetime ]) $ map Color.nodeId - $ eltsUFM + $ nonDetEltsUFM + -- See Note [Unique Determinism and code generation] $ Color.graphMap graph in ( text "-- vreg-conflict-lifetime" diff --git a/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs b/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs index 4bbf5d4c88..a40bec16e4 100644 --- a/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs +++ b/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs @@ -59,7 +59,8 @@ accSqueeze -> UniqFM reg -> Int -accSqueeze count maxCount squeeze ufm = acc count (eltsUFM ufm) +accSqueeze count maxCount squeeze ufm = acc count (nonDetEltsUFM ufm) + -- See Note [Unique Determinism and code generation] where acc count [] = count acc count _ | count >= maxCount = count acc count (r:rs) = acc (count + squeeze r) rs diff --git a/compiler/nativeGen/RegAlloc/Linear/Stats.hs b/compiler/nativeGen/RegAlloc/Linear/Stats.hs index c55df6bee8..71dedaeb55 100644 --- a/compiler/nativeGen/RegAlloc/Linear/Stats.hs +++ b/compiler/nativeGen/RegAlloc/Linear/Stats.hs @@ -66,7 +66,8 @@ pprStats code statss spillTotals = foldl' (zipWith (+)) [0, 0, 0, 0, 0] - $ eltsUFM spills + $ nonDetEltsUFM spills + -- See Note [Unique Determinism and code generation] -- count how many reg-reg-moves remain in the code moves = sum $ map countRegRegMovesNat code |