Skip to content

Commit 634dead

Browse files
committed
[win][arm64ec] Fix duplicate errors with the dontcall attribute
1 parent f9cb95c commit 634dead

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,11 +2786,15 @@ 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+
bool Result = translateCallBase(CI, MIRBuilder);
2792+
if (Result) {
2793+
diagnoseDontCall(CI);
2794+
return true;
2795+
}
2796+
return false;
2797+
}
27942798

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

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 -o - %s 2>&1 | FileCheck %s
2+
; RUN: not llc -mtriple=arm64ec-windows-msvc -filetype=null -global-isel=1 -global-isel-abort=0 -o - %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:

0 commit comments

Comments
 (0)