[llvm] 6bd1db0 - [InstCombine] Don't let an alignment assume prevent new/delete removals.
Hiroshi Yamauchi via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 09:22:44 PDT 2020
Author: Hiroshi Yamauchi
Date: 2020-07-01T09:22:32-07:00
New Revision: 6bd1db08e7ccd61996d3867d22ff8eb1979f8621
URL: https://github.com/llvm/llvm-project/commit/6bd1db08e7ccd61996d3867d22ff8eb1979f8621
DIFF: https://github.com/llvm/llvm-project/commit/6bd1db08e7ccd61996d3867d22ff8eb1979f8621.diff
LOG: [InstCombine] Don't let an alignment assume prevent new/delete removals.
Remove allocations with alignment assume.
Differential Revision: https://reviews.llvm.org/D81854
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/malloc-free-delete.ll
llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 6a406314f63c..fee56e28bd0b 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -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:
diff --git a/llvm/test/Transforms/InstCombine/malloc-free-delete.ll b/llvm/test/Transforms/InstCombine/malloc-free-delete.ll
index 77a60e5d0b0a..fad542893c91 100644
--- a/llvm/test/Transforms/InstCombine/malloc-free-delete.ll
+++ b/llvm/test/Transforms/InstCombine/malloc-free-delete.ll
@@ -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
;
diff --git a/llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll b/llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
index 1dfce2282e1b..eb39a3984b02 100644
--- a/llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
+++ b/llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
@@ -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)
More information about the llvm-commits
mailing list