[llvm] [win][arm64ec] Fix duplicate errors with the dontcall attribute (PR #152810)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 16:15:55 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Daniel Paoliello (dpaoliello)
<details>
<summary>Changes</summary>
Since the `dontcall-*` attributes are checked both by `FastISel` and `SelectionDAGBuilder`, and `FastISel` bails for calls on Arm64EC for AFTER doing the check, we ended up emitting duplicate copies of this error.
This change moves the checking for `dontcall-*` in `FastISel` to after it has been successfully lowered.
---
Full diff: https://github.com/llvm/llvm-project/pull/152810.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/FastISel.cpp (+5-3)
- (added) llvm/test/CodeGen/AArch64/arm64ec-dont-call.ll (+21)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index fb9eff942a464..5bc158a660080 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1148,9 +1148,11 @@ bool FastISel::lowerCall(const CallInst *CI) {
CLI.setCallee(RetTy, FuncTy, CI->getCalledOperand(), std::move(Args), *CI)
.setTailCall(IsTailCall);
- diagnoseDontCall(*CI);
-
- return lowerCallTo(CLI);
+ if (lowerCallTo(CLI)) {
+ diagnoseDontCall(*CI);
+ return true;
+ } else
+ return false;
}
bool FastISel::selectCall(const User *I) {
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-dont-call.ll b/llvm/test/CodeGen/AArch64/arm64ec-dont-call.ll
new file mode 100644
index 0000000000000..febb8997f3e37
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/arm64ec-dont-call.ll
@@ -0,0 +1,21 @@
+; RUN: not llc -mtriple arm64ec-windows-msvc -o - %s 2>&1 | FileCheck %s
+
+define void @baz() #0 {
+ call void @foo()
+ ret void
+}
+
+define void @foo() #1 {
+ ret void
+}
+
+attributes #0 = { noinline optnone }
+attributes #1 = { "dontcall-error"="oh no foo" }
+
+; Regression test for `dontcall-error` for Arm64EC. Since this attribute is
+; checked both by FastISel and SelectionDAGBuilder, and FastISel was bailing for
+; Arm64EC AFTER doing the check, we ended up with duplicate copies of this
+; error.
+
+; CHECK: error: call to #foo marked "dontcall-error": oh no foo
+; CHECK-NOT: error:
``````````
</details>
https://github.com/llvm/llvm-project/pull/152810
More information about the llvm-commits
mailing list