[llvm] [RISCV] Set isTrap for EBREAK and UNIMP (PR #131636)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 09:18:46 PDT 2025


https://github.com/asb created https://github.com/llvm/llvm-project/pull/131636

This is done for completeness. The property isn't used in upstream llvm/, although it is queried in BOLT in MCPlusBuilder.cpp.

>From 7dba3c00a85d1e8abc7dd025081105b95a207898 Mon Sep 17 00:00:00 2001
From: Alex Bradbury <asb at igalia.com>
Date: Mon, 17 Mar 2025 15:49:50 +0000
Subject: [PATCH] [RISCV] Set isTrap for EBREAK and UNIMP

This is done for completeness. The property isn't used in upstream
llvm/, although it is queried in BOLT in MCPlusBuilder.cpp.
---
 llvm/lib/Target/RISCV/RISCVInstrInfo.td | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 11d93892ee7a5..6be4fb1db602d 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -752,6 +752,7 @@ def ECALL : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ecall", "">, Sched<[Write
   let imm12 = 0;
 }
 
+let isTrap = 1 in
 def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
              Sched<[]> {
   let rs1 = 0;
@@ -762,6 +763,7 @@ def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
 // This is a de facto standard (as set by GNU binutils) 32-bit unimplemented
 // instruction (i.e., it should always trap, if your implementation has invalid
 // instruction traps).
+let isTrap = 1 in
 def UNIMP : RVInstI<0b001, OPC_SYSTEM, (outs), (ins), "unimp", "">,
             Sched<[]> {
   let rs1 = 0;



More information about the llvm-commits mailing list