1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

[InstCombine] Don't let an alignment assume prevent new/delete removals.

Remove allocations with alignment assume.

Differential Revision: https://reviews.llvm.org/D81854
This commit is contained in:
Hiroshi Yamauchi 2020-06-15 09:37:07 -07:00
parent d0933009b5
commit a13827cec2
3 changed files with 11 additions and 5 deletions

View File

@ -2480,6 +2480,7 @@ static bool isAllocSiteRemovable(Instruction *AI,
return false;
LLVM_FALLTHROUGH;
}
case Intrinsic::assume:
case Intrinsic::invariant_start:
case Intrinsic::invariant_end:
case Intrinsic::lifetime_start:

View File

@ -276,6 +276,8 @@ declare void @_ZdaPvjSt11align_val_t(i8*, i32, i32) nobuiltin
; delete[](void*, unsigned long, align_val_t)
declare void @_ZdaPvmSt11align_val_t(i8*, i64, i64) nobuiltin
declare void @llvm.assume(i1)
define void @test8() {
; CHECK-LABEL: @test8(
; CHECK-NEXT: ret void
@ -317,6 +319,12 @@ define void @test8() {
call void @_ZdaPvmSt11align_val_t(i8* %naa2, i64 32, i64 8) builtin
%naja2 = call i8* @_ZnajSt11align_val_t(i32 32, i32 8) builtin
call void @_ZdaPvjSt11align_val_t(i8* %naja2, i32 32, i32 8) builtin
; Check that the alignment assume does not prevent the removal.
%nwa3 = call i8* @_ZnwmSt11align_val_t(i64 32, i64 16) builtin
call void @llvm.assume(i1 true) [ "align"(i8* %nwa3, i64 16) ]
call void @_ZdlPvmSt11align_val_t(i8* %nwa3, i64 32, i64 16) builtin
ret void
}
@ -343,7 +351,7 @@ define void @test10() {
define void @test11() {
; CHECK-LABEL: @test11(
; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(8) i8* @_Znwm(i64 8) #6
; CHECK-NEXT: [[CALL:%.*]] = call dereferenceable(8) i8* @_Znwm(i64 8) #7
; CHECK-NEXT: call void @_ZdlPv(i8* nonnull [[CALL]])
; CHECK-NEXT: ret void
;

View File

@ -85,7 +85,7 @@ false2:
ret void
}
; This test illustrates that alignment assumptions may prevent SROA.
; This test checks that alignment assumptions do not prevent SROA.
; See PR45763.
define internal void @callee2(i64* noalias sret align 8 %arg) {
@ -98,9 +98,6 @@ define amdgpu_kernel void @caller2() {
; ASSUMPTIONS-OFF-NEXT: ret void
;
; ASSUMPTIONS-ON-LABEL: @caller2(
; ASSUMPTIONS-ON-NEXT: [[ALLOCA:%.*]] = alloca i64, align 8, addrspace(5)
; ASSUMPTIONS-ON-NEXT: [[CAST:%.*]] = addrspacecast i64 addrspace(5)* [[ALLOCA]] to i64*
; ASSUMPTIONS-ON-NEXT: call void @llvm.assume(i1 true) [ "align"(i64* [[CAST]], i64 8) ]
; ASSUMPTIONS-ON-NEXT: ret void
;
%alloca = alloca i64, align 8, addrspace(5)