forked from OSchip/llvm-project
[NewGVN] Make NewGVN aware of aligned_alloc
Make the New GVN pass aware of aligned_alloc. Depends on D76975. Differential Revision: https://reviews.llvm.org/D76976
This commit is contained in:
parent
4cf70af94f
commit
6ee11c3b0f
|
@ -1470,7 +1470,8 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr,
|
|||
// undef value. This can happen when loading for a fresh allocation with no
|
||||
// intervening stores, for example. Note that this is only true in the case
|
||||
// that the result of the allocation is pointer equal to the load ptr.
|
||||
if (isa<AllocaInst>(DepInst) || isMallocLikeFn(DepInst, TLI)) {
|
||||
if (isa<AllocaInst>(DepInst) || isMallocLikeFn(DepInst, TLI) ||
|
||||
isAlignedAllocLikeFn(DepInst, TLI)) {
|
||||
return createConstantExpression(UndefValue::get(LoadType));
|
||||
}
|
||||
// If this load occurs either right after a lifetime begin,
|
||||
|
|
|
@ -54,3 +54,28 @@ if.end: ; preds = %if.then, %entry
|
|||
; CHECK_NO_LIBCALLS: load
|
||||
; CHECK_NO_LIBCALLS: icmp
|
||||
}
|
||||
|
||||
declare i8* @aligned_alloc(i64, i64) nounwind
|
||||
|
||||
define noalias i8* @test3() nounwind uwtable ssp {
|
||||
entry:
|
||||
%call = tail call i8* @aligned_alloc(i64 256, i64 32) nounwind
|
||||
%0 = load i8, i8* %call, align 32
|
||||
%tobool = icmp eq i8 %0, 0
|
||||
br i1 %tobool, label %if.end, label %if.then
|
||||
|
||||
if.then: ; preds = %entry
|
||||
store i8 0, i8* %call, align 1
|
||||
br label %if.end
|
||||
|
||||
if.end: ; preds = %if.then, %entry
|
||||
ret i8* %call
|
||||
|
||||
; CHECK-LABEL: @test3(
|
||||
; CHECK-NOT: load
|
||||
; CHECK-NOT: icmp
|
||||
|
||||
; CHECK_NO_LIBCALLS-LABEL: @test3(
|
||||
; CHECK_NO_LIBCALLS: load
|
||||
; CHECK_NO_LIBCALLS: icmp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue