diff options
| author | Gabor Greif <ggreif@gmail.com> | 2010-03-20 21:00:25 +0000 |
|---|---|---|
| committer | Gabor Greif <ggreif@gmail.com> | 2010-03-20 21:00:25 +0000 |
| commit | 85c4cc2a1422d46cdf549871c79dd2eb789708da (patch) | |
| tree | fad6797f10e35c67c651371c56650ba1357a6dfc | |
| parent | 6877421a1d94a035c06e0bef8fdb2bb5b72b8cff (diff) | |
| download | external_llvm-85c4cc2a1422d46cdf549871c79dd2eb789708da.zip external_llvm-85c4cc2a1422d46cdf549871c79dd2eb789708da.tar.gz external_llvm-85c4cc2a1422d46cdf549871c79dd2eb789708da.tar.bz2 | |
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.h | 5 | ||||
| -rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 4 | ||||
| -rw-r--r-- | lib/Transforms/InstCombine/InstCombineCalls.cpp | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 80b7ca4..b1f1996 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 7b1e9c0..d8e97a2 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 bdb46eb..65f2e15 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; } |
