[llvm] 6c8adc5 - [InstCombine] Remove unnecessary byval check in callee cast fold
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 3 01:55:23 PST 2022
Author: Nikita Popov
Date: 2022-03-03T10:55:14+01:00
New Revision: 6c8adc505471542be38bd71d1000062daa46d7bc
URL: https://github.com/llvm/llvm-project/commit/6c8adc505471542be38bd71d1000062daa46d7bc
DIFF: https://github.com/llvm/llvm-project/commit/6c8adc505471542be38bd71d1000062daa46d7bc.diff
LOG: [InstCombine] Remove unnecessary byval check in callee cast fold
The logic for handling this was fixed in
8d7f118ab2b9e51d6cf2811291e319b4d977eb8c, 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.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/byval.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 216626f9ffe81..573a8db8479f4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -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();
diff --git a/llvm/test/Transforms/InstCombine/byval.ll b/llvm/test/Transforms/InstCombine/byval.ll
index b7459ef1fdf0e..e62bbe21c8069 100644
--- a/llvm/test/Transforms/InstCombine/byval.ll
+++ b/llvm/test/Transforms/InstCombine/byval.ll
@@ -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*)*
More information about the llvm-commits
mailing list