[PATCH] D44928: [MC] Pass MCSubtargetInfo to fixupNeedsRelaxation and applyFixup

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 6 05:44:23 PDT 2018


peter.smith updated this revision to Diff 141320.
peter.smith retitled this revision from "[MC] Pass MCSubtargetInfo through to fixupNeedsRelaxation" to "[MC] Pass MCSubtargetInfo to fixupNeedsRelaxation and applyFixup".
peter.smith edited the summary of this revision.
peter.smith added a comment.
Herald added subscribers: aheejin, sbc100.

I've updated the diff, description and title to include passing through MCSubtargetInfo to applyFixup() as well. I think that it is worth combining these changes into one as it is possible to introduce a code generation fault with just fixupNeedsRelaxation() receiving the STI.

I found out that it is possible for MCDataFragments to contain instructions with fixups so I've moved up the MCSubtargetInfo STI member from MCRelaxedFragment. To make sure that an STI is present when hasInstructions() is true, I've modified setHasInstructions to take an STI. This flushed out a few streamers that were not setting setHasInstructions() for MCDataFragments that contained instructions with fixups.

I note that the per fragment use of STI in the ARMAsmBackend::applyFixup() seems at best an optimisation and at worst redundant. As I understand it, each use is just skipping the out of range error message check, which we would never see for those subtargets because the instruction would have previously been relaxed. I can remove the tests that check STI->getFeatureBits() and all the tests still pass, I could be missing something though. I've added an extra test case that will silently generate incorrect code (skips an out of range immediate check) if STI is passed to fixupNeedsRelaxation() but not applyFixup().

I've not covered writeNopData() in this patch as I think that it would be best covered by a separate patch or patches.


https://reviews.llvm.org/D44928

Files:
  include/llvm/MC/MCAsmBackend.h
  include/llvm/MC/MCFragment.h
  lib/MC/MCAssembler.cpp
  lib/MC/MCELFStreamer.cpp
  lib/MC/MCMachOStreamer.cpp
  lib/MC/MCObjectStreamer.cpp
  lib/MC/MCWasmStreamer.cpp
  lib/MC/MCWinCOFFStreamer.cpp
  lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h
  lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
  lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
  lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp
  lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
  lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h
  lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
  lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp
  lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
  lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  test/CodeGen/ARM/relax-per-target-feature.ll
  test/MC/ARM/fixup-per-fragment.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44928.141320.patch
Type: text/x-patch
Size: 34559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180406/8669b631/attachment.bin>


More information about the llvm-commits mailing list