[PATCH] D80620: [AArch64][AsmParser] Fix debug output in a few instructions

Cullen Rhodes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 04:17:18 PDT 2020


c-rhodes created this revision.
c-rhodes added reviewers: t.p.northover, ostannard.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.

In the parsing of BTIHint, PSBHint and Prefetch the identifier token
should be lexed after creating the operand, otherwise the StringRef is
moved before being copied and the debug output is incorrect.

Prefetch example:

  $ echo "prfm   pldl1keep, [x2]" | ./bin/llvm-mc \
      -triple aarch64-none-linux-gnu -show-encoding -debug
  
  Before:
  
    Matching formal operand class MCK_Prefetch against actual operand at
    index 1 (<prfop ,>): match success using generic matcher
  
  After:
  
    Matching formal operand class MCK_Prefetch against actual operand at
    index 1 (<prfop pldl1keep>): match success using generic matcher


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80620

Files:
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp


Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===================================================================
--- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -2413,9 +2413,9 @@
     return MatchOperand_ParseFail;
   }
 
-  Parser.Lex(); // Eat identifier token.
   Operands.push_back(AArch64Operand::CreatePrefetch(
       *PRFM, Tok.getString(), S, getContext()));
+  Parser.Lex(); // Eat identifier token.
   return MatchOperand_Success;
 }
 
@@ -2436,9 +2436,9 @@
     return MatchOperand_ParseFail;
   }
 
-  Parser.Lex(); // Eat identifier token.
   Operands.push_back(AArch64Operand::CreatePSBHint(
       PSB->Encoding, Tok.getString(), S, getContext()));
+  Parser.Lex(); // Eat identifier token.
   return MatchOperand_Success;
 }
 
@@ -2459,9 +2459,9 @@
     return MatchOperand_ParseFail;
   }
 
-  Parser.Lex(); // Eat identifier token.
   Operands.push_back(AArch64Operand::CreateBTIHint(
       BTI->Encoding, Tok.getString(), S, getContext()));
+  Parser.Lex(); // Eat identifier token.
   return MatchOperand_Success;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80620.266481.patch
Type: text/x-patch
Size: 1132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200527/925e2ffb/attachment-0001.bin>


More information about the llvm-commits mailing list