This is an archive of the discontinued LLVM Phabricator instance.

Fix the triple used in llvm-mca
ClosedPublic

Authored by Kai on Apr 21 2021, 1:08 PM.

Details

Summary

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.

Diff Detail

Event Timeline

Kai created this revision.Apr 21 2021, 1:08 PM
Kai requested review of this revision.Apr 21 2021, 1:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2021, 1:08 PM
This revision is now accepted and ready to land.Apr 22 2021, 1:36 AM
This revision was landed with ongoing or failed builds.Apr 22 2021, 11:28 AM
This revision was automatically updated to reflect the committed changes.