[llvm-commits] [llvm] r53312 - in /llvm/trunk/lib/Target: TargetAsmInfo.cpp X86/X86TargetAsmInfo.cpp

Anton Korobeynikov asl at math.spbu.ru
Wed Jul 9 06:25:46 PDT 2008


Author: asl
Date: Wed Jul  9 08:25:46 2008
New Revision: 53312

URL: http://llvm.org/viewvc/llvm-project?rev=53312&view=rev
Log:
Fix several bugs in named sections handling

Modified:
    llvm/trunk/lib/Target/TargetAsmInfo.cpp
    llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp

Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=53312&r1=53311&r2=53312&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Wed Jul  9 08:25:46 2008
@@ -235,7 +235,7 @@
   }
 
   // Add flags from sections, if any.
-  if (Name) {
+  if (Name && *Name) {
     Flags |= SectionFlags::Named;
 
     // Some lame default implementation based on some magic section names.
@@ -279,7 +279,7 @@
   // directive and also append funky flags. Otherwise - section name is just
   // some magic assembler directive.
   if (Flags & SectionFlags::Named)
-    Name = SwitchToSectionDirective + Name + PrintSectionFlags(Flags);
+    Name = getSwitchToSectionDirective() + Name + PrintSectionFlags(Flags);
 
   return Name;
 }

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=53312&r1=53311&r2=53312&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Wed Jul  9 08:25:46 2008
@@ -336,9 +336,9 @@
   bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
 
   ReadOnlySection = ".rodata";
-  FourByteConstantSection = ".rodata.cst";
-  EightByteConstantSection = ".rodata.cst";
-  SixteenByteConstantSection = ".rodata.cst";
+  FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\", at progbits,4";
+  EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\", at progbits,8";
+  SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\", at progbits,16";
   CStringSection = ".rodata.str";
   PrivateGlobalPrefix = ".L";
   WeakRefDirective = "\t.weak\t";
@@ -466,12 +466,10 @@
   unsigned Size = SectionFlags::getEntitySize(Flags);
 
   // FIXME: string here is temporary, until stuff will fully land in.
-  if (Size == 4)
-    return FourByteConstantSection;
-  else if (Size == 8)
-    return EightByteConstantSection;
-  else if (Size == 16)
-    return SixteenByteConstantSection;
+  // We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's
+  // currently directly used by asmprinter.
+  if (Size == 4 || Size == 8 || Size == 16)
+    return ".rodata.cst" + utostr(Size);
 
   return getReadOnlySection();
 }
@@ -525,8 +523,8 @@
 
   // Mark section as named, when needed (so, we we will need .section directive
   // to switch into it).
-  if (Flags & (SectionFlags::Mergeable ||
-               SectionFlags::TLS ||
+  if (Flags & (SectionFlags::Mergeable |
+               SectionFlags::TLS |
                SectionFlags::Linkonce))
     Flags |= SectionFlags::Named;
 





More information about the llvm-commits mailing list