Commit 90fae01c authored by dobenour's avatar dobenour Committed by Ben Gamari

Fix LLVM TBAA metadata

Accesses through a Cmm local are currently reported as having the
"other" type, which can only alias other "other" accesses.  However,
this assumption is incorrect, which can result in silent bad LLVM
codegen.

Fixes #9308.
Fixes #9504.

Test Plan: GHC CI

Reviewers: rwbarton, austin, bgamari

Reviewed By: bgamari

Subscribers: michalt, thomie

Differential Revision: https://phabricator.haskell.org/D2758

GHC Trac Issues: #9125, #9308, #9504
parent 62418b87
......@@ -845,8 +845,7 @@ genStore addr@(CmmMachOp (MO_Sub _) [
-- generic case
genStore addr val
= do other <- getTBAAMeta otherN
genStore_slow addr val other
= getTBAAMeta topN >>= genStore_slow addr val
-- | CmmStore operation
-- This is a special case for storing to a global register pointer
......@@ -1494,8 +1493,7 @@ genLoad atomic e@(CmmMachOp (MO_Sub _) [
-- generic case
genLoad atomic e ty
= do other <- getTBAAMeta otherN
genLoad_slow atomic e ty other
= getTBAAMeta topN >>= genLoad_slow atomic e ty
-- | Handle CmmLoad expression.
-- This is a special case for loading from a global register pointer
......
......@@ -6,7 +6,7 @@
module LlvmCodeGen.Regs (
lmGlobalRegArg, lmGlobalRegVar, alwaysLive,
stgTBAA, baseN, stackN, heapN, rxN, otherN, tbaa, getTBAA
stgTBAA, baseN, stackN, heapN, rxN, topN, tbaa, getTBAA
) where
#include "HsVersions.h"
......@@ -102,21 +102,19 @@ stgTBAA
, (heapN, fsLit "heap", Just topN)
, (rxN, fsLit "rx", Just heapN)
, (baseN, fsLit "base", Just topN)
-- FIX: Not 100% sure about 'others' place. Might need to be under 'heap'.
-- OR I think the big thing is Sp is never aliased, so might want
-- to change the hieracy to have Sp on its own branch that is never
-- aliased (e.g never use top as a TBAA node).
, (otherN, fsLit "other", Just topN)
-- FIX: Not 100% sure if this heirarchy is complete. I think the big thing
-- is Sp is never aliased, so might want to change the hierarchy to have Sp
-- on its own branch that is never aliased (e.g never use top as a TBAA
-- node).
]
-- | Id values
topN, stackN, heapN, rxN, baseN, otherN :: Unique
topN, stackN, heapN, rxN, baseN :: Unique
topN = getUnique (fsLit "LlvmCodeGen.Regs.topN")
stackN = getUnique (fsLit "LlvmCodeGen.Regs.stackN")
heapN = getUnique (fsLit "LlvmCodeGen.Regs.heapN")
rxN = getUnique (fsLit "LlvmCodeGen.Regs.rxN")
baseN = getUnique (fsLit "LlvmCodeGen.Regs.baseN")
otherN = getUnique (fsLit "LlvmCodeGen.Regs.otherN")
-- | The TBAA metadata identifier
tbaa :: LMString
......
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