aboutsummaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-22 00:05:44 +0000
committerChris Lattner <sabre@nondot.org>2009-07-22 00:05:44 +0000
commit7cf12c7efd37dc12c3ed536a3f4c373dddac2b85 (patch)
tree9eaf5648fd1b7eb369792e52af192cbf59dbdb0e /lib/Target
parent9c5beed5f5a6da5bd86c7dee6f8f803e8960e6a6 (diff)
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
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/ELFTargetAsmInfo.cpp18
-rw-r--r--lib/Target/TargetAsmInfo.cpp4
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 5deabee0ba..1bcfaf91ad 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -54,20 +54,20 @@ ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
// 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;
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 580c3fe4db..96814fee4c 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -202,13 +202,13 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
if (isSuitableForBSS(GVar)) {
// Variable can be easily put to BSS section.
- return (isThreadLocal ? SectionKind::ThreadBSS : SectionKind::BSS);
+ return isThreadLocal ? SectionKind::ThreadBSS : SectionKind::BSS;
} else if (GVar->isConstant() && !isThreadLocal) {
// Now we know, that variable has initializer and it is constant. We need to
// check its initializer to decide, which section to output it into. Also
// note, there is no thread-local r/o section.
Constant *C = GVar->getInitializer();
- if (C->ContainsRelocations(Reloc::LocalOrGlobal)) {
+ if (C->getRelocationInfo() != 0) {
// Decide whether it is still possible to put symbol into r/o section.
if (TM.getRelocationModel() != Reloc::Static)
return SectionKind::Data;