Skip to content

Commit d7c6397

Browse files
committed
[win][arm64ec] Fix duplicate errors with the dontcall attribute
1 parent d2b3e86 commit d7c6397

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,11 +2786,14 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
27862786
if (CI.isInlineAsm())
27872787
return translateInlineAsm(CI, MIRBuilder);
27882788

2789-
diagnoseDontCall(CI);
2790-
27912789
Intrinsic::ID ID = F ? F->getIntrinsicID() : Intrinsic::not_intrinsic;
2792-
if (!F || ID == Intrinsic::not_intrinsic)
2793-
return translateCallBase(CI, MIRBuilder);
2790+
if (!F || ID == Intrinsic::not_intrinsic) {
2791+
if (translateCallBase(CI, MIRBuilder)) {
2792+
diagnoseDontCall(CI);
2793+
return true;
2794+
}
2795+
return false;
2796+
}
27942797

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

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,9 +1148,12 @@ bool FastISel::lowerCall(const CallInst *CI) {
11481148
CLI.setCallee(RetTy, FuncTy, CI->getCalledOperand(), std::move(Args), *CI)
11491149
.setTailCall(IsTailCall);
11501150

1151-
diagnoseDontCall(*CI);
1151+
if (lowerCallTo(CLI)) {
1152+
diagnoseDontCall(*CI);
1153+
return true;
1154+
}
11521155

1153-
return lowerCallTo(CLI);
1156+
return false;
11541157
}
11551158

11561159
bool FastISel::selectCall(const User *I) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: not llc -mtriple=arm64ec-windows-msvc -filetype=null %s 2>&1 | FileCheck %s
2+
; RUN: not llc -mtriple=arm64ec-windows-msvc -filetype=null -global-isel=1 -global-isel-abort=0 %s 2>&1 | FileCheck %s
3+
4+
define void @baz() #0 {
5+
call void @foo()
6+
ret void
7+
}
8+
9+
define void @foo() #1 {
10+
ret void
11+
}
12+
13+
attributes #0 = { noinline optnone }
14+
attributes #1 = { "dontcall-error"="oh no foo" }
15+
16+
; Regression test for `dontcall-error` for Arm64EC. Since this attribute is
17+
; checked both by FastISel and SelectionDAGBuilder, and FastISel was bailing for
18+
; Arm64EC AFTER doing the check, we ended up with duplicate copies of this
19+
; error.
20+
21+
; CHECK: error: call to #foo marked "dontcall-error": oh no foo
22+
; CHECK-NOT: error:

llvm/test/CodeGen/X86/attr-dontcall.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: not llc -mtriple=x86_64 -global-isel=0 -fast-isel=0 -stop-after=finalize-isel < %s 2>&1 | FileCheck %s
22
; RUN: not llc -mtriple=x86_64 -global-isel=0 -fast-isel=1 -stop-after=finalize-isel < %s 2>&1 | FileCheck %s
3-
; RUN: not llc -mtriple=x86_64 -global-isel=1 -fast-isel=0 -stop-after=irtranslator -global-isel-abort=0 < %s 2>&1 | FileCheck %s
3+
; RUN: not llc -mtriple=x86_64 -global-isel=1 -fast-isel=0 -global-isel-abort=0 < %s 2>&1 | FileCheck %s
44

55
declare void @foo() "dontcall-error"="e"
66
define void @bar() {

0 commit comments

Comments
 (0)