aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO
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
commit6be9a1b0acfb99378d1b4027d13949b46a09392e (patch)
tree5da6a083d7eff2b5ba22d563b1a817caf42abcaf /lib/Transforms/IPO
parent3b2b6bde6ce92e6b8414ca8e89bd031485843ebd (diff)
downloadexternal_llvm-6be9a1b0acfb99378d1b4027d13949b46a09392e.zip
external_llvm-6be9a1b0acfb99378d1b4027d13949b46a09392e.tar.gz
external_llvm-6be9a1b0acfb99378d1b4027d13949b46a09392e.tar.bz2
introduce a useful abstraction to find out if a Use is in the call position of an instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--lib/Transforms/IPO/IPConstantPropagation.cpp7
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp5
3 files changed, 6 insertions, 8 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index 69e427e..183e1a1 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -135,7 +135,7 @@ bool ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
// Ensure that this call site is CALLING the function, not passing it as
// an argument.
- if (UI.getOperandNo() != 0)
+ if (!CS.isCallee(UI))
return false;
}
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index 6ae8276..2dc8558 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/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?
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 00556f9..9f54388 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -149,14 +149,11 @@ bool SRETPromotion::isSafeToUpdateAllCallers(Function *F) {
FnUseI != FnUseE; ++FnUseI) {
// The function is passed in as an argument to (possibly) another function,
// we can't change it!
- if (FnUseI.getOperandNo() != 0)
- return false;
-
CallSite CS = CallSite::get(*FnUseI);
Instruction *Call = CS.getInstruction();
// The function is used by something else than a call or invoke instruction,
// we can't change it!
- if (!Call)
+ if (!Call || !CS.isCallee(FnUseI))
return false;
CallSite::arg_iterator AI = CS.arg_begin();
Value *FirstArg = *AI;