nikic updated this revision to Diff 260105.
nikic added a comment.
Herald added subscribers: cfe-commits, Kayjukh, frgossen, grosul1, Joonsoo, 
liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, 
shauheen, jpienaar, rriddle, mehdi_amini, asbirlea, jfb, george.burgess.iv.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: ftynse.
Herald added a project: clang.

Update tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78862/new/

https://reviews.llvm.org/D78862

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/delete-null-pointer-checks.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/AutoUpgrade.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Analysis/MemorySSA/cyclicphi.ll
  llvm/test/Bitcode/attributes.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/align.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/nonnull.ll
  llvm/test/Transforms/Attributor/norecurse.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
  llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
  llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
  llvm/test/Transforms/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Inline/attributes.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/invariant.group.ll
  llvm/test/Transforms/InstCombine/invoke.ll
  llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
  llvm/test/Transforms/InstCombine/memchr.ll
  llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
  llvm/test/Transforms/InstCombine/memcpy-from-global.ll
  llvm/test/Transforms/InstCombine/memrchr.ll
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/InstCombine/strchr-1.ll
  llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
  llvm/test/Transforms/InstCombine/strlen-1.ll
  llvm/test/Transforms/InstCombine/strncat-2.ll
  llvm/test/Transforms/InstCombine/strncmp-1.ll
  llvm/test/Transforms/InstCombine/strrchr-1.ll
  llvm/test/Transforms/InstCombine/strstr-1.ll
  llvm/test/Transforms/InstCombine/wcslen-1.ll
  llvm/test/Transforms/InstSimplify/compare.ll
  llvm/test/Transforms/LoopIdiom/pr28196.ll
  llvm/test/Transforms/LoopVersioning/lcssa.ll
  llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
  llvm/test/Transforms/SimplifyCFG/invoke.ll
  llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
  llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
  llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
  llvm/test/Transforms/Util/assume-builder.ll
  mlir/test/Target/llvmir.mlir

Index: mlir/test/Target/llvmir.mlir
===================================================================
--- mlir/test/Target/llvmir.mlir
+++ mlir/test/Target/llvmir.mlir
@@ -1205,12 +1205,12 @@
 
 // CHECK-LABEL: @passthrough
 // CHECK: #[[ATTR_GROUP:[0-9]*]]
-llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "4"], "null-pointer-is-valid", ["foo", "bar"]]} {
+llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "4"], "null_pointer_is_valid", ["foo", "bar"]]} {
   llvm.return
 }
 
 // CHECK: attributes #[[ATTR_GROUP]] = {
 // CHECK-DAG: noinline
 // CHECK-DAG: alignstack=4
-// CHECK-DAG: "null-pointer-is-valid"
+// CHECK-DAG: null_pointer_is_valid
 // CHECK-DAG: "foo"="bar"
Index: llvm/test/Transforms/Util/assume-builder.ll
===================================================================
--- llvm/test/Transforms/Util/assume-builder.ll
+++ llvm/test/Transforms/Util/assume-builder.ll
@@ -196,7 +196,7 @@
   ret i32 %28
 }
 
