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

[InstSimplify] Replace calls to null with undef

Calling null is undefined behavior, we can simplify the resulting value
to undef.

llvm-svn: 273777
This commit is contained in:
David Majnemer 2016-06-25 07:37:30 +00:00
parent a8dc7a78cf
commit 3c5c29ea74
2 changed files with 18 additions and 1 deletions

View File

@ -4009,7 +4009,8 @@ static Value *SimplifyCall(Value *V, IterTy ArgBegin, IterTy ArgEnd,
FunctionType *FTy = cast<FunctionType>(Ty);
// call undef -> undef
if (isa<UndefValue>(V))
// call null -> undef
if (isa<UndefValue>(V) || isa<ConstantPointerNull>(V))
return UndefValue::get(FTy->getReturnType());
Function *F = dyn_cast<Function>(V);

View File

@ -187,4 +187,20 @@ cast.end: ; preds = %cast.notnull, %entr
; CHECK: br i1 %cmp, label %cast.end, label %cast.notnull
}
define i32 @call_null() {
entry:
%call = call i32 null()
ret i32 %call
}
; CHECK-LABEL: define i32 @call_null(
; CHECK: ret i32 undef
define i32 @call_undef() {
entry:
%call = call i32 undef()
ret i32 %call
}
; CHECK-LABEL: define i32 @call_undef(
; CHECK: ret i32 undef
declare noalias i8* @malloc(i64)