diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index 6edd2797c2aa..1ee6d50b567a 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -456,6 +456,12 @@ static bool setValueName(Value *V, char *NameStr) { // cerr << "Type: " << Ty->getDescription() << " != " // << cast(V)->getDescription() << "!\n"; } else if (GlobalVariable *EGV = dyn_cast(Existing)) { + // We are allowed to redefine a global variable in two circumstances: + // 1. If at least one of the globals is uninitialized or + // 2. If both initializers have the same value. + // + // This can only be done if the const'ness of the vars is the same. + // if (GlobalVariable *GV = dyn_cast(V)) { if (EGV->isConstant() == GV->isConstant() && (!EGV->hasInitializer() || !GV->hasInitializer() ||