[PATCH] D107593: [Lanai] fix MC / objdump
Serge Bazanski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 12:31:22 PDT 2021
q3k created this revision.
q3k added a reviewer: jpienaar.
Herald added subscribers: rupprecht, hiraditya, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
q3k requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
D78776 <https://reviews.llvm.org/D78776> removed is{Call,Branch,UnconditionalBranch} guards in objdump
before calling MCInstrAnalysis::evaluateBranch. This is fine for other
architectures as they gracefully handle evaluateBranch being called on
non-branches. However, the Lanai MCInstrAnalysis implementation didn't
and that change caused it to crash.
This inserts the same guards back into Lanai's evaluateBranch
implementation and adds a smoke test that exercises `llc | objdump` so
this kind of regression is hopefully caught next time.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107593
Files:
llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
llvm/test/tools/llvm-objdump/ELF/Lanai/lit.local.cfg
llvm/test/tools/llvm-objdump/ELF/Lanai/smoketest.ll
Index: llvm/test/tools/llvm-objdump/ELF/Lanai/smoketest.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/ELF/Lanai/smoketest.ll
@@ -0,0 +1,13 @@
+; RUN: llc -o %t.o -filetype=obj -mtriple=lanai %s
+; RUN: llvm-objdump -d -S %t.o | FileCheck %s
+
+; Ensure that Lanai can be compiled using llc and then objdumped into
+; assembly. This is a smoke test to exercise the basics of the MC
+; implementation in Lanai.
+
+; CHECK-LABEL: smoketest
+; CHECK: st %fp, [--%sp]
+define i32 @smoketest(i32 %x, i32 %y) {
+ %z = add i32 %x, %y
+ ret i32 %z
+}
Index: llvm/test/tools/llvm-objdump/ELF/Lanai/lit.local.cfg
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/ELF/Lanai/lit.local.cfg
@@ -0,0 +1,4 @@
+import platform
+
+if not 'Lanai' in config.root.targets:
+ config.unsupported = True
Index: llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
+++ llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp
@@ -97,6 +97,9 @@
uint64_t &Target) const override {
if (Inst.getNumOperands() == 0)
return false;
+ if (!isConditionalBranch(Inst) && !isUnconditionalBranch(Inst) &&
+ !isCall(Inst))
+ return false;
if (Info->get(Inst.getOpcode()).OpInfo[0].OperandType ==
MCOI::OPERAND_PCREL) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107593.364579.patch
Type: text/x-patch
Size: 1526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/78046637/attachment.bin>
More information about the llvm-commits
mailing list