From 083cf1574facc9ce468fba1735c794bd7e520108 Mon Sep 17 00:00:00 2001 From: Jan Wen Voung Date: Mon, 4 Oct 2010 17:32:41 +0000 Subject: Add hook in MCSection to decide when to use "optimized nops", for each section kind. Previously, optimized nops were only used for MachO. Also added tests for ELF and COFF. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115523 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCSection.h | 4 ++++ include/llvm/MC/MCSectionCOFF.h | 1 + include/llvm/MC/MCSectionELF.h | 3 ++- include/llvm/MC/MCSectionMachO.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 5c99735..3e5b5f1 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -61,6 +61,10 @@ namespace llvm { return false; } + // UseCodeAlign - Return true if a .align directive should use + // "optimized nops" to fill instead of 0s. + virtual bool UseCodeAlign() const = 0; + static bool classof(const MCSection *) { return true; } }; diff --git a/include/llvm/MC/MCSectionCOFF.h b/include/llvm/MC/MCSectionCOFF.h index f828e10..62d07cf 100644 --- a/include/llvm/MC/MCSectionCOFF.h +++ b/include/llvm/MC/MCSectionCOFF.h @@ -55,6 +55,7 @@ namespace llvm { virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; + virtual bool UseCodeAlign() const; static bool classof(const MCSection *S) { return S->getVariant() == SV_COFF; diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index f97ab16..a92d0f2 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -178,7 +178,8 @@ public: void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; - + virtual bool UseCodeAlign() const; + /// isBaseAddressKnownZero - We know that non-allocatable sections (like /// debug info) have a base of zero. virtual bool isBaseAddressKnownZero() const { diff --git a/include/llvm/MC/MCSectionMachO.h b/include/llvm/MC/MCSectionMachO.h index 2d9d133..19d003a 100644 --- a/include/llvm/MC/MCSectionMachO.h +++ b/include/llvm/MC/MCSectionMachO.h @@ -165,6 +165,7 @@ public: virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; + virtual bool UseCodeAlign() const; static bool classof(const MCSection *S) { return S->getVariant() == SV_MachO; -- cgit v1.1