diff options
| author | Tim Northover <tnorthover@apple.com> | 2019-08-03 14:28:34 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2019-08-03 14:28:34 +0000 |
| commit | a009a60a917bc30940422bcef73f8270566d78db (patch) | |
| tree | 585c11f151ecd35dd07677ae76c12aee922c9a7f /llvm/lib | |
| parent | 6bf861298a117f82f453021bc355a1fe38ca818b (diff) | |
| download | bcm5719-llvm-a009a60a917bc30940422bcef73f8270566d78db.tar.gz bcm5719-llvm-a009a60a917bc30940422bcef73f8270566d78db.zip | |
IR: print value numbers for unnamed function arguments
For consistency with normal instructions and clarity when reading IR,
it's best to print the %0, %1, ... names of function arguments in
definitions.
Also modifies the parser to accept IR in that form for obvious reasons.
llvm-svn: 367755
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 14 | ||||
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 87dff6468f2..e707e957a66 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2551,6 +2551,7 @@ bool LLParser::ParseOptionalOperandBundles( /// bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg){ + unsigned CurValID = 0; isVarArg = false; assert(Lex.getKind() == lltok::lparen); Lex.Lex(); // eat the (. @@ -2575,6 +2576,12 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, if (Lex.getKind() == lltok::LocalVar) { Name = Lex.getStrVal(); Lex.Lex(); + } else if (Lex.getKind() == lltok::LocalVarID) { + if (Lex.getUIntVal() != CurValID) + return Error(TypeLoc, "argument expected to be numbered '%" + + Twine(CurValID) + "'"); + ++CurValID; + Lex.Lex(); } if (!FunctionType::isValidArgumentType(ArgTy)) @@ -2602,6 +2609,13 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, Name = Lex.getStrVal(); Lex.Lex(); } else { + if (Lex.getKind() == lltok::LocalVarID) { + if (Lex.getUIntVal() != CurValID) + return Error(TypeLoc, "argument expected to be numbered '%" + + Twine(CurValID) + "'"); + Lex.Lex(); + } + ++CurValID; Name = ""; } diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index eb5760daecb..2462e933ba4 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -3553,6 +3553,10 @@ void AssemblyWriter::printArgument(const Argument *Arg, AttributeSet Attrs) { if (Arg->hasName()) { Out << ' '; PrintLLVMName(Out, Arg); + } else { + int Slot = Machine.getLocalSlot(Arg); + assert(Slot != -1 && "expect argument in function here"); + Out << " %" << Slot; } } |

