-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[SelectionDAG] Use reportFatalUsageError() for invalid operand bundles #142613
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
Replace the asserts with reportFatalUsageError(), as these can be reached with invalid user-provided IR.
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-backend-x86 Author: Nikita Popov (nikic) ChangesReplace the asserts with reportFatalUsageError(), as these can be reached with invalid user-provided IR. Fixes #142531. Full diff: https://github.com/llvm/llvm-project/pull/142613.diff 4 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 84f600744fb39..907997d0aa752 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3275,12 +3275,13 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
// Deopt and ptrauth bundles are lowered in helper functions, and we don't
// have to do anything here to lower funclet bundles.
- assert(!I.hasOperandBundlesOtherThan(
- {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
- LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
- LLVMContext::OB_cfguardtarget, LLVMContext::OB_ptrauth,
- LLVMContext::OB_clang_arc_attachedcall}) &&
- "Cannot lower invokes with arbitrary operand bundles yet!");
+ if (I.hasOperandBundlesOtherThan(
+ {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
+ LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
+ LLVMContext::OB_cfguardtarget, LLVMContext::OB_ptrauth,
+ LLVMContext::OB_clang_arc_attachedcall}))
+ reportFatalUsageError(
+ "Cannot lower invokes with arbitrary operand bundles!");
const Value *Callee(I.getCalledOperand());
const Function *Fn = dyn_cast<Function>(Callee);
@@ -3380,9 +3381,10 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) {
// Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
// have to do anything here to lower funclet bundles.
- assert(!I.hasOperandBundlesOtherThan(
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
- "Cannot lower callbrs with arbitrary operand bundles yet!");
+ if (I.hasOperandBundlesOtherThan(
+ {LLVMContext::OB_deopt, LLVMContext::OB_funclet}))
+ reportFatalUsageError(
+ "Cannot lower callbrs with arbitrary operand bundles!");
assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr");
visitInlineAsm(I);
@@ -9549,12 +9551,12 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
// Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
// have to do anything here to lower funclet bundles.
// CFGuardTarget bundles are lowered in LowerCallTo.
- assert(!I.hasOperandBundlesOtherThan(
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet,
- LLVMContext::OB_cfguardtarget, LLVMContext::OB_preallocated,
- LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_kcfi,
- LLVMContext::OB_convergencectrl}) &&
- "Cannot lower calls with arbitrary operand bundles!");
+ if (I.hasOperandBundlesOtherThan(
+ {LLVMContext::OB_deopt, LLVMContext::OB_funclet,
+ LLVMContext::OB_cfguardtarget, LLVMContext::OB_preallocated,
+ LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_kcfi,
+ LLVMContext::OB_convergencectrl}))
+ reportFatalUsageError("Cannot lower calls with arbitrary operand bundles!");
SDValue Callee = getValue(I.getCalledOperand());
diff --git a/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll b/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
new file mode 100644
index 0000000000000..493ffd85af74b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
@@ -0,0 +1,10 @@
+; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: Cannot lower calls with arbitrary operand bundles!
+
+declare void @g()
+
+define void @f(i32 %arg) {
+ call void @g() [ "foo"(i32 %arg) ]
+ ret void
+}
diff --git a/llvm/test/CodeGen/X86/invalid-operand-bundle-callbr.ll b/llvm/test/CodeGen/X86/invalid-operand-bundle-callbr.ll
new file mode 100644
index 0000000000000..b7c5d71776089
--- /dev/null
+++ b/llvm/test/CodeGen/X86/invalid-operand-bundle-callbr.ll
@@ -0,0 +1,11 @@
+; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: Cannot lower callbrs with arbitrary operand bundles!
+
+define void @f(i32 %arg) {
+ callbr void asm "", ""() [ "foo"(i32 %arg) ]
+ to label %cont []
+
+cont:
+ ret void
+}
diff --git a/llvm/test/CodeGen/X86/invalid-operand-bundle-invoke.ll b/llvm/test/CodeGen/X86/invalid-operand-bundle-invoke.ll
new file mode 100644
index 0000000000000..ddfa5d2f60da4
--- /dev/null
+++ b/llvm/test/CodeGen/X86/invalid-operand-bundle-invoke.ll
@@ -0,0 +1,19 @@
+; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: Cannot lower invokes with arbitrary operand bundles!
+
+declare void @g()
+declare i32 @__gxx_personality_v0(...)
+
+define void @f(i32 %arg) personality ptr @__gxx_personality_v0 {
+ invoke void @g() [ "foo"(i32 %arg) ]
+ to label %cont unwind label %lpad
+
+lpad:
+ %l = landingpad {ptr, i32}
+ cleanup
+ resume {ptr, i32} %l
+
+cont:
+ ret void
+}
|
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.
Should these be IR verifier errors?
I don't think so. From an IR perspective operand bundles are extensible. |
llvm#142613) Replace the asserts with reportFatalUsageError(), as these can be reached with invalid user-provided IR. Fixes llvm#142531.
llvm#142613) Replace the asserts with reportFatalUsageError(), as these can be reached with invalid user-provided IR. Fixes llvm#142531.
Replace the asserts with reportFatalUsageError(), as these can be reached with invalid user-provided IR.
Fixes #142531.