From: Alex Lorenz <arphaman@gmail.com>
Date: Wed, 5 Aug 2015 17:41:17 +0000 (+0000)
Subject: MIR Serialization: Serialize the 'debug-use' register operand flag.
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=13fa799e5f34e743fdf6455b2bd24a04c0434dfb;p=oota-llvm.git

MIR Serialization: Serialize the 'debug-use' register operand flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244071 91177308-0d34-0410-b5e6-96231b3b80d8
---

diff --git a/lib/CodeGen/MIRParser/MILexer.cpp b/lib/CodeGen/MIRParser/MILexer.cpp
index 624ef664620..5134da9d455 100644
--- a/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/lib/CodeGen/MIRParser/MILexer.cpp
@@ -146,6 +146,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
       .Case("dead", MIToken::kw_dead)
       .Case("killed", MIToken::kw_killed)
       .Case("undef", MIToken::kw_undef)
+      .Case("debug-use", MIToken::kw_debug_use)
       .Case("frame-setup", MIToken::kw_frame_setup)
       .Case("debug-location", MIToken::kw_debug_location)
       .Case(".cfi_offset", MIToken::kw_cfi_offset)
diff --git a/lib/CodeGen/MIRParser/MILexer.h b/lib/CodeGen/MIRParser/MILexer.h
index f72897a5217..9a403496351 100644
--- a/lib/CodeGen/MIRParser/MILexer.h
+++ b/lib/CodeGen/MIRParser/MILexer.h
@@ -47,6 +47,7 @@ struct MIToken {
     kw_dead,
     kw_killed,
     kw_undef,
+    kw_debug_use,
     kw_frame_setup,
     kw_debug_location,
     kw_cfi_offset,
@@ -118,7 +119,8 @@ public:
 
   bool isRegisterFlag() const {
     return Kind == kw_implicit || Kind == kw_implicit_define ||
-           Kind == kw_dead || Kind == kw_killed || Kind == kw_undef;
+           Kind == kw_dead || Kind == kw_killed || Kind == kw_undef ||
+           Kind == kw_debug_use;
   }
 
   bool isMemoryOperandFlag() const { return Kind == kw_volatile; }
diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp
index 149e4dd1b61..7b9e45ea7f5 100644
--- a/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/lib/CodeGen/MIRParser/MIParser.cpp
@@ -490,6 +490,9 @@ bool MIParser::parseRegisterFlag(unsigned &Flags) {
   case MIToken::kw_undef:
     Flags |= RegState::Undef;
     break;
+  case MIToken::kw_debug_use:
+    Flags |= RegState::Debug;
+    break;
   // TODO: report an error when we specify the same flag more than once.
   // TODO: parse the other register flags.
   default:
@@ -532,7 +535,7 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest, bool IsDef) {
   Dest = MachineOperand::CreateReg(
       Reg, Flags & RegState::Define, Flags & RegState::Implicit,
       Flags & RegState::Kill, Flags & RegState::Dead, Flags & RegState::Undef,
-      /*isEarlyClobber=*/false, SubReg);
+      /*isEarlyClobber=*/false, SubReg, Flags & RegState::Debug);
   return false;
 }
 
@@ -882,6 +885,7 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest) {
   case MIToken::kw_dead:
   case MIToken::kw_killed:
   case MIToken::kw_undef:
+  case MIToken::kw_debug_use:
   case MIToken::underscore:
   case MIToken::NamedRegister:
   case MIToken::VirtualRegister:
diff --git a/lib/CodeGen/MIRPrinter.cpp b/lib/CodeGen/MIRPrinter.cpp
index fb5a36ce9a7..2eb5cbfc6ce 100644
--- a/lib/CodeGen/MIRPrinter.cpp
+++ b/lib/CodeGen/MIRPrinter.cpp
@@ -529,6 +529,8 @@ void MIPrinter::print(const MachineOperand &Op, const TargetRegisterInfo *TRI) {
       OS << "killed ";
     if (Op.isUndef())
       OS << "undef ";
+    if (Op.isDebug())
+      OS << "debug-use ";
     printReg(Op.getReg(), OS, TRI);
     // Print the sub register.
     if (Op.getSubReg() != 0)
diff --git a/test/CodeGen/MIR/X86/instructions-debug-location.mir b/test/CodeGen/MIR/X86/instructions-debug-location.mir
index 247009a7b54..ca5f77d2a32 100644
--- a/test/CodeGen/MIR/X86/instructions-debug-location.mir
+++ b/test/CodeGen/MIR/X86/instructions-debug-location.mir
@@ -55,11 +55,11 @@ body:
     name:         entry
     liveins:      [ '%edi' ]
     instructions:
-      # CHECK: DBG_VALUE _, 0, !12, !13, debug-location !14
+      # CHECK: DBG_VALUE debug-use _, 0, !12, !13, debug-location !14
       # CHECK: %eax = COPY %0, debug-location !15
       # CHECK: RETQ %eax, debug-location !15
       - '%0 = COPY %edi'
-      - 'DBG_VALUE _, 0, !12, !13, debug-location !14'
+      - 'DBG_VALUE debug-use _, 0, !12, !13, debug-location !14'
       - 'MOV32mr %stack.0.x.addr, 1, _, 0, _, %0'
       - '%eax = COPY %0, debug-location !15'
       - 'RETQ %eax, debug-location !15'