[clang] f89f7da - [IR] Convert null-pointer-is-valid into an enum attribute

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Fri May 15 10:42:26 PDT 2020


Author: Nikita Popov
Date: 2020-05-15T19:41:07+02:00
New Revision: f89f7da999f362e4213c69923328dd1033276e59

URL: https://github.com/llvm/llvm-project/commit/f89f7da999f362e4213c69923328dd1033276e59
DIFF: https://github.com/llvm/llvm-project/commit/f89f7da999f362e4213c69923328dd1033276e59.diff

LOG: [IR] Convert null-pointer-is-valid into an enum attribute

The "null-pointer-is-valid" attribute needs to be checked by many
pointer-related combines. To make the check more efficient, convert
it from a string into an enum attribute.

In the future, this attribute may be replaced with data layout
properties.

Differential Revision: https://reviews.llvm.org/D78862

Added: 
    

Modified: 
    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/Analysis/ValueTracking/assume.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

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 32a9ba499ecb..068d053d17cc 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1744,7 +1744,7 @@ void CodeGenModule::ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
                            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",

diff  --git a/clang/test/CodeGen/delete-null-pointer-checks.c b/clang/test/CodeGen/delete-null-pointer-checks.c
index a3c1460f0a06..261598f43dd2 100644
--- a/clang/test/CodeGen/delete-null-pointer-checks.c
+++ b/clang/test/CodeGen/delete-null-pointer-checks.c
@@ -16,5 +16,5 @@ int null_check(int *P) {
   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

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 07320de7cf4b..a1f3297d6454 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1580,8 +1580,8 @@ example:
     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.

diff  --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 2f09ad3e7c59..e0093a12a7fe 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -637,6 +637,7 @@ enum AttributeKindCodes {
   ATTR_KIND_SANITIZE_MEMTAG = 64,
   ATTR_KIND_PREALLOCATED = 65,
   ATTR_KIND_NO_MERGE = 66,
+  ATTR_KIND_NULL_POINTER_IS_VALID = 67,
 };
 
 enum ComdatSelectionKindCodes {

diff  --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td
index 63b85eb7993b..209b8cca8e4d 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -127,6 +127,9 @@ def NoCfCheck : EnumAttr<"nocf_check">;
 /// 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">;
 

diff  --git a/llvm/include/llvm/IR/AutoUpgrade.h b/llvm/include/llvm/IR/AutoUpgrade.h
index 42f50cc991de..9ddec28f0d64 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -92,9 +92,8 @@ namespace llvm {
   /// 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
 

diff  --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index eb85ef7783bd..71cf22ca4753 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -665,6 +665,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(nosync);
   KEYWORD(nocf_check);
   KEYWORD(nounwind);
+  KEYWORD(null_pointer_is_valid);
   KEYWORD(optforfuzzing);
   KEYWORD(optnone);
   KEYWORD(optsize);

diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index d045bcd741f5..8455a027ae14 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -1316,6 +1316,8 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B,
     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;

diff  --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h
index ffced33253e2..201ba04025a0 100644
--- a/llvm/lib/AsmParser/LLToken.h
+++ b/llvm/lib/AsmParser/LLToken.h
@@ -211,6 +211,7 @@ enum Kind {
   kw_nosync,
   kw_nocf_check,
   kw_nounwind,
+  kw_null_pointer_is_valid,
   kw_optforfuzzing,
   kw_optnone,
   kw_optsize,

diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 21759c5091af..c3c49960a4fe 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1469,6 +1469,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
     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:
@@ -1654,7 +1656,7 @@ Error BitcodeReader::parseAttributeGroupBlock() {
         }
       }
 
-      UpgradeFramePointerAttributes(B);
+      UpgradeAttributes(B);
       MAttributeGroups[GrpID] = AttributeList::get(Context, Idx, B);
       break;
     }

diff  --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 5b62a475203c..fd4275f7d569 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -667,6 +667,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
     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:

diff  --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index ebf5dd9b5205..bf397409478f 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -385,6 +385,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
     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))
@@ -1930,12 +1932,12 @@ adjustMinLegalVectorWidth(Function &Caller, const Function &Callee) {
   }
 }
 
-/// 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);
   }
 }
 

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index d61b79725d5e..d7a4f44fef60 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4245,7 +4245,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
   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 @@ void llvm::UpgradeFramePointerAttributes(AttrBuilder &B) {
       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);
+  }
 }

