diff options
author | Daniel Sanders <daniel.sanders@imgtec.com> | 2016-05-04 13:21:06 +0000 |
---|---|---|
committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2016-05-04 13:21:06 +0000 |
commit | c07f06aeee6d469f7675ec3e1de68169d71536b0 (patch) | |
tree | c5fd4fd241e2e6c94e3288ec49b22d51cae4e1c4 /llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp | |
parent | 2c51e619d5d89c44173e93e3b7caa32d89784a91 (diff) | |
download | bcm5719-llvm-c07f06aeee6d469f7675ec3e1de68169d71536b0.tar.gz bcm5719-llvm-c07f06aeee6d469f7675ec3e1de68169d71536b0.zip |
[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.
llvm-svn: 268496
Diffstat (limited to 'llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp')
-rw-r--r-- | llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index 73b7722aa08..58c1f0ee4ee 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -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); + } } } |