[llvm-commits] [llvm] r163390 - in /llvm/trunk: lib/Target/X86/AsmParser/X86AsmParser.cpp test/MC/ELF/cfi-reg.s
Benjamin Kramer
benny.kra at googlemail.com
Fri Sep 7 07:51:35 PDT 2012
Author: d0k
Date: Fri Sep 7 09:51:35 2012
New Revision: 163390
URL: http://llvm.org/viewvc/llvm-project?rev=163390&view=rev
Log:
PR13754: llvm-mc/x86 crashes on .cfi directives without the % prefix for registers.
gas accepts this and it seems to be common enough to be worth supporting. This
doesn't affect the parsing of reg operands outside of .cfi directives.
Added:
llvm/trunk/test/MC/ELF/cfi-reg.s
Modified:
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=163390&r1=163389&r2=163390&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Sep 7 09:51:35 2012
@@ -521,12 +521,13 @@
bool X86AsmParser::ParseRegister(unsigned &RegNo,
SMLoc &StartLoc, SMLoc &EndLoc) {
RegNo = 0;
- if (!isParsingIntelSyntax()) {
- const AsmToken &TokPercent = Parser.getTok();
- assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!");
- StartLoc = TokPercent.getLoc();
+ const AsmToken &PercentTok = Parser.getTok();
+ StartLoc = PercentTok.getLoc();
+
+ // If we encounter a %, ignore it. This code handles registers with and
+ // without the prefix, unprefixed registers can occur in cfi directives.
+ if (!isParsingIntelSyntax() && PercentTok.is(AsmToken::Percent))
Parser.Lex(); // Eat percent token.
- }
const AsmToken &Tok = Parser.getTok();
if (Tok.isNot(AsmToken::Identifier)) {
Added: llvm/trunk/test/MC/ELF/cfi-reg.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-reg.s?rev=163390&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-reg.s (added)
+++ llvm/trunk/test/MC/ELF/cfi-reg.s Fri Sep 7 09:51:35 2012
@@ -0,0 +1,18 @@
+// RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -o - | FileCheck %s
+// PR13754
+
+f:
+ .cfi_startproc
+ nop
+ .cfi_offset 6, -16
+ nop
+ .cfi_offset %rsi, -16
+ nop
+ .cfi_offset rbx, -16
+ nop
+ .cfi_endproc
+
+// CHECK: f:
+// CHECK: .cfi_offset %rbp, -16
+// CHECK: .cfi_offset %rsi, -16
+// CHECK: .cfi_offset %rbx, -16
More information about the llvm-commits
mailing list