[PATCH] D12423: MCAsmInfo: Allow targets to specify when the .section directive should be omitted
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 07:39:33 PDT 2015
I don't think this is correct. If a target is not using
COFF/MachO/ELF, it should never create a
MCSectionCOFF/MCSectionMacho/MCSectionELF.
IMHO what is needed is something like r245047 (with the logic for
picking the triple from -march fixed). With that you can them make
sure that you never create a section if your object format doesn't
have one.
On 27 August 2015 at 21:50, Tom Stellard <thomas.stellard at amd.com> wrote:
> tstellarAMD created this revision.
> tstellarAMD added reviewers: rafael, grosbach.
> tstellarAMD added a subscriber: llvm-commits.
>
> The default behavior is to omit the .section directive for .text, .data,
> and sometimes .bss, but some targets may want to omit this directive for
> other sections too.
>
> A future change to the AMDGPU backend will make use of this new feature
> and have tests.
>
> http://reviews.llvm.org/D12423
>
> Files:
> include/llvm/MC/MCAsmInfo.h
> lib/MC/MCAsmInfo.cpp
> lib/MC/MCSectionELF.cpp
>
> Index: lib/MC/MCSectionELF.cpp
> ===================================================================
> --- lib/MC/MCSectionELF.cpp
> +++ lib/MC/MCSectionELF.cpp
> @@ -27,12 +27,7 @@
> if (isUnique())
> return false;
>
> - // FIXME: Does .section .bss/.data/.text work everywhere??
> - if (Name == ".text" || Name == ".data" ||
> - (Name == ".bss" && !MAI.usesELFSectionDirectiveForBSS()))
> - return true;
> -
> - return false;
> + return MAI.shouldOmitSectionDirective(Name);
> }
>
> static void printName(raw_ostream &OS, StringRef Name) {
> Index: lib/MC/MCAsmInfo.cpp
> ===================================================================
> --- lib/MC/MCAsmInfo.cpp
> +++ lib/MC/MCAsmInfo.cpp
> @@ -157,3 +157,9 @@
>
> return true;
> }
> +
> +bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
> + // FIXME: Does .section .bss/.data/.text work everywhere??
> + return SectionName == ".text" || SectionName == ".data" ||
> + (SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
> +}
> Index: include/llvm/MC/MCAsmInfo.h
> ===================================================================
> --- include/llvm/MC/MCAsmInfo.h
> +++ include/llvm/MC/MCAsmInfo.h
> @@ -414,6 +414,10 @@
> /// syntactically correct.
> virtual bool isValidUnquotedName(StringRef Name) const;
>
> + /// Return true if the .section directive should be omitted when
> + /// emitting \p SectionName.
> + virtual bool shouldOmitSectionDirective(StringRef SectionName) const;
> +
> bool usesSunStyleELFSectionSwitchSyntax() const {
> return SunStyleELFSectionSwitchSyntax;
> }
>
>
More information about the llvm-commits
mailing list