summaryrefslogtreecommitdiff
path: root/include/llvm/Support/CallSite.h
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-03-19 11:55:53 +0000
committerGabor Greif <ggreif@gmail.com>2010-03-19 11:55:53 +0000
commitf4f10e37791cef519a057d10d12f688333f554a7 (patch)
tree08e36ccdb6b97dac5ae0aecc00aeceff03cdfae5 /include/llvm/Support/CallSite.h
parent1a9158c301b58d8119664f416461d5a5549170c4 (diff)
downloadllvm-f4f10e37791cef519a057d10d12f688333f554a7.tar.gz
llvm-f4f10e37791cef519a057d10d12f688333f554a7.tar.bz2
llvm-f4f10e37791cef519a057d10d12f688333f554a7.tar.xz
Recommit r80858 again (which has been backed out in r80871).
This time I did a self-hosted bootstrap on Linux x86-64, with no problems. Let's see how darwin 64-bit self-hosting goes. At the first sign of failure I'll back this out. Maybe the valgrind bots give me a hint of what may be wrong (it at all). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/CallSite.h')
-rw-r--r--include/llvm/Support/CallSite.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h
index 285b558afc..5bfcc6d84f 100644
--- a/include/llvm/Support/CallSite.h
+++ b/include/llvm/Support/CallSite.h
@@ -118,7 +118,7 @@ public:
///
Value *getCalledValue() const {
assert(getInstruction() && "Not a call or invoke instruction!");
- return getInstruction()->getOperand(0);
+ return *getCallee();
}
/// getCalledFunction - Return the function being called if this is a direct
@@ -132,7 +132,7 @@ public:
///
void setCalledFunction(Value *V) {
assert(getInstruction() && "Not a call or invoke instruction!");
- getInstruction()->setOperand(0, V);
+ *getCallee() = V;
}
Value *getArgument(unsigned ArgNo) const {
@@ -146,6 +146,16 @@ public:
getInstruction()->setOperand(getArgumentOffset() + ArgNo, newVal);
}
+ /// Given a value use iterator, returns the argument that corresponds to it.
+ /// Iterator must actually correspond to an argument.
+ unsigned getArgumentNo(Value::use_iterator I) const {
+ assert(getInstruction() && "Not a call or invoke instruction!");
+ assert(arg_begin() <= &I.getUse() && &I.getUse() < arg_end()
+ && "Argument # out of range!");
+
+ return &I.getUse() - arg_begin();
+ }
+
/// Given an operand number, returns the argument that corresponds to it.
/// OperandNo must be a valid operand number that actually corresponds to an
/// argument.
@@ -171,7 +181,7 @@ public:
return getInstruction()->op_begin() + getArgumentOffset();
}
- arg_iterator arg_end() const { return getInstruction()->op_end(); }
+ arg_iterator arg_end() const { return getInstruction()->op_end() - getArgumentEndOffset(); }
bool arg_empty() const { return arg_end() == arg_begin(); }
unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); }
@@ -180,17 +190,25 @@ public:
}
bool isCallee(Value::use_iterator UI) const {
- return getInstruction()->op_begin() == &UI.getUse();
+ return getCallee() == &UI.getUse();
}
-
private:
/// Returns the operand number of the first argument
unsigned getArgumentOffset() const {
if (isCall())
return 1; // Skip Function
else
- return 3; // Skip Function, BB, BB
+ return 0; // Args are at the front
}
+
+ unsigned getArgumentEndOffset() const {
+ if (isCall())
+ return 0; // Unchanged
+ else
+ return 3; // Skip BB, BB, Function
+ }
+
+ User::op_iterator getCallee() const;
};
} // End llvm namespace