1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[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:
Uday Bondhugula 2020-03-28 13:03:06 +05:30
parent 386b6fa7b3
commit fba73700fd
2 changed files with 27 additions and 1 deletions

View File

@ -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,

View File

@ -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
}