diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-03-29 17:13:18 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-03-29 17:13:18 +0000 |
| commit | 7437b59caf36e995ae62a47490d5919dc9146548 (patch) | |
| tree | b9207b536d6e70314c4ccfa2475334278ef8f614 /llvm/lib | |
| parent | e6adeeece35cf93c9840095a62ec38ae03dae60e (diff) | |
| download | bcm5719-llvm-7437b59caf36e995ae62a47490d5919dc9146548.tar.gz bcm5719-llvm-7437b59caf36e995ae62a47490d5919dc9146548.zip | |
Extend the relocation tracker handler, so we can filter on different 'kinds' of relocations required.
llvm-svn: 68004
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 6c99a1ffe88..62b3a0c6916 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -90,14 +90,29 @@ 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; +/// ContainsRelocations - Return true if the constant value contains relocations +/// which cannot be resolved at compile time. Kind argument is used to filter +/// only 'interesting' sorts of relocations. +bool Constant::ContainsRelocations(unsigned Kind) const { + if (const GlobalValue* GV = dyn_cast<GlobalValue>(this)) { + bool isLocal = GV->hasLocalLinkage(); + if ((Kind & Reloc::Local) && isLocal) { + // Global has local linkage and 'local' kind of relocations are + // requested + return true; + } + + if ((Kind & Reloc::Global) && !isLocal) { + // Global has non-local linkage and 'global' kind of relocations are + // requested + return true; + } + } + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) if (getOperand(i)->ContainsRelocations()) return true; + return false; } |

