Merge commit 7214f7a79 from llvm git (by Sam Elliott):

[RISCV] Lower llvm.trap and llvm.debugtrap

  Summary:
  Until this commit, these have lowered to a call to abort().

  `llvm.trap()` now lowers to `unimp`, which should trap on all systems.

  `llvm.debugtrap()` now lowers to `ebreak`, which is exactly what this
  instruction is for.

  Reviewers: asb, luismarques

  Reviewed By: asb

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D69390

This fixes miscompilation resulting in linking failures with
INVARIANTS disabled.

Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D23857
This commit is contained in:
Brooks Davis 2020-02-27 20:08:46 +00:00
parent 8af44ff889
commit 8582cd3101
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358408
2 changed files with 13 additions and 0 deletions

View File

@ -185,6 +185,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::READCYCLECOUNTER, MVT::i64,
Subtarget.is64Bit() ? Legal : Custom);
setOperationAction(ISD::TRAP, MVT::Other, Legal);
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
if (Subtarget.hasStdExtA()) {
setMaxAtomicSizeInBitsSupported(Subtarget.getXLen());
setMinCmpXchgSizeInBits(32);

View File

@ -1075,6 +1075,16 @@ let Predicates = [IsRV32], usesCustomInserter = 1, hasSideEffects = 0,
mayLoad = 0, mayStore = 0, hasNoSchedulingInfo = 1 in
def ReadCycleWide : Pseudo<(outs GPR:$lo, GPR:$hi), (ins), [], "", "">;
/// traps
// We lower `trap` to `unimp`, as this causes a hard exception on nearly all
// systems.
def : Pat<(trap), (UNIMP)>;
// We lower `debugtrap` to `ebreak`, as this will get the attention of the
// debugger if possible.
def : Pat<(debugtrap), (EBREAK)>;
//===----------------------------------------------------------------------===//
// Standard extensions
//===----------------------------------------------------------------------===//