[DSE] Check for noalias calls rather than alloc functions
For these "visible on unwind/ret" checks we only care about the fact that no other code has access to the pointer (unless it escapes). A noalias call is sufficient for this, it does not have to be a known allocation function. This is basically the same change as D116728, but for DSE rather than LICM.
This commit is contained in:
@@ -961,7 +961,7 @@ struct DSEState {
|
||||
I.first->second = false;
|
||||
} else {
|
||||
auto *Inst = dyn_cast<Instruction>(V);
|
||||
if (Inst && isAllocLikeFn(Inst, &TLI))
|
||||
if (Inst && isNoAliasCall(Inst))
|
||||
I.first->second = !PointerMayBeCaptured(V, true, false);
|
||||
}
|
||||
}
|
||||
@@ -974,7 +974,7 @@ struct DSEState {
|
||||
auto I = InvisibleToCallerBeforeRet.insert({V, false});
|
||||
if (I.second) {
|
||||
auto *Inst = dyn_cast<Instruction>(V);
|
||||
if (Inst && isAllocLikeFn(Inst, &TLI))
|
||||
if (Inst && isNoAliasCall(Inst))
|
||||
// NOTE: This could be made more precise by PointerMayBeCapturedBefore
|
||||
// with the killing MemoryDef. But we refrain from doing so for now to
|
||||
// limit compile-time and this does not cause any changes to the number
|
||||
|
||||
@@ -229,9 +229,6 @@ define i32* @test_custom_malloc_no_escape_before_return() {
|
||||
; CHECK-LABEL: @test_custom_malloc_no_escape_before_return(
|
||||
; CHECK-NEXT: [[PTR:%.*]] = tail call i8* @custom_malloc(i32 4)
|
||||
; CHECK-NEXT: [[P:%.*]] = bitcast i8* [[PTR]] to i32*
|
||||
; CHECK-NEXT: [[DEAD:%.*]] = load i32, i32* [[P]], align 4
|
||||
; CHECK-NEXT: [[DEAD2:%.*]] = add i32 [[DEAD]], 1
|
||||
; CHECK-NEXT: store i32 [[DEAD2]], i32* [[P]], align 4
|
||||
; CHECK-NEXT: call void @may_unwind()
|
||||
; CHECK-NEXT: store i32 0, i32* [[P]], align 4
|
||||
; CHECK-NEXT: ret i32* [[P]]
|
||||
@@ -313,7 +310,6 @@ define void @malloc_no_escape() {
|
||||
define void @custom_malloc_no_escape() {
|
||||
; CHECK-LABEL: @custom_malloc_no_escape(
|
||||
; CHECK-NEXT: [[M:%.*]] = call i8* @custom_malloc(i32 24)
|
||||
; CHECK-NEXT: store i8 0, i8* [[M]], align 1
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
%m = call i8* @custom_malloc(i32 24)
|
||||
|
||||
Reference in New Issue
Block a user