summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/MIRParser/MIParser.cpp16
-rw-r--r--lib/CodeGen/MIRPrinter.cpp7
-rw-r--r--test/CodeGen/MIR/X86/expected-from-in-memory-operand.mir24
-rw-r--r--test/CodeGen/MIR/X86/memory-operands.mir15
4 files changed, 28 insertions, 34 deletions
diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp
index 8c7345111c5..41454dd9d66 100644
--- a/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1778,14 +1778,16 @@ bool MIParser::parseMachineMemoryOperand(MachineMemOperand *&Dest) {
return true;
lex();
- const char *Word = Flags & MachineMemOperand::MOLoad ? "from" : "into";
- if (Token.isNot(MIToken::Identifier) || Token.stringValue() != Word)
- return error(Twine("expected '") + Word + "'");
- lex();
-
MachinePointerInfo Ptr = MachinePointerInfo();
- if (parseMachinePointerInfo(Ptr))
- return true;
+ if (Token.is(MIToken::Identifier)) {
+ const char *Word = Flags & MachineMemOperand::MOLoad ? "from" : "into";
+ if (Token.stringValue() != Word)
+ return error(Twine("expected '") + Word + "'");
+ lex();
+
+ if (parseMachinePointerInfo(Ptr))
+ return true;
+ }
unsigned BaseAlignment = Size;
AAMDNodes AAInfo;
MDNode *Range = nullptr;
diff --git a/lib/CodeGen/MIRPrinter.cpp b/lib/CodeGen/MIRPrinter.cpp
index 95b58b7c0fe..703c99d9edd 100644
--- a/lib/CodeGen/MIRPrinter.cpp
+++ b/lib/CodeGen/MIRPrinter.cpp
@@ -883,11 +883,12 @@ void MIPrinter::print(const MachineMemOperand &Op) {
assert(Op.isStore() && "Non load machine operand must be a store");
OS << "store ";
}
- OS << Op.getSize() << (Op.isLoad() ? " from " : " into ");
+ OS << Op.getSize();
if (const Value *Val = Op.getValue()) {
+ OS << (Op.isLoad() ? " from " : " into ");
printIRValueReference(*Val);
- } else {
- const PseudoSourceValue *PVal = Op.getPseudoValue();
+ } else if (const PseudoSourceValue *PVal = Op.getPseudoValue()) {
+ OS << (Op.isLoad() ? " from " : " into ");
assert(PVal && "Expected a pseudo source value");
switch (PVal->kind()) {
case PseudoSourceValue::Stack:
diff --git a/test/CodeGen/MIR/X86/expected-from-in-memory-operand.mir b/test/CodeGen/MIR/X86/expected-from-in-memory-operand.mir
deleted file mode 100644
index f9e9d0b2296..00000000000
--- a/test/CodeGen/MIR/X86/expected-from-in-memory-operand.mir
+++ /dev/null
@@ -1,24 +0,0 @@
-# RUN: not llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
-
---- |
-
- define i32 @test(i32* %a) {
- entry:
- %b = load i32, i32* %a
- ret i32 %b
- }
-
-...
----
-name: test
-tracksRegLiveness: true
-liveins:
- - { reg: '%rdi' }
-body: |
- bb.0.entry:
- liveins: %rdi
- ; CHECK: [[@LINE+1]]:55: expected 'from'
- %eax = MOV32rm killed %rdi, 1, _, 0, _ :: (load 4 %ir.a)
- RETQ %eax
-...
-
diff --git a/test/CodeGen/MIR/X86/memory-operands.mir b/test/CodeGen/MIR/X86/memory-operands.mir
index 1f295df7551..0cf74ddbe70 100644
--- a/test/CodeGen/MIR/X86/memory-operands.mir
+++ b/test/CodeGen/MIR/X86/memory-operands.mir
@@ -186,6 +186,10 @@
%0 = load i8*, i8** undef, align 8
ret i8* %0
}
+
+ define void @dummy() {
+ ret void
+ }
...
---
name: test
@@ -506,3 +510,14 @@ body: |
%rax = MOV64rm undef %rax, 1, _, 0, _ :: (load 8 from `i8** undef`)
RETQ %rax
...
+---
+# Test memory operand without associated value.
+# CHECK-LABEL: name: dummy
+# CHECK: %rax = MOV64rm undef %rax, 1, _, 0, _ :: (load 8)
+name: dummy
+tracksRegLiveness: true
+body: |
+ bb.0:
+ %rax = MOV64rm undef %rax, 1, _, 0, _ :: (load 8)
+ RETQ %rax
+...