[llvm] [AMDGPU] Add an asm directive to track code_object_version (PR #76267)

Scott Linder via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 2 16:24:59 PST 2024


================
@@ -123,45 +124,32 @@ bool isHsaAbi(const MCSubtargetInfo &STI) {
   return STI.getTargetTriple().getOS() == Triple::AMDHSA;
 }
 
-std::optional<uint8_t> getHsaAbiVersion(const MCSubtargetInfo *STI) {
-  if (STI && STI->getTargetTriple().getOS() != Triple::AMDHSA)
-    return std::nullopt;
-
-  switch (AmdhsaCodeObjectVersion) {
-  case 4:
-    return ELF::ELFABIVERSION_AMDGPU_HSA_V4;
-  case 5:
-    return ELF::ELFABIVERSION_AMDGPU_HSA_V5;
-  default:
-    report_fatal_error(Twine("Unsupported AMDHSA Code Object Version ") +
-                       Twine(AmdhsaCodeObjectVersion));
+unsigned getCodeObjectVersion(const Module &M) {
+  if (auto Ver = mdconst::extract_or_null<ConstantInt>(
+          M.getModuleFlag("amdgpu_code_object_version"))) {
----------------
slinder1 wrote:

Ah, the naming issue is even more difficult to resolve since the module flag was added with `amdgpu`. It is unfortunate how many names we have grown for this, between `amdgpu`, `amdgcn`, and `amdhsa`.

For some things the distinctions are meaningful, but here we are always referring to the same thing, just with confusingly distinct names.

@kzhuravl do you have thoughts on how to resolve the prefix proliferation? It seems like we really want `amdhsa` everywhere as the ABI is specific to the HSA OS, right? Can we rename the module flag with an auto-upgrade or something?

https://github.com/llvm/llvm-project/pull/76267


More information about the llvm-commits mailing list