summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-11-01 21:17:46 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-11-01 21:17:46 +0000
commit66837aba0aafd95257dd679d12927ac3726a5536 (patch)
treeec2e87179bdc9a5546b16f2e2e380f5d3d0479f1 /llvm/lib/Transforms
parent857086edda1d13b0859d108075e3e14a053ce053 (diff)
downloadbcm5719-llvm-66837aba0aafd95257dd679d12927ac3726a5536.tar.gz
bcm5719-llvm-66837aba0aafd95257dd679d12927ac3726a5536.zip
[MemorySSA] Tighten up types to make our API prettier. NFC.
Patch by bryant. Differential Revision: https://reviews.llvm.org/D26126 llvm-svn: 285750
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNHoist.cpp7
-rw-r--r--llvm/lib/Transforms/Utils/MemorySSA.cpp25
2 files changed, 15 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 4328afe3d85..7de1b37df19 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -538,7 +538,7 @@ private:
BasicBlock *HoistBB = HoistPt->getParent();
MemoryUseOrDef *UD;
if (K != InsKind::Scalar)
- UD = cast<MemoryUseOrDef>(MSSA->getMemoryAccess(HoistPt));
+ UD = MSSA->getMemoryAccess(HoistPt);
for (++II; II != InstructionsToHoist.end(); ++II) {
Instruction *Insn = *II;
@@ -582,8 +582,7 @@ private:
// Also check that it is safe to move the load or store from HoistPt
// to NewHoistPt, and from Insn to NewHoistPt.
safeToHoistLdSt(NewHoistPt, HoistPt, UD, K, NBBsOnAllPaths) &&
- safeToHoistLdSt(NewHoistPt, Insn,
- cast<MemoryUseOrDef>(MSSA->getMemoryAccess(Insn)),
+ safeToHoistLdSt(NewHoistPt, Insn, MSSA->getMemoryAccess(Insn),
K, NBBsOnAllPaths)) {
// Extend HoistPt to NewHoistPt.
HoistPt = NewHoistPt;
@@ -600,7 +599,7 @@ private:
// Start over from BB.
Start = II;
if (K != InsKind::Scalar)
- UD = cast<MemoryUseOrDef>(MSSA->getMemoryAccess(*Start));
+ UD = MSSA->getMemoryAccess(*Start);
HoistPt = Insn;
HoistBB = BB;
NBBsOnAllPaths = MaxNumberOfBBSInPath;
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp
index c71b72ab2eb..58a8c88323c 100644
--- a/llvm/lib/Transforms/Utils/MemorySSA.cpp
+++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp
@@ -1589,9 +1589,10 @@ MemoryAccess *MemorySSA::createMemoryAccessInBB(Instruction *I,
BlockNumberingValid.erase(BB);
return NewAccess;
}
-MemoryAccess *MemorySSA::createMemoryAccessBefore(Instruction *I,
- MemoryAccess *Definition,
- MemoryAccess *InsertPt) {
+
+MemoryUseOrDef *MemorySSA::createMemoryAccessBefore(Instruction *I,
+ MemoryAccess *Definition,
+ MemoryUseOrDef *InsertPt) {
assert(I->getParent() == InsertPt->getBlock() &&
"New and old access must be in the same block");
MemoryUseOrDef *NewAccess = createDefinedAccess(I, Definition);
@@ -1601,9 +1602,9 @@ MemoryAccess *MemorySSA::createMemoryAccessBefore(Instruction *I,
return NewAccess;
}
-MemoryAccess *MemorySSA::createMemoryAccessAfter(Instruction *I,
- MemoryAccess *Definition,
- MemoryAccess *InsertPt) {
+MemoryUseOrDef *MemorySSA::createMemoryAccessAfter(Instruction *I,
+ MemoryAccess *Definition,
+ MemoryAccess *InsertPt) {
assert(I->getParent() == InsertPt->getBlock() &&
"New and old access must be in the same block");
MemoryUseOrDef *NewAccess = createDefinedAccess(I, Definition);
@@ -1888,21 +1889,19 @@ void MemorySSA::verifyDefUses(Function &F) const {
}
for (Instruction &I : B) {
- if (MemoryAccess *MA = getMemoryAccess(&I)) {
- assert(isa<MemoryUseOrDef>(MA) &&
- "Found a phi node not attached to a bb");
- verifyUseInDefs(cast<MemoryUseOrDef>(MA)->getDefiningAccess(), MA);
+ if (MemoryUseOrDef *MA = getMemoryAccess(&I)) {
+ verifyUseInDefs(MA->getDefiningAccess(), MA);
}
}
}
}
-MemoryAccess *MemorySSA::getMemoryAccess(const Value *I) const {
- return ValueToMemoryAccess.lookup(I);
+MemoryUseOrDef *MemorySSA::getMemoryAccess(const Instruction *I) const {
+ return cast_or_null<MemoryUseOrDef>(ValueToMemoryAccess.lookup(I));
}
MemoryPhi *MemorySSA::getMemoryAccess(const BasicBlock *BB) const {
- return cast_or_null<MemoryPhi>(getMemoryAccess((const Value *)BB));
+ return cast_or_null<MemoryPhi>(ValueToMemoryAccess.lookup(cast<Value>(BB)));
}
/// Perform a local numbering on blocks so that instruction ordering can be
OpenPOWER on IntegriCloud