From 2791dcca605496da8b56fa1d625f165fc9cdc7e8 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 --- llvm/lib/CodeGen/MIRParser/MIParser.cpp | 3 +++ llvm/test/CodeGen/MIR/X86/memory-operands.mir | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index b6c393994717..b333f0b52b1b 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/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/llvm/test/CodeGen/MIR/X86/memory-operands.mir b/llvm/test/CodeGen/MIR/X86/memory-operands.mir index 002d147b3547..1bde368f5767 100644 --- a/llvm/test/CodeGen/MIR/X86/memory-operands.mir +++ b/llvm/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: -- GitLab