summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp15
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp5
-rw-r--r--llvm/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir4
-rw-r--r--llvm/test/CodeGen/MIR/X86/frame-info-stack-references.mir2
-rw-r--r--llvm/test/CodeGen/MIR/X86/memory-operands.mir21
5 files changed, 32 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 3260249d95b..d706f04eccc 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1531,9 +1531,6 @@ bool MIParser::parseIRValue(const 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());
break;
}
case MIToken::IRValue: {
@@ -1543,6 +1540,14 @@ bool MIParser::parseIRValue(const Value *&V) {
V = getIRValue(SlotNumber);
break;
}
+ case MIToken::NamedGlobalValue:
+ case MIToken::GlobalValue: {
+ GlobalValue *GV = nullptr;
+ if (parseGlobalValue(GV))
+ return true;
+ V = GV;
+ break;
+ }
default:
llvm_unreachable("The current token should be an IR block reference");
}
@@ -1646,7 +1651,9 @@ bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) {
Dest = MachinePointerInfo(PSV, Offset);
return false;
}
- if (Token.isNot(MIToken::NamedIRValue) && Token.isNot(MIToken::IRValue))
+ if (Token.isNot(MIToken::NamedIRValue) && Token.isNot(MIToken::IRValue) &&
+ Token.isNot(MIToken::GlobalValue) &&
+ Token.isNot(MIToken::NamedGlobalValue))
return error("expected an IR value reference");
const Value *V = nullptr;
if (parseIRValue(V))
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 1be845f8b89..4b4d7b4f25c 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -608,7 +608,10 @@ void MIPrinter::printIRBlockReference(const BasicBlock &BB) {
}
void MIPrinter::printIRValueReference(const Value &V) {
- // TODO: Global values should use the '@' syntax.
+ if (isa<GlobalValue>(V)) {
+ V.printAsOperand(OS, /*PrintType=*/false, MST);
+ return;
+ }
OS << "%ir.";
if (V.hasName()) {
printLLVMNameWithoutPrefix(OS, V.getName());
diff --git a/llvm/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir b/llvm/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
index 4b0c4eccf6b..9471516db64 100644
--- a/llvm/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
+++ b/llvm/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
@@ -32,10 +32,10 @@ stack:
body: |
bb.0.entry:
%0 = ADRP @var
- %1 = LDRXui killed %0, @var :: (load 8 from %ir.var)
+ %1 = LDRXui killed %0, @var :: (load 8 from @var)
STRXui killed %1, %stack.0.local_var, 0 :: (store 8 into %ir.local_var)
%2 = ADRP @local_addr
%3 = ADDXri %stack.0.local_var, 0, 0
- STRXui killed %3, killed %2, @local_addr :: (store 8 into %ir.local_addr)
+ STRXui killed %3, killed %2, @local_addr :: (store 8 into @local_addr)
RET_ReallyLR
...
diff --git a/llvm/test/CodeGen/MIR/X86/frame-info-stack-references.mir b/llvm/test/CodeGen/MIR/X86/frame-info-stack-references.mir
index a1f13aff68f..c8fa3bbe226 100644
--- a/llvm/test/CodeGen/MIR/X86/frame-info-stack-references.mir
+++ b/llvm/test/CodeGen/MIR/X86/frame-info-stack-references.mir
@@ -57,7 +57,7 @@ body: |
frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp
%rsp = frame-setup SUB64ri8 %rsp, 32, implicit-def dead %eflags
- %rbx = LOAD_STACK_GUARD :: (invariant load 8 from %ir.__stack_chk_guard)
+ %rbx = LOAD_STACK_GUARD :: (invariant load 8 from @__stack_chk_guard)
MOV64mr %rsp, 1, _, 24, _, %rbx
%rsi = LEA64r %rsp, 1, _, 19, _
MOV64mr %rsp, 1, _, 8, _, %rsi
diff --git a/llvm/test/CodeGen/MIR/X86/memory-operands.mir b/llvm/test/CodeGen/MIR/X86/memory-operands.mir
index ba5bcec820e..6621b7e2e75 100644
--- a/llvm/test/CodeGen/MIR/X86/memory-operands.mir
+++ b/llvm/test/CodeGen/MIR/X86/memory-operands.mir
@@ -93,11 +93,15 @@
ret i32 %b
}
+ @0 = external global i32
+
define i32 @global_value() {
entry:
%a = load i32, i32* @G
%b = add i32 %a, 1
- ret i32 %b
+ %c = load i32, i32* @0
+ %d = add i32 %b, %c
+ ret i32 %d
}
define i32 @jumptable_psv(i32 %in) {
@@ -358,10 +362,13 @@ tracksRegLiveness: true
body: |
bb.0.entry:
%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
+ ; CHECK-LABEL: name: global_value
+ ; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @G)
+ ; CHECK: %ecx = MOV32rm killed %rcx, 1, _, 0, _, implicit-def %rcx :: (load 4 from @0)
+ %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @G)
+ %rcx = MOV64rm %rip, 1, _, @0, _
+ %ecx = MOV32rm killed %rcx, 1, _, 0, _, implicit-def %rcx :: (load 4 from @0)
+ %eax = LEA64_32r killed %rax, 1, killed %rcx, 1, _
RETQ %eax
...
---
@@ -421,9 +428,9 @@ body: |
bb.0.entry:
%rax = MOV64rm %rip, 1, _, @a, _ :: (load 8 from got)
; CHECK-LABEL: name: tbaa_metadata
- ; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.a, !tbaa !2)
+ ; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @a, !tbaa !2)
; CHECK-NEXT: %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
- %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.a, !tbaa !2)
+ %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @a, !tbaa !2)
%eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
RETQ %eax
...
OpenPOWER on IntegriCloud