Skip to content

Commit 44e3735

Browse files
authored
llvm-reduce: Preserve original callsite calling conv when removing arguments (#133411)
In undefined mismatch cases, this was fixing the callsite to use the calling convention of the new function. Preserve the original wrong callsite's calling convention.
1 parent 827f2ad commit 44e3735

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; Check that when removing arguments, incorrect callsite calling conventions are preserved
2+
3+
; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=arguments --test FileCheck --test-arg --check-prefixes=INTERESTING --test-arg %s --test-arg --input-file %s -o %t
4+
; RUN: FileCheck --check-prefixes=RESULT %s < %t
5+
6+
; INTERESTING-LABEL: @fastcc_callee(
7+
define fastcc i32 @fastcc_callee(i32 %a, i32 %b) {
8+
ret i32 %a
9+
}
10+
11+
; INTERESTING-LABEL: @fastcc_callee_decl(
12+
declare fastcc i32 @fastcc_callee_decl(i32 %a, i32 %b)
13+
14+
; INTERESTING-LABEL: @caller_wrong_callsites(
15+
; INTERESTING: call
16+
; INTERESTING: call
17+
18+
; RESULT-LABEL: define i32 @caller_wrong_callsites()
19+
; RESULT: %call0 = call coldcc i32 @fastcc_callee()
20+
; RESULT: %call1 = call i32 @fastcc_callee_decl()
21+
define i32 @caller_wrong_callsites(i32 %x) {
22+
%call0 = call coldcc i32 @fastcc_callee(i32 %x, i32 2)
23+
%call1 = call ccc i32 @fastcc_callee_decl(i32 %x, i32 2)
24+
%result = add i32 %call0, %call1
25+
ret i32 %result
26+
}
27+

llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void replaceFunctionCalls(Function &OldF, Function &NewF,
6565
CI->getOperandBundlesAsDefs(OpBundles);
6666

6767
CallInst *NewCI = CallInst::Create(&NewF, Args, OpBundles);
68-
NewCI->setCallingConv(NewF.getCallingConv());
68+
NewCI->setCallingConv(CI->getCallingConv());
6969

7070
AttrBuilder CallSiteAttrs(Ctx, CI->getAttributes().getFnAttrs());
7171
NewCI->setAttributes(

0 commit comments

Comments
 (0)