diff  --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 7bf3ab59b877..d8663be873c8 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1641,9 +1641,7 @@ Optional<StringRef> Function::getSectionPrefix() const {
 }
 
 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) {

diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 8fbc9e743990..ed211c5d0ca8 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1563,6 +1563,7 @@ static bool isFuncOnlyAttr(Attribute::AttrKind Kind) {
   case Attribute::SpeculativeLoadHardening:
   case Attribute::Speculatable:
   case Attribute::StrictFP:
+  case Attribute::NullPointerIsValid:
     return true;
   default:
     break;

diff  --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index e8154ec73ed7..27103912da2b 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -911,6 +911,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs,
       case Attribute::NonLazyBind:
       case Attribute::NoRedZone:
       case Attribute::NoUnwind:
+      case Attribute::NullPointerIsValid:
       case Attribute::OptForFuzzing:
       case Attribute::OptimizeNone:
       case Attribute::OptimizeForSize:

diff  --git a/llvm/test/Analysis/MemorySSA/cyclicphi.ll b/llvm/test/Analysis/MemorySSA/cyclicphi.ll
index b64348908541..9db19685197e 100644
--- a/llvm/test/Analysis/MemorySSA/cyclicphi.ll
+++ b/llvm/test/Analysis/MemorySSA/cyclicphi.ll
@@ -152,4 +152,4 @@ bb77:                                             ; preds = %bb68, %bb26
   br label %bb26
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Analysis/ValueTracking/assume.ll b/llvm/test/Analysis/ValueTracking/assume.ll
index f480c80b7eb3..ece429153f86 100644
--- a/llvm/test/Analysis/ValueTracking/assume.ll
+++ b/llvm/test/Analysis/ValueTracking/assume.ll
@@ -91,7 +91,7 @@ A:
   ret i32 %6
 }
 
-define dso_local i32 @test4b(i32* readonly %0, i1 %cond) "null-pointer-is-valid"="true" {
+define dso_local i32 @test4b(i32* readonly %0, i1 %cond) null_pointer_is_valid {
 ; CHECK-LABEL: @test4b(
 ; CHECK-NEXT:    call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[TMP0:%.*]], i32 4) ]
 ; CHECK-NEXT:    br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]

diff  --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll
index d38eaee485ab..71c1fb59ebaa 100644
--- a/llvm/test/Bitcode/attributes.ll
+++ b/llvm/test/Bitcode/attributes.ll
@@ -380,6 +380,12 @@ define void @f64(i32* preallocated(i32) %a)
   ret void
 }
 
+; CHECK: define void @f65() #40
+define void @f65() null_pointer_is_valid
+{
+  ret void;
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -420,4 +426,5 @@ define void @f64(i32* preallocated(i32) %a)
 ; CHECK: attributes #37 = { nofree }
 ; CHECK: attributes #38 = { nosync }
 ; CHECK: attributes #39 = { sanitize_memtag }
+; CHECK: attributes #40 = { null_pointer_is_valid }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }

diff  --git a/llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll b/llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
index 517f8af1e0b9..4f072d772556 100644
--- a/llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
+++ b/llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
@@ -68,7 +68,7 @@ entry:
   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:%.*]])

diff  --git a/llvm/test/Transforms/Attributor/align.ll b/llvm/test/Transforms/Attributor/align.ll
index 0dd2b96a5dfe..ab104248e0a5 100644
--- a/llvm/test/Transforms/Attributor/align.ll
+++ b/llvm/test/Transforms/Attributor/align.ll
@@ -779,4 +779,4 @@ exit:
 
 attributes #0 = { nounwind uwtable noinline }
 attributes #1 = { uwtable noinline }
-attributes #2 = { "null-pointer-is-valid"="true" }
+attributes #2 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/Attributor/nocapture-1.ll b/llvm/test/Transforms/Attributor/nocapture-1.ll
index 6ca1a80cb654..559c626b5741 100644
--- a/llvm/test/Transforms/Attributor/nocapture-1.ll
+++ b/llvm/test/Transforms/Attributor/nocapture-1.ll
@@ -528,7 +528,7 @@ define i1 @nocaptureDereferenceableOrNullICmp(i32* dereferenceable_or_null(4) %x
   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*

diff  --git a/llvm/test/Transforms/Attributor/nonnull.ll b/llvm/test/Transforms/Attributor/nonnull.ll
index c9f380fc9e6d..9e4a4ac4bb18 100644
--- a/llvm/test/Transforms/Attributor/nonnull.ll
+++ b/llvm/test/Transforms/Attributor/nonnull.ll
@@ -1231,5 +1231,5 @@ define void @nonnull_assume_neg(i8* %arg) {
 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}

diff  --git a/llvm/test/Transforms/Attributor/norecurse.ll b/llvm/test/Transforms/Attributor/norecurse.ll
index 0740ea3998a9..41e8d7c0bb11 100644
--- a/llvm/test/Transforms/Attributor/norecurse.ll
+++ b/llvm/test/Transforms/Attributor/norecurse.ll
@@ -211,8 +211,8 @@ define i32 @eval_func1(i32 (i32)* , i32) local_unnamed_addr {
   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]])

