Added ContainsRelocations() to check if a constant might only be resolvable at load...
authorEvan Cheng <evan.cheng@apple.com>
Thu, 8 Mar 2007 00:59:12 +0000 (00:59 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 8 Mar 2007 00:59:12 +0000 (00:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35014 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constant.h
lib/VMCore/Constants.cpp

index 985f1908dab70e636839bf6513913763ffe54967..4b3547ebf8f6b8c9192be0f26d0395429fbe09e6 100644 (file)
@@ -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) {
index 9d9cc5a2ec0348c0c5550ab179dee3104aac7bad..1685923e4338cb436b31a46ddc751a45f8e946ec 100644 (file)
@@ -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()) {