Repository navigation
AMDGPU: Warn if trying to codegen without a subarch - #220245
Merged
Merged
Conversation
Warn if using the legacy amdgcn name, or amdgpu without a specified subarch. This is to push all the non-clang frontends to update to the new system, but this should turn into an error in the next release. Co-authored-by: Claude (Opus 4.8) <[email protected]>
|
@llvm/pr-subscribers-backend-amdgpu Author: Matt Arsenault (arsenm) ChangesWarn if using the legacy amdgcn name, or amdgpu without a Co-authored-by: Claude (Opus 4.8) <[email protected]> 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 7afda107a59bc..f754fd8bd24f3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -385,7 +385,26 @@ void AMDGPUAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
}
bool AMDGPUAsmPrinter::doInitialization(Module &M) {
- const llvm::Triple &TT = M.getTargetTriple();
+ const Triple &TT = M.getTargetTriple();
+ if (TT.getSubArch() == Triple::NoSubArch) {
+ Triple::SubArchType SubArch =
+ AMDGPU::getSubArch(AMDGPU::parseArchAMDGCN(getGlobalSTI()->getCPU()));
+ if (SubArch != Triple::NoSubArch) {
+ Triple Fixed(TT);
+ Fixed.setArch(Triple::amdgpu, SubArch);
+ M.getContext().diagnose(DiagnosticInfoGeneric(
+ "codegen with no subarch in the target triple is deprecated and will "
+ "become an error; use the target triple '" +
+ Fixed.str() + "' instead",
+ DS_Warning));
+ } else {
+ M.getContext().diagnose(DiagnosticInfoGeneric(
+ "codegen with no subarch in the target triple is deprecated and will "
+ "become an error",
+ DS_Warning));
+ }
+ }
+
CodeObjectVersion = AMDGPU::getAMDHSACodeObjectVersion(M);
if (TT.getOS() == Triple::AMDHSA) {
diff --git a/llvm/test/CodeGen/AMDGPU/codegen-no-subarch-warn.ll b/llvm/test/CodeGen/AMDGPU/codegen-no-subarch-warn.ll
new file mode 100644
index 0000000000000..d8360decef9b0
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/codegen-no-subarch-warn.ll
@@ -0,0 +1,16 @@
+; A target triple with no subarch still codegens, but is deprecated. Check that
+; the warning fires and names the replacement triple derived from -mcpu.
+
+; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck %s
+; RUN: llc -mtriple=amdgpu -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck %s
+
+; Without -mcpu there is no subarch to suggest, so the warning omits a triple.
+; RUN: llc -mtriple=amdgcn -filetype=null %s 2>&1 | FileCheck -check-prefix=NOCPU %s
+
+; CHECK: warning: codegen with no subarch in the target triple is deprecated and will become an error; use the target triple 'amdgpu9.00--' instead{{$}}
+
+; NOCPU: warning: codegen with no subarch in the target triple is deprecated and will become an error{{$}}
+
+define amdgpu_kernel void @kernel() {
+ ret void
+}
|
shiltian
approved these changes
Sep 1, 2026
addmisol
pushed a commit
to addmisol/llvm-project2
that referenced
this pull request
Sep 6, 2026
Warn if using the legacy amdgcn name, or amdgpu without a specified subarch. This is to push all the non-clang frontends to update to the new system, but this should turn into an error in the next release. Co-authored-by: Claude (Opus 4.8) <[email protected]>
vadimkotov
pushed a commit
to vadimkotov/llvm-project
that referenced
this pull request
Sep 8, 2026
Warn if using the legacy amdgcn name, or amdgpu without a specified subarch. This is to push all the non-clang frontends to update to the new system, but this should turn into an error in the next release. Co-authored-by: Claude (Opus 4.8) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Warn if using the legacy amdgcn name, or amdgpu without a
specified subarch. This is to push all the non-clang frontends
to update to the new system, but this should turn into an error
in the next release.
Co-authored-by: Claude (Opus 4.8) [email protected]