From dde76ff09c76bde19f4af7992c3ca14e1a69c694 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 11 Dec 2014 02:10:28 +0000 Subject: [PATCH] Fix LLVMContext to match what MDKind names that the LL parser permits. Fixes PR21799! llvm-svn: 223995 --- llvm/lib/IR/LLVMContext.cpp | 22 ++-------------------- llvm/test/Feature/metadata.ll | 2 +- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index c62bc09..b6d95c4f 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -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(MDName[0]))) - return false; - - for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E; - ++I) { - if (!std::isalnum(static_cast(*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( diff --git a/llvm/test/Feature/metadata.ll b/llvm/test/Feature/metadata.ll index d1cc706..851e5e7 100644 --- a/llvm/test/Feature/metadata.ll +++ b/llvm/test/Feature/metadata.ll @@ -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 -- 2.7.4