[InstCombine] Remove unnecessary byval check in callee cast fold

The logic for handling this was fixed in
8d7f118ab2, 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.
This commit is contained in:
Nikita Popov 2022-03-03 10:49:00 +01:00
parent 2555ed55a4
commit 6c8adc5054
2 changed files with 3 additions and 3 deletions

View File

@ -3142,8 +3142,7 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
//
// Similarly, avoid folding away bitcasts of byval calls.
if (Callee->getAttributes().hasAttrSomewhere(Attribute::InAlloca) ||
Callee->getAttributes().hasAttrSomewhere(Attribute::Preallocated) ||
Callee->getAttributes().hasAttrSomewhere(Attribute::ByVal))
Callee->getAttributes().hasAttrSomewhere(Attribute::Preallocated))
return false;
auto AI = Call.arg_begin();

View File

@ -18,7 +18,8 @@ define void @add_byval(i64* %in) {
define void @add_byval_2(i64* %in) {
; CHECK-LABEL: @add_byval_2(
; CHECK-NEXT: call void bitcast (void (double*)* @add_byval_callee_2 to void (i64*)*)(i64* byval(i64) [[IN:%.*]])
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64* [[IN:%.*]] to double*
; CHECK-NEXT: call void @add_byval_callee_2(double* byval(double) [[TMP1]])
; CHECK-NEXT: ret void
;
%tmp = bitcast void (double*)* @add_byval_callee_2 to void (i64*)*