Skip to content

Commit

Permalink
[InstCombine] Remove unnecessary byval check in callee cast fold
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Mar 3, 2022
1 parent 2555ed5 commit 6c8adc5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/Transforms/InstCombine/byval.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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*)*
Expand Down

0 comments on commit 6c8adc5

Please sign in to comment.