Skip to content

[AMDGCNSPIRV][NFC] Match AMDGPU's __builtin_va_list type #152044

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexVlx
Copy link
Contributor

@AlexVlx AlexVlx commented Aug 4, 2025

AMDGCN flavoured SPIRV should math AMDGPU TI as much as possible, and the va_list difference was spurious.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 4, 2025
@AlexVlx AlexVlx requested review from chinmaydd and yxsamliu August 4, 2025 22:09
@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2025

@llvm/pr-subscribers-clang

Author: Alex Voicu (AlexVlx)

Changes

AMDGCN flavoured SPIRV should math AMDGPU TI as much as possible, and the va_list difference was spurious.


Full diff: https://github.com/llvm/llvm-project/pull/152044.diff

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/SPIR.h (+4)
  • (added) clang/test/Sema/amdgcn-va-list-type.c (+13)
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index c13b286cd7916..9d0ced2afdbc7 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -438,6 +438,10 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
 
   ArrayRef<const char *> getGCCRegNames() const override;
 
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+    return TargetInfo::CharPtrBuiltinVaList;
+  }
+
   bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
                       StringRef,
                       const std::vector<std::string> &) const override;
diff --git a/clang/test/Sema/amdgcn-va-list-type.c b/clang/test/Sema/amdgcn-va-list-type.c
new file mode 100644
index 0000000000000..1c0e93adabae4
--- /dev/null
+++ b/clang/test/Sema/amdgcn-va-list-type.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple spirv64-amd-amdhsa -fsyntax-only -verify
+
+// expected-no-diagnostics
+
+typedef char* va_list;
+
+void foo(const char* f, ...) {
+    int r;
+    va_list args;
+    __builtin_va_start(args, f);
+    __builtin_va_end(args);
+}
\ No newline at end of file

Copy link
Contributor

@chinmaydd chinmaydd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Moreover, I believe this change is relevant to #119661 i.e representation of the va_list type for the NVPTX backend on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants