aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-03-20 21:00:25 +0000
committerGabor Greif <ggreif@gmail.com>2010-03-20 21:00:25 +0000
commit654c06f6457f80428e40810ad251c412462731e4 (patch)
treefad6797f10e35c67c651371c56650ba1357a6dfc
parent25eb5013d0516e7ba5105a1ca25c9f61d2ddb0b2 (diff)
Add a setCalledFunction member to InvokeInst (like in CallInst)
and use this (as well as getCalledValue) to access the callee, instead of {g|s}etOperand(0). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99084 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Instructions.h5
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp4
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp2
3 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 80b7ca4f82..b1f1996045 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -2516,6 +2516,11 @@ public:
const Value *getCalledValue() const { return getOperand(0); }
Value *getCalledValue() { return getOperand(0); }
+ /// setCalledFunction - Set the function called.
+ void setCalledFunction(Value* Fn) {
+ Op<0>() = Fn;
+ }
+
// get*Dest - Return the destination basic blocks...
BasicBlock *getNormalDest() const {
return cast<BasicBlock>(getOperand(1));
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 7b1e9c0efd..d8e97a26ad 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -622,12 +622,12 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V,
return false; // Storing the value.
}
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
- if (CI->getOperand(0) != V) {
+ if (CI->getCalledValue() != V) {
//cerr << "NONTRAPPING USE: " << **UI;
return false; // Not calling the ptr
}
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
- if (II->getOperand(0) != V) {
+ if (II->getCalledValue() != V) {
//cerr << "NONTRAPPING USE: " << **UI;
return false; // Not calling the ptr
}
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index bdb46ebd1a..65f2e15d27 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -820,7 +820,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// We cannot remove an invoke, because it would change the CFG, just
// change the callee to a null pointer.
- cast<InvokeInst>(OldCall)->setOperand(0,
+ cast<InvokeInst>(OldCall)->setCalledFunction(
Constant::getNullValue(CalleeF->getType()));
return 0;
}