Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -5165,6 +5165,10 @@ Lex.Lex(); } + Type *Ty = nullptr; + if (ParseType(Ty)) return true; + ParseToken(lltok::comma, "expected comma after getelementptr's type"); + if (ParseTypeAndValue(Val, Loc, PFS) || ParseScopeAndOrdering(isAtomic, Scope, Ordering) || ParseOptionalCommaAlign(Alignment, AteExtraComma)) @@ -5179,6 +5183,9 @@ return Error(Loc, "atomic load cannot use Release ordering"); Inst = new LoadInst(Val, "", isVolatile, Alignment, Ordering, Scope); + + assert(Ty == Inst->getType()); + return AteExtraComma ? InstExtraComma : InstNormal; } Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -2880,6 +2880,11 @@ Out << ", "; TypePrinter.print(I.getType(), Out); } else if (Operand) { // Print the normal way. + if (auto *LI = dyn_cast(&I)) { + Out << ' '; + TypePrinter.print(LI->getType(), Out); + Out << ", "; + } // PrintAllTypes - Instructions who have operands of all the same type // omit the type from all but the first operand. If the instruction has