[llvm-commits] [llvm] r68032 - in /llvm/trunk: include/llvm/Target/ELFTargetAsmInfo.h lib/Target/DarwinTargetAsmInfo.cpp lib/Target/ELFTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp
Anton Korobeynikov
asl at math.spbu.ru
Mon Mar 30 08:27:43 PDT 2009
Author: asl
Date: Mon Mar 30 10:27:43 2009
New Revision: 68032
URL: http://llvm.org/viewvc/llvm-project?rev=68032&view=rev
Log:
Do not propagate ELF-specific stuff (data.rel) into other targets. This simplifies code and also ensures correctness.
Modified:
llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
llvm/trunk/lib/Target/TargetAsmInfo.cpp
llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
Modified: llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h?rev=68032&r1=68031&r2=68032&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h Mon Mar 30 10:27:43 2009
@@ -25,6 +25,7 @@
struct ELFTargetAsmInfo: public TargetAsmInfo {
explicit ELFTargetAsmInfo(const TargetMachine &TM);
+ SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const;
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
virtual std::string printSectionFlags(unsigned flags) const;
const Section* MergeableConstSection(const GlobalVariable *GV) const;
Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=68032&r1=68031&r2=68032&view=diff
==============================================================================
--- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Mon Mar 30 10:27:43 2009
@@ -85,9 +85,6 @@
else
return TextSection;
case SectionKind::Data:
- case SectionKind::DataRel:
- case SectionKind::DataRelRO:
- case SectionKind::DataRelROLocal:
case SectionKind::ThreadData:
case SectionKind::BSS:
case SectionKind::ThreadBSS:
Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=68032&r1=68031&r2=68032&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Mon Mar 30 10:27:43 2009
@@ -44,6 +44,30 @@
SectionFlags::Writeable);
}
+SectionKind::Kind
+ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
+ SectionKind::Kind Kind = TargetAsmInfo::SectionKindForGlobal(GV);
+
+ if (Kind != SectionKind::Data)
+ return Kind;
+
+ // Decide, whether we need data.rel stuff
+ const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
+ if (GVar->hasInitializer()) {
+ Constant *C = GVar->getInitializer();
+ bool isConstant = GVar->isConstant();
+ unsigned Reloc = RelocBehaviour();
+ if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
+ return (C->ContainsRelocations(Reloc::Local) ?
+ (isConstant ?
+ SectionKind::DataRelROLocal : SectionKind::DataRelLocal) :
+ (isConstant ?
+ SectionKind::DataRelRO : SectionKind::DataRel));
+ }
+
+ return Kind;
+}
+
const Section*
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
SectionKind::Kind Kind = SectionKindForGlobal(GV);
Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=68032&r1=68031&r2=68032&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Mon Mar 30 10:27:43 2009
@@ -220,18 +220,14 @@
unsigned Reloc = RelocBehaviour();
// We already did a query for 'all' relocs, thus - early exits.
- if (Reloc == Reloc::LocalOrGlobal) {
- return (C->ContainsRelocations(Reloc::Local) ?
- SectionKind::DataRelROLocal : SectionKind::DataRelRO);
- } else if (Reloc == Reloc::None)
+ if (Reloc == Reloc::LocalOrGlobal)
+ return SectionKind::Data;
+ else if (Reloc == Reloc::None)
return SectionKind::ROData;
else {
// Ok, target wants something funny. Honour it.
- if (C->ContainsRelocations(Reloc)) {
- return (Reloc == Reloc::Local ?
- SectionKind::DataRelROLocal : SectionKind::DataRelRO);
- } else
- return SectionKind::ROData;
+ return (C->ContainsRelocations(Reloc) ?
+ SectionKind::Data : SectionKind::ROData);
}
} else {
// Check, if initializer is a null-terminated string
@@ -243,18 +239,7 @@
}
// Variable either is not constant or thread-local - output to data section.
- if (isThreadLocal)
- return SectionKind::ThreadData;
-
- if (GVar->hasInitializer()) {
- Constant *C = GVar->getInitializer();
- unsigned Reloc = RelocBehaviour();
- if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
- return (C->ContainsRelocations(Reloc::Local) ?
- SectionKind::DataRelLocal : SectionKind::DataRel);
- }
-
- return SectionKind::Data;
+ return (isThreadLocal ? SectionKind::ThreadData : SectionKind::Data);
}
unsigned
Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=68032&r1=68031&r2=68032&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Mon Mar 30 10:27:43 2009
@@ -305,12 +305,17 @@
switch (kind) {
case SectionKind::Text:
return ".text$linkonce" + GV->getName();
+ case SectionKind::Data:
+ case SectionKind::BSS:
+ case SectionKind::ThreadData:
+ case SectionKind::ThreadBSS:
+ return ".data$linkonce" + GV->getName();
case SectionKind::ROData:
case SectionKind::RODataMergeConst:
case SectionKind::RODataMergeStr:
return ".rdata$linkonce" + GV->getName();
default:
- return ".data$linkonce" + GV->getName();
+ assert(0 && "Unknown section kind");
}
return NULL;
}
More information about the llvm-commits
mailing list