[PATCH] D44928: [MC] Pass MCSubtargetInfo through to fixupNeedsRelaxation

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 27 06:34:03 PDT 2018


peter.smith created this revision.
peter.smith added reviewers: echristo, eli.friedman, asb.
Herald added subscribers: fedor.sergeev, kbarton, kristof.beyls, javed.absar, mehdi_amini, nhaehnle, nemanjai, sdardis, jyknight, arsenm.

On targets like Arm some relaxations may only be performed when certain architectural features are available. As functions can be compiled with differing levels of architectural support we must make a judgement on whether we can relax based on the MCSubtargetInfo for the function. This change passes through the MCSubtargetInfo for the function to fixupNeedsRelaxation so that the decision on whether to relax can be made per function. In this patch, only the ARM backend makes use of this information.

This addresses part of PR36542 where each function has the cpu and target features it was compiled with in its attributes, these features included support for Thumb2, whereas the default cpu passed to the lto plugin did not. As the decision on whether to relax was using the default cpu, a branch, used for a tail call by a Thumb2 function did not get relaxed to a wide branch.

I don't think that there is an alternative to making the relaxation decision based on per function information as if we use some kind of aggregate MCSubtargetInfo determined from a combination of all the Functions and the module we run into two self contradictory use-cases

- I want to do runtime selection of a specific function, we should use the least capable target feature set for a per module relaxation decision.
- I want to run on a specific target architecture, we should use the target features of that arch/cpu for a per module relaxation decision.

As we can't tell which of these use-cases I think we should make the decision per function.


https://reviews.llvm.org/D44928

Files:
  include/llvm/MC/MCAsmBackend.h
  include/llvm/MC/MCFragment.h
  lib/MC/MCAssembler.cpp
  lib/MC/MCObjectStreamer.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.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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44928.139908.patch
Type: text/x-patch
Size: 13384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180327/214d28b0/attachment-0001.bin>


More information about the llvm-commits mailing list