OSDN Git Service

llvm: Add support for "-fno-delete-null-pointer-checks"
authorManoj Gupta <manojgupta@google.com>
Mon, 9 Jul 2018 22:27:23 +0000 (22:27 +0000)
committerManoj Gupta <manojgupta@google.com>
Mon, 9 Jul 2018 22:27:23 +0000 (22:27 +0000)
commitc6da6867a1d033384367983944f7c1ad103e9559
treeb76ce831d5d762480d5ea2d46e7ce2f821642568
parent1897a62c2efa7867857d280a77444ef8f421c37e
llvm: Add support for "-fno-delete-null-pointer-checks"

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336613 91177308-0d34-0410-b5e6-96231b3b80d8
66 files changed:
docs/LangRef.rst
include/llvm/Analysis/BasicAliasAnalysis.h
include/llvm/IR/CallSite.h
include/llvm/IR/Function.h
lib/Analysis/BasicAliasAnalysis.cpp
lib/Analysis/ConstantFolding.cpp
lib/Analysis/InlineCost.cpp
lib/Analysis/InstructionSimplify.cpp
lib/Analysis/LazyValueInfo.cpp
lib/Analysis/LoopAccessAnalysis.cpp
lib/Analysis/ValueTracking.cpp
lib/IR/ConstantFold.cpp
lib/IR/Function.cpp
lib/Transforms/IPO/GlobalOpt.cpp
lib/Transforms/InstCombine/InstCombineCalls.cpp
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
lib/Transforms/Scalar/DeadStoreElimination.cpp
lib/Transforms/Scalar/SCCP.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
test/Analysis/MemorySSA/cyclicphi.ll
test/Transforms/CorrelatedValuePropagation/non-null.ll
test/Transforms/FunctionAttrs/nonnull.ll
test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/heap-sra-1.ll
test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/heap-sra-2.ll
test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/heap-sra-3.ll
test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/heap-sra-4.ll
test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/heap-sra-phi.ll
test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/malloc-promote-1.ll
test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/malloc-promote-2.ll
test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll [new file with mode: 0644]
test/Transforms/GlobalOpt/storepointer-no-null-opt.ll [new file with mode: 0644]
test/Transforms/IPConstantProp/PR26044.ll
test/Transforms/Inline/attributes.ll
test/Transforms/InstCombine/atomic.ll
test/Transforms/InstCombine/invariant.group.ll
test/Transforms/InstCombine/invoke.ll
test/Transforms/InstCombine/lifetime-no-null-opt.ll [new file with mode: 0644]
test/Transforms/InstCombine/load.ll
test/Transforms/InstCombine/memcpy-addrspace.ll
test/Transforms/InstCombine/memcpy-from-global.ll
test/Transforms/InstCombine/select.ll
test/Transforms/InstCombine/store.ll
test/Transforms/InstCombine/strcpy_chk-64.ll
test/Transforms/InstCombine/strlen-1.ll
test/Transforms/InstCombine/wcslen-1.ll
test/Transforms/InstSimplify/compare.ll
test/Transforms/LoopIdiom/pr28196.ll
test/Transforms/LoopVersioning/lcssa.ll
test/Transforms/SimplifyCFG/UnreachableEliminate.ll
test/Transforms/SimplifyCFG/invoke.ll
test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll [new file with mode: 0644]
test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
unittests/Analysis/AliasAnalysisTest.cpp
unittests/Analysis/MemorySSA.cpp