summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/LlvmCodeGen
diff options
context:
space:
mode:
authorDemi Obenour <demiobenour@gmail.com>2016-12-09 15:41:59 -0500
committerBen Gamari <ben@smart-cactus.org>2016-12-09 16:38:45 -0500
commit90fae01c326bf8b0802b4e8968f84886be4e1380 (patch)
treed91307f5d7811c46dfa3fd8e19e019b82af10f1b /compiler/llvmGen/LlvmCodeGen
parent62418b878a1e57b6d187c4f98bf90f6cd64a58b6 (diff)
downloadhaskell-90fae01c326bf8b0802b4e8968f84886be4e1380.tar.gz
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
Diffstat (limited to 'compiler/llvmGen/LlvmCodeGen')
-rw-r--r--compiler/llvmGen/LlvmCodeGen/CodeGen.hs6
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Regs.hs14
2 files changed, 8 insertions, 12 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index 7b610c0a0a..d88d234057 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -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
diff --git a/compiler/llvmGen/LlvmCodeGen/Regs.hs b/compiler/llvmGen/LlvmCodeGen/Regs.hs
index 8ac41530cb..1ee9fc10a0 100644
--- a/compiler/llvmGen/LlvmCodeGen/Regs.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Regs.hs
@@ -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