-define i32 @test3(%struct.S* %0, i32* %1, i8* %2) "null-pointer-is-valid"="true" {
+define i32 @test3(%struct.S* %0, i32* %1, i8* %2) null_pointer_is_valid {
 ; BASIC-LABEL: @test3(
 ; BASIC-NEXT:    [[TMP4:%.*]] = alloca %struct.S*, align 8
 ; BASIC-NEXT:    [[TMP5:%.*]] = alloca i32*, align 8
Index: llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
+++ llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
@@ -122,4 +122,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
+++ llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
@@ -7,7 +7,7 @@
   ret void, !dbg !7
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 !llvm.dbg.cu = !{!2}
 !llvm.module.flags = !{!10}
Index: llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
+++ llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
@@ -236,4 +236,4 @@
 ; CHECK-NEXT: phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/SimplifyCFG/invoke.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/invoke.ll
+++ llvm/test/Transforms/SimplifyCFG/invoke.ll
@@ -159,4 +159,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
+++ llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
@@ -206,4 +206,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/LoopVersioning/lcssa.ll
===================================================================
--- llvm/test/Transforms/LoopVersioning/lcssa.ll
+++ llvm/test/Transforms/LoopVersioning/lcssa.ll
@@ -69,4 +69,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/LoopIdiom/pr28196.ll
===================================================================
--- llvm/test/Transforms/LoopIdiom/pr28196.ll
+++ llvm/test/Transforms/LoopIdiom/pr28196.ll
@@ -50,4 +50,4 @@
 ; CHECK: load
 ; CHECK: store
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstSimplify/compare.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/compare.ll
+++ llvm/test/Transforms/InstSimplify/compare.ll
@@ -1673,4 +1673,4 @@
   ret i1 %cmp
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/wcslen-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/wcslen-1.ll
+++ llvm/test/Transforms/InstCombine/wcslen-1.ll
@@ -219,4 +219,4 @@
   ret i64 %l
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/strstr-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strstr-1.ll
+++ llvm/test/Transforms/InstCombine/strstr-1.ll
@@ -80,7 +80,7 @@
   ret i8* %ret
 }
 
-define i8* @test2(i8* %str1, i8* %str2) "null-pointer-is-valid"="true" {
+define i8* @test2(i8* %str1, i8* %str2) null_pointer_is_valid {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:    [[RET:%.*]] = call i8* @strstr(i8* [[STR1:%.*]], i8* [[STR2:%.*]])
 ; CHECK-NEXT:    ret i8* [[RET]]
Index: llvm/test/Transforms/InstCombine/strrchr-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strrchr-1.ll
+++ llvm/test/Transforms/InstCombine/strrchr-1.ll
@@ -81,7 +81,7 @@
   ret i8* %ret
 }
 
-define i8* @test2(i8* %str, i32 %c) "null-pointer-is-valid"="true" {
+define i8* @test2(i8* %str, i32 %c) null_pointer_is_valid {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:    [[RET:%.*]] = call i8* @strrchr(i8* [[STR:%.*]], i32 [[C:%.*]])
 ; CHECK-NEXT:    ret i8* [[RET]]
Index: llvm/test/Transforms/InstCombine/strncmp-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strncmp-1.ll
+++ llvm/test/Transforms/InstCombine/strncmp-1.ll
@@ -139,7 +139,7 @@
   ret i32 %temp1
 }
 
-define i32 @test12(i8* %str1, i8* %str2, i32 %n) "null-pointer-is-valid"="true" {
+define i32 @test12(i8* %str1, i8* %str2, i32 %n) null_pointer_is_valid {
 ; CHECK-LABEL: @test12(
 ; CHECK-NEXT:    [[TEMP1:%.*]] = call i32 @strncmp(i8* [[STR1:%.*]], i8* [[STR2:%.*]], i32 [[N:%.*]])
 ; CHECK-NEXT:    ret i32 [[TEMP1]]
Index: llvm/test/Transforms/InstCombine/strncat-2.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strncat-2.ll
+++ llvm/test/Transforms/InstCombine/strncat-2.ll
@@ -90,7 +90,7 @@
   ret i8* %temp1
 }
 
-define i8* @test4(i8* %str1, i8* %str2, i32 %n) "null-pointer-is-valid"="true" {
+define i8* @test4(i8* %str1, i8* %str2, i32 %n) null_pointer_is_valid {
 ; CHECK-LABEL: @test4(
 ; CHECK-NEXT:    [[TEMP1:%.*]] = call i8* @strncat(i8* [[STR1:%.*]], i8* [[STR2:%.*]], i32 [[N:%.*]])
 ; CHECK-NEXT:    ret i8* [[TEMP1]]
Index: llvm/test/Transforms/InstCombine/strlen-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strlen-1.ll
+++ llvm/test/Transforms/InstCombine/strlen-1.ll
@@ -219,4 +219,4 @@
   ret i32 %len
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
+++ llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
@@ -28,4 +28,4 @@
 
 declare void @func2(i8*)
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/strchr-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strchr-1.ll
+++ llvm/test/Transforms/InstCombine/strchr-1.ll
@@ -114,7 +114,7 @@
   ret i8* %ret
 }
 
-define i8* @test2(i8* %str, i32 %c) "null-pointer-is-valid"="true" {
+define i8* @test2(i8* %str, i32 %c) null_pointer_is_valid {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:    [[RET:%.*]] = call i8* @strchr(i8* [[STR:%.*]], i32 [[C:%.*]])
 ; CHECK-NEXT:    ret i8* [[RET]]
Index: llvm/test/Transforms/InstCombine/store.ll
===================================================================
--- llvm/test/Transforms/InstCombine/store.ll
+++ llvm/test/Transforms/InstCombine/store.ll
@@ -45,7 +45,7 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 ;; Simple sinking tests
 
Index: llvm/test/Transforms/InstCombine/select.ll
===================================================================
--- llvm/test/Transforms/InstCombine/select.ll
+++ llvm/test/Transforms/InstCombine/select.ll
@@ -375,7 +375,7 @@
   ret i32 %V
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 define i1 @test17(i32* %X, i1 %C) {
 ; CHECK-LABEL: @test17(
Index: llvm/test/Transforms/InstCombine/memrchr.ll
===================================================================
--- llvm/test/Transforms/InstCombine/memrchr.ll
+++ llvm/test/Transforms/InstCombine/memrchr.ll
@@ -34,7 +34,7 @@
   ret i8* %ret
 }
 
-define i8* @test4(i8* %str, i32 %c) "null-pointer-is-valid"="true" {
+define i8* @test4(i8* %str, i32 %c) null_pointer_is_valid {
 ; CHECK-LABEL: @test4(
 ; CHECK-NEXT:    [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
 ; CHECK-NEXT:    ret i8* [[RET]]
Index: llvm/test/Transforms/InstCombine/memcpy-from-global.ll
===================================================================
--- llvm/test/Transforms/InstCombine/memcpy-from-global.ll
+++ llvm/test/Transforms/InstCombine/memcpy-from-global.ll
@@ -323,4 +323,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
===================================================================
--- llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
+++ llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
@@ -122,4 +122,4 @@
 declare void @llvm.memcpy.p0i8.p2i8.i64(i8* nocapture writeonly, i8 addrspace(2)* nocapture readonly, i64, i1)
 declare i32 @foo(i32* %x)
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/memchr.ll
===================================================================
--- llvm/test/Transforms/InstCombine/memchr.ll
+++ llvm/test/Transforms/InstCombine/memchr.ll
@@ -233,7 +233,7 @@
   ret i8* %ret
 }
 
-define i8* @test19(i8* %str, i32 %c) "null-pointer-is-valid"="true" {
+define i8* @test19(i8* %str, i32 %c) null_pointer_is_valid {
 ; CHECK-LABEL: @test19(
 ; CHECK-NEXT:    [[RET:%.*]] = call i8* @memchr(i8* dereferenceable(5) [[STR:%.*]], i32 [[C:%.*]], i32 5)
 ; CHECK-NEXT:    ret i8* [[RET]]
Index: llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
===================================================================
--- llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
+++ llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
@@ -55,7 +55,7 @@
   ret i32 %call
 }
 
-define i32 @memcmp_const_size_update_deref5(i8* nocapture readonly %d, i8* nocapture readonly %s) "null-pointer-is-valid"="false" {
+define i32 @memcmp_const_size_update_deref5(i8* nocapture readonly %d, i8* nocapture readonly %s) {
 ; CHECK-LABEL: @memcmp_const_size_update_deref5(
 ; CHECK-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(i8* nonnull dereferenceable(40) [[D:%.*]], i8* nonnull dereferenceable(16) [[S:%.*]], i64 16)
 ; CHECK-NEXT:    ret i32 [[CALL]]
@@ -64,7 +64,7 @@
   ret i32 %call
 }
 
-define i32 @memcmp_const_size_update_deref6(i8* nocapture readonly %d, i8* nocapture readonly %s) "null-pointer-is-valid"="true" {
+define i32 @memcmp_const_size_update_deref6(i8* nocapture readonly %d, i8* nocapture readonly %s) null_pointer_is_valid {
 ; CHECK-LABEL: @memcmp_const_size_update_deref6(
 ; CHECK-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(i8* dereferenceable(16) dereferenceable_or_null(40) [[D:%.*]], i8* dereferenceable(16) [[S:%.*]], i64 16)
 ; CHECK-NEXT:    ret i32 [[CALL]]
@@ -73,7 +73,7 @@
   ret i32 %call
 }
 
-define i32 @memcmp_const_size_update_deref7(i8* nocapture readonly %d, i8* nocapture readonly %s) "null-pointer-is-valid"="true" {
+define i32 @memcmp_const_size_update_deref7(i8* nocapture readonly %d, i8* nocapture readonly %s) null_pointer_is_valid {
 ; CHECK-LABEL: @memcmp_const_size_update_deref7(
 ; CHECK-NEXT:    [[CALL:%.*]] = tail call i32 @memcmp(i8* nonnull dereferenceable(40) [[D:%.*]], i8* dereferenceable(16) [[S:%.*]], i64 16)
 ; CHECK-NEXT:    ret i32 [[CALL]]
Index: llvm/test/Transforms/InstCombine/load.ll
===================================================================
--- llvm/test/Transforms/InstCombine/load.ll
+++ llvm/test/Transforms/InstCombine/load.ll
@@ -78,7 +78,7 @@
   %R = load i32, i32* %V          ; <i32> [#uses=1]
   ret i32 %R
 }
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 define i32 @test8(i32* %P) {
 ; CHECK-LABEL: @test8(
Index: llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
+++ llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
@@ -60,7 +60,7 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!22, !23}
Index: llvm/test/Transforms/InstCombine/invoke.ll
===================================================================
--- llvm/test/Transforms/InstCombine/invoke.ll
+++ llvm/test/Transforms/InstCombine/invoke.ll
@@ -66,7 +66,7 @@
   tail call void @__cxa_call_unexpected(i8* %2) noreturn nounwind
   unreachable
 }
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 ; CHECK-LABEL: @f3(
 define void @f3() nounwind uwtable ssp personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
Index: llvm/test/Transforms/InstCombine/invariant.group.ll
===================================================================
--- llvm/test/Transforms/InstCombine/invariant.group.ll
+++ llvm/test/Transforms/InstCombine/invariant.group.ll
@@ -147,4 +147,4 @@
 declare i16* @llvm.strip.invariant.group.p0i16(i16* %c1)
 declare i16 addrspace(42)* @llvm.strip.invariant.group.p42i16(i16 addrspace(42)* %c1)
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/InstCombine/atomic.ll
===================================================================
--- llvm/test/Transforms/InstCombine/atomic.ll
+++ llvm/test/Transforms/InstCombine/atomic.ll
@@ -330,4 +330,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/Inline/attributes.ll
===================================================================
--- llvm/test/Transforms/Inline/attributes.ll
+++ llvm/test/Transforms/Inline/attributes.ll
@@ -389,18 +389,18 @@
 ; CHECK-NEXT: ret i32
 }
 
-; Callee with "null-pointer-is-valid"="true" attribute should not be inlined
+; Callee with null_pointer_is_valid attribute should not be inlined
 ; into a caller without this attribute.
 ; Exception: alwaysinline callee can still be inlined but
-; "null-pointer-is-valid"="true" should get copied to caller.
+; null_pointer_is_valid should get copied to caller.
 
-define i32 @null-pointer-is-valid_callee0(i32 %i) "null-pointer-is-valid"="true" {
+define i32 @null-pointer-is-valid_callee0(i32 %i) null_pointer_is_valid {
   ret i32 %i
 ; CHECK: @null-pointer-is-valid_callee0(i32 %i)
 ; CHECK-NEXT: ret i32
 }
 
-define i32 @null-pointer-is-valid_callee1(i32 %i) alwaysinline "null-pointer-is-valid"="true" {
+define i32 @null-pointer-is-valid_callee1(i32 %i) alwaysinline null_pointer_is_valid {
   ret i32 %i
 ; CHECK: @null-pointer-is-valid_callee1(i32 %i)
 ; CHECK-NEXT: ret i32
@@ -412,7 +412,7 @@
 ; CHECK-NEXT: ret i32
 }
 
-; No inlining since caller does not have "null-pointer-is-valid"="true" attribute.
+; No inlining since caller does not have null_pointer_is_valid attribute.
 define i32 @test_null-pointer-is-valid0(i32 %i) {
   %1 = call i32 @null-pointer-is-valid_callee0(i32 %i)
   ret i32 %1
@@ -422,18 +422,18 @@
 }
 
 ; alwaysinline should force inlining even when caller does not have
-; "null-pointer-is-valid"="true" attribute. However, the attribute should be
+; null_pointer_is_valid attribute. However, the attribute should be
 ; copied to caller.
-define i32 @test_null-pointer-is-valid1(i32 %i) "null-pointer-is-valid"="false" {
+define i32 @test_null-pointer-is-valid1(i32 %i) {
   %1 = call i32 @null-pointer-is-valid_callee1(i32 %i)
   ret i32 %1
 ; CHECK: @test_null-pointer-is-valid1(i32 %i) [[NULLPOINTERISVALID:#[0-9]+]] {
 ; CHECK-NEXT: ret i32
 }
 
-; Can inline since both caller and callee have "null-pointer-is-valid"="true"
+; Can inline since both caller and callee have null_pointer_is_valid
 ; attribute.
-define i32 @test_null-pointer-is-valid2(i32 %i) "null-pointer-is-valid"="true" {
+define i32 @test_null-pointer-is-valid2(i32 %i) null_pointer_is_valid {
   %1 = call i32 @null-pointer-is-valid_callee2(i32 %i)
   ret i32 %1
 ; CHECK: @test_null-pointer-is-valid2(i32 %i) [[NULLPOINTERISVALID]] {
@@ -445,4 +445,4 @@
 ; CHECK: attributes [[FPMAD_TRUE]] = { "less-precise-fpmad"="true" }
 ; CHECK: attributes [[NOIMPLICITFLOAT]] = { noimplicitfloat }
 ; CHECK: attributes [[NOUSEJUMPTABLES]] = { "no-jump-tables"="true" }
-; CHECK: attributes [[NULLPOINTERISVALID]] = { "null-pointer-is-valid"="true" }
+; CHECK: attributes [[NULLPOINTERISVALID]] = { null_pointer_is_valid }
Index: llvm/test/Transforms/IPConstantProp/PR26044.ll
===================================================================
--- llvm/test/Transforms/IPConstantProp/PR26044.ll
+++ llvm/test/Transforms/IPConstantProp/PR26044.ll
@@ -84,4 +84,4 @@
   ret i32 %cond
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
@@ -24,4 +24,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
@@ -37,4 +37,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
+++ llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
@@ -24,4 +24,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
@@ -21,4 +21,4 @@
 }
 
 declare noalias i8* @malloc(i64)
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
+++ llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
@@ -28,5 +28,5 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
Index: llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
@@ -28,4 +28,4 @@
 ; CHECK: ret i32 %V
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
@@ -25,4 +25,4 @@
 ; CHECK: load
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
@@ -49,4 +49,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
@@ -51,4 +51,4 @@
 	ret i32 %tmp3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
@@ -43,5 +43,5 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
Index: llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
@@ -41,4 +41,4 @@
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
@@ -43,4 +43,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
@@ -38,4 +38,4 @@
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
@@ -42,4 +42,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
@@ -36,4 +36,4 @@
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
@@ -42,4 +42,4 @@
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
@@ -36,5 +36,5 @@
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
Index: llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
+++ llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
@@ -31,4 +31,4 @@
 
 declare noalias i8* @malloc(i32)
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
===================================================================
--- llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
+++ llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
@@ -58,7 +58,7 @@
   %call = tail call i32 @bar(i8* %3, i8* %6)
   ret i32 %call
 }
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 declare i32 @bar(i8*, i8*) local_unnamed_addr #1
 !llvm.dbg.cu = !{!0}
Index: llvm/test/Transforms/FunctionAttrs/nonnull.ll
===================================================================
--- llvm/test/Transforms/FunctionAttrs/nonnull.ll
+++ llvm/test/Transforms/FunctionAttrs/nonnull.ll
@@ -770,5 +770,5 @@
   br i1 %11, label %7, label %8
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 attributes #1 = { nounwind willreturn}
Index: llvm/test/Transforms/FunctionAttrs/nocapture.ll
===================================================================
--- llvm/test/Transforms/FunctionAttrs/nocapture.ll
+++ llvm/test/Transforms/FunctionAttrs/nocapture.ll
@@ -311,7 +311,7 @@
 }
 
 ; FNATTR: define i1 @captureDereferenceableOrNullICmp(i32* readnone dereferenceable_or_null(4) %x)
-define i1 @captureDereferenceableOrNullICmp(i32* dereferenceable_or_null(4) %x) "null-pointer-is-valid"="true" {
+define i1 @captureDereferenceableOrNullICmp(i32* dereferenceable_or_null(4) %x) null_pointer_is_valid {
   %1 = bitcast i32* %x to i8*
   %2 = icmp eq i8* %1, null
   ret i1 %2
Index: llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
===================================================================
--- llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
+++ llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
@@ -333,4 +333,4 @@
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/test/Transforms/Attributor/undefined_behavior.ll
===================================================================
--- llvm/test/Transforms/Attributor/undefined_behavior.ll
+++ llvm/test/Transforms/Attributor/undefined_behavior.ll
@@ -49,7 +49,7 @@
 
 ; Note that while the load is removed (because it's unused), the block
 ; is not changed to unreachable
-define void @load_null_pointer_is_defined() "null-pointer-is-valid"="true" {
+define void @load_null_pointer_is_defined() null_pointer_is_valid {
 ; CHECK-LABEL: define {{[^@]+}}@load_null_pointer_is_defined()
 ; CHECK-NEXT:    ret void
 ;
@@ -100,7 +100,7 @@
   ret void
 }
 
-define void @store_null_pointer_is_defined() "null-pointer-is-valid"="true" {
+define void @store_null_pointer_is_defined() null_pointer_is_valid {
 ; CHECK-LABEL: define {{[^@]+}}@store_null_pointer_is_defined()
 ; CHECK-NEXT:    store i32 5, i32* null, align 536870912
 ; CHECK-NEXT:    ret void
@@ -148,7 +148,7 @@
   ret void
 }
 
-define void @atomicrmw_null_pointer_is_defined() "null-pointer-is-valid"="true" {
+define void @atomicrmw_null_pointer_is_defined() null_pointer_is_valid {
 ; CHECK-LABEL: define {{[^@]+}}@atomicrmw_null_pointer_is_defined()
 ; CHECK-NEXT:    [[A:%.*]] = atomicrmw add i32* null, i32 1 acquire
 ; CHECK-NEXT:    ret void
@@ -196,7 +196,7 @@
   ret void
 }
 
-define void @atomiccmpxchg_null_pointer_is_defined() "null-pointer-is-valid"="true" {
+define void @atomiccmpxchg_null_pointer_is_defined() null_pointer_is_valid {
 ; CHECK-LABEL: define {{[^@]+}}@atomiccmpxchg_null_pointer_is_defined()
 ; CHECK-NEXT:    [[A:%.*]] = cmpxchg i32* null, i32 2, i32 3 acq_rel monotonic
 ; CHECK-NEXT:    ret void
Index: llvm/test/Transforms/Attributor/norecurse.ll
===================================================================
--- llvm/test/Transforms/Attributor/norecurse.ll
+++ llvm/test/Transforms/Attributor/norecurse.ll
@@ -193,8 +193,8 @@
   ret i32 %3
 }
 
-; CHECK-NOT: Function Attrs
-define i32 @eval_func2(i32 (i32)* , i32) local_unnamed_addr "null-pointer-is-valid"="true"{
+; CHECK: Function Attrs: null_pointer_is_valid
+define i32 @eval_func2(i32 (i32)* , i32) local_unnamed_addr null_pointer_is_valid{
 ; CHECK-LABEL: define {{[^@]+}}@eval_func2
 ; CHECK-SAME: (i32 (i32)* nocapture nofree [[TMP0:%.*]], i32 [[TMP1:%.*]]) local_unnamed_addr
 ; CHECK-NEXT:    [[TMP3:%.*]] = tail call i32 [[TMP0]](i32 [[TMP1]])
Index: llvm/test/Transforms/Attributor/nonnull.ll
===================================================================
--- llvm/test/Transforms/Attributor/nonnull.ll
+++ llvm/test/Transforms/Attributor/nonnull.ll
@@ -1201,5 +1201,5 @@
 declare void @use_i8_ptr(i8* nofree nocapture readnone) nounwind
 declare void @use_i8_ptr_ret(i8* nofree nocapture readnone) nounwind willreturn
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 attributes #1 = { nounwind willreturn}
Index: llvm/test/Transforms/Attributor/nocapture-1.ll
===================================================================
--- llvm/test/Transforms/Attributor/nocapture-1.ll
+++ llvm/test/Transforms/Attributor/nocapture-1.ll
@@ -539,7 +539,7 @@
   ret i1 %2
 }
 
-define i1 @captureDereferenceableOrNullICmp(i32* dereferenceable_or_null(4) %x) "null-pointer-is-valid"="true" {
+define i1 @captureDereferenceableOrNullICmp(i32* dereferenceable_or_null(4) %x) null_pointer_is_valid {
 ; CHECK-LABEL: define {{[^@]+}}@captureDereferenceableOrNullICmp
 ; CHECK-SAME: (i32* nofree readnone dereferenceable_or_null(4) [[X:%.*]])
 ; CHECK-NEXT:    [[TMP1:%.*]] = bitcast i32* [[X]] to i8*
Index: llvm/test/Transforms/Attributor/align.ll
===================================================================
--- llvm/test/Transforms/Attributor/align.ll
+++ llvm/test/Transforms/Attributor/align.ll
@@ -774,4 +774,4 @@
 
 attributes #0 = { nounwind uwtable noinline }
 attributes #1 = { uwtable noinline }
-attributes #2 = { "null-pointer-is-valid"="true" }
+attributes #2 = { null_pointer_is_valid }
Index: llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
===================================================================
--- llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
+++ llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
@@ -68,7 +68,7 @@
   ret i32 %cond
 }
 
-define void @fn_no_null_opt(i32* %P, i1 %C) "null-pointer-is-valid"="true" {
+define void @fn_no_null_opt(i32* %P, i1 %C) null_pointer_is_valid {
 ;
 ; IS__TUNIT____-LABEL: define {{[^@]+}}@fn_no_null_opt
 ; IS__TUNIT____-SAME: (i32* nocapture nofree writeonly [[P:%.*]], i1 [[C:%.*]])
Index: llvm/test/Bitcode/attributes.ll
===================================================================
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -204,7 +204,7 @@
 ; CHECK: define void @f34()
 {
   call void @nobuiltin() nobuiltin
-; CHECK: call void @nobuiltin() #40
+; CHECK: call void @nobuiltin() #[[NOBUILTIN:[0-9]+]]
         ret void;
 }
 
@@ -374,6 +374,12 @@
   ret void;
 }
 
+; CHECK: define void @f64() #40
+define void @f64() null_pointer_is_valid
+{
+  ret void;
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -414,4 +420,5 @@
 ; CHECK: attributes #37 = { nofree }
 ; CHECK: attributes #38 = { nosync }
 ; CHECK: attributes #39 = { sanitize_memtag }
-; CHECK: attributes #40 = { nobuiltin }
+; CHECK: attributes #40 = { null_pointer_is_valid }
+; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/test/Analysis/MemorySSA/cyclicphi.ll
===================================================================
--- llvm/test/Analysis/MemorySSA/cyclicphi.ll
+++ llvm/test/Analysis/MemorySSA/cyclicphi.ll
@@ -152,4 +152,4 @@
   br label %bb26
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -903,6 +903,7 @@
       case Attribute::NonLazyBind:
       case Attribute::NoRedZone:
       case Attribute::NoUnwind:
+      case Attribute::NullPointerIsValid:
       case Attribute::OptForFuzzing:
       case Attribute::OptimizeNone:
       case Attribute::OptimizeForSize:
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1552,6 +1552,7 @@
   case Attribute::SpeculativeLoadHardening:
   case Attribute::Speculatable:
   case Attribute::StrictFP:
+  case Attribute::NullPointerIsValid:
     return true;
   default:
     break;
Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -1634,9 +1634,7 @@
 }
 
 bool Function::nullPointerIsDefined() const {
-  return getFnAttribute("null-pointer-is-valid")
-          .getValueAsString()
-          .equals("true");
+  return hasFnAttribute(Attribute::NullPointerIsValid);
 }
 
 bool llvm::NullPointerIsDefined(const Function *F, unsigned AS) {
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -4245,7 +4245,7 @@
   return Res;
 }
 
-void llvm::UpgradeFramePointerAttributes(AttrBuilder &B) {
+void llvm::UpgradeAttributes(AttrBuilder &B) {
   StringRef FramePointer;
   if (B.contains("no-frame-pointer-elim")) {
     // The value can be "true" or "false".
@@ -4260,7 +4260,17 @@
       FramePointer = "non-leaf";
     B.removeAttribute("no-frame-pointer-elim-non-leaf");
   }
-
   if (!FramePointer.empty())
     B.addAttribute("frame-pointer", FramePointer);
+
+  if (B.contains("null-pointer-is-valid")) {
+    // The value can be "true" or "false".
+    bool NullPointerIsValid = false;
+    for (const auto &I : B.td_attrs())
+      if (I.first == "null-pointer-is-valid")
+        NullPointerIsValid = I.second == "true";
+    B.removeAttribute("null-pointer-is-valid");
+    if (NullPointerIsValid)
+      B.addAttribute(Attribute::NullPointerIsValid);
+  }
 }
Index: llvm/lib/IR/Attributes.cpp
===================================================================
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -376,6 +376,8 @@
     return "noreturn";
   if (hasAttribute(Attribute::NoSync))
     return "nosync";
+  if (hasAttribute(Attribute::NullPointerIsValid))
+    return "null_pointer_is_valid";
   if (hasAttribute(Attribute::WillReturn))
     return "willreturn";
   if (hasAttribute(Attribute::NoCfCheck))
@@ -1881,12 +1883,12 @@
   }
 }
 
-/// If the inlined function has "null-pointer-is-valid=true" attribute,
+/// If the inlined function has null_pointer_is_valid attribute,
 /// set this attribute in the caller post inlining.
 static void
 adjustNullPointerValidAttr(Function &Caller, const Function &Callee) {
   if (Callee.nullPointerIsDefined() && !Caller.nullPointerIsDefined()) {
-    Caller.addFnAttr(Callee.getFnAttribute("null-pointer-is-valid"));
+    Caller.addFnAttr(Attribute::NullPointerIsValid);
   }
 }
 
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -666,6 +666,8 @@
     return bitc::ATTR_KIND_NOCF_CHECK;
   case Attribute::NoUnwind:
     return bitc::ATTR_KIND_NO_UNWIND;
+  case Attribute::NullPointerIsValid:
+    return bitc::ATTR_KIND_NULL_POINTER_IS_VALID;
   case Attribute::OptForFuzzing:
     return bitc::ATTR_KIND_OPT_FOR_FUZZING;
   case Attribute::OptimizeForSize:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1284,25 +1284,10 @@
     return 1ULL << 62;
   case Attribute::NoFree:
     return 1ULL << 63;
-  case Attribute::NoSync:
-    llvm_unreachable("nosync attribute not supported in raw format");
-    break;
-  case Attribute::Dereferenceable:
-    llvm_unreachable("dereferenceable attribute not supported in raw format");
-    break;
-  case Attribute::DereferenceableOrNull:
-    llvm_unreachable("dereferenceable_or_null attribute not supported in raw "
-                     "format");
-    break;
-  case Attribute::ArgMemOnly:
-    llvm_unreachable("argmemonly attribute not supported in raw format");
-    break;
-  case Attribute::AllocSize:
-    llvm_unreachable("allocsize not supported in raw format");
-    break;
-  case Attribute::SanitizeMemTag:
-    llvm_unreachable("sanitize_memtag attribute not supported in raw format");
-    break;
+  default:
+    // Other attributes are not supported in the raw format,
+    // as we ran out of space.
+    return 0;
   }
   llvm_unreachable("Unsupported attribute type");
 }
@@ -1312,13 +1297,6 @@
 
   for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
        I = Attribute::AttrKind(I + 1)) {
-    if (I == Attribute::SanitizeMemTag ||
-        I == Attribute::Dereferenceable ||
-        I == Attribute::DereferenceableOrNull ||
-        I == Attribute::ArgMemOnly ||
-        I == Attribute::AllocSize ||
-        I == Attribute::NoSync)
-      continue;
     if (uint64_t A = (Val & getRawAttributeMask(I))) {
       if (I == Attribute::Alignment)
         B.addAlignmentAttr(1ULL << ((A >> 16) - 1));
@@ -1484,6 +1462,8 @@
     return Attribute::NoCfCheck;
   case bitc::ATTR_KIND_NO_UNWIND:
     return Attribute::NoUnwind;
+  case bitc::ATTR_KIND_NULL_POINTER_IS_VALID:
+    return Attribute::NullPointerIsValid;
   case bitc::ATTR_KIND_OPT_FOR_FUZZING:
     return Attribute::OptForFuzzing;
   case bitc::ATTR_KIND_OPTIMIZE_FOR_SIZE:
@@ -1664,7 +1644,7 @@
         }
       }
 
-      UpgradeFramePointerAttributes(B);
+      UpgradeAttributes(B);
       MAttributeGroups[GrpID] = AttributeList::get(Context, Idx, B);
       break;
     }
Index: llvm/lib/AsmParser/LLToken.h
===================================================================
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -210,6 +210,7 @@
   kw_nosync,
   kw_nocf_check,
   kw_nounwind,
+  kw_null_pointer_is_valid,
   kw_optforfuzzing,
   kw_optnone,
   kw_optsize,
Index: llvm/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -1312,6 +1312,8 @@
     case lltok::kw_nocf_check: B.addAttribute(Attribute::NoCfCheck); break;
     case lltok::kw_norecurse: B.addAttribute(Attribute::NoRecurse); break;
     case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break;
+    case lltok::kw_null_pointer_is_valid:
+      B.addAttribute(Attribute::NullPointerIsValid); break;
     case lltok::kw_optforfuzzing:
       B.addAttribute(Attribute::OptForFuzzing); break;
     case lltok::kw_optnone: B.addAttribute(Attribute::OptimizeNone); break;
Index: llvm/lib/AsmParser/LLLexer.cpp
===================================================================
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -664,6 +664,7 @@
   KEYWORD(nosync);
   KEYWORD(nocf_check);
   KEYWORD(nounwind);
+  KEYWORD(null_pointer_is_valid);
   KEYWORD(optforfuzzing);
   KEYWORD(optnone);
   KEYWORD(optsize);
Index: llvm/include/llvm/IR/AutoUpgrade.h
===================================================================
--- llvm/include/llvm/IR/AutoUpgrade.h
+++ llvm/include/llvm/IR/AutoUpgrade.h
@@ -92,9 +92,8 @@
   /// pointers.
   std::string UpgradeDataLayoutString(StringRef DL, StringRef Triple);
 
-  /// Upgrade function attributes "no-frame-pointer-elim" and
-  /// "no-frame-pointer-elim-non-leaf" to "frame-pointer".
-  void UpgradeFramePointerAttributes(AttrBuilder &B);
+  /// Upgrade attributes that changed format or kind.
+  void UpgradeAttributes(AttrBuilder &B);
 
 } // End llvm namespace
 
Index: llvm/include/llvm/IR/Attributes.td
===================================================================
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -118,6 +118,9 @@
 /// Function doesn't unwind stack.
 def NoUnwind : EnumAttr<"nounwind">;
 
+/// Null pointer in address space zero is valid.
+def NullPointerIsValid : EnumAttr<"null_pointer_is_valid">;
+
 /// Select optimizations for best fuzzing signal.
 def OptForFuzzing : EnumAttr<"optforfuzzing">;
 
Index: llvm/include/llvm/Bitcode/LLVMBitCodes.h
===================================================================
--- llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -633,6 +633,7 @@
   ATTR_KIND_NOFREE = 62,
   ATTR_KIND_NOSYNC = 63,
   ATTR_KIND_SANITIZE_MEMTAG = 64,
+  ATTR_KIND_NULL_POINTER_IS_VALID = 65,
 };
 
 enum ComdatSelectionKindCodes {
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -1543,8 +1543,8 @@
     trap or generate asynchronous exceptions. Exception handling schemes
     that are recognized by LLVM to handle asynchronous exceptions, such
     as SEH, will still provide their implementation defined semantics.
-``"null-pointer-is-valid"``
-   If ``"null-pointer-is-valid"`` is set to ``"true"``, then ``null`` address
+``null_pointer_is_valid``
+   If ``null_pointer_is_valid`` is set, then the ``null`` address
    in address-space 0 is considered to be a valid address for memory loads and
    stores. Any analysis or optimization should not treat dereferencing a
    pointer to ``null`` as undefined behavior in this function.
Index: clang/test/CodeGen/delete-null-pointer-checks.c
===================================================================
--- clang/test/CodeGen/delete-null-pointer-checks.c
+++ clang/test/CodeGen/delete-null-pointer-checks.c
@@ -16,5 +16,5 @@
   return *Q;
 }
 
-// NULL-POINTER-INVALID-NOT: attributes #0 = {{.*}} "null-pointer-is-valid"="true"
-// NULL-POINTER-VALID: attributes #0 = {{.*}} "null-pointer-is-valid"="true"
+// NULL-POINTER-INVALID-NOT: attributes #0 = {{.*}} null_pointer_is_valid
+// NULL-POINTER-VALID: attributes #0 = {{.*}} null_pointer_is_valid
Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1747,7 +1747,7 @@
                            llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
 
     if (CodeGenOpts.NullPointerIsValid)
-      FuncAttrs.addAttribute("null-pointer-is-valid", "true");
+      FuncAttrs.addAttribute(llvm::Attribute::NullPointerIsValid);
 
     if (CodeGenOpts.FPDenormalMode != llvm::DenormalMode::getIEEE())
       FuncAttrs.addAttribute("denormal-fp-math",
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to