Added ContainsRelocations() to check if a constant might only be resolvable at load time.

llvm-svn: 35014
This commit is contained in:
Evan Cheng 2007-03-08 00:59:12 +00:00
parent f030f2d628
commit f9e003b653
2 changed files with 15 additions and 0 deletions

View 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) {

View 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()) {