[llvm] r268496 - [mips][ias] Only round section sizes when explicitly requested.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 06:21:07 PDT 2016


Author: dsanders
Date: Wed May  4 08:21:06 2016
New Revision: 268496

URL: http://llvm.org/viewvc/llvm-project?rev=268496&view=rev
Log:
[mips][ias] Only round section sizes when explicitly requested.

As requested by Rafael Espindola in his post-commit comments on r268036. This
makes the previous behaviour the default while still allowing verification of
IAS.


Modified:
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
    llvm/trunk/test/DebugInfo/Mips/delay-slot.ll
    llvm/trunk/test/MC/Mips/section-size.s

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=268496&r1=268495&r2=268496&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Wed May  4 08:21:06 2016
@@ -21,12 +21,19 @@
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCSymbolELF.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
 
 using namespace llvm;
 
+namespace {
+static cl::opt<bool> RoundSectionSizes(
+    "mips-round-section-sizes", cl::init(false),
+    cl::desc("Round section sizes up to the section alignment"), cl::Hidden);
+} // end anonymous namespace
+
 MipsTargetStreamer::MipsTargetStreamer(MCStreamer &S)
     : MCTargetStreamer(S), ModuleDirectiveAllowed(true) {
   GPRInfoSet = FPRInfoSet = FrameInfoSet = false;
@@ -729,18 +736,23 @@ void MipsTargetELFStreamer::finish() {
   DataSection.setAlignment(std::max(16u, DataSection.getAlignment()));
   BSSSection.setAlignment(std::max(16u, BSSSection.getAlignment()));
 
-  // Make sections sizes a multiple of the alignment.
-  MCStreamer &OS = getStreamer();
-  for (MCSection &S : MCA) {
-    MCSectionELF &Section = static_cast<MCSectionELF &>(S);
-
-    unsigned Alignment = Section.getAlignment();
-    if (Alignment) {
-      OS.SwitchSection(&Section);
-      if (Section.UseCodeAlign())
-        OS.EmitCodeAlignment(Alignment, Alignment);
-      else
-        OS.EmitValueToAlignment(Alignment, 0, 1, Alignment);
+  if (RoundSectionSizes) {
+    // Make sections sizes a multiple of the alignment. This is useful for
+    // verifying the output of IAS against the output of other assemblers but
+    // it's not necessary to produce a correct object and increases section
+    // size.
+    MCStreamer &OS = getStreamer();
+    for (MCSection &S : MCA) {
+      MCSectionELF &Section = static_cast<MCSectionELF &>(S);
+
+      unsigned Alignment = Section.getAlignment();
+      if (Alignment) {
+        OS.SwitchSection(&Section);
+        if (Section.UseCodeAlign())
+          OS.EmitCodeAlignment(Alignment, Alignment);
+        else
+          OS.EmitValueToAlignment(Alignment, 0, 1, Alignment);
+      }
     }
   }
 

Modified: llvm/trunk/test/DebugInfo/Mips/delay-slot.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Mips/delay-slot.ll?rev=268496&r1=268495&r2=268496&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/Mips/delay-slot.ll (original)
+++ llvm/trunk/test/DebugInfo/Mips/delay-slot.ll Wed May  4 08:21:06 2016
@@ -19,7 +19,7 @@
 ; CHECK: 0x000000000000002c      3      0      1   0             0  is_stmt
 ; CHECK: 0x000000000000003c      4      0      1   0             0  is_stmt
 ; CHECK: 0x0000000000000048      5      0      1   0             0  is_stmt
-; CHECK: 0x0000000000000060      5      0      1   0             0  is_stmt end_sequence
+; CHECK: 0x0000000000000058      5      0      1   0             0  is_stmt end_sequence
 
 
 target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"

Modified: llvm/trunk/test/MC/Mips/section-size.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/section-size.s?rev=268496&r1=268495&r2=268496&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/section-size.s (original)
+++ llvm/trunk/test/MC/Mips/section-size.s Wed May  4 08:21:06 2016
@@ -1,5 +1,5 @@
-# RUN: llvm-mc -triple mips-unknown-linux -filetype=obj %s | \
-# RUN:     llvm-readobj -sections | FileCheck %s
+# RUN: llvm-mc -triple mips-unknown-linux -filetype=obj \
+# RUN:     -mips-round-section-sizes %s | llvm-readobj -sections | FileCheck %s
 	.section ".talign1", "ax"
 	.p2align 4
 t1:	.byte 1




More information about the llvm-commits mailing list