[PATCH] D100992: Fix the triple used in llvm-mca

Kai Nacke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 13:08:31 PDT 2021


Kai created this revision.
Kai added reviewers: bkramer, andreadb, kazu, hubert.reinterpretcast, daltenty, anirudhp, abhina.sreeskantharajan, yusra.syeda.
Herald added subscribers: pengfei, gbedwell, kristof.beyls.
Kai requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

lookupTarget() can update the passed triple argument. This happens
when no triple is given on the command line, and the architecture
argument does not match the architecture in the default triple.

For example, passing -march=aarch64 on the command line, and the
default triple being x86_64-windows-msvc, the triple is changed
to aarch64-windows-msvc.

However, this triple is not saved, and later in the code, the
triple is constructed again from the triple name, which is the
default triple at this point. Thus the default triple is passed
to constructor of MCSubtargetInfo instance.

The triple is only used determine the object file format, and by
chance, the AArch64 target also uses the COFF file format, and
all is fine. Obviously, the AArch64 target does not support all
available binary file formats, e.g. XCOFF and GOFF, and llvm-mca
crashes in this case.

The fix is to update the triple name with the changed triple
name for the target lookup. Then the default object file format
for the architecture is used, in the example ELF.

Many LIT test cases in llvm/tools/llvm-mca/AArch64 fail if the
binary format is not MachO, COFF, or ELF. This change fixes this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100992

Files:
  llvm/tools/llvm-mca/llvm-mca.cpp


Index: llvm/tools/llvm-mca/llvm-mca.cpp
===================================================================
--- llvm/tools/llvm-mca/llvm-mca.cpp
+++ llvm/tools/llvm-mca/llvm-mca.cpp
@@ -236,6 +236,9 @@
     return nullptr;
   }
 
+  // Update TripleName with the updated triple from the target lookup.
+  TripleName = TheTriple.str();
+
   // Return the found target.
   return TheTarget;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100992.339357.patch
Type: text/x-patch
Size: 392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210421/1dc1b263/attachment.bin>


More information about the llvm-commits mailing list