Skip to content

Commit 6c8adc5

Browse files
committed
[InstCombine] Remove unnecessary byval check in callee cast fold
The logic for handling this was fixed in 8d7f118, but the check for byval on the callee was retained. This resulted in a weird situation where the transform would work depending on whether the byval was only on the call or on both the call and the function.
1 parent 2555ed5 commit 6c8adc5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,8 +3142,7 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
31423142
//
31433143
// Similarly, avoid folding away bitcasts of byval calls.
31443144
if (Callee->getAttributes().hasAttrSomewhere(Attribute::InAlloca) ||
3145-
Callee->getAttributes().hasAttrSomewhere(Attribute::Preallocated) ||
3146-
Callee->getAttributes().hasAttrSomewhere(Attribute::ByVal))
3145+
Callee->getAttributes().hasAttrSomewhere(Attribute::Preallocated))
31473146
return false;
31483147

31493148
auto AI = Call.arg_begin();

llvm/test/Transforms/InstCombine/byval.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ define void @add_byval(i64* %in) {
1818

1919
define void @add_byval_2(i64* %in) {
2020
; CHECK-LABEL: @add_byval_2(
21-
; CHECK-NEXT: call void bitcast (void (double*)* @add_byval_callee_2 to void (i64*)*)(i64* byval(i64) [[IN:%.*]])
21+
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64* [[IN:%.*]] to double*
22+
; CHECK-NEXT: call void @add_byval_callee_2(double* byval(double) [[TMP1]])
2223
; CHECK-NEXT: ret void
2324
;
2425
%tmp = bitcast void (double*)* @add_byval_callee_2 to void (i64*)*

0 commit comments

Comments
 (0)