-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Add code model (#70760) test for amdgpu target. #71019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-backend-amdgpu Author: Pravin Jagtap (pravinjagtap) ChangesMissed adding code model test during #70760. Full diff: https://github.com/llvm/llvm-project/pull/71019.diff 1 Files Affected:
diff --git a/llvm/test/CodeGen/AMDGPU/codemodel.ll b/llvm/test/CodeGen/AMDGPU/codemodel.ll
new file mode 100644
index 000000000000000..8b60257b2076aed
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/codemodel.ll
@@ -0,0 +1,9 @@
+; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=tiny < %s 2>&1 | FileCheck %s --check-prefix=TINY
+; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=kernel < %s 2>&1 | FileCheck %s --check-prefix=KERNEL
+
+; TINY: Target does not support the tiny CodeModel
+; KERNEL: Target does not support the kernel CodeModel
+
+define void @foo() {
+ ret void
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't test the driver behavior, which is what the patch changed. This should be a clang driver test, not codegen
clang/test/Driver/mcmodel.c
Outdated
@@ -13,6 +13,11 @@ | |||
// RUN: not %clang -### -c --target=aarch64 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s | |||
// RUN: not %clang -### -c --target=aarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=ERR-KERNEL %s | |||
// RUN: not %clang --target=aarch64_32-linux -### -S -mcmodel=small %s 2>&1 | FileCheck --check-prefix=ERR-AARCH64_32 %s | |||
// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-TINY %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure exactly what's being tested here, this looks like it's targeting C as a target? The more relevant case would be with amdgcn as the offload target. For direct compilation it would make more sense to emit the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is intended to handle all possible code models for AMDGPU target. Basically, we want to avoid erroring out for device side code models. Does it make sense to have negative case for amdgpu ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's 2 cases. The case where we're directly codegening to the target, in which case it behaves like a regular CPU target. That's what you're testing here, but it's somewhat unusual. We could error here as before.
The more realistic case is treating it as an offload target from OpenMP or HIP, so I think it's more important to test that case. We definitely don't want an error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, recent updates to PR (3rd commit: 9dc7689983b74dd381df556bc9e61165e08d85b4) address both the cases you are referring to.
@@ -0,0 +1,9 @@ | |||
; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=tiny < %s 2>&1 | FileCheck %s --check-prefix=TINY | |||
; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=kernel < %s 2>&1 | FileCheck %s --check-prefix=KERNEL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need test for all -code-model values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As matt suggested, this test is not exercising the code changes that I intended in #70760. So I will remove this test.
I think we need to fix clang and not passing -mcmodel=tiny/kernel to clang -cc1. https://github.com/llvm/llvm-project/pull/70760/files#r1383372722 probably we can do that in this PR |
746c515
to
d171525
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
7b3d4dc
to
30f98ec
Compare
30f98ec
to
34c14bb
Compare
} else if (Triple.isAMDGPU()) { | ||
// AMDGPU does not care about the code model. | ||
Ok = true; | ||
// AMDGPU target ignores CM tiny and kernel. | ||
if (CM == "tiny" || CM == "kernel") { | ||
Skip = true; | ||
D.Diag(diag::warn_ignored_clang_option) | ||
<< A->getSpelling() << CM << TripleStr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is doing more than adding the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please update PR title before merging
So this was only supposed to add the test, or implement this too? |
reverse ping |
Missed adding code model test during #70760.