[RISCV] Enable tools such as llvm-objdump to process objects with unrecognised base...
authorAlex Bradbury <asb@igalia.com>
Mon, 27 Mar 2023 03:32:58 +0000 (04:32 +0100)
committerAlex Bradbury <asb@igalia.com>
Mon, 27 Mar 2023 03:32:58 +0000 (04:32 +0100)
commit062065888f645bbe6a8eec99ba58487a539afd62
treedc91ca60f5300a2d9d26cb9630b95589868b0e2f
parent41eafdf9aac4bd23ebff90d072eb595dfc143b7b
[RISCV] Enable tools such as llvm-objdump to process objects with unrecognised base ISA versions

Tools such as llvm-objdump will currently inputs when the base ISA has
an unrecognised version. I addressed a similar issue in LLD in D144353,
introducing parseArchStringNormalized. While it would make sense to
migrate `llvm/lib/Object/ELFObjectFile.cpp` to using
`parseArchStringNormalized` as well, this patch takes a less ambitious
initial step. By tweaking the behaviour of `parseArchString` when
`IgnoreUnknown` is true (which only has one in-tree user), we use the
default supported ISA version when a base ISA with unrecognised version
is encountered.

This means that llvm-objdump and related tools will function better for
objects produced from a recent GCC. This isn't a full fix, as
IgnoreUnknown means that an imafd object with attributes specifying
newer A/F/D versions will have those extensions ignored.

Differential Revision: https://reviews.llvm.org/D146070
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/lib/Support/RISCVISAInfo.cpp
llvm/test/tools/llvm-objdump/ELF/RISCV/riscv-attributes.s
llvm/unittests/Support/RISCVISAInfoTest.cpp