[PATCH] D21743: Convenience function for MCStreamer to get named sections when lowering.

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 11:20:53 PDT 2016


Reid, didn't you add something like this for COFF?

Sent from my phone

On Sunday, June 26, 2016, Dean Michael Berris via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> dberris created this revision.
> dberris added reviewers: echristo, grosbach.
> dberris added a subscriber: llvm-commits.
> Herald added a subscriber: mehdi_amini.
>
> This change allows us to create uniquely identified "COMDAT" or "ELF
> Group" sections while lowering. In particular, for ELF sections this is
> useful for creating function-specific groups that get merged into the
> same named section.
>
> http://reviews.llvm.org/D21743
>
> Files:
>   include/llvm/MC/MCELFStreamer.h
>   include/llvm/MC/MCStreamer.h
>   lib/MC/MCELFStreamer.cpp
>   lib/MC/MCStreamer.cpp
>
> Index: lib/MC/MCStreamer.cpp
> ===================================================================
> --- lib/MC/MCStreamer.cpp
> +++ lib/MC/MCStreamer.cpp
> @@ -806,3 +806,8 @@
>    EmitLabel(Sym);
>    return Sym;
>  }
> +
> +MCSection *MCStreamer::getNamedGroupSection(StringRef, StringRef,
> unsigned) {
> +  llvm_unreachable("Unimplemented.");
> +  return nullptr;
> +}
> Index: lib/MC/MCELFStreamer.cpp
> ===================================================================
> --- lib/MC/MCELFStreamer.cpp
> +++ lib/MC/MCELFStreamer.cpp
> @@ -672,3 +672,11 @@
>                                     uint64_t Size, unsigned ByteAlignment)
> {
>    llvm_unreachable("ELF doesn't support this directive");
>  }
> +
> +MCSection *MCELFStreamer::getNamedGroupSection(StringRef Section,
> +                                               StringRef Identifier,
> +                                               unsigned EntSize) {
> +  return getContext().getELFSection(Section, ELF::SHT_PROGBITS,
> +                                    ELF::SHF_ALLOC | ELF::SHF_GROUP,
> EntSize,
> +                                    Identifier);
> +}
> Index: include/llvm/MC/MCStreamer.h
> ===================================================================
> --- include/llvm/MC/MCStreamer.h
> +++ include/llvm/MC/MCStreamer.h
> @@ -760,6 +760,12 @@
>    /// Get the .xdata section used for the given section.
>    MCSection *getAssociatedXDataSection(const MCSection *TextSec);
>
> +  /// Get a group section with provided group identifier. This is in ELF,
> for
> +  /// instance, named by concatenating \p Section with '.' then \p
> Identifier.
> +  virtual MCSection *getNamedGroupSection(StringRef Section,
> +                                          StringRef Identifier,
> +                                          unsigned EntSize);
> +
>    virtual void EmitSyntaxDirective();
>
>    /// \brief Emit a .reloc directive.
> Index: include/llvm/MC/MCELFStreamer.h
> ===================================================================
> --- include/llvm/MC/MCELFStreamer.h
> +++ include/llvm/MC/MCELFStreamer.h
> @@ -81,6 +81,9 @@
>    void EmitBundleLock(bool AlignToEnd) override;
>    void EmitBundleUnlock() override;
>
> +  MCSection *getNamedGroupSection(StringRef Section, StringRef Identifer,
> +                                  unsigned EntSize) override;
> +
>  private:
>    bool isBundleLocked() const;
>    void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &)
> override;
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160627/6389e197/attachment.html>


More information about the llvm-commits mailing list