[llvm-commits] [poolalloc] r111030 - in /poolalloc/trunk/lib/DSA: CallTargets.cpp Local.cpp
John Criswell
criswell at uiuc.edu
Fri Aug 13 12:32:00 PDT 2010
Author: criswell
Date: Fri Aug 13 14:32:00 2010
New Revision: 111030
URL: http://llvm.org/viewvc/llvm-project?rev=111030&view=rev
Log:
Replaced older code to strip off pointer casts to use the
Value::stripPointerCasts() method.
Added some code in CallTargets to strip off pointer casts when looking for
direct function calls.
Modified:
poolalloc/trunk/lib/DSA/CallTargets.cpp
poolalloc/trunk/lib/DSA/Local.cpp
Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=111030&r1=111029&r2=111030&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CallTargets.cpp (original)
+++ poolalloc/trunk/lib/DSA/CallTargets.cpp Fri Aug 13 14:32:00 2010
@@ -51,15 +51,18 @@
CallSite cs = CallSite::get(B);
AllSites.push_back(cs);
Function* CF = cs.getCalledFunction();
- // If the called function is casted from one function type to another, peer
- // into the cast instruction and pull out the actual function being called.
- if (ConstantExpr *CE = dyn_cast<ConstantExpr>(cs.getCalledValue()))
- if (CE->getOpcode() == Instruction::BitCast &&
- isa<Function>(CE->getOperand(0)))
- CF = cast<Function>(CE->getOperand(0));
-
+
+ //
+ // If the called function is casted from one function type to
+ // another, peer into the cast instruction and pull out the actual
+ // function being called.
+ //
+ if (!CF)
+ CF = dyn_cast<Function>(cs.getCalledValue()->stripPointerCasts());
+
+ Value * calledValue = cs.getCalledValue()->stripPointerCasts();
if (!CF) {
- if (isa<ConstantPointerNull>(cs.getCalledValue())) {
+ if (isa<ConstantPointerNull>(calledValue)) {
++DirCall;
CompleteSites.insert(cs);
} else {
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=111030&r1=111029&r2=111030&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Fri Aug 13 14:32:00 2010
@@ -850,7 +850,10 @@
}
void GraphBuilder::visitCallSite(CallSite CS) {
- Value *Callee = CS.getCalledValue();
+ //
+ // Get the called value. Strip off any casts which are lossless.
+ //
+ Value *Callee = CS.getCalledValue()->stripPointerCasts();
// Special case handling of certain libc allocation functions here.
if (Function *F = dyn_cast<Function>(Callee))
@@ -861,7 +864,7 @@
return;
//Can't do much about inline asm (yet!)
- if (isa<InlineAsm>(CS.getCalledValue())) {
+ if (isa<InlineAsm> (Callee)) {
++NumAsmCall;
DSNodeHandle RetVal;
Instruction *I = CS.getInstruction();
@@ -878,7 +881,7 @@
}
//uninteresting direct call
- if (CS.getCalledFunction() && !DSCallGraph::hasPointers(CS)) {
+ if (isa<Function>(Callee) && !DSCallGraph::hasPointers(CS)) {
++NumBoringCall;
return;
}
@@ -889,11 +892,6 @@
if (isa<PointerType>(I->getType()))
RetVal = getValueDest(I);
- if (!isa<Function>(Callee))
- if (ConstantExpr* EX = dyn_cast<ConstantExpr>(Callee))
- if (EX->isCast() && isa<Function>(EX->getOperand(0)))
- Callee = cast<Function>(EX->getOperand(0));
-
DSNode *CalleeNode = 0;
if (!isa<Function>(Callee)) {
CalleeNode = getValueDest(Callee).getNode();
More information about the llvm-commits
mailing list