Skip to content

Commit 8608344

Browse files
authored
[CFIInserter] Turn a reachable llvm_unreachable into a report_fatal_error. (#168777)
This prevents it from being optimized out in non-asserts builds. Update X86 test to remove REQUIRES: asserts and check for LLVM ERROR. Add FileCheck to RISC-V test and remove UNSUPPORTED. This is the more complete fix for #168772 and #168525.
1 parent db20a7f commit 8608344

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

llvm/lib/CodeGen/CFIInstrInserter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
272272
CSRLocMap.insert(
273273
{CFI.getRegister(), CSRSavedLocation(CSRReg, CSROffset)});
274274
} else if (It->second.Reg != CSRReg || It->second.Offset != CSROffset) {
275-
llvm_unreachable("Different saved locations for the same CSR");
275+
reportFatalInternalError(
276+
"Different saved locations for the same CSR");
276277
}
277278
CSRSaved.set(CFI.getRegister());
278279
}

llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# RUN: llc -x mir < %s -mtriple=riscv64 \
1+
# RUN: not --crash llc %s -mtriple=riscv64 \
22
# RUN: -run-pass=cfi-instr-inserter \
3-
# RUN: -riscv-enable-cfi-instr-inserter=true
4-
# UNSUPPORTED: target={{.*}}
3+
# RUN: -riscv-enable-cfi-instr-inserter=true 2>&1 | FileCheck %s
4+
5+
# CHECK: LLVM ERROR: Different saved locations for the same CSR
56

67
# Technically, it is possible that a callee-saved register is saved in multiple different locations.
78
# CFIInstrInserter should handle this, but currently it does not.

llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# REQUIRES: asserts
21
# RUN: not --crash llc -o - %s -mtriple=x86_64-- \
32
# RUN: -run-pass=cfi-instr-inserter 2>&1 | FileCheck %s
43
# Test that CSR being saved in multiple locations can be caught by
@@ -10,8 +9,7 @@
109
}
1110
...
1211
---
13-
# CHECK: Different saved locations for the same CSR
14-
# CHECK-NEXT: UNREACHABLE executed
12+
# CHECK: LLVM ERROR: Different saved locations for the same CSR
1513
name: inconsistentlocs
1614
body: |
1715
bb.0:

0 commit comments

Comments
 (0)