Skip to content

Commit

Permalink
[MC][AMDGPU] Consume EndOfStatement in asm parser
Browse files Browse the repository at this point in the history
Avoids spurious newlines showing up in the output when emitting assembly
via MC.

Reviewed By: MaskRay, arsenm

Differential Revision: https://reviews.llvm.org/D92690
  • Loading branch information
slinder1 committed Dec 9, 2020
1 parent 5ff5cf8 commit 9260a99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Expand Up @@ -5020,9 +5020,11 @@ bool AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
while (!getLexer().is(AsmToken::EndOfStatement)) {
Parser.Lex();
}
Parser.Lex();
return true;
}
}
Parser.Lex();

return false;
}
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/MC/AMDGPU/round-trip.s
@@ -0,0 +1,13 @@
# RUN: llvm-mc -preserve-comments -triple amdgcn-amd-amdhsa %s >%t-1.s
# RUN: llvm-mc -preserve-comments -triple amdgcn-amd-amdhsa %t-1.s >%t-2.s
# RUN: diff %t-1.s %t-2.s

# Test that AMDGPU assembly round-trips when run through MC; the first
# transition from hand-written to "canonical" output may introduce some small
# differences, so we don't include the initial input in the comparison.

.text

# The AMDGPU asm parser didn't consume the end of statement
# consistently, which led to extra empty lines in the output.
s_nop 0

0 comments on commit 9260a99

Please sign in to comment.