mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220616 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5c50ab84b3
commit
05b492db56
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,10 +46,8 @@ void AssumptionTracker::CallCallbackVH::deleted() {
|
||||
|
||||
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 *F) {
|
||||
// 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() const {
|
||||
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() const {
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user