diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2480,6 +2480,7 @@ 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 --- a/llvm/test/Transforms/InstCombine/malloc-free-delete.ll +++ b/llvm/test/Transforms/InstCombine/malloc-free-delete.ll @@ -276,6 +276,8 @@ ; 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 @@ 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 @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 ;