aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/lib/MIR/MIPrinter.cpp8
-rw-r--r--backend/unittests/MIR/MIParserTest.cpp11
2 files changed, 14 insertions, 5 deletions
diff --git a/backend/lib/MIR/MIPrinter.cpp b/backend/lib/MIR/MIPrinter.cpp
index 9e86b72..25a7a0c 100644
--- a/backend/lib/MIR/MIPrinter.cpp
+++ b/backend/lib/MIR/MIPrinter.cpp
@@ -1278,9 +1278,11 @@ Expected<void> BodyPrinter::printMemoryOperand(const MachineMemOperand &Operand)
const std::string_view Preposition =
Operand.isLoad() && Operand.isStore() ? " on " : (Operand.isLoad() ? " from " : " into ");
- Output.append(Preposition);
- if (auto Printed = printMemoryBase(Description.Base, Description.Offset); !Printed) {
- return Printed;
+ if (Description.Base.kind() != MemoryBase::Kind::Unknown || Description.Offset != 0) {
+ Output.append(Preposition);
+ if (auto Printed = printMemoryBase(Description.Base, Description.Offset); !Printed) {
+ return Printed;
+ }
}
if (!Description.Size.isKnown() ||
diff --git a/backend/unittests/MIR/MIParserTest.cpp b/backend/unittests/MIR/MIParserTest.cpp
index ab6b69d..e57cdfb 100644
--- a/backend/unittests/MIR/MIParserTest.cpp
+++ b/backend/unittests/MIR/MIParserTest.cpp
@@ -504,6 +504,7 @@ void testLLVMInlineAsmAndConstantMemorySyntax(TestContext &Context) {
const std::string Body = R"(bb.0:
INLINEASM &"", sideeffect mayload inteldialect
%0:gpr64 = TEST_LOAD $g0 :: (load (s64) from `ptr poison`)
+ %1:gpr64 = TEST_LOAD $g0 :: (load (s64) from unknown-address + 4)
)";
rcc::mir::MIParserContext ParserContext;
ParserContext.DefaultPointerSizeInBits = 64;
@@ -533,8 +534,9 @@ void testLLVMInlineAsmAndConstantMemorySyntax(TestContext &Context) {
Context.expect(Printed &&
Printed->find("INLINEASM &\"\", sideeffect mayload inteldialect") !=
std::string::npos &&
- Printed->find("from `ptr poison`") != std::string::npos,
- "canonical MIR must print symbolic inline-asm flags and LLVM constant bases");
+ Printed->find("from `ptr poison`") != std::string::npos &&
+ Printed->find("from unknown-address + 4") != std::string::npos,
+ "canonical MIR must print symbolic inline-asm flags and explicit memory bases");
}
void testLLVMCompareExchangeMemorySyntax(TestContext &Context) {
@@ -567,6 +569,11 @@ void testLLVMCompareExchangeMemorySyntax(TestContext &Context) {
Memory.SuccessOrdering == rcc::AtomicOrdering::Monotonic &&
Memory.FailureOrdering == rcc::AtomicOrdering::NotAtomic,
"compare-exchange opcode must disambiguate a one-ordering LLVM MMO");
+
+ auto Printed = rcc::mir::printMachineFunctionBody(*Function, *Target, ParserContext);
+ Context.expect(Printed && Printed->find(":: (load store monotonic (s8))") != std::string::npos &&
+ Printed->find("unknown-address") == std::string::npos,
+ "canonical LLVM MMOs must omit an absent zero-offset pointer base");
}
void expectParseError(TestContext &Context, const rcc::TargetDescription &Target, std::string Body,