summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-06-12 17:48:10 +0000
committerPete Cooper <peter_cooper@apple.com>2015-06-12 17:48:10 +0000
commitb4eede2c079ef0475c023f883d48e10e15401d16 (patch)
tree3b38116b03b948b7381c9085bc022889d979f4bc /llvm/lib/IR/Value.cpp
parent74510a409dcef1a8f102f4a2accb9a61b37c738a (diff)
downloadbcm5719-llvm-b4eede2c079ef0475c023f883d48e10e15401d16.tar.gz
bcm5719-llvm-b4eede2c079ef0475c023f883d48e10e15401d16.zip
Rename NumOperands to make it clear its managed by the User. NFC.
This is to try make it very clear that subclasses shouldn't be changing the value directly. Now that OperandList for normal instructions is computed using the NumOperands, its critical that the NumOperands is accurate or we could compute the wrong offset to the first operand. I looked over all places which update NumOperands and they are all safe. Hung off use User's don't use NumOperands to compute the OperandList so they are safe to continue to manipulate it. The only other User which changed it was GlobalVariable which has an optional init list but always allocated space for a single Use. It was correctly setting NumOperands to 1 before setting an initializer, and setting it to 0 after clearing the init list, so the order was safe. Added some comments to that code to make sure that this isn't changed in future without being aware of this constraint. Reviewed by Duncan Exon Smith. llvm-svn: 239621
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index dcf0ad50190..eb5c2253f4e 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -39,6 +39,7 @@ using namespace llvm;
//===----------------------------------------------------------------------===//
// Value Class
//===----------------------------------------------------------------------===//
+const unsigned Value::NumUserOperandsBits;
static inline Type *checkType(Type *Ty) {
assert(Ty && "Value defined with a null type: Error!");
@@ -48,7 +49,7 @@ static inline Type *checkType(Type *Ty) {
Value::Value(Type *ty, unsigned scid)
: VTy(checkType(ty)), UseList(nullptr), SubclassID(scid),
HasValueHandle(0), SubclassOptionalData(0), SubclassData(0),
- NumOperands(0), IsUsedByMD(false), HasName(false) {
+ NumUserOperands(0), IsUsedByMD(false), HasName(false) {
// FIXME: Why isn't this in the subclass gunk??
// Note, we cannot call isa<CallInst> before the CallInst has been
// constructed.
OpenPOWER on IntegriCloud