summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-10-13 19:26:58 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-10-13 19:26:58 +0000
commitbe4d8cba1ccf6f0611db50e8c7ba366ce3a3137d (patch)
tree4f4f4b1bd5dddda9e75f4258b2e80104f17cd2b8 /llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
parentea244fcb84c807a7d213754657e452d30acfcab8 (diff)
downloadbcm5719-llvm-be4d8cba1ccf6f0611db50e8c7ba366ce3a3137d.tar.gz
bcm5719-llvm-be4d8cba1ccf6f0611db50e8c7ba366ce3a3137d.zip
Scalar: Remove remaining ilist iterator implicit conversions
Remove remaining `ilist_iterator` implicit conversions from LLVMScalarOpts. This change exposed some scary behaviour in lib/Transforms/Scalar/SCCP.cpp around line 1770. This patch changes a call from `Function::begin()` to `&Function::front()`, since the return was immediately being passed into another function that takes a `Function*`. `Function::front()` started to assert, since the function was empty. Note that `Function::end()` does not point at a legal `Function*` -- it points at an `ilist_half_node` -- so the other function was getting garbage before. (I added the missing check for `Function::isDeclaration()`.) Otherwise, no functionality change intended. llvm-svn: 250211
Diffstat (limited to 'llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
index e4ecf678dff..4161d6f7dd7 100644
--- a/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
+++ b/llvm/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
@@ -258,7 +258,7 @@ LoadInst *MergedLoadStoreMotion::canHoistFromBlock(BasicBlock *BB1,
for (BasicBlock::iterator BBI = BB1->begin(), BBE = BB1->end(); BBI != BBE;
++BBI) {
- Instruction *Inst = BBI;
+ Instruction *Inst = &*BBI;
// Only merge and hoist loads when their result in used only in BB
if (!isa<LoadInst>(Inst) || Inst->isUsedOutsideOfBlock(BB1))
@@ -365,8 +365,7 @@ bool MergedLoadStoreMotion::mergeLoads(BasicBlock *BB) {
int NLoads = 0;
for (BasicBlock::iterator BBI = Succ0->begin(), BBE = Succ0->end();
BBI != BBE;) {
-
- Instruction *I = BBI;
+ Instruction *I = &*BBI;
++BBI;
// Only move non-simple (atomic, volatile) loads.
@@ -444,7 +443,7 @@ PHINode *MergedLoadStoreMotion::getPHIOperand(BasicBlock *BB, StoreInst *S0,
Value *Opd2 = S1->getValueOperand();
if (Opd1 != Opd2) {
NewPN = PHINode::Create(Opd1->getType(), 2, Opd2->getName() + ".sink",
- BB->begin());
+ &BB->front());
NewPN->addIncoming(Opd1, S0->getParent());
NewPN->addIncoming(Opd2, S1->getParent());
if (MD && NewPN->getType()->getScalarType()->isPointerTy())
@@ -478,7 +477,7 @@ bool MergedLoadStoreMotion::sinkStore(BasicBlock *BB, StoreInst *S0,
// Create the new store to be inserted at the join point.
StoreInst *SNew = (StoreInst *)(S0->clone());
Instruction *ANew = A0->clone();
- SNew->insertBefore(InsertPt);
+ SNew->insertBefore(&*InsertPt);
ANew->insertBefore(SNew);
assert(S0->getParent() == A0->getParent());
@@ -574,7 +573,7 @@ bool MergedLoadStoreMotion::runOnFunction(Function &F) {
// Merge unconditional branches, allowing PRE to catch more
// optimization opportunities.
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
- BasicBlock *BB = FI++;
+ BasicBlock *BB = &*FI++;
// Hoist equivalent loads and sink stores
// outside diamonds when possible
OpenPOWER on IntegriCloud