Commit 9d67f04d authored by Erik de Castro Lopo's avatar Erik de Castro Lopo Committed by Erik de Castro Lopo

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
parent 1f48fbc9
......@@ -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
-- -----------------------------------------------------------------------------
......
......@@ -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")
......
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