-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[CFIInserter] Turn a reachable llvm_unreachable into a report_fatal_error. #168777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This prevents it from being optimized out in non-assert 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 better fix for llvm#168772 and llvm#168525.
|
@llvm/pr-subscribers-backend-x86 Author: Craig Topper (topperc) ChangesThis prevents it from being optimized out in non-assert 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 better fix for #168772 and #168525. Full diff: https://github.com/llvm/llvm-project/pull/168777.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/CFIInstrInserter.cpp b/llvm/lib/CodeGen/CFIInstrInserter.cpp
index 14098bc821617..1e65dd230dc86 100644
--- a/llvm/lib/CodeGen/CFIInstrInserter.cpp
+++ b/llvm/lib/CodeGen/CFIInstrInserter.cpp
@@ -272,7 +272,7 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
CSRLocMap.insert(
{CFI.getRegister(), CSRSavedLocation(CSRReg, CSROffset)});
} else if (It->second.Reg != CSRReg || It->second.Offset != CSROffset) {
- llvm_unreachable("Different saved locations for the same CSR");
+ report_fatal_error("Different saved locations for the same CSR");
}
CSRSaved.set(CFI.getRegister());
}
diff --git a/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir b/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
index d2e5a8208cecf..55515aa364016 100644
--- a/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
+++ b/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
@@ -1,7 +1,8 @@
-# RUN: llc -x mir < %s -mtriple=riscv64 \
+# RUN: not --crash llc %s -mtriple=riscv64 \
# RUN: -run-pass=cfi-instr-inserter \
-# RUN: -riscv-enable-cfi-instr-inserter=true
-# UNSUPPORTED: target={{.*}}
+# RUN: -riscv-enable-cfi-instr-inserter=true 2>&1 | FileCheck %s
+
+# CHECK: LLVM ERROR: Different saved locations for the same CSR
# Technically, it is possible that a callee-saved register is saved in multiple different locations.
# CFIInstrInserter should handle this, but currently it does not.
diff --git a/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir b/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir
index ef9fb22476a71..8211f8940d27a 100644
--- a/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir
+++ b/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir
@@ -1,4 +1,3 @@
-# REQUIRES: asserts
# RUN: not --crash llc -o - %s -mtriple=x86_64-- \
# RUN: -run-pass=cfi-instr-inserter 2>&1 | FileCheck %s
# Test that CSR being saved in multiple locations can be caught by
@@ -10,8 +9,7 @@
}
...
---
-# CHECK: Different saved locations for the same CSR
-# CHECK-NEXT: UNREACHABLE executed
+# CHECK: LLVM ERROR: Different saved locations for the same CSR
name: inconsistentlocs
body: |
bb.0:
|
|
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesThis prevents it from being optimized out in non-assert 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 better fix for #168772 and #168525. Full diff: https://github.com/llvm/llvm-project/pull/168777.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/CFIInstrInserter.cpp b/llvm/lib/CodeGen/CFIInstrInserter.cpp
index 14098bc821617..1e65dd230dc86 100644
--- a/llvm/lib/CodeGen/CFIInstrInserter.cpp
+++ b/llvm/lib/CodeGen/CFIInstrInserter.cpp
@@ -272,7 +272,7 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
CSRLocMap.insert(
{CFI.getRegister(), CSRSavedLocation(CSRReg, CSROffset)});
} else if (It->second.Reg != CSRReg || It->second.Offset != CSROffset) {
- llvm_unreachable("Different saved locations for the same CSR");
+ report_fatal_error("Different saved locations for the same CSR");
}
CSRSaved.set(CFI.getRegister());
}
diff --git a/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir b/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
index d2e5a8208cecf..55515aa364016 100644
--- a/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
+++ b/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
@@ -1,7 +1,8 @@
-# RUN: llc -x mir < %s -mtriple=riscv64 \
+# RUN: not --crash llc %s -mtriple=riscv64 \
# RUN: -run-pass=cfi-instr-inserter \
-# RUN: -riscv-enable-cfi-instr-inserter=true
-# UNSUPPORTED: target={{.*}}
+# RUN: -riscv-enable-cfi-instr-inserter=true 2>&1 | FileCheck %s
+
+# CHECK: LLVM ERROR: Different saved locations for the same CSR
# Technically, it is possible that a callee-saved register is saved in multiple different locations.
# CFIInstrInserter should handle this, but currently it does not.
diff --git a/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir b/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir
index ef9fb22476a71..8211f8940d27a 100644
--- a/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir
+++ b/llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-loc.mir
@@ -1,4 +1,3 @@
-# REQUIRES: asserts
# RUN: not --crash llc -o - %s -mtriple=x86_64-- \
# RUN: -run-pass=cfi-instr-inserter 2>&1 | FileCheck %s
# Test that CSR being saved in multiple locations can be caught by
@@ -10,8 +9,7 @@
}
...
---
-# CHECK: Different saved locations for the same CSR
-# CHECK-NEXT: UNREACHABLE executed
+# CHECK: LLVM ERROR: Different saved locations for the same CSR
name: inconsistentlocs
body: |
bb.0:
|
🐧 Linux x64 Test Results
|
lenary
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/22564 Here is the relevant piece of the build log for the reference |
| @@ -1,7 +1,8 @@ | |||
| # RUN: llc -x mir < %s -mtriple=riscv64 \ | |||
| # RUN: not --crash llc %s -mtriple=riscv64 \ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change llc will now open cfi-multiple-locations.s for writing in the local directory (which may be write protected). Can we add back the "-x mir < " or add "-o -" or something to avoid this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents it from being optimized out in non-assert 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.