[llvm] r220616 - Clean up assume intrinsic pattern matching, no need to check that the argument is a value.
Benjamin Kramer
benny.kra at googlemail.com
Sat Oct 25 11:09:01 PDT 2014
Author: d0k
Date: Sat Oct 25 13:09:01 2014
New Revision: 220616
URL: http://llvm.org/viewvc/llvm-project?rev=220616&view=rev
Log:
Clean up assume intrinsic pattern matching, no need to check that the argument is a value.
Also make it const safe and remove superfluous casting. NFC.
Modified:
llvm/trunk/include/llvm/IR/PatternMatch.h
llvm/trunk/lib/Analysis/AssumptionTracker.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombine.h
Modified: llvm/trunk/include/llvm/IR/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PatternMatch.h?rev=220616&r1=220615&r2=220616&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/IR/PatternMatch.h Sat Oct 25 13:09:01 2014
@@ -32,7 +32,6 @@
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Operator.h"
namespace llvm {
@@ -1158,8 +1157,10 @@ struct IntrinsicID_match {
template<typename OpTy>
bool match(OpTy *V) {
- IntrinsicInst *II = dyn_cast<IntrinsicInst>(V);
- return II && II->getIntrinsicID() == ID;
+ if (const CallInst *CI = dyn_cast<CallInst>(V))
+ if (const Function *F = CI->getCalledFunction())
+ return F->getIntrinsicID() == ID;
+ return false;
}
};
Modified: llvm/trunk/lib/Analysis/AssumptionTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AssumptionTracker.cpp?rev=220616&r1=220615&r2=220616&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AssumptionTracker.cpp (original)
+++ llvm/trunk/lib/Analysis/AssumptionTracker.cpp Sat Oct 25 13:09:01 2014
@@ -46,10 +46,8 @@ void AssumptionTracker::CallCallbackVH::
AssumptionTracker::FunctionCallsMap::iterator
AssumptionTracker::scanFunction(Function *F) {
- auto IP =
- CachedAssumeCalls.insert(std::make_pair(FunctionCallbackVH(F, this),
- std::unique_ptr<CallHandleSet>(
- new CallHandleSet())));
+ auto IP = CachedAssumeCalls.insert(std::make_pair(
+ FunctionCallbackVH(F, this), llvm::make_unique<CallHandleSet>()));
assert(IP.second && "Scanning function already in the map?");
FunctionCallsMap::iterator I = IP.first;
@@ -58,7 +56,7 @@ AssumptionTracker::scanFunction(Function
// to our cache.
for (BasicBlock &B : *F)
for (Instruction &II : B)
- if (match(cast<Value>(&II), m_Intrinsic<Intrinsic::assume>(m_Value())))
+ if (match(&II, m_Intrinsic<Intrinsic::assume>()))
I->second->insert(CallCallbackVH(&II, this));
return I;
@@ -69,10 +67,8 @@ void AssumptionTracker::verifyAnalysis()
for (const auto &I : CachedAssumeCalls) {
for (const BasicBlock &B : cast<Function>(*I.first))
for (const Instruction &II : B) {
- Instruction *C = const_cast<Instruction*>(&II);
- if (match(C, m_Intrinsic<Intrinsic::assume>(m_Value()))) {
- assert(I.second->count(CallCallbackVH(C,
- const_cast<AssumptionTracker*>(this))) &&
+ if (match(&II, m_Intrinsic<Intrinsic::assume>())) {
+ assert(I.second->find_as(&II) != I.second->end() &&
"Assumption in scanned function not in cache");
}
}
@@ -81,8 +77,7 @@ void AssumptionTracker::verifyAnalysis()
}
void AssumptionTracker::registerAssumption(CallInst *CI) {
- assert(match(cast<Value>(CI),
- m_Intrinsic<Intrinsic::assume>(m_Value())) &&
+ assert(match(CI, m_Intrinsic<Intrinsic::assume>()) &&
"Registered call does not call @llvm.assume");
assert(CI->getParent() &&
"Cannot register @llvm.assume call not in a basic block");
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombine.h?rev=220616&r1=220615&r2=220616&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombine.h (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombine.h Sat Oct 25 13:09:01 2014
@@ -86,7 +86,7 @@ public:
Worklist.Add(I);
using namespace llvm::PatternMatch;
- if ((match(I, m_Intrinsic<Intrinsic::assume>(m_Value()))))
+ if (match(I, m_Intrinsic<Intrinsic::assume>()))
AT->registerAssumption(cast<CallInst>(I));
}
};
More information about the llvm-commits
mailing list