diff options
author | Erik de Castro Lopo <erik.decastrolopo@ambiata.com> | 2017-01-16 06:17:17 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2017-01-16 06:18:03 +1100 |
commit | 9d67f04d4892ea399631fd67ce91782b821a127e (patch) | |
tree | 9767bbd3a415b8558af538c0e4f083f34da9b418 | |
parent | 1f48fbc9cda8c61ff0c032b683377dc23697079d (diff) | |
download | haskell-9d67f04d4892ea399631fd67ce91782b821a127e.tar.gz |
LLVM: Tweak TBAA metadata codegen
This change is requred for llvm 4.0. GHC doesn't use that version yet,
but this change is just as valid for versions eariler than 4.0.
Two changes needed:
* Previously, GHC defined a `topN` node in the TBAA heiarchy and some IR
instructions referenced that node. With LLVM 4.0 the root node can no
longer be referenced by IR instructions, so we introduce a new element
`rootN` and make `topN` a child of that.
* Previously the root TBAA node was rendered as "!0 = !{!"root", null}".
With LLVM 4.0 that needs to be "!0 = !{!"root"}" which is also
accepted by earlier versions.
Test Plan: Build with quick-llvm BuildFlavor and run tests
Reviewers: bgamari, drbo, austin, angerman, michalt, DemiMarie
Reviewed By: DemiMarie
Subscribers: mpickering, DemiMarie, thomie
Differential Revision: https://phabricator.haskell.org/D2975
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen.hs | 13 | ||||
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen/Regs.hs | 9 |
2 files changed, 14 insertions, 8 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs index c240d09965..5596d599c4 100644 --- a/compiler/llvmGen/LlvmCodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen.hs @@ -188,12 +188,13 @@ cmmMetaLlvmPrelude = do setUniqMeta uniq tbaaId parentId <- maybe (return Nothing) getUniqMeta parent -- Build definition - return $ MetaUnnamed tbaaId $ MetaStruct - [ MetaStr name - , case parentId of - Just p -> MetaNode p - Nothing -> MetaVar $ LMLitVar $ LMNullLit i8Ptr - ] + return $ MetaUnnamed tbaaId $ MetaStruct $ + case parentId of + Just p -> [ MetaStr name, MetaNode p ] + -- As of LLVM 4.0, a node without parents should be rendered as + -- just a name on its own. Previously `null` was accepted as the + -- name. + Nothing -> [ MetaStr name ] renderLlvm $ ppLlvmMetas metas -- ----------------------------------------------------------------------------- diff --git a/compiler/llvmGen/LlvmCodeGen/Regs.hs b/compiler/llvmGen/LlvmCodeGen/Regs.hs index 186eda31a3..e09ab8026c 100644 --- a/compiler/llvmGen/LlvmCodeGen/Regs.hs +++ b/compiler/llvmGen/LlvmCodeGen/Regs.hs @@ -97,7 +97,8 @@ alwaysLive = [BaseReg, Sp, Hp, SpLim, HpLim, node] -- | STG Type Based Alias Analysis hierarchy stgTBAA :: [(Unique, LMString, Maybe Unique)] stgTBAA - = [ (topN, fsLit "top", Nothing) + = [ (rootN, fsLit "root", Nothing) + , (topN, fsLit "top", Just rootN) , (stackN, fsLit "stack", Just topN) , (heapN, fsLit "heap", Just topN) , (rxN, fsLit "rx", Just heapN) @@ -109,7 +110,11 @@ stgTBAA ] -- | Id values -topN, stackN, heapN, rxN, baseN :: Unique +-- The `rootN` node is the root (there can be more than one) of the TBAA +-- hierarchy and as of LLVM 4.0 should *only* be referenced by other nodes. It +-- should never occur in any LLVM instruction statement. +rootN, topN, stackN, heapN, rxN, baseN :: Unique +rootN = getUnique (fsLit "LlvmCodeGen.Regs.rootN") topN = getUnique (fsLit "LlvmCodeGen.Regs.topN") stackN = getUnique (fsLit "LlvmCodeGen.Regs.stackN") heapN = getUnique (fsLit "LlvmCodeGen.Regs.heapN") |