From 8c37e3e64bb1432f771ec4d191837e6b3be5bf0c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 7 Feb 2024 08:23:57 -0800 Subject: [RISCV] Only set Zca flag for EF_RISCV_RVC in ELFObjectFileBase::getRISCVFeatures(). (#80928) This code appears to be a hack to set the features to include compressed instructions if the ELF EFLAGS flags bit is present, but the ELF attribute for the ISA string is no present or not accurate. We can't remove the hack because llvm-mc doesn't create ELF attributes by default so a lot of tests fail to disassembler properly. Using clang as the assembler does set the attributes. This patch changes the hack to only set Zca since that is the minimum implied by the flag. Setting anything else potentially conflicts with the ISA string containing Zcmp or Zcmt. JITLink also needs to be updated to recognize Zca in addition to C. --- llvm/lib/Object/ELFObjectFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Object/ELFObjectFile.cpp') diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index 8f7eead..38a9e0e 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -292,7 +292,7 @@ Expected ELFObjectFileBase::getRISCVFeatures() const { unsigned PlatformFlags = getPlatformFlags(); if (PlatformFlags & ELF::EF_RISCV_RVC) { - Features.AddFeature("c"); + Features.AddFeature("zca"); } RISCVAttributeParser Attributes; -- cgit v1.1