[PATCH] D65837: For explicit sections, limit unique section ids to when fintegrated-as=true.
Rahman Lavaee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 09:50:27 PDT 2019
rahmanl updated this revision to Diff 213930.
rahmanl edited the summary of this revision.
rahmanl added a comment.
Added test case.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65837/new/
https://reviews.llvm.org/D65837
Files:
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
test/CodeGen/X86/explicit-elf-sections.ll
Index: test/CodeGen/X86/explicit-elf-sections.ll
===================================================================
--- test/CodeGen/X86/explicit-elf-sections.ll
+++ test/CodeGen/X86/explicit-elf-sections.ll
@@ -1,4 +1,5 @@
; 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 -no-integrated-as -function-sections=1 -data-sections=1 | FileCheck %s -check-prefix=NIAS
; 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 }
@@ -63,3 +64,28 @@
; SECTIONS: w:
+; With -no-integrated-as, function and data sections are only created
+; for implicit sections.
+;
+; NIAS: .section aaa,"ax", at progbits
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: f:
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: g:
+; NIAS: .section .text.h,"ax", at progbits
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: h:
+; NIAS: .section aaa,"ax", at progbits
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: i:
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: x:
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: y:
+; NIAS: .section .data.z,"aw", at progbits
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: z:
+; NIAS: .section aaa,"ax", at progbits
+; NIAS-NOT: {{\.section|\.text|\.data}}
+; NIAS: w:
+
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -588,15 +588,18 @@
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();
+ if (TM.getMCAsmInfo()->useIntegratedAssembler()) {
+ // If we are using the integrated assembler and we have -ffunction-sections
+ // or -fdata-sections, then we emit the global value into 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();
}
- EmitUniqueSection |= GO->hasComdat();
// A section can have at most one associated section. Put each global with
// MD_associated in a unique section.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65837.213930.patch
Type: text/x-patch
Size: 2696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190807/a40a6fb5/attachment.bin>
More information about the llvm-commits
mailing list