Skip to content

[win][arm64ec] Fix duplicate errors with the dontcall attribute #152810

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

Merged
merged 1 commit into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2786,11 +2786,14 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
if (CI.isInlineAsm())
return translateInlineAsm(CI, MIRBuilder);

diagnoseDontCall(CI);

Intrinsic::ID ID = F ? F->getIntrinsicID() : Intrinsic::not_intrinsic;
if (!F || ID == Intrinsic::not_intrinsic)
return translateCallBase(CI, MIRBuilder);
if (!F || ID == Intrinsic::not_intrinsic) {
if (translateCallBase(CI, MIRBuilder)) {
diagnoseDontCall(CI);
return true;
}
return false;
}

assert(ID != Intrinsic::not_intrinsic && "unknown intrinsic");

Expand Down
7 changes: 5 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,12 @@ bool FastISel::lowerCall(const CallInst *CI) {
CLI.setCallee(RetTy, FuncTy, CI->getCalledOperand(), std::move(Args), *CI)
.setTailCall(IsTailCall);

diagnoseDontCall(*CI);
if (lowerCallTo(CLI)) {
diagnoseDontCall(*CI);
return true;
}

return lowerCallTo(CLI);
return false;
}

bool FastISel::selectCall(const User *I) {
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/AArch64/arm64ec-dont-call.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: not llc -mtriple=arm64ec-windows-msvc -filetype=null %s 2>&1 | FileCheck %s
; RUN: not llc -mtriple=arm64ec-windows-msvc -filetype=null -global-isel=1 -global-isel-abort=0 %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:
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/attr-dontcall.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; RUN: not llc -mtriple=x86_64 -global-isel=0 -fast-isel=0 -stop-after=finalize-isel < %s 2>&1 | FileCheck %s
; RUN: not llc -mtriple=x86_64 -global-isel=0 -fast-isel=1 -stop-after=finalize-isel < %s 2>&1 | FileCheck %s
; RUN: not llc -mtriple=x86_64 -global-isel=1 -fast-isel=0 -stop-after=irtranslator -global-isel-abort=0 < %s 2>&1 | FileCheck %s
; RUN: not llc -mtriple=x86_64 -global-isel=1 -fast-isel=0 -global-isel-abort=0 < %s 2>&1 | FileCheck %s

declare void @foo() "dontcall-error"="e"
define void @bar() {
Expand Down
Loading