summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/InstructionPrecedenceTracking.cpp12
-rw-r--r--llvm/lib/Analysis/MustExecute.cpp13
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp5
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp6
4 files changed, 21 insertions, 15 deletions
diff --git a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
index b98975b006a..816126f407c 100644
--- a/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
+++ b/llvm/lib/Analysis/InstructionPrecedenceTracking.cpp
@@ -99,9 +99,17 @@ void InstructionPrecedenceTracking::validateAll() const {
}
#endif
-void InstructionPrecedenceTracking::invalidateBlock(const BasicBlock *BB) {
+void InstructionPrecedenceTracking::insertInstructionTo(const Instruction *Inst,
+ const BasicBlock *BB) {
+ if (isSpecialInstruction(Inst))
+ FirstSpecialInsts.erase(BB);
OI.invalidateBlock(BB);
- FirstSpecialInsts.erase(BB);
+}
+
+void InstructionPrecedenceTracking::removeInstruction(const Instruction *Inst) {
+ if (isSpecialInstruction(Inst))
+ FirstSpecialInsts.erase(Inst->getParent());
+ OI.invalidateBlock(Inst->getParent());
}
void InstructionPrecedenceTracking::clear() {
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp
index 281b8f5ab98..180c38ddacc 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -83,16 +83,15 @@ void ICFLoopSafetyInfo::computeLoopSafetyInfo(const Loop *CurLoop) {
computeBlockColors(CurLoop);
}
-void ICFLoopSafetyInfo::insertInstructionTo(const BasicBlock *BB) {
- ICF.invalidateBlock(BB);
- MW.invalidateBlock(BB);
+void ICFLoopSafetyInfo::insertInstructionTo(const Instruction *Inst,
+ const BasicBlock *BB) {
+ ICF.insertInstructionTo(Inst, BB);
+ MW.insertInstructionTo(Inst, BB);
}
void ICFLoopSafetyInfo::removeInstruction(const Instruction *Inst) {
- // TODO: So far we just conservatively drop cache, but maybe we can not do it
- // when Inst is not an ICF instruction. Follow-up on that.
- ICF.invalidateBlock(Inst->getParent());
- MW.invalidateBlock(Inst->getParent());
+ ICF.removeInstruction(Inst);
+ MW.removeInstruction(Inst);
}
void LoopSafetyInfo::computeBlockColors(const Loop *CurLoop) {
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 04ed914b86c..9598e595c5e 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2079,10 +2079,9 @@ bool GVN::processBlock(BasicBlock *BB) {
salvageDebugInfo(*I);
if (MD) MD->removeInstruction(I);
LLVM_DEBUG(verifyRemoved(I));
+ ICF->removeInstruction(I);
I->eraseFromParent();
}
-
- ICF->invalidateBlock(BB);
InstrsToErase.clear();
if (AtStart)
@@ -2301,7 +2300,7 @@ bool GVN::performScalarPRE(Instruction *CurInst) {
LLVM_DEBUG(verifyRemoved(CurInst));
// FIXME: Intended to be markInstructionForDeletion(CurInst), but it causes
// some assertion failures.
- ICF->invalidateBlock(CurrentBlock);
+ ICF->removeInstruction(CurInst);
CurInst->eraseFromParent();
++NumGVNInstr;
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 5ebf035bf51..3b44ac564d8 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -742,13 +742,13 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
auto One = llvm::ConstantFP::get(Divisor->getType(), 1.0);
auto ReciprocalDivisor = BinaryOperator::CreateFDiv(One, Divisor);
ReciprocalDivisor->setFastMathFlags(I.getFastMathFlags());
- SafetyInfo->insertInstructionTo(I.getParent());
+ SafetyInfo->insertInstructionTo(ReciprocalDivisor, I.getParent());
ReciprocalDivisor->insertBefore(&I);
auto Product =
BinaryOperator::CreateFMul(I.getOperand(0), ReciprocalDivisor);
Product->setFastMathFlags(I.getFastMathFlags());
- SafetyInfo->insertInstructionTo(I.getParent());
+ SafetyInfo->insertInstructionTo(Product, I.getParent());
Product->insertAfter(&I);
I.replaceAllUsesWith(Product);
eraseInstruction(I, *SafetyInfo, CurAST);
@@ -1189,7 +1189,7 @@ static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo,
static void moveInstructionBefore(Instruction &I, Instruction &Dest,
ICFLoopSafetyInfo &SafetyInfo) {
SafetyInfo.removeInstruction(&I);
- SafetyInfo.insertInstructionTo(Dest.getParent());
+ SafetyInfo.insertInstructionTo(&I, Dest.getParent());
I.moveBefore(&Dest);
}
OpenPOWER on IntegriCloud