aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-03-29 17:13:18 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-03-29 17:13:18 +0000
commitab267a28239f628e65bef34578695d80ba6d0a9e (patch)
treeb0d893d4948cfb45c0abe5c01de1d04f3474bedb /lib/VMCore/Constants.cpp
parent004e27cc1bba070f013589cc8e434b03589c3c22 (diff)
Extend the relocation tracker handler, so we can filter on different 'kinds' of relocations required.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r--lib/VMCore/Constants.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 6c99a1ffe8..62b3a0c691 100644
--- a/lib/VMCore/Constants.cpp
+++ b/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;
}