mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
647946fa14
Summary: Support for this option is needed for building Linux kernel. This is a very frequently requested feature by kernel developers. More details : https://lkml.org/lkml/2018/4/4/601 GCC option description for -fdelete-null-pointer-checks: This Assume that programs cannot safely dereference null pointers, and that no code or data element resides at address zero. -fno-delete-null-pointer-checks is the inverse of this implying that null pointer dereferencing is not undefined. This feature is implemented in LLVM IR in this CL as the function attribute "null-pointer-is-valid"="true" in IR (Under review at D47894). The CL updates several passes that assumed null pointer dereferencing is undefined to not optimize when the "null-pointer-is-valid"="true" attribute is present. Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, george.burgess.iv Reviewed By: efriedma, george.burgess.iv Subscribers: eraman, haicheng, george.burgess.iv, drinkcat, theraven, reames, sanjoy, xbolva00, llvm-commits Differential Revision: https://reviews.llvm.org/D47895 llvm-svn: 336613
63 lines
1.7 KiB
LLVM
63 lines
1.7 KiB
LLVM
; RUN: opt < %s -S -ipsccp | FileCheck %s
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
define void @fn2() {
|
|
entry:
|
|
br label %if.end
|
|
|
|
for.cond1: ; preds = %if.end, %for.end
|
|
br i1 undef, label %if.end, label %if.end
|
|
|
|
if.end: ; preds = %lbl, %for.cond1
|
|
%e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
|
|
%0 = load i32, i32* %e.2, align 4
|
|
%call = call i32 @fn1(i32 %0)
|
|
br label %for.cond1
|
|
}
|
|
|
|
define internal i32 @fn1(i32 %p1) {
|
|
entry:
|
|
%tobool = icmp ne i32 %p1, 0
|
|
%cond = select i1 %tobool, i32 %p1, i32 %p1
|
|
ret i32 %cond
|
|
}
|
|
|
|
define void @fn_no_null_opt() #0 {
|
|
entry:
|
|
br label %if.end
|
|
|
|
for.cond1: ; preds = %if.end, %for.end
|
|
br i1 undef, label %if.end, label %if.end
|
|
|
|
if.end: ; preds = %lbl, %for.cond1
|
|
%e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ]
|
|
%0 = load i32, i32* %e.2, align 4
|
|
%call = call i32 @fn0(i32 %0)
|
|
br label %for.cond1
|
|
}
|
|
|
|
define internal i32 @fn0(i32 %p1) {
|
|
entry:
|
|
%tobool = icmp ne i32 %p1, 0
|
|
%cond = select i1 %tobool, i32 %p1, i32 %p1
|
|
ret i32 %cond
|
|
}
|
|
|
|
attributes #0 = { "null-pointer-is-valid"="true" }
|
|
|
|
; CHECK-LABEL: define void @fn2(
|
|
; CHECK: call i32 @fn1(i32 undef)
|
|
|
|
; CHECK-LABEL: define internal i32 @fn1(
|
|
; CHECK:%[[COND:.*]] = select i1 undef, i32 undef, i32 undef
|
|
; CHECK: ret i32 %[[COND]]
|
|
|
|
; CHECK-LABEL: define void @fn_no_null_opt(
|
|
; CHECK: call i32 @fn0(i32 %0)
|
|
|
|
; CHECK-LABEL: define internal i32 @fn0(
|
|
; CHECK:%[[TOBOOL:.*]] = icmp ne i32 %p1, 0
|
|
; CHECK:%[[COND:.*]] = select i1 %[[TOBOOL]], i32 %p1, i32 %p1
|
|
; CHECK: ret i32 %[[COND]]
|