Fix LLVMContext to match what MDKind names that the LL parser permits. Fixes PR21799!
authorNick Lewycky <nicholas@mxc.ca>
Thu, 11 Dec 2014 02:10:28 +0000 (02:10 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 11 Dec 2014 02:10:28 +0000 (02:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223995 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/LLVMContext.cpp
test/Feature/metadata.ll

index c62bc0936c49d4e6908eb9795b13e8cfb4880f5d..b6d95c4fcf32c44eec54e5ffdb66dcc0a9ba90b7 100644 (file)
@@ -229,28 +229,10 @@ void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) {
 // Metadata Kind Uniquing
 //===----------------------------------------------------------------------===//
 
-#ifndef NDEBUG
-/// isValidName - Return true if Name is a valid custom metadata handler name.
-static bool isValidName(StringRef MDName) {
-  if (MDName.empty())
-    return false;
-
-  if (!std::isalpha(static_cast<unsigned char>(MDName[0])))
-    return false;
-
-  for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E;
-       ++I) {
-    if (!std::isalnum(static_cast<unsigned char>(*I)) && *I != '_' &&
-        *I != '-' && *I != '.')
-      return false;
-  }
-  return true;
-}
-#endif
-
 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
 unsigned LLVMContext::getMDKindID(StringRef Name) const {
-  assert(isValidName(Name) && "Invalid MDNode name");
+  assert(!std::isdigit(Name.front()) &&
+         "Named metadata may not start with a digit");
 
   // If this is new, assign it its ID.
   return pImpl->CustomMDKindNames.insert(std::make_pair(
index d1cc706fb1f3ac8e389f5a5d19c73dc8d6a2d474..851e5e751912effddbff9604c5bc7408957a5317 100644 (file)
@@ -5,7 +5,7 @@ define void @foo(i32 %x) {
   call void @llvm.zonk(metadata !{i32 %x}, i64 0, metadata !1)
   store i32 0, i32* null, !whatever !0, !whatever_else !{}, !more !{metadata !"hello"}
   store i32 0, i32* null, !whatever !{metadata !"hello", metadata !1, metadata !{}, metadata !2}
-  ret void
+  ret void, !_1 !0
 }
 
 declare void @llvm.zonk(metadata, i64, metadata) nounwind readnone