Revert r367501 "Create unique, but identically-named ELF sections..."
authorBob Haarman <llvm@inglorion.net>
Wed, 7 Aug 2019 20:45:23 +0000 (20:45 +0000)
committerBob Haarman <llvm@inglorion.net>
Wed, 7 Aug 2019 20:45:23 +0000 (20:45 +0000)
This reverts commit fbc563e2cb6c5f1d0200b390513506b6aca4d2e9 "Create
unique, but identically-named ELF sections for explicitly-sectioned
functions and globals when using -function-sections and
-data-sections."

Reason for revert: sections are created with potentially wrong
attributes.

llvm-svn: 368204

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/X86/elf-associated.ll
llvm/test/CodeGen/X86/explicit-elf-sections.ll [deleted file]

index 7a93a262bb9add8641b71638300a07d140299c5a..ac7c4c50ae4cb08127649031a89319b5d25a148d 100644 (file)
@@ -586,30 +586,15 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
     Flags |= ELF::SHF_GROUP;
   }
 
-  bool EmitUniqueSection = false;
-
-  // If we have -ffunction-sections or -fdata-sections then we should emit the
-  // global value to a uniqued section of the same name.
-  if (!(Flags & ELF::SHF_MERGE) && !Kind.isCommon()) {
-    if (Kind.isText())
-      EmitUniqueSection = TM.getFunctionSections();
-    else
-      EmitUniqueSection = TM.getDataSections();
-  }
-  EmitUniqueSection |= GO->hasComdat();
-
   // A section can have at most one associated section. Put each global with
   // MD_associated in a unique section.
+  unsigned UniqueID = MCContext::GenericSectionID;
   const MCSymbolELF *AssociatedSymbol = getAssociatedSymbol(GO, TM);
   if (AssociatedSymbol) {
-    EmitUniqueSection = true;
+    UniqueID = NextUniqueID++;
     Flags |= ELF::SHF_LINK_ORDER;
   }
 
-  unsigned UniqueID = MCContext::GenericSectionID;
-  if (EmitUniqueSection)
-    UniqueID = NextUniqueID++;
-
   MCSectionELF *Section = getContext().getELFSection(
       SectionName, getELFSectionType(SectionName, Kind), Flags,
       getEntrySizeForKind(Kind), Group, UniqueID, AssociatedSymbol);
index 3d0cf6c1f8734d4946cec596aa33909f27e3b666..e0e9e00582892e1784057cc19dd4ab90bc62f87b 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llc -data-sections=1 -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s --check-prefix=DSECTIONS --check-prefix=CHECK
-; RUN: llc -data-sections=0 -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s --check-prefix=NDSECTIONS --check-prefix=CHECK
+; RUN: llc -data-sections=1 -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s
+; RUN: llc -data-sections=0 -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s
 
 @a = global i32 1
 @b = global i32 2, !associated !0
 @j = global i32 1, section "bbb", !associated !4
 @k = global i32 1, !associated !4
 !4 = !{i32* @h}
-; NDSECTIONS-DAG: .section     aaa,"aw",@progbits
-; NDSECTIONS-DAG: .section     bbb,"awo",@progbits,h,unique,1
-; NDSECTIONS-DAG: .section     bbb,"awo",@progbits,h,unique,2
-
-; DSECTIONS-DAG: .section      aaa,"aw",@progbits,unique,1
-; DSECTIONS-DAG: .section      bbb,"awo",@progbits,h,unique,2
-; DSECTIONS-DAG: .section      bbb,"awo",@progbits,h,unique,3
-
+; CHECK-DAG: .section  aaa,"aw",@progbits
+; CHECK-DAG: .section  bbb,"awo",@progbits,h,unique,1
+; CHECK-DAG: .section  bbb,"awo",@progbits,h,unique,2
 ; CHECK-DAG: .section  .data.k,"awo",@progbits,h
 
 ; Non-GlobalValue metadata.
@@ -52,5 +47,4 @@
 @n = alias i32, i32* inttoptr (i64 add (i64 ptrtoint (i32* @a to i64), i64 1297036692682702848) to i32*)
 @o = global i32 1, section "eee", !associated !7
 !7 = !{i32* @n}
-; NDSECTIONS-DAG: .section     eee,"awo",@progbits,n,unique,3
-; DSECTIONS-DAG: .section      eee,"awo",@progbits,n,unique,6
+; CHECK-DAG: .section  eee,"awo",@progbits,n,unique,3
diff --git a/llvm/test/CodeGen/X86/explicit-elf-sections.ll b/llvm/test/CodeGen/X86/explicit-elf-sections.ll
deleted file mode 100644 (file)
index 549d362..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections=1 -data-sections=1 | FileCheck %s -check-prefix=SECTIONS
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections=0 -data-sections=0 | FileCheck %s -check-prefix=NSECTIONS
-
-define void @f() section "aaa" { ret void }
-define void @g() section "aaa" { ret void }
-
-define void @h() { ret void }
-
-@x = global i32 1, section "aaa"
-@y = global i32 1, section "aaa"
-@z = global i32 1
-
-define void @i() section "aaa" { ret void }
-
-@w = global i32 1, section "aaa"
-
-; NSECTIONS:           .section        aaa,"ax",@progbits
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           f:
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           g:
-; NSECTIONS:           .text
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           h:
-; NSECTIONS:           .section        aaa,"ax",@progbits
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           i:
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           x:
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           y:
-; NSECTIONS:           .data
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           z:
-; NSECTIONS:           .section        aaa,"ax",@progbits
-; NSECTIONS-NOT:       {{\.section|\.text|\.data}}
-; NSECTIONS:           w:
-
-
-; SECTIONS:    .section        aaa,"ax",@progbits,unique,1
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    f:
-; SECTIONS:    .section        aaa,"ax",@progbits,unique,2
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    g:
-; SECTIONS:    .section        .text.h,"ax",@progbits
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    h:
-; SECTIONS:    .section        aaa,"ax",@progbits,unique,3
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    i:
-; SECTIONS:    .section        aaa,"aw",@progbits,unique,4
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    x:
-; SECTIONS:    .section        aaa,"aw",@progbits,unique,5
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    y:
-; SECTIONS:    .section        .data.z,"aw",@progbits
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    z:
-; SECTIONS:    .section        aaa,"aw",@progbits,unique,6
-; SECTIONS-NOT:        {{\.section|\.text|\.data}}
-; SECTIONS:    w:
-
-