diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-03-08 00:59:12 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-03-08 00:59:12 +0000 |
commit | afe15815571b34d7d53e5a005240686089b18361 (patch) | |
tree | 2b4ea3ef05386422f00c3ce24b9d46829a313598 | |
parent | 603b83ebcdfb9c27e44c1da16f2799755e3e3022 (diff) | |
download | external_llvm-afe15815571b34d7d53e5a005240686089b18361.zip external_llvm-afe15815571b34d7d53e5a005240686089b18361.tar.gz external_llvm-afe15815571b34d7d53e5a005240686089b18361.tar.bz2 |
Added ContainsRelocations() to check if a constant might only be resolvable at load time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35014 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Constant.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index 985f190..4b3547e 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -59,6 +59,10 @@ public: /// true for things like constant expressions that could divide by zero. bool canTrap() const; + /// ContaintsRelocations - Return true if the constant value contains + /// relocations which cannot be resolved at compile time. + bool ContainsRelocations() const; + // Specialize get/setOperand for Constant's as their operands are always // constants as well. Constant *getOperand(unsigned i) { diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 9d9cc5a..1685923 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -90,6 +90,17 @@ bool Constant::canTrap() const { } } +/// ContaintsRelocations - Return true if the constant value contains +/// relocations which cannot be resolved at compile time. +bool Constant::ContainsRelocations() const { + if (isa<GlobalValue>(this)) + return true; + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) + if (getOperand(i)->ContainsRelocations()) + return true; + return false; +} + // Static constructor to create a '0' constant of arbitrary type... Constant *Constant::getNullValue(const Type *Ty) { switch (Ty->getTypeID()) { |