aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Function.cpp
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-03-24 13:21:49 +0000
committerGabor Greif <ggreif@gmail.com>2010-03-24 13:21:49 +0000
commitc9f7500d1752feac7cece26d20007a99d21f677c (patch)
tree855c74f792cd3e5ba272a2a73df5a17feb2729ab /lib/VMCore/Function.cpp
parent6d6aaeca4f50e1ce101b71b33a52cbd66db01c52 (diff)
downloadexternal_llvm-c9f7500d1752feac7cece26d20007a99d21f677c.tar.gz
external_llvm-c9f7500d1752feac7cece26d20007a99d21f677c.tar.bz2
external_llvm-c9f7500d1752feac7cece26d20007a99d21f677c.zip
Finally land the InvokeInst operand reordering.
I have audited all getOperandNo calls now, fixing hidden assumptions. CallSite related uglyness will be eliminated successively. Note this patch has a long and griveous history, for all the back-and-forths have a look at CallSite.h's log. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r--lib/VMCore/Function.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 4f55098da1..575381e030 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -16,6 +16,7 @@
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
#include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/Support/CallSite.h"
#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/StringPool.h"
@@ -402,11 +403,14 @@ Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys,
/// hasAddressTaken - returns true if there are any uses of this function
/// other than direct calls or invokes to it.
-bool Function::hasAddressTaken() const {
+bool Function::hasAddressTaken(const User* *PutOffender) const {
for (Value::use_const_iterator I = use_begin(), E = use_end(); I != E; ++I) {
- if (I.getOperandNo() != 0 ||
- (!isa<CallInst>(*I) && !isa<InvokeInst>(*I)))
- return true;
+ const User *U = *I;
+ if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
+ return PutOffender ? (*PutOffender = U, true) : true;
+ CallSite CS(const_cast<Instruction*>(static_cast<const Instruction*>(U)));
+ if (!CS.isCallee(I))
+ return PutOffender ? (*PutOffender = U, true) : true;
}
return false;
}