reimplement Constant::ContainsRelocations as
Constant::getRelocationInfo(), which has a much simpler
to use API. It still should not be part of libvmcore, but
is better than it was. Also teach it to be smart about
hidden visibility.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76700 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 5deabee..1bcfaf9 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -54,20 +54,20 @@
// Decide, whether we need data.rel stuff
const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
- if (GVar->hasInitializer()) {
+ if (GVar->hasInitializer() && TM.getRelocationModel() != Reloc::Static) {
Constant *C = GVar->getInitializer();
bool isConstant = GVar->isConstant();
-
// By default - all relocations in PIC mode would force symbol to be
// placed in r/w section.
- if (TM.getRelocationModel() != Reloc::Static &&
- C->ContainsRelocations(Reloc::LocalOrGlobal))
- return (C->ContainsRelocations(Reloc::Global) ?
- (isConstant ?
- SectionKind::DataRelRO : SectionKind::DataRel) :
- (isConstant ?
- SectionKind::DataRelROLocal : SectionKind::DataRelLocal));
+ switch (C->getRelocationInfo()) {
+ default: break;
+ case 1:
+ return isConstant ? SectionKind::DataRelROLocal :
+ SectionKind::DataRelLocal;
+ case 2:
+ return isConstant ? SectionKind::DataRelRO : SectionKind::DataRel;
+ }
}
return Kind;