From 143b52b95d9c052c6a849d8c60fa009eedb2942d Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 12 Aug 2015 21:27:16 +0000 Subject: [PATCH] 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. llvm-svn: 244817 --- lib/CodeGen/MIRParser/MIParser.cpp | 3 +++ test/CodeGen/MIR/X86/memory-operands.mir | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp index b6c39399471..b333f0b52b1 100644 --- a/lib/CodeGen/MIRParser/MIParser.cpp +++ b/lib/CodeGen/MIRParser/MIParser.cpp @@ -1085,6 +1085,9 @@ bool MIParser::parseIRValue(Value *&V) { switch (Token.kind()) { 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; diff --git a/test/CodeGen/MIR/X86/memory-operands.mir b/test/CodeGen/MIR/X86/memory-operands.mir index 002d147b354..1bde368f576 100644 --- a/test/CodeGen/MIR/X86/memory-operands.mir +++ b/test/CodeGen/MIR/X86/memory-operands.mir @@ -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 [ @@ -290,6 +297,20 @@ body: - '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 liveins: