[all-commits] [llvm/llvm-project] da003d: AMDGPU: Use module flags to control xnack and sramecc

Matt Arsenault via All-commits all-commits at lists.llvm.org
Wed Jul 15 11:01:30 PDT 2026


  Branch: refs/heads/users/arsenm/amdgpu/use-module-flag-xnack-sramecc
  Home:   https://github.com/llvm/llvm-project
  Commit: da003dfdf8ca196f2f883dd424f8dc5b03efa66e
      https://github.com/llvm/llvm-project/commit/da003dfdf8ca196f2f883dd424f8dc5b03efa66e
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-07-15 (Wed, 15 Jul 2026)

  Changed paths:
    M clang/include/clang/Basic/TargetOptions.h
    M clang/include/clang/CIR/Dialect/IR/CIRDialect.td
    M clang/include/clang/Options/Options.td
    M clang/lib/Basic/Targets/AMDGPU.cpp
    M clang/lib/CIR/CodeGen/CIRGenAMDGPU.cpp
    M clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/Clang.h
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/test/CIR/CodeGenHIP/target-features.hip
    A clang/test/CodeGenOpenCL/amdgpu-module-flag-xnack-sramecc.cl
    A clang/test/CodeGenOpenCL/amdgpu-xnack-any-only.cl
    M clang/test/Driver/amdgpu-features.c
    M clang/test/Driver/amdgpu-openmp-toolchain.c
    M clang/test/Driver/amdgpu-toolchain.c
    M clang/test/Driver/amdgpu-xnack-sramecc-flags.c
    M clang/test/Driver/hip-sanitize-options.hip
    M clang/test/Driver/hip-target-id.hip
    M clang/test/Driver/hip-toolchain-features.hip
    M clang/test/Driver/target-id.cl
    M llvm/docs/AMDGPUUsage.rst
    M llvm/docs/ReleaseNotes.md
    M llvm/lib/IR/VerifierAMDGPU.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
    M llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
    M llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
    M llvm/lib/Target/AMDGPU/GCNSubtarget.h
    M llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
    M llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.h
    M llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement-stack-lower.ll
    M llvm/test/CodeGen/AMDGPU/amdpal-callable.ll
    M llvm/test/CodeGen/AMDGPU/break-smem-soft-clauses.mir
    M llvm/test/CodeGen/AMDGPU/callee-special-input-vgprs-packed.ll
    M llvm/test/CodeGen/AMDGPU/cluster-flat-loads-postra.mir
    M llvm/test/CodeGen/AMDGPU/cluster_stores.ll
    M llvm/test/CodeGen/AMDGPU/directive-amdgcn-target-legacy-triples.ll
    M llvm/test/CodeGen/AMDGPU/elf-header-flags-sramecc.ll
    M llvm/test/CodeGen/AMDGPU/elf-header-flags-xnack.ll
    M llvm/test/CodeGen/AMDGPU/flat-saddr-load.ll
    M llvm/test/CodeGen/AMDGPU/flat-scratch-reg.ll
    M llvm/test/CodeGen/AMDGPU/gfx902-without-xnack.ll
    M llvm/test/CodeGen/AMDGPU/greedy-reverse-local-assignment.ll
    M llvm/test/CodeGen/AMDGPU/hazard-hidden-bundle.mir
    M llvm/test/CodeGen/AMDGPU/hazard-in-bundle.mir
    M llvm/test/CodeGen/AMDGPU/hsa-metadata-kernel-code-props.ll
    M llvm/test/CodeGen/AMDGPU/hsa-metadata-resource-usage-function-ordering.ll
    M llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll
    M llvm/test/CodeGen/AMDGPU/immv216.ll
    M llvm/test/CodeGen/AMDGPU/limit-soft-clause-reg-pressure.mir
    M llvm/test/CodeGen/AMDGPU/materialize-frame-index-sgpr.ll
    A llvm/test/CodeGen/AMDGPU/mattr-xnack-sramecc-legacy.ll
    A llvm/test/CodeGen/AMDGPU/module-flag-sramecc.ll
    A llvm/test/CodeGen/AMDGPU/module-flag-xnack-no-on-off-modes.ll
    A llvm/test/CodeGen/AMDGPU/module-flag-xnack-sramecc-combined.ll
    A llvm/test/CodeGen/AMDGPU/module-flag-xnack.ll
    M llvm/test/CodeGen/AMDGPU/nsa-reassign.ll
    M llvm/test/CodeGen/AMDGPU/nsa-vmem-hazard.mir
    M llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
    M llvm/test/CodeGen/AMDGPU/post-ra-soft-clause-dbg-info.ll
    M llvm/test/CodeGen/AMDGPU/s_addk_i32.ll
    M llvm/test/CodeGen/AMDGPU/s_mulk_i32.ll
    M llvm/test/CodeGen/AMDGPU/schedule-amdgpu-tracker-physreg-crash.ll
    M llvm/test/CodeGen/AMDGPU/soft-clause-dbg-value.mir
    M llvm/test/CodeGen/AMDGPU/spill-scavenge-offset.ll
    M llvm/test/CodeGen/AMDGPU/sram-ecc-default.ll
    M llvm/test/CodeGen/AMDGPU/sramecc-subtarget-feature-disabled.ll
    M llvm/test/CodeGen/AMDGPU/sramecc-subtarget-feature-enabled.ll
    M llvm/test/CodeGen/AMDGPU/target-id-xnack-always-on.ll
    M llvm/test/CodeGen/AMDGPU/tid-kd-xnack-off.ll
    M llvm/test/CodeGen/AMDGPU/tid-kd-xnack-on.ll
    M llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-all-off.ll
    M llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-all-on.ll
    M llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-any-off-1.ll
    M llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-any-off-2.ll
    M llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-any-on-1.ll
    M llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-any-on-2.ll
    R llvm/test/CodeGen/AMDGPU/tid-mul-func-xnack-invalid-any-off-on.ll
    M llvm/test/CodeGen/AMDGPU/tid-one-func-xnack-off.ll
    M llvm/test/CodeGen/AMDGPU/tid-one-func-xnack-on.ll
    M llvm/test/CodeGen/AMDGPU/xnack-subtarget-feature-disabled.ll
    M llvm/test/CodeGen/AMDGPU/xnack-subtarget-feature-enabled.ll
    A llvm/test/Linker/Inputs/amdgpu-sramecc-module-flag-0.ll
    A llvm/test/Linker/Inputs/amdgpu-sramecc-module-flag-1.ll
    A llvm/test/Linker/Inputs/amdgpu-sramecc-module-flag-any.ll
    A llvm/test/Linker/Inputs/amdgpu-xnack-module-flag-0.ll
    A llvm/test/Linker/Inputs/amdgpu-xnack-module-flag-1.ll
    A llvm/test/Linker/Inputs/amdgpu-xnack-module-flag-any.ll
    A llvm/test/Linker/amdgpu-sramecc-module-flag-0.ll
    A llvm/test/Linker/amdgpu-sramecc-module-flag-1.ll
    A llvm/test/Linker/amdgpu-sramecc-module-flag-any.ll
    A llvm/test/Linker/amdgpu-xnack-module-flag-0.ll
    A llvm/test/Linker/amdgpu-xnack-module-flag-1.ll
    A llvm/test/Linker/amdgpu-xnack-module-flag-any.ll
    M llvm/test/MC/AMDGPU/xnack-mask.s
    A llvm/test/Verifier/AMDGPU/module-flag-sramecc.ll
    A llvm/test/Verifier/AMDGPU/module-flag-xnack.ll

  Log Message:
  -----------
  AMDGPU: Use module flags to control xnack and sramecc

This ensures these ABI details are encoded in the IR module
rather than depending on external state from command-line flags.
Previously, these were encoded as function-level subtarget features.
The code object output was a single target ID directive implied
by the global subtarget. The backend would previously check if a
function's subtarget feature mismatched the global subtarget. This
is avoided by making xnack and sramecc module-level properties from
the start. This also provides proper linker compatibility
enforcement, moving the error point earlier.

The old encoding was also an abuse of the subtarget feature system.
Subtarget features are a bitvector, and later features in the string
can override earlier ones. The old handling added a special case
where explicit settings were preserved: ordinarily +feature,-feature
should result in the feature being disabled, but +xnack,-xnack would
preserve the explicit "-xnack" state, which differs from the absence
of any xnack setting.

The new flags are encoded as 0/1, with the "any" case represented
as the absence of the flag. I considered an explicit tri-state unknown
value, but decided against it.

This also removes warnings when using these module flags on targets
that do not support the corresponding feature. Previously, messages
were written directly to stderr instead of using proper diagnostics.
Avoiding the warning reduces burden on frontends to check which targets
require the flags.

For migration purposes, the subtarget features still exist. Currently,
they are still respected in the various binary tools, pending
disassembler changes to determine target ID modifiers from e_flags.
CodeGen requires using the module flags. An error will be raised when
attempting to use the old global subtarget features. These should be
removed after a migration period for frontends to update. Functionality
wise, bitcode autoupgrade should work. Old bitcode will not have the
flags, resulting in a different target ID in the output binary than
expected, but it should run correctly.

New cl::opts exist only because it was inconvenient to update all
tests using multiple xnack modes. Users should never use these.

Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list