diff  --git a/llvm/test/Transforms/Attributor/undefined_behavior.ll b/llvm/test/Transforms/Attributor/undefined_behavior.ll
index c5f9284805d4..8a2185f5adc7 100644
--- a/llvm/test/Transforms/Attributor/undefined_behavior.ll
+++ b/llvm/test/Transforms/Attributor/undefined_behavior.ll
@@ -49,7 +49,7 @@ e:
 
 ; 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 @@ e:
   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 @@ e:
   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 @@ e:
   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

diff  --git a/llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll b/llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
index 2a4ff5e6d596..fe4fc09129f9 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
@@ -333,4 +333,4 @@ merge:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/FunctionAttrs/nocapture.ll b/llvm/test/Transforms/FunctionAttrs/nocapture.ll
index 25759cffe13f..ba43f9637b88 100644
--- a/llvm/test/Transforms/FunctionAttrs/nocapture.ll
+++ b/llvm/test/Transforms/FunctionAttrs/nocapture.ll
@@ -311,7 +311,7 @@ define i1 @nocaptureDereferenceableOrNullICmp(i32* dereferenceable_or_null(4) %x
 }
 
 ; 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

diff  --git a/llvm/test/Transforms/FunctionAttrs/nonnull.ll b/llvm/test/Transforms/FunctionAttrs/nonnull.ll
index 128a2bdbe50c..a71d65688204 100644
--- a/llvm/test/Transforms/FunctionAttrs/nonnull.ll
+++ b/llvm/test/Transforms/FunctionAttrs/nonnull.ll
@@ -770,5 +770,5 @@ define void @PR43833_simple(i32* %0, i32 %1) {
   br i1 %11, label %7, label %8
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 attributes #1 = { nounwind willreturn}

diff  --git a/llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll b/llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
index 88896a4e97ed..f6c731444b24 100644
--- a/llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
+++ b/llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
@@ -58,7 +58,7 @@ cond.end:
   %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}

diff  --git a/llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
index c9b3f6fc1cdc..2b4bbb50af55 100644
--- a/llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
@@ -31,4 +31,4 @@ entry:
 
 declare noalias i8* @malloc(i32)
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
index c826e7f7a048..95ee0b74a9fa 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
@@ -36,5 +36,5 @@ bb2:		; preds = %bb1
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-1.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
index 28a20ada03fb..9c060e487146 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
@@ -42,4 +42,4 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
index c33bcba9921e..a8456ea75eae 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
@@ -36,4 +36,4 @@ bb2:		; preds = %bb1
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-2.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
index ec05b22b33b8..150642e2d4d0 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
@@ -42,4 +42,4 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
index ba3b0a418a1b..c6760ed7f311 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
@@ -38,4 +38,4 @@ bb2:		; preds = %bb1
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-3.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
index 67058c8aba25..2063966c12bc 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
@@ -43,4 +43,4 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
index 607c93d1e8a3..a17f347f69a4 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
@@ -41,4 +41,4 @@ bb2:		; preds = %bb1
 	ret i32 %3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-4.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
index 71832f349237..ef6f1046e40e 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
@@ -43,5 +43,5 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
index 06c74e5bfc42..a942fb351b9b 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
@@ -51,4 +51,4 @@ bb2:		; preds = %bb1
 	ret i32 %tmp3
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll b/llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
index 770220dd07b2..e16881a04883 100644
--- a/llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
+++ b/llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
@@ -49,4 +49,4 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
index d319d162ff4d..a1011c68c37a 100644
--- a/llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
@@ -25,4 +25,4 @@ define i64* @bar() {
 ; CHECK: load
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
index fc6dab31640d..81d24e4c561b 100644
--- a/llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
@@ -28,4 +28,4 @@ define i32 @get() #0 {
 ; CHECK: ret i32 %V
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
index a8f127474e38..51f06b12a843 100644
--- a/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
+++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
@@ -28,5 +28,5 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 

diff  --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
index 009a33435fd6..c3e958d5a38f 100644
--- a/llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
@@ -21,4 +21,4 @@ define void @t() #0 {
 }
 
 declare noalias i8* @malloc(i64)
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll b/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
index 64f379365c71..5e8d7d47de8f 100644
--- a/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
+++ b/llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
@@ -24,4 +24,4 @@ entry:
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
index 709df17e0b5d..179e83bfd80c 100644
--- a/llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
@@ -37,4 +37,4 @@ isNull:         ; preds = %0
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll b/llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
index c9a63f0080d7..1ffab8074e23 100644
--- a/llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
+++ b/llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
@@ -24,4 +24,4 @@ define void @doit() #0 {
         ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/IPConstantProp/PR26044.ll b/llvm/test/Transforms/IPConstantProp/PR26044.ll
