[llvm] r231751 - Remove incredibly confusing isBaseAddressKnownZero.

Rafael Espindola rafael.espindola at gmail.com
Mon Mar 9 21:11:52 PDT 2015


Author: rafael
Date: Mon Mar  9 23:11:52 2015
New Revision: 231751

URL: http://llvm.org/viewvc/llvm-project?rev=231751&view=rev
Log:
Remove incredibly confusing isBaseAddressKnownZero.

When referring to a symbol in a dwarf section on ELF we should use

.long foo

instead of

.long foo - .debug_something

because ELF is unaware of the content of the sections and therefore needs
relocations. This has nothing to do with optimizing a -0.

Modified:
    llvm/trunk/include/llvm/MC/MCSection.h
    llvm/trunk/include/llvm/MC/MCSectionELF.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
    llvm/trunk/lib/Target/NVPTX/NVPTXSection.h

Modified: llvm/trunk/include/llvm/MC/MCSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=231751&r1=231750&r2=231751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSection.h (original)
+++ llvm/trunk/include/llvm/MC/MCSection.h Mon Mar  9 23:11:52 2015
@@ -52,14 +52,6 @@ namespace llvm {
                                       raw_ostream &OS,
                                       const MCExpr *Subsection) const = 0;
 
-    /// isBaseAddressKnownZero - Return true if we know that this section will
-    /// get a base address of zero.  In cases where we know that this is true we
-    /// can emit section offsets as direct references to avoid a subtraction
-    /// from the base of the section, saving a relocation.
-    virtual bool isBaseAddressKnownZero() const {
-      return false;
-    }
-
     // UseCodeAlign - Return true if a .align directive should use
     // "optimized nops" to fill instead of 0s.
     virtual bool UseCodeAlign() const = 0;

Modified: llvm/trunk/include/llvm/MC/MCSectionELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionELF.h?rev=231751&r1=231750&r2=231751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSectionELF.h (original)
+++ llvm/trunk/include/llvm/MC/MCSectionELF.h Mon Mar  9 23:11:52 2015
@@ -75,12 +75,6 @@ public:
   bool UseCodeAlign() const override;
   bool isVirtualSection() const override;
 
-  /// isBaseAddressKnownZero - We know that non-allocatable sections (like
-  /// debug info) have a base of zero.
-  bool isBaseAddressKnownZero() const override {
-    return (getFlags() & ELF::SHF_ALLOC) == 0;
-  }
-
   static bool classof(const MCSection *S) {
     return S->getVariant() == SV_ELF;
   }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=231751&r1=231750&r2=231751&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Mon Mar  9 23:11:52 2015
@@ -179,9 +179,8 @@ void AsmPrinter::EmitSectionOffset(const
   assert((!Label->isInSection() || &Label->getSection() == &Section) &&
          "Section offset using wrong section base for label");
 
-  // If the section in question will end up with an address of 0 anyway, we can
-  // just emit an absolute reference to save a relocation.
-  if (Section.isBaseAddressKnownZero()) {
+  // If the format uses relocations with dwarf, refer to the symbol directly.
+  if (MAI->doesDwarfUseRelocationsAcrossSections()) {
     OutStreamer.EmitSymbolValue(Label, 4);
     return;
   }

Modified: llvm/trunk/lib/Target/NVPTX/NVPTXSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXSection.h?rev=231751&r1=231750&r2=231751&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXSection.h (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXSection.h Mon Mar  9 23:11:52 2015
@@ -36,7 +36,6 @@ public:
                             const MCExpr *Subsection) const override {}
 
   /// Base address of PTX sections is zero.
-  bool isBaseAddressKnownZero() const override { return true; }
   bool UseCodeAlign() const override { return false; }
   bool isVirtualSection() const override { return false; }
 };





More information about the llvm-commits mailing list