aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Target/TargetAsmInfo.h3
-rw-r--r--lib/Target/X86/X86TargetAsmInfo.cpp30
2 files changed, 22 insertions, 11 deletions
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index 0c946da..bcd6561 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -53,8 +53,9 @@ namespace llvm {
TLS = 1 << 5, ///< Section contains thread-local data
Debug = 1 << 6, ///< Section contains debug data
Linkonce = 1 << 7, ///< Section is linkonce
- Named = 1 << 8, ///< Section is named
+ TypeFlags = 0xFF,
// Some gap for future flags
+ Named = 1 << 23, ///< Section is named
EntitySize = 0xFF << 24 ///< Entity size for mergeable sections
};
diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp
index a53f4a1..0fdc0ee 100644
--- a/lib/Target/X86/X86TargetAsmInfo.cpp
+++ b/lib/Target/X86/X86TargetAsmInfo.cpp
@@ -323,8 +323,10 @@ X86DarwinTargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
Type = C->getType();
unsigned Size = TD->getABITypeSize(Type);
- if (Size > 16) {
- // Too big for mergeable
+ if (Size > 16 ||
+ !(Flags & SectionFlags::Strings ||
+ (Size == 4 || Size == 8 || Size == 16))) {
+ // Not suitable for mergeable
Size = 0;
Flags &= ~SectionFlags::Mergeable;
}
@@ -516,8 +518,12 @@ X86ELFTargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
Type = C->getType();
unsigned Size = TD->getABITypeSize(Type);
- if (Size > 16) {
- // Too big for mergeable
+ // FIXME: size check here ugly, and will hopefully have gone, when we will
+ // have sane interface for attaching flags to sections.
+ if (Size > 16 ||
+ !(Flags & SectionFlags::Strings ||
+ (Size == 4 || Size == 8 || Size == 16))) {
+ // Not suitable for mergeable
Size = 0;
Flags &= ~SectionFlags::Mergeable;
}
@@ -529,9 +535,11 @@ X86ELFTargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
// Mark section as named, when needed (so, we we will need .section directive
// to switch into it).
- if (Flags & (SectionFlags::Mergeable |
- SectionFlags::TLS |
- SectionFlags::Linkonce))
+ unsigned TypeFlags = Flags & SectionFlags::TypeFlags;
+ if (!TypeFlags /* Read-only section */ ||
+ (TypeFlags & (SectionFlags::Mergeable |
+ SectionFlags::TLS |
+ SectionFlags::Linkonce)))
Flags |= SectionFlags::Named;
return Flags;
@@ -668,9 +676,11 @@ X86COFFTargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
// Mark section as named, when needed (so, we we will need .section directive
// to switch into it).
- if (Flags & (SectionFlags::Mergeable ||
- SectionFlags::TLS ||
- SectionFlags::Linkonce))
+ unsigned TypeFlags = Flags & SectionFlags::TypeFlags;
+ if (!TypeFlags /* Read-only section */ ||
+ (TypeFlags & (SectionFlags::Mergeable |
+ SectionFlags::TLS |
+ SectionFlags::Linkonce)))
Flags |= SectionFlags::Named;
return Flags;