aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2009-01-22 21:35:57 +0000
committerGabor Greif <ggreif@gmail.com>2009-01-22 21:35:57 +0000
commitf4013373cd9919fb7f4425ad549e4fdf0c875fba (patch)
treeca91eca70111f94b6a90c0122a063b49db4c37ae /llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
parent8c5ffd07610476f5e7fd95fca8817e12c76584f4 (diff)
downloadllvm-f4013373cd9919fb7f4425ad549e4fdf0c875fba.zip
llvm-f4013373cd9919fb7f4425ad549e4fdf0c875fba.tar.gz
llvm-f4013373cd9919fb7f4425ad549e4fdf0c875fba.tar.bz2
introduce a useful abstraction to find out if a Use is in the call position of an instruction
llvm-svn: 62788
Diffstat (limited to 'llvm/lib/Transforms/IPO/IPConstantPropagation.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/IPConstantPropagation.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp b/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
index 6ae8276..2dc85582 100644
--- a/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -88,11 +88,12 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) {
for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) {
// Used by a non-instruction, or not the callee of a function, do not
// transform.
- if (UI.getOperandNo() != 0 ||
- (!isa<CallInst>(*UI) && !isa<InvokeInst>(*UI)))
+ if (!isa<CallInst>(*UI) && !isa<InvokeInst>(*UI))
return false;
CallSite CS = CallSite::get(cast<Instruction>(*UI));
+ if (!CS.isCallee(UI))
+ return false;
// Check out all of the potentially constant arguments. Note that we don't
// inspect varargs here.
@@ -219,7 +220,7 @@ bool IPCP::PropagateConstantReturn(Function &F) {
// Not a call instruction or a call instruction that's not calling F
// directly?
- if (!Call || UI.getOperandNo() != 0)
+ if (!Call || !CS.isCallee(UI))
continue;
// Call result not used?