[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
AlexVlx wrote: This is the run time part needed to make things work: https://github.com/llvm/llvm-project/pull/146813 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: simplify. eraseFromModule(*M.ifuncs().begin()); } +static inline SmallVector> +collectIndirectableUses(GlobalVariable *G) { + // We are interested only in use chains that end in an Instruction. +

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/146813 >From d98e3785a144ada9881cdbe24c86f273850eca20 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 3 Jul 2025 02:02:04 +0100 Subject: [PATCH 1/6] Add support for true globals. --- llvm/lib/Transforms/HipStdPa

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: simplify. eraseFromModule(*M.ifuncs().begin()); } +static inline SmallVector> +collectIndirectableUses(GlobalVariable *G) { + // We are interested only in use chains that end in an Instruction. +

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: simplify. eraseFromModule(*M.ifuncs().begin()); } +static inline SmallVector> +collectIndirectableUses(GlobalVariable *G) { + // We are interested only in use chains that end in an Instruction. +

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: simplify. eraseFromModule(*M.ifuncs().begin()); } +static inline SmallVector> +collectIndirectableUses(GlobalVariable *G) { + // We are interested only in use chains that end in an Instruction. +

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
@@ -114,24 +115,221 @@ static inline void clearModule(Module &M) { // TODO: simplify. eraseFromModule(*M.ifuncs().begin()); } +static inline SmallVector> +collectIndirectableUses(GlobalVariable *G) { + // We are interested only in use chains that end in an Instruction. +

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/146813 >From d98e3785a144ada9881cdbe24c86f273850eca20 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 3 Jul 2025 02:02:04 +0100 Subject: [PATCH 1/5] Add support for true globals. --- llvm/lib/Transforms/HipStdPa

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/146813 >From d98e3785a144ada9881cdbe24c86f273850eca20 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 3 Jul 2025 02:02:04 +0100 Subject: [PATCH 1/4] Add support for true globals. --- llvm/lib/Transforms/HipStdPa

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-03 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/146813 >From d98e3785a144ada9881cdbe24c86f273850eca20 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 3 Jul 2025 02:02:04 +0100 Subject: [PATCH 1/4] Add support for true globals. --- llvm/lib/Transforms/HipStdPa

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-07-03 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > @efriedma-quic was kind enough to have a call where we discussed this a bit > more. I'll update tomorrow with a potential way forward, for the group's > consideration. Following up, here's a possible approach to making progress, broken down in phases, (@efriedma-quic can corr

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-02 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/146813 >From d98e3785a144ada9881cdbe24c86f273850eca20 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 3 Jul 2025 02:02:04 +0100 Subject: [PATCH 1/3] Add support for true globals. --- llvm/lib/Transforms/HipStdPa

[clang] [llvm] [HIPSTDPAR] Add support for globals (PR #146813)

2025-07-02 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx created https://github.com/llvm/llvm-project/pull/146813 This (mostly) removes one of the largest remaining limitations of `hipstdpar` based algorithm acceleration, by adding support for global variable usage in offloaded algorithms. It is mean to compose with a run

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-07-02 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > So your users today are building for generic AMDGPU but using builtins that > are only available on a specific processor release? Presumably that code is > protected _somehow_ and their programs are not simply crashing at runtime. Is > that something you'd be able to leverage

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-07-02 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > I think Eli is suggesting something like the rule for > [@available](https://clang.llvm.org/docs/LanguageExtensions.html#objective-c-available): > > * If a builtin is unconditionally available, you can always use it without > any diagnostics. > * If a builtin is only available

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-07-02 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > > Definitely, more than happy to have a 1-on-1 (2-on-1 even, since I think > > @AaronBallman also suggested something along these lines as well :) ). > > Please email me with some times that will work for you. > > > We've just made the call to foo() illegal on anything that is

[clang] [llvm] [SPIRV] Add more id and range builtIns (PR #143909)

2025-07-02 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/143909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > An intrinsic seems like the right IR model for CPU recognition, even for > targets that don't specifically need to late-resolve it. That should be much > easier for passes to optimize based on CPU settings than directly emitting > the compiler-rt reference in the frontend. I k

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > Let me add my few cents here. > > > In the case where the target features are known during clang codegen, > > lowering is easy: you just skip generating the bodies of the if statements > > that don't match. If you want to some kind of "runtime" (actual runtime, or > > SPIR-V

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > Alex, can you talk about why your design decides to check for specific > builtins rather than building out the set of features supported by > `__builtin_cpu_supports`? I went into it a bit above without having seen your question (race condition I guess:) ), but to have it in

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > Right, I don't see any semantic reason why `__builtin_cpu_is` or > `__builtin_cpu_supports` shouldn't be resolved statically if we have that > information on hand. `-mcpu` / `-march` are not usually sufficient for > folding `__builtin_cpu_is`, since those attributes just speci

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > We briefly discussed this in the clang area team meeting, and we weren't > really happy with the design as-is. The underlying idea behind the feature > makes sense, but semantics of the actual builtin is ugly: there's a loose > connection between the condition check, and the r

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > On a different point: I don't think this builtin is actually semantically > different from `__builtin_cpu_is`. As long as we're not treating it as > `constexpr`, the fact that it's lowered by the compiler and doesn't need a > runtime check is just a happy property of GPU targe

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-30 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > I mean, I'm not particularly attached to the syntax of the "if". I guess we > could designate `if (__builtin_amdgcn_processor_is("gfx900")) {}` as a > "processor-feature-if". The point is that we need to know at the AST level > which processor features are available for each s

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-25 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx commented: > Well, I'm not sure if my review is gating here, if "AMDGPU does not support > any libcalls at the moment" - it is what it is, no objections from my side. Since I am modifying the shared CodeGenInfo bit, it made sense to ask:) Also, I wasn't entirely cer

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-25 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx closed https://github.com/llvm/llvm-project/pull/143814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-25 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx edited https://github.com/llvm/llvm-project/pull/143814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-24 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,157 @@ +//===- AMDGPUExpandFeaturePredicates.cpp - Feature Predicate Expander Pass ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-24 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,157 @@ +//===- AMDGPUExpandFeaturePredicates.cpp - Feature Predicate Expander Pass ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-24 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,157 @@ +//===- AMDGPUExpandFeaturePredicates.cpp - Feature Predicate Expander Pass ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-23 Thread Alex Voicu via cfe-commits
@@ -9102,6 +9102,15 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ConversionFailed: { QualType FromType = OnlyArg->getType(); +// __amdgpu_feature_predicate_t can be explicitly cast to the logical op +// type, although this is almost always an error a

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-23 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > I'm generally very unhappy about any kind of functionality that can cause > compilation failures either because the optimizer did not optimize enough > (including at O0) or because it optimized too much (producing code patterns > that are no longer recognized as trivially dead

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-23 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,157 @@ +//===- AMDGPUExpandFeaturePredicates.cpp - Feature Predicate Expander Pass ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-23 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,157 @@ +//===- AMDGPUExpandFeaturePredicates.cpp - Feature Predicate Expander Pass ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [HIP] Emit the CUID value in the module with the new driver (PR #144570)

2025-06-19 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx approved this pull request. LGTM, thanks. https://github.com/llvm/llvm-project/pull/144570 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-18 Thread Alex Voicu via cfe-commits
@@ -9102,6 +9102,15 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ConversionFailed: { QualType FromType = OnlyArg->getType(); +// __amdgpu_feature_predicate_t can be explicitly cast to the logical op +// type, although this is almost always an error a

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-18 Thread Alex Voicu via cfe-commits
@@ -9102,6 +9102,15 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ConversionFailed: { QualType FromType = OnlyArg->getType(); +// __amdgpu_feature_predicate_t can be explicitly cast to the logical op +// type, although this is almost always an error a

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-18 Thread Alex Voicu via cfe-commits
@@ -9102,6 +9102,15 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ConversionFailed: { QualType FromType = OnlyArg->getType(); +// __amdgpu_feature_predicate_t can be explicitly cast to the logical op +// type, although this is almost always an error a

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-17 Thread Alex Voicu via cfe-commits
@@ -9102,6 +9102,15 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ConversionFailed: { QualType FromType = OnlyArg->getType(); +// __amdgpu_feature_predicate_t can be explicitly cast to the logical op +// type, although this is almost always an error a

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-16 Thread Alex Voicu via cfe-commits
AlexVlx wrote: Gentle ping. https://github.com/llvm/llvm-project/pull/134016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-13 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/143814 >From a976da9d6033a252fab75de216fe6580d6e3e6ff Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 12 Jun 2025 00:47:43 +0100 Subject: [PATCH 1/2] Override `SPIRVTargetCodeGenInfo::supportsLibCall()` in order

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/143814 >From a976da9d6033a252fab75de216fe6580d6e3e6ff Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Thu, 12 Jun 2025 00:47:43 +0100 Subject: [PATCH 1/2] Override `SPIRVTargetCodeGenInfo::supportsLibCall()` in order

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx commented: #143431 is related to this, but it proposes a more pervasive change, which would require further discussion and clarification around what the SPIR-V BE wants to do / support in term of libcalls. https://github.com/llvm/llvm-project/pull/143814

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx edited https://github.com/llvm/llvm-project/pull/143814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][SPIRV][AMDGPU] Override `supportsLibCall` for AMDGCNSPIRV (PR #143814)

2025-06-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx created https://github.com/llvm/llvm-project/pull/143814 The `supportsLibCall` predicate is used to select whether some math builtins get expanded in the FE or they get lowered into libcalls. The default implementation unconditionally returns true, which is problemat

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-10 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,21 @@ +// REQUIRES: amdgpu-registered-target +// REQUIRES: spirv-registered-target +// RUN: %clang_cc1 -fsyntax-only -verify -triple amdgcn -Wno-unused-value %s +// RUN: %clang_cc1 -fsyntax-only -verify -triple spirv64-amd-amdhsa -Wno-unused-value %s +// RUN: %clang_cc

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-10 Thread Alex Voicu via cfe-commits
AlexVlx wrote: Gentle ping. https://github.com/llvm/llvm-project/pull/134016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-02 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx edited https://github.com/llvm/llvm-project/pull/134016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-06-02 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx commented: > First, please take a look at the LLVM coding standard re the use of 'auto'. > > Second: The use of a special type for these builtins is a little novel > (though I see the predicate type already exists?), but I guess I'm ok with > it. I have some concern

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-22 Thread Alex Voicu via cfe-commits
@@ -4966,6 +4966,89 @@ If no address spaces names are provided, all address spaces are fenced. __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "workgroup", "local") __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "workgroup", "local", "global") +__builtin_amdgcn_processor_is and __buil

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-22 Thread Alex Voicu via cfe-commits
@@ -29,6 +29,8 @@ MODULE_PASS("amdgpu-printf-runtime-binding", AMDGPUPrintfRuntimeBindingPass()) MODULE_PASS("amdgpu-remove-incompatible-functions", AMDGPURemoveIncompatibleFunctionsPass(*this)) MODULE_PASS("amdgpu-sw-lower-lds", AMDGPUSwLowerLDSPass(*this)) MODULE_PASS("amdg

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-22 Thread Alex Voicu via cfe-commits
@@ -13338,4 +13338,23 @@ def err_acc_device_type_multiple_archs // AMDGCN builtins diagnostics def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">; def note_amdgcn_load_lds_size_valid_value : Note<"size must be %select{1, 2, or 4|1, 2, 4, 12 or 16}0">; +de

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-16 Thread Alex Voicu via cfe-commits
AlexVlx wrote: Gentle ping. https://github.com/llvm/llvm-project/pull/134016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HIP] change default offload archs (PR #139281)

2025-05-13 Thread Alex Voicu via cfe-commits
AlexVlx wrote: I think that in general we also need to decide on what happens when you pick an amdgcn— triple. IMHO for that case we should probably error out if no mcpu is provided, since there’s no reasonable default, except for “all”, but that would be incredibly disruptive. https://github

[clang] [HIP] change default offload archs (PR #139281)

2025-05-13 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > > > The main obstacle of letting clang emit error when `--offload-arch` is > > > not specified is HIP apps using hipcc as CMAKE_CXX_COMPILER. hipcc adds > > > -xhip by default for .cpp programs. This is a known and long existing > > > issue. > > > Another option is to have mul

[clang] [HIP] change default offload archs (PR #139281)

2025-05-13 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > The main obstacle of letting clang emit error when `--offload-arch` is not > specified is HIP apps using hipcc as CMAKE_CXX_COMPILER. hipcc adds -xhip by > default for .cpp programs. This is a known and long existing issue. > > Another option is to have multiple `--offload-arc

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-12 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134016 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-08 Thread Alex Voicu via cfe-commits
AlexVlx wrote: @erichkeane @AaronBallman if, when you have time, you could please indicate if the new direction is at least generally aligned with what you had in mind, it'd be appreciated! https://github.com/llvm/llvm-project/pull/134016 ___ cfe-com

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-07 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134016 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-07 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx edited https://github.com/llvm/llvm-project/pull/134016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-07 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx commented: > A side question, is it legal to use the builtin in unstructured control flow, > like here: https://godbolt.org/z/no7Kzv19r ? Note, if the answer is "no", > then enforcing the builtin to initialize something would (probably) > automatically prevent this c

[clang] [llvm] [HIP][HIPSTDPAR] Re-work allocation interposition for `hipstdpar` (PR #138790)

2025-05-07 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx closed https://github.com/llvm/llvm-project/pull/138790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HIP][HIPSTDPAR] Re-work allocation interposition for `hipstdpar` (PR #138790)

2025-05-06 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx created https://github.com/llvm/llvm-project/pull/138790 The allocation interposition mode had a number of issues, which are primarily addressed in the library component via . However, it is necessary to interpose some add

[clang] [llvm] [HIP][HIPSTDPAR] Re-work allocation interposition for `hipstdpar` (PR #138790)

2025-05-06 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/138790 >From 865ff3dff1833607f0d546ab0ebd95b98a8ed71b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Wed, 7 May 2025 01:25:17 +0100 Subject: [PATCH 1/2] Re-work allocation interposition for `hipstdpar`. --- clang/do

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-05 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134016 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-05-02 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134016 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix AS of globals and set the default AS to 4 (PR #135251)

2025-04-24 Thread Alex Voicu via cfe-commits
@@ -1217,11 +1217,13 @@ void CGOpenMPRuntimeGPU::emitParallelCall(CodeGenFunction &CGF, CGBuilderTy &Bld = CGF.Builder; llvm::Value *NumThreadsVal = NumThreads; llvm::Function *WFn = WrapperFunctionsMap[OutlinedFn]; +llvm::FunctionCallee RuntimeFn = OMPBuilder.

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix AS of globals and set the default AS to 4 (PR #135251)

2025-04-24 Thread Alex Voicu via cfe-commits
AlexVlx wrote: Overall this seems a bit AS cast heavy in the OMP parts, I wonder if we have a chance to figure out if we cannot just emit things in the right ASes from the get-go? This is the path we took when cleaning up some of this stuff in Clang for C/C++, and whilst it was definitely more

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix AS of globals and set the default AS to 4 (PR #135251)

2025-04-24 Thread Alex Voicu via cfe-commits
@@ -1217,11 +1217,13 @@ void CGOpenMPRuntimeGPU::emitParallelCall(CodeGenFunction &CGF, CGBuilderTy &Bld = CGF.Builder; llvm::Value *NumThreadsVal = NumThreads; llvm::Function *WFn = WrapperFunctionsMap[OutlinedFn]; +llvm::FunctionCallee RuntimeFn = OMPBuilder.

[clang] [clang][SPIR-V] Addrspace of opencl_global should always be 1 (PR #136753)

2025-04-24 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx approved this pull request. LGTM, thanks! FWIW, perhaps it'd be worthwhile (as a follow-up, not here) to simply make the DefIsGen AS map correct/valid, and replace the dummy bits? https://github.com/llvm/llvm-project/pull/136753 ___

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-04-16 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > > You could default the warning to an error to make it more visible to the > user. Not certain if that's a bad idea or not though. > Possibly. I had to drop this for a bit so circling around again, so apologies for the late reply. In the meanwhile, @epilk pointed out somethi

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-14 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > LLVM Buildbot has detected a new failure on builder > `llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while > building `clang,llvm` at step 6 "test-build-unified-tree-check-all". > > Full details are available at: > https://lab.llvm.org/buildbot/#/builders/1

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-04-14 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134016 >From 91eeaf02336e539f14dcb0a79ff15dbe8befe6f1 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Wed, 2 Apr 2025 02:47:42 +0100 Subject: [PATCH 01/11] Add the functional identity and feature queries. --- clang/d

[clang] [llvm] [NFC] Fix bot breakage introduced by #134753 (PR #135697)

2025-04-14 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx closed https://github.com/llvm/llvm-project/pull/135697 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [NFC] Fix bot breakage introduced by #134753 (PR #135697)

2025-04-14 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx created https://github.com/llvm/llvm-project/pull/135697 This test needs the amdgpu target, and its absence wreaked havoc with some of the bots, therefore we now require it. >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Dat

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-14 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx closed https://github.com/llvm/llvm-project/pull/134753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-14 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/8] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-13 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/7] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-13 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/7] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-12 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,21 @@ +// Test that the accelerator code selection pass only gets invoked after linking + +// Ensure Pass HipStdParAcceleratorCodeSelectionPass is not invoked in PreLink. +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -mllvm -amdgpu-enable-hipstdpar -flto -emit-llvm-bc

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-12 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,21 @@ +// Test that the accelerator code selection pass only gets invoked after linking + +// Ensure Pass HipStdParAcceleratorCodeSelectionPass is not invoked in PreLink. +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -mllvm -amdgpu-enable-hipstdpar -flto -emit-llvm-bc

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-12 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,11 @@ +// Check that if we are compiling with fgpu-rdc amdgpu-enable-hipstdpar is not +// passed to CC1, to avoid eager, per TU, removal of potentially accessible +// functions. + +// RUN: %clang -### --hipstdpar --offload-arch=gfx906 %s -nogpulib -nogpuinc \ +// RUN:

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-12 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/6] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/5] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-11 Thread Alex Voicu via cfe-commits
@@ -0,0 +1,11 @@ +// Check that if we are compiling with fgpu-rdc amdgpu-enable-hipstdpar is not +// passed to CC1, to avoid eager, per TU, removal of potentially accessible +// functions. + +// RUN: %clang -### --hipstdpar --offload-arch=gfx906 %s -nogpulib -nogpuinc \ +// RUN:

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-11 Thread Alex Voicu via cfe-commits
@@ -883,6 +883,12 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { PB.registerFullLinkTimeOptimizationLastEPCallback( [this](ModulePassManager &PM, OptimizationLevel Level) { +// When we are using -fgpu-rdc, we can onky run accelera

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/4] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-11 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/3] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

2025-04-10 Thread Alex Voicu via cfe-commits
@@ -37,8 +37,8 @@ static const unsigned SPIRDefIsPrivMap[] = { 0, // cuda_device 0, // cuda_constant 0, // cuda_shared -// SYCL address space values for this map are dummy -0, // sycl_global +// Most SYCL address space values for this map are dummy -

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

2025-04-10 Thread Alex Voicu via cfe-commits
@@ -5384,6 +5384,11 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { LangAS AS; if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS)) return AS; +if (LangOpts.OpenMPIsTargetDevice && getTriple().isSPIRV()) AlexVlx w

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

2025-04-10 Thread Alex Voicu via cfe-commits
@@ -5384,6 +5384,11 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { LangAS AS; if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS)) return AS; +if (LangOpts.OpenMPIsTargetDevice && getTriple().isSPIRV()) AlexVlx w

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

2025-04-08 Thread Alex Voicu via cfe-commits
@@ -37,8 +37,8 @@ static const unsigned SPIRDefIsPrivMap[] = { 0, // cuda_device 0, // cuda_constant 0, // cuda_shared -// SYCL address space values for this map are dummy -0, // sycl_global +// Most SYCL address space values for this map are dummy -

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

2025-04-08 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/134399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-08 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx commented: > Needs test Done. https://github.com/llvm/llvm-project/pull/134753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-08 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/134753 >From a988ecf63dc79d226c2f7aa1430f65d08256888b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 8 Apr 2025 00:20:27 +0100 Subject: [PATCH 1/3] Re-order & adapt `hipstdpar` specific passes. --- clang/lib/Co

[clang] [llvm] [HIP][HIPSTDPAR][NFC] Re-order & adapt `hipstdpar` specific passes (PR #134753)

2025-04-08 Thread Alex Voicu via cfe-commits
https://github.com/AlexVlx edited https://github.com/llvm/llvm-project/pull/134753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][OpenMP][SPIR-V] Fix addrspace of globals and global constants (PR #134399)

2025-04-08 Thread Alex Voicu via cfe-commits
@@ -37,8 +37,8 @@ static const unsigned SPIRDefIsPrivMap[] = { 0, // cuda_device 0, // cuda_constant 0, // cuda_shared -// SYCL address space values for this map are dummy -0, // sycl_global +// Most SYCL address space values for this map are dummy -

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-04-05 Thread Alex Voicu via cfe-commits
AlexVlx wrote: > > This change adds two semi-magical builtins for AMDGPU: > > ``` > > * `__builtin_amdgcn_processor_is`, which is similar in observable behaviour > > with `__builtin_cpu_is`, except that it is never "evaluated" at run time; > > > > * `__builtin_amdgcn_is_invocable`, which is beh

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-04-05 Thread Alex Voicu via cfe-commits
@@ -4920,6 +4920,116 @@ If no address spaces names are provided, all address spaces are fenced. __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "workgroup", "local") __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "workgroup", "local", "global") +__builtin_amdgcn_processor_is and __bui

[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-04-05 Thread Alex Voicu via cfe-commits
@@ -15576,6 +15609,38 @@ static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T) { return Ctx.getIntWidth(T) >= Ctx.getIntWidth(Ctx.IntTy); } +static Expr *ExpandAMDGPUPredicateBI(ASTContext &Ctx, CallExpr *CE) { + if (!CE->getBuiltinCallee()) +return CXXBool

  1   2   3   4   5   6   7   8   >