[llvm] [win][arm64ec] Fix duplicate errors with the dontcall attribute (PR #152810)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 16:15:29 PDT 2025
https://github.com/dpaoliello created https://github.com/llvm/llvm-project/pull/152810
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.
>From 551006c66b991ed07925dfed7ed86ff33612a6ce Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Fri, 8 Aug 2025 16:01:56 -0700
Subject: [PATCH] [win][arm64ec] Fix duplicate errors with the dontcall
attribute
---
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 8 ++++---
.../test/CodeGen/AArch64/arm64ec-dont-call.ll | 21 +++++++++++++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
create mode 100644 llvm/test/CodeGen/AArch64/arm64ec-dont-call.ll
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:
More information about the llvm-commits
mailing list