index efd229e1dac5..6e63d2471684 100644
--- a/llvm/test/Transforms/IPConstantProp/PR26044.ll
+++ b/llvm/test/Transforms/IPConstantProp/PR26044.ll
@@ -84,4 +84,4 @@ entry:
   ret i32 %cond
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/Inline/attributes.ll b/llvm/test/Transforms/Inline/attributes.ll
index 81c189a3c7a7..5f27ac555129 100644
--- a/llvm/test/Transforms/Inline/attributes.ll
+++ b/llvm/test/Transforms/Inline/attributes.ll
@@ -389,18 +389,18 @@ define i32 @test_no-use-jump-tables3(i32 %i) "no-jump-tables"="true" {
 ; 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 @@ define i32 @null-pointer-is-valid_callee2(i32 %i)  {
 ; 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 @@ define i32 @test_null-pointer-is-valid0(i32 %i) {
 }
 
 ; 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 @@ define i32 @test_null-pointer-is-valid2(i32 %i) "null-pointer-is-valid"="true" {
 ; 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 }

diff  --git a/llvm/test/Transforms/InstCombine/atomic.ll b/llvm/test/Transforms/InstCombine/atomic.ll
index 16b222afd367..869b12526de9 100644
--- a/llvm/test/Transforms/InstCombine/atomic.ll
+++ b/llvm/test/Transforms/InstCombine/atomic.ll
@@ -330,4 +330,4 @@ define void @no_atomic_vector_store(<2 x float> %p, i8* %p2) {
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/InstCombine/invariant.group.ll b/llvm/test/Transforms/InstCombine/invariant.group.ll
index 6b79ceb5b2d0..f3774ad6c14d 100644
--- a/llvm/test/Transforms/InstCombine/invariant.group.ll
+++ b/llvm/test/Transforms/InstCombine/invariant.group.ll
@@ -147,4 +147,4 @@ declare i8 addrspace(42)* @llvm.strip.invariant.group.p42i8(i8 addrspace(42)*)
 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 }

diff  --git a/llvm/test/Transforms/InstCombine/invoke.ll b/llvm/test/Transforms/InstCombine/invoke.ll
index deb4a2b87a4f..6585ff000d92 100644
--- a/llvm/test/Transforms/InstCombine/invoke.ll
+++ b/llvm/test/Transforms/InstCombine/invoke.ll
@@ -66,7 +66,7 @@ lpad:
   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*) {

diff  --git a/llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll b/llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
index ee3668b3d809..bfc9667a4151 100644
--- a/llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
+++ b/llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
@@ -60,7 +60,7 @@ fin:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!22, !23}

diff  --git a/llvm/test/Transforms/InstCombine/load.ll b/llvm/test/Transforms/InstCombine/load.ll
index 3c41176eb613..4fc87219fa83 100644
--- a/llvm/test/Transforms/InstCombine/load.ll
+++ b/llvm/test/Transforms/InstCombine/load.ll
@@ -78,7 +78,7 @@ define i32 @test7_no_null_opt(i32 %X) #0 {
   %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(

diff  --git a/llvm/test/Transforms/InstCombine/mem-deref-bytes.ll b/llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
index c19597a4b4c6..a72f88b72885 100644
--- a/llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
+++ b/llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
@@ -55,7 +55,7 @@ define i32 @memcmp_const_size_update_deref4(i8* nocapture readonly %d, i8* nocap
   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 @@ define i32 @memcmp_const_size_update_deref5(i8* nocapture readonly %d, i8* nocap
   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 @@ define i32 @memcmp_const_size_update_deref6(i8* nocapture readonly %d, i8* nocap
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/memchr.ll b/llvm/test/Transforms/InstCombine/memchr.ll
index 2e2c29a07d57..a38eca2dff4b 100644
--- a/llvm/test/Transforms/InstCombine/memchr.ll
+++ b/llvm/test/Transforms/InstCombine/memchr.ll
@@ -233,7 +233,7 @@ define i8* @test18(i8* %str, i32 %c) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll b/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
index b57a24e58b05..62a272406967 100644
--- a/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
+++ b/llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
@@ -122,4 +122,4 @@ entry:
 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 }

diff  --git a/llvm/test/Transforms/InstCombine/memcpy-from-global.ll b/llvm/test/Transforms/InstCombine/memcpy-from-global.ll
index 96029fa59bfe..60a06d2a3169 100644
--- a/llvm/test/Transforms/InstCombine/memcpy-from-global.ll
+++ b/llvm/test/Transforms/InstCombine/memcpy-from-global.ll
@@ -323,4 +323,4 @@ entry:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/InstCombine/memrchr.ll b/llvm/test/Transforms/InstCombine/memrchr.ll
index feb384702f5c..4ed01f4c043b 100644
--- a/llvm/test/Transforms/InstCombine/memrchr.ll
+++ b/llvm/test/Transforms/InstCombine/memrchr.ll
@@ -34,7 +34,7 @@ define i8* @test3(i8* %str, i32 %c) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll
index 20b6dd1a990c..bbed168265dc 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -375,7 +375,7 @@ define i32 @test16_no_null_opt_2(i1 %C, i32* %P) #0 {
   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(

diff  --git a/llvm/test/Transforms/InstCombine/store.ll b/llvm/test/Transforms/InstCombine/store.ll
index af3628918553..98869ffaefe4 100644
--- a/llvm/test/Transforms/InstCombine/store.ll
+++ b/llvm/test/Transforms/InstCombine/store.ll
@@ -45,7 +45,7 @@ define void @store_at_gep_off_no_null_opt(i64 %offset) #0 {
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }
 
 ;; Simple sinking tests
 

diff  --git a/llvm/test/Transforms/InstCombine/strchr-1.ll b/llvm/test/Transforms/InstCombine/strchr-1.ll
index 081c3bf7a8ea..c18859e796b2 100644
--- a/llvm/test/Transforms/InstCombine/strchr-1.ll
+++ b/llvm/test/Transforms/InstCombine/strchr-1.ll
@@ -114,7 +114,7 @@ define i8* @test1(i8* %str, i32 %c) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/strcpy_chk-64.ll b/llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
index 6ff063b2b2bc..34ba0631240f 100644
--- a/llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
+++ b/llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
@@ -28,4 +28,4 @@ declare i8* @__strcpy_chk(i8*, i8*, i64) nounwind
 
 declare void @func2(i8*)
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/InstCombine/strlen-1.ll b/llvm/test/Transforms/InstCombine/strlen-1.ll
index 0ecf233a2603..f7629e026066 100644
--- a/llvm/test/Transforms/InstCombine/strlen-1.ll
+++ b/llvm/test/Transforms/InstCombine/strlen-1.ll
@@ -219,4 +219,4 @@ define i32 @test2(i8* %str) #0 {
   ret i32 %len
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/InstCombine/strncat-2.ll b/llvm/test/Transforms/InstCombine/strncat-2.ll
index 4aed71829a6e..32eb4a9b36ec 100644
--- a/llvm/test/Transforms/InstCombine/strncat-2.ll
+++ b/llvm/test/Transforms/InstCombine/strncat-2.ll
@@ -90,7 +90,7 @@ define i8* @test3(i8* %str1, i8* %str2, i32 %n) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/strncmp-1.ll b/llvm/test/Transforms/InstCombine/strncmp-1.ll
index 4bb03cc7a9a8..a6ce83b1d950 100644
--- a/llvm/test/Transforms/InstCombine/strncmp-1.ll
+++ b/llvm/test/Transforms/InstCombine/strncmp-1.ll
@@ -139,7 +139,7 @@ define i32 @test11(i8* %str1, i8* %str2, i32 %n) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/strrchr-1.ll b/llvm/test/Transforms/InstCombine/strrchr-1.ll
index e60e9bcd36c7..ad353fb90df4 100644
--- a/llvm/test/Transforms/InstCombine/strrchr-1.ll
+++ b/llvm/test/Transforms/InstCombine/strrchr-1.ll
@@ -81,7 +81,7 @@ define i8* @test1(i8* %str, i32 %c) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/strstr-1.ll b/llvm/test/Transforms/InstCombine/strstr-1.ll
index 4a9e62045bd4..7603f6458931 100644
--- a/llvm/test/Transforms/InstCombine/strstr-1.ll
+++ b/llvm/test/Transforms/InstCombine/strstr-1.ll
@@ -80,7 +80,7 @@ define i8* @test1(i8* %str1, i8* %str2) {
   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]]

diff  --git a/llvm/test/Transforms/InstCombine/wcslen-1.ll b/llvm/test/Transforms/InstCombine/wcslen-1.ll
index 1139048c7067..5610681681f2 100644
--- a/llvm/test/Transforms/InstCombine/wcslen-1.ll
+++ b/llvm/test/Transforms/InstCombine/wcslen-1.ll
@@ -219,4 +219,4 @@ define i64 @test_no_simplify4() {
   ret i64 %l
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index 5b997a5fc491..86d26a82fa1e 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -1673,4 +1673,4 @@ define i1 @cmp_through_addrspacecast(i32 addrspace(1)* %p1) {
   ret i1 %cmp
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/LoopIdiom/pr28196.ll b/llvm/test/Transforms/LoopIdiom/pr28196.ll
index d65acec22142..7689bce98b69 100644
--- a/llvm/test/Transforms/LoopIdiom/pr28196.ll
+++ b/llvm/test/Transforms/LoopIdiom/pr28196.ll
@@ -50,4 +50,4 @@ for.body:                                         ; preds = %for.body, %for.body
 ; CHECK: load
 ; CHECK: store
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/LoopVersioning/lcssa.ll b/llvm/test/Transforms/LoopVersioning/lcssa.ll
index 64993061008b..01178a5931e4 100644
--- a/llvm/test/Transforms/LoopVersioning/lcssa.ll
+++ b/llvm/test/Transforms/LoopVersioning/lcssa.ll
@@ -69,4 +69,4 @@ bb3:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
index 36b44a25aa8e..c8f59d4bd9ae 100644
--- a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
+++ b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
@@ -206,4 +206,4 @@ else:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/SimplifyCFG/invoke.ll b/llvm/test/Transforms/SimplifyCFG/invoke.ll
index a58e80057931..dcba88e9ab68 100644
--- a/llvm/test/Transforms/SimplifyCFG/invoke.ll
+++ b/llvm/test/Transforms/SimplifyCFG/invoke.ll
@@ -159,4 +159,4 @@ lpad:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll b/llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
index e7e9e7273467..af598721ae00 100644
--- a/llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
+++ b/llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
@@ -236,4 +236,4 @@ if.end7:                                          ; preds = %if.else, %if.then4,
 ; 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 }

diff  --git a/llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll b/llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
index b3c104d7ae5d..4cd5d2f6bfcb 100644
--- a/llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
+++ b/llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
@@ -7,7 +7,7 @@ define void @foo() nounwind ssp #0 !dbg !0 {
   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}

diff  --git a/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll b/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
index b074393e453a..de847c361a3a 100644
--- a/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
+++ b/llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
@@ -122,4 +122,4 @@ F:
   ret void
 }
 
-attributes #0 = { "null-pointer-is-valid"="true" }
+attributes #0 = { null_pointer_is_valid }

diff  --git a/llvm/test/Transforms/Util/assume-builder.ll b/llvm/test/Transforms/Util/assume-builder.ll
index 22938ee41260..f2ca8a3c4c8c 100644
--- a/llvm/test/Transforms/Util/assume-builder.ll
+++ b/llvm/test/Transforms/Util/assume-builder.ll
@@ -386,7 +386,7 @@ define i32 @test2(%struct.S* %0, i32* %1, i8* %2) {
   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: define {{[^@]+}}@test3
 ; BASIC-SAME: (%struct.S* [[TMP0:%.*]], i32* [[TMP1:%.*]], i8* [[TMP2:%.*]]) #4
 ; BASIC-NEXT:    [[TMP4:%.*]] = alloca %struct.S*, align 8

diff  --git a/mlir/test/Target/llvmir.mlir b/mlir/test/Target/llvmir.mlir
index 2dcbc2f74950..88f0e2f47ca6 100644
--- a/mlir/test/Target/llvmir.mlir
+++ b/mlir/test/Target/llvmir.mlir
@@ -1205,12 +1205,12 @@ llvm.func @callFenceInst() {
 
 // 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"


        


More information about the cfe-commits mailing list