[llvm] r244817 - MIR Parser: Allow the MI IR references to reference global values.

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 14:27:17 PDT 2015


Author: arphaman
Date: Wed Aug 12 16:27:16 2015
New Revision: 244817

URL: http://llvm.org/viewvc/llvm-project?rev=244817&view=rev
Log:
MIR Parser: Allow the MI IR references to reference global values.

This commit fixes a bug where MI parser couldn't resolve the named IR
references that referenced named global values.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
    llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=244817&r1=244816&r2=244817&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Aug 12 16:27:16 2015
@@ -1086,6 +1086,9 @@ bool MIParser::parseIRValue(Value *&V) {
   case MIToken::NamedIRValue: {
     V = MF.getFunction()->getValueSymbolTable().lookup(Token.stringValue());
     if (!V)
+      V = MF.getFunction()->getParent()->getValueSymbolTable().lookup(
+          Token.stringValue());
+    if (!V)
       return error(Twine("use of undefined IR value '") + Token.range() + "'");
     break;
   }

Modified: llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir?rev=244817&r1=244816&r2=244817&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir Wed Aug 12 16:27:16 2015
@@ -84,6 +84,13 @@
     ret i32 %b
   }
 
+  define i32 @global_value() {
+  entry:
+    %a = load i32, i32* @G
+    %b = add i32 %a, 1
+    ret i32 %b
+  }
+
   define i32 @jumptable_psv(i32 %in) {
   entry:
     switch i32 %in, label %def [
@@ -289,6 +296,20 @@ body:
       - '%eax = INC32r killed %eax, implicit-def dead %eflags'
       - 'RETQ %eax'
 ...
+---
+name:            global_value
+tracksRegLiveness: true
+body:
+  - id:          0
+    name:        entry
+    instructions:
+      - '%rax = MOV64rm %rip, 1, _, @G, _'
+# CHECK: name: global_value
+# CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.G)
+      - '%eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.G)'
+      - '%eax = INC32r killed %eax, implicit-def dead %eflags'
+      - 'RETQ %eax'
+...
 ---
 name:            jumptable_psv
 tracksRegLiveness: true




More information about the llvm-commits mailing list