diff options
author | Kai Nacke <kai.peter.nacke@ibm.com> | 2021-04-21 11:23:13 -0400 |
---|---|---|
committer | Kai Nacke <kai.peter.nacke@ibm.com> | 2021-04-22 14:27:09 -0400 |
commit | 832340ca879a18e32c79716e52e204b1611cbd07 (patch) | |
tree | 59040edaa5d8588bc4c702f99cab02727523605b /llvm/tools/llvm-mca/llvm-mca.cpp | |
parent | 47283e15565a51758409573d9b1ac00372d9a10d (diff) | |
download | llvm-832340ca879a18e32c79716e52e204b1611cbd07.zip llvm-832340ca879a18e32c79716e52e204b1611cbd07.tar.gz llvm-832340ca879a18e32c79716e52e204b1611cbd07.tar.bz2 |
Fix the triple used in llvm-mca.
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.
Reviewed By: andreadb, abhina.sreeskantharajan
Differential Revision: https://reviews.llvm.org/D100992
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r-- | llvm/tools/llvm-mca/llvm-mca.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp index 53c582a..858b406 100644 --- a/llvm/tools/llvm-mca/llvm-mca.cpp +++ b/llvm/tools/llvm-mca/llvm-mca.cpp @@ -236,6 +236,9 @@ const Target *getTarget(const char *ProgName) { return nullptr; } + // Update TripleName with the updated triple from the target lookup. + TripleName = TheTriple.str(); + // Return the found target. return TheTarget; } |