[llvm-commits] [poolalloc] r58530 - /poolalloc/trunk/lib/DSA/CallTargets.cpp
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Fri Oct 31 12:17:04 PDT 2008
Author: alenhar2
Date: Fri Oct 31 14:17:03 2008
New Revision: 58530
URL: http://llvm.org/viewvc/llvm-project?rev=58530&view=rev
Log:
add cast peering to CTF
Modified:
poolalloc/trunk/lib/DSA/CallTargets.cpp
Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=58530&r1=58529&r2=58530&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CallTargets.cpp (original)
+++ poolalloc/trunk/lib/DSA/CallTargets.cpp Fri Oct 31 14:17:03 2008
@@ -50,7 +50,15 @@
if (isa<CallInst>(B) || isa<InvokeInst>(B)) {
CallSite cs = CallSite::get(B);
AllSites.push_back(cs);
- if (!cs.getCalledFunction()) {
+ 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 (!CF) {
if (isa<ConstantPointerNull>(cs.getCalledValue())) {
++DirCall;
CompleteSites.insert(cs);
More information about the llvm-commits
mailing list