Index: llvm/lib/AsmParser/LLParser.cpp =================================================================== --- llvm/lib/AsmParser/LLParser.cpp +++ llvm/lib/AsmParser/LLParser.cpp @@ -3439,9 +3439,23 @@ // Set the name on the instruction. Inst->setName(NameStr); - if (Inst->getName() != NameStr) + if (Inst->getName() != NameStr) { + + size_t InstNameSize = Inst->getName().size(); + size_t NameStrSize = NameStr.size(); + + if (InstNameSize != NameStrSize + 1) { + // The name is too long and was trimmed when stored in SmallString with + // NonGlobalValueMaxNameSize + return P.error(NameLoc, "name length exceeds non global max name size, " + "consider making the name shorter or " + "increasing -non-global-value-max-name-size: '" + + NameStr + "'"); + } + return P.error(NameLoc, "multiple definition of local value named '" + NameStr + "'"); + } return false; } Index: llvm/test/Assembler/non-global-value-max-name-size.ll =================================================================== --- llvm/test/Assembler/non-global-value-max-name-size.ll +++ llvm/test/Assembler/non-global-value-max-name-size.ll @@ -5,6 +5,7 @@ define void @f() { bb0: + %length = alloca i32, align 4 br label %testz testz: