[llvm] [compiler-rt] [clang-tools-extra] [clang] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
@@ -334,6 +335,15 @@ template<> struct simplify_type { } }; +template <> struct GraphTraits { wenju-he wrote: > For the specific problem here, I'd consider expanding all constant > expressions in the function upfront, and then not having to deal with it. is it right that I can use convertUsersOfConstantsToInstructions to expand constantexp to instructions? However, convertUsersOfConstantsToInstructions changes other functions as well. An option to add an addition function parameter to convertUsersOfConstantsToInstructions to ensure only constexpr users in the function is expanded. @nikic WDYT of this option? convertUsersOfConstantsToInstructions is also doing a DFS on user of User. https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang-tools-extra] [clang] [compiler-rt] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
wenju-he wrote: > I think it would be better if we could eliminate ConstantExpr addrspacecasts > from the IR altogether, which would avoid most of the complexity here. I > would also somewhat prefer to push this DFS into a helper function, but can > live with it inline as-is thank you for the review. I'll draft another PR to modify convertUsersOfConstantsToInstructions to allow change in a function only, so that DFS is not need here. https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [compiler-rt] [clang-tools-extra] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/70611 >From 7c41be75c1ef661e757bfaca8d693b3937df649e Mon Sep 17 00:00:00 2001 From: Wenju He Date: Mon, 30 Oct 2023 08:36:52 +0800 Subject: [PATCH 1/2] [InferAddressSpaces] Fix constant replace to avoid modifying other functions A constant value is unique in llvm context. InferAddressSpaces was replacing its users in other functions as well. This leads to unexpected behavior in our downstream use case after the pass. InferAddressSpaces is a function passe, so it shall not modify functions other than currently processed one. Co-authored-by: Abhinav Gaba --- llvm/include/llvm/IR/User.h | 10 + .../Transforms/Scalar/InferAddressSpaces.cpp | 20 +- .../ensure-other-funcs-unchanged.ll | 40 +++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h index a9cf60151e5dc6c..d27d4bf4f5f1e66 100644 --- a/llvm/include/llvm/IR/User.h +++ b/llvm/include/llvm/IR/User.h @@ -18,6 +18,7 @@ #ifndef LLVM_IR_USER_H #define LLVM_IR_USER_H +#include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include "llvm/IR/Use.h" @@ -334,6 +335,15 @@ template<> struct simplify_type { } }; +template <> struct GraphTraits { + using NodeRef = User *; + using ChildIteratorType = Value::user_iterator; + + static NodeRef getEntryNode(NodeRef N) { return N; } + static ChildIteratorType child_begin(NodeRef N) { return N->user_begin(); } + static ChildIteratorType child_end(NodeRef N) { return N->user_end(); } +}; + } // end namespace llvm #endif // LLVM_IR_USER_H diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp index 2da521375c00161..828b1e765cb1af2 100644 --- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp +++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -1166,6 +1166,8 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces( } SmallVector DeadInstructions; + ValueToValueMapTy VMap; + ValueMapper VMapper(VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); // Replaces the uses of the old address expressions with the new ones. for (const WeakTrackingVH &WVH : Postorder) { @@ -1184,7 +1186,18 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces( if (C != Replace) { LLVM_DEBUG(dbgs() << "Inserting replacement const cast: " << Replace << ": " << *Replace << '\n'); -C->replaceAllUsesWith(Replace); +VMap[C] = Replace; +for (User *U : make_early_inc_range(C->users())) { + for (auto It = df_begin(U), E = df_end(U); It != E;) { +if (auto *I = dyn_cast(*It)) { + if (I->getFunction() == F) +VMapper.remapInstruction(*I); + It.skipChildren(); + continue; +} +++It; + } +} V = Replace; } } @@ -1210,6 +1223,11 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces( // Skip if the current user is the new value itself. if (CurUser == NewV) continue; + + if (auto *CurUserI = dyn_cast(CurUser); + CurUserI && CurUserI->getFunction() != F) +continue; + // Handle more complex cases like intrinsic that need to be remangled. if (auto *MI = dyn_cast(CurUser)) { if (!MI->isVolatile() && handleMemIntrinsicPtrUse(MI, V, NewV)) diff --git a/llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll b/llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll new file mode 100644 index 000..ae052a69f9ed02d --- /dev/null +++ b/llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll @@ -0,0 +1,40 @@ +; RUN: opt -assume-default-is-flat-addrspace -print-module-scope -print-after-all -S -disable-output -passes=infer-address-spaces <%s 2>&1 | FileCheck %s + +; CHECK: IR Dump After InferAddressSpacesPass on f2 + +; Check that after running infer-address-spaces on f2, the redundant addrspace cast %x1 in f2 is gone. +; CHECK-LABEL: define spir_func void @f2() +; CHECK: [[X:%.*]] = addrspacecast ptr addrspace(1) @x to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef [[X]]) + +; But it should not affect f3. +; CHECK-LABEL: define spir_func void @f3() +; CHECK: %x1 = addrspacecast ptr addrspacecast (ptr addrspace(1) @x to ptr) to ptr addrspace(1) +; CHECK-NEXT:%x2 = addrspacecast ptr addrspace(1) %x1 to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef %x2) + +; Ensure that the pass hasn't run on f3 yet. +; CHECK: IR Dump After InferAddressSpacesPass on f3 + +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256
[clang] [llvm] [compiler-rt] [clang-tools-extra] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/70611 >From 7c41be75c1ef661e757bfaca8d693b3937df649e Mon Sep 17 00:00:00 2001 From: Wenju He Date: Mon, 30 Oct 2023 08:36:52 +0800 Subject: [PATCH 1/3] [InferAddressSpaces] Fix constant replace to avoid modifying other functions A constant value is unique in llvm context. InferAddressSpaces was replacing its users in other functions as well. This leads to unexpected behavior in our downstream use case after the pass. InferAddressSpaces is a function passe, so it shall not modify functions other than currently processed one. Co-authored-by: Abhinav Gaba --- llvm/include/llvm/IR/User.h | 10 + .../Transforms/Scalar/InferAddressSpaces.cpp | 20 +- .../ensure-other-funcs-unchanged.ll | 40 +++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h index a9cf60151e5dc6c..d27d4bf4f5f1e66 100644 --- a/llvm/include/llvm/IR/User.h +++ b/llvm/include/llvm/IR/User.h @@ -18,6 +18,7 @@ #ifndef LLVM_IR_USER_H #define LLVM_IR_USER_H +#include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include "llvm/IR/Use.h" @@ -334,6 +335,15 @@ template<> struct simplify_type { } }; +template <> struct GraphTraits { + using NodeRef = User *; + using ChildIteratorType = Value::user_iterator; + + static NodeRef getEntryNode(NodeRef N) { return N; } + static ChildIteratorType child_begin(NodeRef N) { return N->user_begin(); } + static ChildIteratorType child_end(NodeRef N) { return N->user_end(); } +}; + } // end namespace llvm #endif // LLVM_IR_USER_H diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp index 2da521375c00161..828b1e765cb1af2 100644 --- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp +++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -1166,6 +1166,8 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces( } SmallVector DeadInstructions; + ValueToValueMapTy VMap; + ValueMapper VMapper(VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); // Replaces the uses of the old address expressions with the new ones. for (const WeakTrackingVH &WVH : Postorder) { @@ -1184,7 +1186,18 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces( if (C != Replace) { LLVM_DEBUG(dbgs() << "Inserting replacement const cast: " << Replace << ": " << *Replace << '\n'); -C->replaceAllUsesWith(Replace); +VMap[C] = Replace; +for (User *U : make_early_inc_range(C->users())) { + for (auto It = df_begin(U), E = df_end(U); It != E;) { +if (auto *I = dyn_cast(*It)) { + if (I->getFunction() == F) +VMapper.remapInstruction(*I); + It.skipChildren(); + continue; +} +++It; + } +} V = Replace; } } @@ -1210,6 +1223,11 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces( // Skip if the current user is the new value itself. if (CurUser == NewV) continue; + + if (auto *CurUserI = dyn_cast(CurUser); + CurUserI && CurUserI->getFunction() != F) +continue; + // Handle more complex cases like intrinsic that need to be remangled. if (auto *MI = dyn_cast(CurUser)) { if (!MI->isVolatile() && handleMemIntrinsicPtrUse(MI, V, NewV)) diff --git a/llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll b/llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll new file mode 100644 index 000..ae052a69f9ed02d --- /dev/null +++ b/llvm/test/Transforms/InferAddressSpaces/ensure-other-funcs-unchanged.ll @@ -0,0 +1,40 @@ +; RUN: opt -assume-default-is-flat-addrspace -print-module-scope -print-after-all -S -disable-output -passes=infer-address-spaces <%s 2>&1 | FileCheck %s + +; CHECK: IR Dump After InferAddressSpacesPass on f2 + +; Check that after running infer-address-spaces on f2, the redundant addrspace cast %x1 in f2 is gone. +; CHECK-LABEL: define spir_func void @f2() +; CHECK: [[X:%.*]] = addrspacecast ptr addrspace(1) @x to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef [[X]]) + +; But it should not affect f3. +; CHECK-LABEL: define spir_func void @f3() +; CHECK: %x1 = addrspacecast ptr addrspacecast (ptr addrspace(1) @x to ptr) to ptr addrspace(1) +; CHECK-NEXT:%x2 = addrspacecast ptr addrspace(1) %x1 to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef %x2) + +; Ensure that the pass hasn't run on f3 yet. +; CHECK: IR Dump After InferAddressSpacesPass on f3 + +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256
[clang] [llvm] [compiler-rt] [clang-tools-extra] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
https://github.com/wenju-he ready_for_review https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [compiler-rt] [clang-tools-extra] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
@@ -0,0 +1,40 @@ +; RUN: opt -assume-default-is-flat-addrspace -print-module-scope -print-after-all -S -disable-output -passes=infer-address-spaces <%s 2>&1 | FileCheck %s + +; CHECK: IR Dump After InferAddressSpacesPass on f2 + +; Check that after running infer-address-spaces on f2, the redundant addrspace cast %x1 in f2 is gone. +; CHECK-LABEL: define spir_func void @f2() +; CHECK: [[X:%.*]] = addrspacecast ptr addrspace(1) @x to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef [[X]]) + +; But it should not affect f3. +; CHECK-LABEL: define spir_func void @f3() +; CHECK: %x1 = addrspacecast ptr addrspacecast (ptr addrspace(1) @x to ptr) to ptr addrspace(1) +; CHECK-NEXT:%x2 = addrspacecast ptr addrspace(1) %x1 to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef %x2) + +; Ensure that the pass hasn't run on f3 yet. +; CHECK: IR Dump After InferAddressSpacesPass on f3 wenju-he wrote: done https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [compiler-rt] [clang-tools-extra] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
@@ -0,0 +1,40 @@ +; RUN: opt -assume-default-is-flat-addrspace -print-module-scope -print-after-all -S -disable-output -passes=infer-address-spaces <%s 2>&1 | FileCheck %s + +; CHECK: IR Dump After InferAddressSpacesPass on f2 + +; Check that after running infer-address-spaces on f2, the redundant addrspace cast %x1 in f2 is gone. +; CHECK-LABEL: define spir_func void @f2() +; CHECK: [[X:%.*]] = addrspacecast ptr addrspace(1) @x to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef [[X]]) + +; But it should not affect f3. +; CHECK-LABEL: define spir_func void @f3() +; CHECK: %x1 = addrspacecast ptr addrspacecast (ptr addrspace(1) @x to ptr) to ptr addrspace(1) +; CHECK-NEXT:%x2 = addrspacecast ptr addrspace(1) %x1 to ptr +; CHECK-NEXT:call spir_func void @f1(ptr noundef %x2) + +; Ensure that the pass hasn't run on f3 yet. +; CHECK: IR Dump After InferAddressSpacesPass on f3 + +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" +target triple = "spir64" + +@x = addrspace(1) global i32 0, align 4 + +define spir_func void @f2() { wenju-he wrote: done https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [llvm] [clang] [clang-tools-extra] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
@@ -334,6 +335,15 @@ template<> struct simplify_type { } }; +template <> struct GraphTraits { wenju-he wrote: > In any case, this should not be in a public IR header. I've reverted the change in this file. https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [clang] [clang-tools-extra] [llvm] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
@@ -334,6 +335,15 @@ template<> struct simplify_type { } }; +template <> struct GraphTraits { wenju-he wrote: I measured llvm-project compile time impact of this change to llvm/IR/User.h on intel icx 8358 cpu. Build command: ` cmake -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;clang-tools-extra" -DLLVM_INCLUDE_TESTS=ON -DLLVM_BUILD_TESTS=ON -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release ../llvm -DBUILD_SHARED_LIBS=OFF -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU" -DCMAKE_INSTALL_PREFIX=install && ninja -j40 ` Ref: (https://github.com/llvm/llvm-project.git c0d78c4232057768b04d3330e581d81544391e68) Exp: (https://github.com/llvm/llvm-project.git c0d78c4232057768b04d3330e581d81544391e68) + change to User.h ### OS: RHEL9 (note: llvm-project build on this system also builds https://github.com/KhronosGroup/SPIRV-LLVM-Translator as a project inside llvm/project folder) REF: real10m39.052s user398m36.074s sys 19m26.839s real10m39.058s user398m31.903s sys 19m18.405s EXP: real10m39.910s user398m55.339s sys 19m36.278s real10m40.319s user398m52.378s sys 19m38.137s ### OS: Ubuntu 22 REF: real10m2.783s user376m47.038s sys 18m35.310s real10m2.983s user376m47.032s sys 18m46.517s real10m3.059s user376m52.423s sys 18m45.694s EXP: real10m2.730s user376m46.556s sys 18m44.566s real10m3.007s user376m48.369s sys 18m46.733s real10m2.860s user376m44.655s sys 18m51.154s Summary: On RHEL9 build time is slowed down by ~1 second. On Ubuntu 22 there is no obvious change of compile time. @nikic could we add GraphTraits to User.h since compile time impact is not obvious? https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [clang-tools-extra] [llvm] [clang] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
https://github.com/wenju-he edited https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [llvm] [compiler-rt] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
https://github.com/wenju-he edited https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [clang-tools-extra] [clang] [llvm] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
@@ -334,6 +335,15 @@ template<> struct simplify_type { } }; +template <> struct GraphTraits { wenju-he wrote: added 3 more runs on RHEL9 today, the compile time diff is very small. https://github.com/llvm/llvm-project/pull/70611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [llvm] [IR] Disallow ZeroInit for spirv.Image (PR #73887)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/73887 >From e369b5d62094c9b48f3c33075d764c115a208a74 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 30 Nov 2023 09:57:06 +0800 Subject: [PATCH] [IR] Disallow ZeroInit for spirv.Image According to spirv spec, OpConstantNull's result type can't be image type. So we can't generate zeroinitializer for spirv.Image. --- llvm/lib/IR/Type.cpp| 2 ++ llvm/unittests/Transforms/Utils/ValueMapperTest.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 3d2e203a20dac7..e3a09018ad8b98 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -841,6 +841,8 @@ struct TargetTypeInfo { static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) { LLVMContext &C = Ty->getContext(); StringRef Name = Ty->getName(); + if (Name.equals("spirv.Image")) +return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::CanBeGlobal); if (Name.startswith("spirv.")) return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit, TargetExtType::CanBeGlobal); diff --git a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp index 17083b3846430d..c0c9d383ac1816 100644 --- a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp +++ b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp @@ -423,7 +423,7 @@ TEST(ValueMapperTest, mapValuePoisonWithTypeRemap) { TEST(ValueMapperTest, mapValueConstantTargetNoneToLayoutTypeNullValue) { LLVMContext C; - auto *OldTy = TargetExtType::get(C, "spirv.Image"); + auto *OldTy = TargetExtType::get(C, "spirv.Event"); Type *NewTy = OldTy->getLayoutType(); TestTypeRemapper TM(NewTy); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [llvm] [libc] [flang] [compiler-rt] [libcxx] [IR] Disallow ZeroInit for spirv.Image (PR #73887)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/73887 >From e369b5d62094c9b48f3c33075d764c115a208a74 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 30 Nov 2023 09:57:06 +0800 Subject: [PATCH] [IR] Disallow ZeroInit for spirv.Image According to spirv spec, OpConstantNull's result type can't be image type. So we can't generate zeroinitializer for spirv.Image. --- llvm/lib/IR/Type.cpp| 2 ++ llvm/unittests/Transforms/Utils/ValueMapperTest.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 3d2e203a20dac7..e3a09018ad8b98 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -841,6 +841,8 @@ struct TargetTypeInfo { static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) { LLVMContext &C = Ty->getContext(); StringRef Name = Ty->getName(); + if (Name.equals("spirv.Image")) +return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::CanBeGlobal); if (Name.startswith("spirv.")) return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit, TargetExtType::CanBeGlobal); diff --git a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp index 17083b3846430d..c0c9d383ac1816 100644 --- a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp +++ b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp @@ -423,7 +423,7 @@ TEST(ValueMapperTest, mapValuePoisonWithTypeRemap) { TEST(ValueMapperTest, mapValueConstantTargetNoneToLayoutTypeNullValue) { LLVMContext C; - auto *OldTy = TargetExtType::get(C, "spirv.Image"); + auto *OldTy = TargetExtType::get(C, "spirv.Event"); Type *NewTy = OldTy->getLayoutType(); TestTypeRemapper TM(NewTy); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [llvm] [clang] [flang] [libcxx] [clang-tools-extra] [libc] [IR] Disallow ZeroInit for spirv.Image (PR #73887)
wenju-he wrote: > image-unoptimized.ll backtrace: ``` #0 0x01d2f0e1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/export/users/wenjuhe/llvm/llvm-project/build/bin/llc+0x1d2f0e1) #1 0x01d2c644 SignalHandler(int) Signals.cpp:0:0 #2 0x7fd516a7ddb0 __restore_rt (/lib64/libc.so.6+0x59db0) #3 0x7fd516aca42c __pthread_kill_implementation (/lib64/libc.so.6+0xa642c) #4 0x7fd516a7dd06 gsignal (/lib64/libc.so.6+0x59d06) #5 0x7fd516a507d3 abort (/lib64/libc.so.6+0x2c7d3) #6 0x7fd516a506fb _nl_load_domain.cold (/lib64/libc.so.6+0x2c6fb) #7 0x7fd516a76c86 (/lib64/libc.so.6+0x52c86) #8 0x014b3bf1 llvm::ConstantTargetNone::get(llvm::TargetExtType*) (/export/users/wenjuhe/llvm/llvm-project/build/bin/llc+0x14b3bf1) #9 0x00abac68 (anonymous namespace)::SPIRVEmitIntrinsics::runOnFunction(llvm::Function&) (.part.0) SPIRVEmitIntrinsics.cpp:0:0 ``` SPIRVEmitIntrinsics pass probably needs fix to not generate ConstantTargetNone for spirv.Image. @bogner WDYT? https://github.com/llvm/llvm-project/pull/73887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/130755 In libclc, we observe that compiling OpenCL source files to bitcode is executed sequentially on Windows, which increases debug build time by about an hour. add_custom_command may introduce additional implicit dependencies, see https://gitlab.kitware.com/cmake/cmake/-/issues/17097 This PR adds a target for each command and enables parallel builds of OpenCL source files. >From 1f8b5bfbfea6b562e9cae088256e8e5dddf0a335 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 04:24:36 -0700 Subject: [PATCH] [libclc] Fix commands in compile_to_bc are executed sequentially In libclc, we observe that compiling OpenCL source files to bitcode is executed sequentially on Windows, which increases debug build time by about an hour. add_custom_command may introduce additional implicit dependencies, see https://gitlab.kitware.com/cmake/cmake/-/issues/17097 This PR adds a target for each command and enables parallel builds of OpenCL source files. --- libclc/cmake/modules/AddLibclc.cmake | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..9dc328fcd489c 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -1,6 +1,8 @@ # Compiles an OpenCL C - or assembles an LL file - to bytecode # # Arguments: +# * TARGET +# Custom target to create # * TRIPLE # Target triple for which to compile the bytecode file. # * INPUT @@ -17,7 +19,7 @@ function(compile_to_bc) cmake_parse_arguments(ARG "" -"TRIPLE;INPUT;OUTPUT" +"TARGET;TRIPLE;INPUT;OUTPUT" "EXTRA_OPTS;DEPENDENCIES" ${ARGN} ) @@ -60,9 +62,11 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} - ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) + add_custom_target( ${ARG_TARGET} +DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} + ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( @@ -70,6 +74,7 @@ function(compile_to_bc) COMMAND ${llvm-as_exe} -o ${ARG_OUTPUT} ${ARG_OUTPUT}${TMP_SUFFIX} DEPENDS ${llvm-as_target} ${ARG_OUTPUT}${TMP_SUFFIX} ) +add_custom_target( ${ARG_TARGET}-as DEPENDS ${ARG_OUTPUT} ) endif() endfunction() @@ -227,6 +232,7 @@ function(add_libclc_builtin_set) set( bytecode_files ) set( bytecode_ir_files ) + set( compile_tgts ) foreach( file IN LISTS ARG_GEN_FILES ARG_LIB_FILES ) # We need to take each file and produce an absolute input file, as well # as a unique architecture-specific output file. We deal with a mix of @@ -256,7 +262,11 @@ function(add_libclc_builtin_set) get_filename_component( file_dir ${file} DIRECTORY ) +string( REPLACE "/" "-" replaced ${file} ) +set( tgt compile_tgt-${ARG_ARCH_SUFFIX}${replaced}) + compile_to_bc( + TARGET ${tgt} TRIPLE ${ARG_TRIPLE} INPUT ${input_file} OUTPUT ${output_file} @@ -264,11 +274,13 @@ function(add_libclc_builtin_set) "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} DEPENDENCIES ${input_file_dep} ) +list( APPEND compile_tgts ${tgt} ) # Collect all files originating in LLVM IR separately get_filename_component( file_ext ${file} EXT ) if( ${file_ext} STREQUAL ".ll" ) list( APPEND bytecode_ir_files ${output_file} ) + list( APPEND compile_tgts ${tgt}-as ) else() list( APPEND bytecode_files ${output_file} ) endif() @@ -283,7 +295,7 @@ function(add_libclc_builtin_set) set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} ) add_custom_target( ${builtins_comp_lib_tgt} -DEPENDS ${bytecode_files} +DEPENDS ${compile_tgts} ) set_target_properties( ${builtins_comp_lib_tgt} PROPERTIES FOLDER "libclc/Device IR/Comp" ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130755 >From 1f8b5bfbfea6b562e9cae088256e8e5dddf0a335 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 04:24:36 -0700 Subject: [PATCH 1/2] [libclc] Fix commands in compile_to_bc are executed sequentially In libclc, we observe that compiling OpenCL source files to bitcode is executed sequentially on Windows, which increases debug build time by about an hour. add_custom_command may introduce additional implicit dependencies, see https://gitlab.kitware.com/cmake/cmake/-/issues/17097 This PR adds a target for each command and enables parallel builds of OpenCL source files. --- libclc/cmake/modules/AddLibclc.cmake | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..9dc328fcd489c 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -1,6 +1,8 @@ # Compiles an OpenCL C - or assembles an LL file - to bytecode # # Arguments: +# * TARGET +# Custom target to create # * TRIPLE # Target triple for which to compile the bytecode file. # * INPUT @@ -17,7 +19,7 @@ function(compile_to_bc) cmake_parse_arguments(ARG "" -"TRIPLE;INPUT;OUTPUT" +"TARGET;TRIPLE;INPUT;OUTPUT" "EXTRA_OPTS;DEPENDENCIES" ${ARGN} ) @@ -60,9 +62,11 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} - ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) + add_custom_target( ${ARG_TARGET} +DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} + ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( @@ -70,6 +74,7 @@ function(compile_to_bc) COMMAND ${llvm-as_exe} -o ${ARG_OUTPUT} ${ARG_OUTPUT}${TMP_SUFFIX} DEPENDS ${llvm-as_target} ${ARG_OUTPUT}${TMP_SUFFIX} ) +add_custom_target( ${ARG_TARGET}-as DEPENDS ${ARG_OUTPUT} ) endif() endfunction() @@ -227,6 +232,7 @@ function(add_libclc_builtin_set) set( bytecode_files ) set( bytecode_ir_files ) + set( compile_tgts ) foreach( file IN LISTS ARG_GEN_FILES ARG_LIB_FILES ) # We need to take each file and produce an absolute input file, as well # as a unique architecture-specific output file. We deal with a mix of @@ -256,7 +262,11 @@ function(add_libclc_builtin_set) get_filename_component( file_dir ${file} DIRECTORY ) +string( REPLACE "/" "-" replaced ${file} ) +set( tgt compile_tgt-${ARG_ARCH_SUFFIX}${replaced}) + compile_to_bc( + TARGET ${tgt} TRIPLE ${ARG_TRIPLE} INPUT ${input_file} OUTPUT ${output_file} @@ -264,11 +274,13 @@ function(add_libclc_builtin_set) "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} DEPENDENCIES ${input_file_dep} ) +list( APPEND compile_tgts ${tgt} ) # Collect all files originating in LLVM IR separately get_filename_component( file_ext ${file} EXT ) if( ${file_ext} STREQUAL ".ll" ) list( APPEND bytecode_ir_files ${output_file} ) + list( APPEND compile_tgts ${tgt}-as ) else() list( APPEND bytecode_files ${output_file} ) endif() @@ -283,7 +295,7 @@ function(add_libclc_builtin_set) set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} ) add_custom_target( ${builtins_comp_lib_tgt} -DEPENDS ${bytecode_files} +DEPENDS ${compile_tgts} ) set_target_properties( ${builtins_comp_lib_tgt} PROPERTIES FOLDER "libclc/Device IR/Comp" ) >From 318148023265ea8e71d7c1d65e932748bacd417a Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 06:04:41 -0700 Subject: [PATCH 2/2] revert ARG_DEPENDENCIES change --- libclc/cmake/modules/AddLibclc.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 9dc328fcd489c..fba3b0110aaec 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -62,11 +62,10 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} + ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) - add_custom_target( ${ARG_TARGET} -DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} - ) + add_custom_target( ${ARG_TARGET} DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
wenju-he wrote: @frasercrmck could you please review? thanks https://github.com/llvm/llvm-project/pull/130755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/130882 When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +--- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) +set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + +# Add opt target +add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc +${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} +) +add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc +) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" +) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) +set( builtins_opt_lib $ ) - set( builtins_opt_lib $ ) +set( builtins_link_opt_lib ${builtins_opt_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() +set( builtins_link_opt_lib ${builtins_link_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} -COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} -DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) +COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} +DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
wenju-he wrote: @frasercrmck could you please review? thanks https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] add --only-needed to llvm-link when INTERNALIZE flag is set (PR #130871)
wenju-he wrote: @frasercrmck could you please review? thanks https://github.com/llvm/llvm-project/pull/130871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130882 >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH 1/4] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +--- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) +set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + +# Add opt target +add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc +${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} +) +add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc +) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" +) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) +set( builtins_opt_lib $ ) - set( builtins_opt_lib $ ) +set( builtins_link_opt_lib ${builtins_opt_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() +set( builtins_link_opt_lib ${builtins_link_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} -COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} -DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) +COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} +DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) >From d3543f3601469b2e2b51f3fa275019f06c8378e6 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 04:04:34 -0700 Subject: [PATCH 2/4] unconditionally add builtins_opt_lib_tgt, which is empty if OPT_FLAGS is empty --- libclc/cmake/modules/AddLibclc.cmake | 30 +--- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index de24848256d72..14f28a0b525b0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,37 +340,35 @@ function(add_libclc_builtin_set) return() endif() - if( ${ARG_OPT_FLAGS} ) -set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + add_custom_target( ${builtins_opt_lib_tgt} ALL ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES +FOLDER "libclc/Device IR/Opt" + ) + add_dependencies( ${builtins_opt_lib_tgt} ${builtins_link_lib_tgt} ) -# Add opt target + # Add opt target + if( ${ARG_OPT_FLAGS} STREQUAL "" ) +# no-op +set( builtins_opt_lib ${builtins_link_lib} ) + else() add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc ${builtins_link_lib} DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} ) -add_custom_target( ${builtins_opt_lib_tgt} - ALL DEPENDS ${builtins_opt_lib_tgt}.bc -) set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc - FOLDER "libclc/Device IR/Opt" + DEPENDS ${builtins_opt_lib_tgt}.bc ) - set( builtins_opt_lib $ ) - -set( builtins_link_opt_lib ${builtins_opt_lib} ) -set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) - else() -set( builtins_link_opt_lib ${builtins_link_lib} ) -set
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
wenju-he wrote: > Am I right in thinking that CMake 3.27's `DEPENDS_EXPLICIT_ONLY` would also > fix this? If so it might be worth documenting this explicitly, both in the > PR/commit and in the code? We might be able to refactor this in the future, > when LLVM updates its minimum version to 3.27. done. I noticed DEPENDS_EXPLICIT_ONLY in the cmake issue link above, but I didn't test it. I have just test DEPENDS_EXPLICIT_ONLY on windows, it can indeed fix the sequential build issue. https://github.com/llvm/llvm-project/pull/130755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he edited https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130882 >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH 1/5] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +--- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) +set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + +# Add opt target +add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc +${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} +) +add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc +) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" +) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) +set( builtins_opt_lib $ ) - set( builtins_opt_lib $ ) +set( builtins_link_opt_lib ${builtins_opt_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() +set( builtins_link_opt_lib ${builtins_link_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} -COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} -DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) +COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} +DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) >From d3543f3601469b2e2b51f3fa275019f06c8378e6 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 04:04:34 -0700 Subject: [PATCH 2/5] unconditionally add builtins_opt_lib_tgt, which is empty if OPT_FLAGS is empty --- libclc/cmake/modules/AddLibclc.cmake | 30 +--- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index de24848256d72..14f28a0b525b0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,37 +340,35 @@ function(add_libclc_builtin_set) return() endif() - if( ${ARG_OPT_FLAGS} ) -set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + add_custom_target( ${builtins_opt_lib_tgt} ALL ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES +FOLDER "libclc/Device IR/Opt" + ) + add_dependencies( ${builtins_opt_lib_tgt} ${builtins_link_lib_tgt} ) -# Add opt target + # Add opt target + if( ${ARG_OPT_FLAGS} STREQUAL "" ) +# no-op +set( builtins_opt_lib ${builtins_link_lib} ) + else() add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc ${builtins_link_lib} DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} ) -add_custom_target( ${builtins_opt_lib_tgt} - ALL DEPENDS ${builtins_opt_lib_tgt}.bc -) set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc - FOLDER "libclc/Device IR/Opt" + DEPENDS ${builtins_opt_lib_tgt}.bc ) - set( builtins_opt_lib $ ) - -set( builtins_link_opt_lib ${builtins_opt_lib} ) -set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) - else() -set( builtins_link_opt_lib ${builtins_link_lib} ) -set
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130755 >From 1f8b5bfbfea6b562e9cae088256e8e5dddf0a335 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 04:24:36 -0700 Subject: [PATCH 1/3] [libclc] Fix commands in compile_to_bc are executed sequentially In libclc, we observe that compiling OpenCL source files to bitcode is executed sequentially on Windows, which increases debug build time by about an hour. add_custom_command may introduce additional implicit dependencies, see https://gitlab.kitware.com/cmake/cmake/-/issues/17097 This PR adds a target for each command and enables parallel builds of OpenCL source files. --- libclc/cmake/modules/AddLibclc.cmake | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..9dc328fcd489c 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -1,6 +1,8 @@ # Compiles an OpenCL C - or assembles an LL file - to bytecode # # Arguments: +# * TARGET +# Custom target to create # * TRIPLE # Target triple for which to compile the bytecode file. # * INPUT @@ -17,7 +19,7 @@ function(compile_to_bc) cmake_parse_arguments(ARG "" -"TRIPLE;INPUT;OUTPUT" +"TARGET;TRIPLE;INPUT;OUTPUT" "EXTRA_OPTS;DEPENDENCIES" ${ARGN} ) @@ -60,9 +62,11 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} - ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) + add_custom_target( ${ARG_TARGET} +DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} + ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( @@ -70,6 +74,7 @@ function(compile_to_bc) COMMAND ${llvm-as_exe} -o ${ARG_OUTPUT} ${ARG_OUTPUT}${TMP_SUFFIX} DEPENDS ${llvm-as_target} ${ARG_OUTPUT}${TMP_SUFFIX} ) +add_custom_target( ${ARG_TARGET}-as DEPENDS ${ARG_OUTPUT} ) endif() endfunction() @@ -227,6 +232,7 @@ function(add_libclc_builtin_set) set( bytecode_files ) set( bytecode_ir_files ) + set( compile_tgts ) foreach( file IN LISTS ARG_GEN_FILES ARG_LIB_FILES ) # We need to take each file and produce an absolute input file, as well # as a unique architecture-specific output file. We deal with a mix of @@ -256,7 +262,11 @@ function(add_libclc_builtin_set) get_filename_component( file_dir ${file} DIRECTORY ) +string( REPLACE "/" "-" replaced ${file} ) +set( tgt compile_tgt-${ARG_ARCH_SUFFIX}${replaced}) + compile_to_bc( + TARGET ${tgt} TRIPLE ${ARG_TRIPLE} INPUT ${input_file} OUTPUT ${output_file} @@ -264,11 +274,13 @@ function(add_libclc_builtin_set) "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} DEPENDENCIES ${input_file_dep} ) +list( APPEND compile_tgts ${tgt} ) # Collect all files originating in LLVM IR separately get_filename_component( file_ext ${file} EXT ) if( ${file_ext} STREQUAL ".ll" ) list( APPEND bytecode_ir_files ${output_file} ) + list( APPEND compile_tgts ${tgt}-as ) else() list( APPEND bytecode_files ${output_file} ) endif() @@ -283,7 +295,7 @@ function(add_libclc_builtin_set) set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} ) add_custom_target( ${builtins_comp_lib_tgt} -DEPENDS ${bytecode_files} +DEPENDS ${compile_tgts} ) set_target_properties( ${builtins_comp_lib_tgt} PROPERTIES FOLDER "libclc/Device IR/Comp" ) >From 318148023265ea8e71d7c1d65e932748bacd417a Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 06:04:41 -0700 Subject: [PATCH 2/3] revert ARG_DEPENDENCIES change --- libclc/cmake/modules/AddLibclc.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 9dc328fcd489c..fba3b0110aaec 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -62,11 +62,10 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} + ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) - add_custom_target( ${ARG_TARGET} -DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} - ) + add_custom_target( ${ARG_TARGET} DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( >From ea2f503e3c8ea76de06dccf125f985a862535ae8 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 03:14:41 -0700 Subject: [PATCH 3/3] add FIXME about DEPENDS_EXPLICIT_ONLY --- libclc/cmake/modules/AddLibclc.cmake | 5 + 1 file changed, 5 insertions(+) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index fba3b0110aaec..5d03acc73b3d0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -65,6 +65,11 @@ funct
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130882 >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH 1/2] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +--- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) +set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + +# Add opt target +add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc +${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} +) +add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc +) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" +) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) +set( builtins_opt_lib $ ) - set( builtins_opt_lib $ ) +set( builtins_link_opt_lib ${builtins_opt_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() +set( builtins_link_opt_lib ${builtins_link_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} -COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} -DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) +COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} +DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) >From d3543f3601469b2e2b51f3fa275019f06c8378e6 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 04:04:34 -0700 Subject: [PATCH 2/2] unconditionally add builtins_opt_lib_tgt, which is empty if OPT_FLAGS is empty --- libclc/cmake/modules/AddLibclc.cmake | 30 +--- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index de24848256d72..14f28a0b525b0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,37 +340,35 @@ function(add_libclc_builtin_set) return() endif() - if( ${ARG_OPT_FLAGS} ) -set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + add_custom_target( ${builtins_opt_lib_tgt} ALL ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES +FOLDER "libclc/Device IR/Opt" + ) + add_dependencies( ${builtins_opt_lib_tgt} ${builtins_link_lib_tgt} ) -# Add opt target + # Add opt target + if( ${ARG_OPT_FLAGS} STREQUAL "" ) +# no-op +set( builtins_opt_lib ${builtins_link_lib} ) + else() add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc ${builtins_link_lib} DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} ) -add_custom_target( ${builtins_opt_lib_tgt} - ALL DEPENDS ${builtins_opt_lib_tgt}.bc -) set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc - FOLDER "libclc/Device IR/Opt" + DEPENDS ${builtins_opt_lib_tgt}.bc ) - set( builtins_opt_lib $ ) - -set( builtins_link_opt_lib ${builtins_opt_lib} ) -set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) - else() -set( builtins_link_opt_lib ${builtins_link_lib} ) -set
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130882 >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH 1/3] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +--- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) +set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + +# Add opt target +add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc +${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} +) +add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc +) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" +) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) +set( builtins_opt_lib $ ) - set( builtins_opt_lib $ ) +set( builtins_link_opt_lib ${builtins_opt_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() +set( builtins_link_opt_lib ${builtins_link_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} -COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} -DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) +COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} +DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) >From d3543f3601469b2e2b51f3fa275019f06c8378e6 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 04:04:34 -0700 Subject: [PATCH 2/3] unconditionally add builtins_opt_lib_tgt, which is empty if OPT_FLAGS is empty --- libclc/cmake/modules/AddLibclc.cmake | 30 +--- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index de24848256d72..14f28a0b525b0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,37 +340,35 @@ function(add_libclc_builtin_set) return() endif() - if( ${ARG_OPT_FLAGS} ) -set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + add_custom_target( ${builtins_opt_lib_tgt} ALL ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES +FOLDER "libclc/Device IR/Opt" + ) + add_dependencies( ${builtins_opt_lib_tgt} ${builtins_link_lib_tgt} ) -# Add opt target + # Add opt target + if( ${ARG_OPT_FLAGS} STREQUAL "" ) +# no-op +set( builtins_opt_lib ${builtins_link_lib} ) + else() add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc ${builtins_link_lib} DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} ) -add_custom_target( ${builtins_opt_lib_tgt} - ALL DEPENDS ${builtins_opt_lib_tgt}.bc -) set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc - FOLDER "libclc/Device IR/Opt" + DEPENDS ${builtins_opt_lib_tgt}.bc ) - set( builtins_opt_lib $ ) - -set( builtins_link_opt_lib ${builtins_opt_lib} ) -set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) - else() -set( builtins_link_opt_lib ${builtins_link_lib} ) -set
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
@@ -342,21 +342,32 @@ function(add_libclc_builtin_set) set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) + if( ${ARG_OPT_FLAGS} STREQUAL "" ) +# Add empty opt target. +add_custom_target( ${builtins_opt_lib_tgt} ALL ) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES wenju-he wrote: thanks for the suggestion. Done. https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
wenju-he wrote: > Another option would be to unconditionally have builtin.opt targets but if no > flags are passed, just make them empty targets that rely only on builtin.link > targets. Thanks for the suggestion. Done. Please review again. https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
https://github.com/wenju-he edited https://github.com/llvm/llvm-project/pull/130755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/132338 >From 6ce54aa767f8cdff2f938cdce8656e495a1346f0 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 20 Mar 2025 22:01:55 -0700 Subject: [PATCH 1/2] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix Currently link_bc command depends on the bitcode file that is associated with custom target builtins.link.clc-arch_suffix. On windows we randomly see following error: ` Generating builtins.link.clc-${ARCH}--.bc Generating builtins.link.libspirv-${ARCH}.bc error : The requested operation cannot be performed on a file with a user-mapped section open. ` I suspect that builtins.link.clc-${ARCH}--.bc file is being generated while it is being used in link_bc. This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first. --- libclc/CMakeLists.txt| 2 +- libclc/cmake/modules/AddLibclc.cmake | 9 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 426f210a73fcc..3de7ee9b707a8 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -413,7 +413,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) GEN_FILES ${opencl_gen_files} ALIASES ${${d}_aliases} # Link in the CLC builtins and internalize their symbols - INTERNAL_LINK_DEPENDENCIES $ + INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix} ) endforeach( d ) endforeach( t ) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..0808b39e06555 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -211,8 +211,9 @@ endfunction() # * ALIASES ... # List of aliases # * INTERNAL_LINK_DEPENDENCIES ... -# A list of extra bytecode files to link into the builtin library. Symbols -# from these link dependencies will be internalized during linking. +# A list of extra bytecode file's targets. The bitcode files will be linked +# into the builtin library. Symbols from these link dependencies will be +# internalized during linking. function(add_libclc_builtin_set) cmake_parse_arguments(ARG "CLC_INTERNAL" @@ -313,8 +314,8 @@ function(add_libclc_builtin_set) INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -${ARG_INTERNAL_LINK_DEPENDENCIES} - DEPENDENCIES ${builtins_link_lib_tmp_tgt} +$ + DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} ) endif() >From 7b9a65f8dac3ab5e13fcabade3e9ed4d384c5b92 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 21 Mar 2025 01:29:51 -0700 Subject: [PATCH 2/2] update comment, fix files to link --- libclc/cmake/modules/AddLibclc.cmake | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 0808b39e06555..29d728494cd3e 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -210,7 +210,7 @@ endfunction() # Optimization options (for opt) # * ALIASES ... # List of aliases -# * INTERNAL_LINK_DEPENDENCIES ... +# * INTERNAL_LINK_DEPENDENCIES ... # A list of extra bytecode file's targets. The bitcode files will be linked # into the builtin library. Symbols from these link dependencies will be # internalized during linking. @@ -310,11 +310,15 @@ function(add_libclc_builtin_set) INPUTS ${bytecode_files} DEPENDENCIES ${builtins_comp_lib_tgt} ) +set( internal_link_depend_files ) +foreach( tgt ${ARG_INTERNAL_LINK_DEPENDENCIES} ) + list( APPEND internal_link_depend_files $ ) +endforeach() link_bc( INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -$ +${internal_link_depend_files} DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} ) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
@@ -342,22 +342,32 @@ function(add_libclc_builtin_set) set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) + if( ${ARG_OPT_FLAGS} STREQUAL "" ) wenju-he wrote: let me know if it worth to update PR to unifies the code path and avoids early exit. Otherwise I'll close this PR. The original request of this PR is to disable opt -O3. But things has changed and the request is irrelevant. Though in practice it might still make sense to apply the PR to avoid code diverge like for SPIR-V. https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
@@ -313,8 +314,8 @@ function(add_libclc_builtin_set) INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -${ARG_INTERNAL_LINK_DEPENDENCIES} - DEPENDENCIES ${builtins_link_lib_tmp_tgt} +$ wenju-he wrote: thanks, changed to reading TARGE_FILE from each target https://github.com/llvm/llvm-project/pull/132338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] add --only-needed to llvm-link when INTERNALIZE flag is set (PR #130871)
wenju-he wrote: @frasercrmck could you please try this PR on https://github.com/intel/llvm repo? My experiment: clang --version clang version 21.0.0git (https://github.com/llvm/llvm-project f5ee10538b68835112323c241ca7db67ca78bf62) before PR: find . -name "builtins.link*.bc" -printf "%s\n" | paste -sd+ | bc 101593692 after PR: find . -name "builtins.link*.bc" -printf "%s\n" | paste -sd+ | bc 101316928 This PR reduces bitcode file sizes by 0.27% https://github.com/llvm/llvm-project/pull/130871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
@@ -342,22 +342,32 @@ function(add_libclc_builtin_set) set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) + if( ${ARG_OPT_FLAGS} STREQUAL "" ) wenju-he wrote: > I just realised this code isn't triggered upstream. I take it you have a > downstream making use of it? there is a case in upstream LLVM that opt flag is empty: https://github.com/llvm/llvm-project/blob/ad5cac3b06c3cb41397acc1fc96beae9b460f20c/libclc/CMakeLists.txt#L353 > I tried it locally and this needs to be `if( "${ARG_OPT_FLAGS} STREQUAL "" )` > or maybe better yet `if ( NOT ARG_OPT_FLAGS )`. The code as-is generates an > error if I pass in an empty OPT_FLAGS: > > ``` > CMake Error at /llvm-project/libclc/cmake/modules/AddLibclc.cmake:345 (if): > if given arguments: > > "STREQUAL" "" > > Unknown arguments specified > ``` Thanks for the testing. Changed to `if ( NOT ARG_OPT_FLAGS )` I don't know what happened, a few days ago I did observe that bitcode size become smaller when opt flag is empty. https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/132338 >From 6ce54aa767f8cdff2f938cdce8656e495a1346f0 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 20 Mar 2025 22:01:55 -0700 Subject: [PATCH] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix Currently link_bc command depends on the bitcode file that is associated with custom target builtins.link.clc-arch_suffix. On windows we randomly see following error: ` Generating builtins.link.clc-${ARCH}--.bc Generating builtins.link.libspirv-${ARCH}.bc error : The requested operation cannot be performed on a file with a user-mapped section open. ` I suspect that builtins.link.clc-${ARCH}--.bc file is being generated while it is being used in link_bc. This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first. --- libclc/CMakeLists.txt| 2 +- libclc/cmake/modules/AddLibclc.cmake | 9 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 426f210a73fcc..3de7ee9b707a8 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -413,7 +413,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) GEN_FILES ${opencl_gen_files} ALIASES ${${d}_aliases} # Link in the CLC builtins and internalize their symbols - INTERNAL_LINK_DEPENDENCIES $ + INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix} ) endforeach( d ) endforeach( t ) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..0808b39e06555 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -211,8 +211,9 @@ endfunction() # * ALIASES ... # List of aliases # * INTERNAL_LINK_DEPENDENCIES ... -# A list of extra bytecode files to link into the builtin library. Symbols -# from these link dependencies will be internalized during linking. +# A list of extra bytecode file's targets. The bitcode files will be linked +# into the builtin library. Symbols from these link dependencies will be +# internalized during linking. function(add_libclc_builtin_set) cmake_parse_arguments(ARG "CLC_INTERNAL" @@ -313,8 +314,8 @@ function(add_libclc_builtin_set) INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -${ARG_INTERNAL_LINK_DEPENDENCIES} - DEPENDENCIES ${builtins_link_lib_tmp_tgt} +$ + DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} ) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130882 >From 1727cb49ebbee324ecad0a766ec341eb1aed082b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 19:05:25 -0700 Subject: [PATCH 1/6] [libclc] Skip opt command if opt_flags is empty When the flag is empty, the opt command won't modify the bitcode; however, the command is slow for large bitcode files in debug mode. --- libclc/cmake/modules/AddLibclc.cmake | 42 +--- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..de24848256d72 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,29 +340,37 @@ function(add_libclc_builtin_set) return() endif() - set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + if( ${ARG_OPT_FLAGS} ) +set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + +# Add opt target +add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc + COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc +${builtins_link_lib} + DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} +) +add_custom_target( ${builtins_opt_lib_tgt} + ALL DEPENDS ${builtins_opt_lib_tgt}.bc +) +set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES + TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc + FOLDER "libclc/Device IR/Opt" +) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) - set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES -TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc -FOLDER "libclc/Device IR/Opt" - ) +set( builtins_opt_lib $ ) - set( builtins_opt_lib $ ) +set( builtins_link_opt_lib ${builtins_opt_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) + else() +set( builtins_link_opt_lib ${builtins_link_lib} ) +set( builtins_link_opt_lib_tgt ${builtins_link_lib_tgt} ) + endif() # Add prepare target set( obj_suffix ${ARG_ARCH_SUFFIX}.bc ) add_custom_command( OUTPUT ${obj_suffix} -COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_opt_lib} -DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target} ) +COMMAND ${prepare_builtins_exe} -o ${obj_suffix} ${builtins_link_opt_lib} +DEPENDS ${builtins_link_opt_lib} ${builtins_link_opt_lib_tgt} ${prepare_builtins_target} ) add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} ) set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" ) >From d3543f3601469b2e2b51f3fa275019f06c8378e6 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 04:04:34 -0700 Subject: [PATCH 2/6] unconditionally add builtins_opt_lib_tgt, which is empty if OPT_FLAGS is empty --- libclc/cmake/modules/AddLibclc.cmake | 30 +--- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index de24848256d72..14f28a0b525b0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -340,37 +340,35 @@ function(add_libclc_builtin_set) return() endif() - if( ${ARG_OPT_FLAGS} ) -set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) + add_custom_target( ${builtins_opt_lib_tgt} ALL ) + set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES +FOLDER "libclc/Device IR/Opt" + ) + add_dependencies( ${builtins_opt_lib_tgt} ${builtins_link_lib_tgt} ) -# Add opt target + # Add opt target + if( ${ARG_OPT_FLAGS} STREQUAL "" ) +# no-op +set( builtins_opt_lib ${builtins_link_lib} ) + else() add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc ${builtins_link_lib} DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} ) -add_custom_target( ${builtins_opt_lib_tgt} - ALL DEPENDS ${builtins_opt_lib_tgt}.bc -) set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc - FOLDER "libclc/Device IR/Opt" + DEPENDS ${builtins_opt_lib_tgt}.bc ) - set( builtins_opt_lib $ ) - -set( builtins_link_opt_lib ${builtins_opt_lib} ) -set( builtins_link_opt_lib_tgt ${builtins_opt_lib_tgt} ) - else() -set( builtins_link_opt_lib ${builtins_link_lib} ) -set
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
wenju-he wrote: I've tested on Windows for half a day, it seems this PR can fix the issue. https://github.com/llvm/llvm-project/pull/132338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
https://github.com/wenju-he edited https://github.com/llvm/llvm-project/pull/132338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
wenju-he wrote: @frasercrmck could you please review? thanks https://github.com/llvm/llvm-project/pull/132338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
wenju-he wrote: @frasercrmck please help to merge, thanks. I don't have merge access. https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
@@ -211,8 +211,9 @@ endfunction() # * ALIASES ... # List of aliases # * INTERNAL_LINK_DEPENDENCIES ... wenju-he wrote: done https://github.com/llvm/llvm-project/pull/132338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/132338 Currently link_bc command depends on the bitcode file that is associated with custom target builtins.link.clc-arch_suffix. On windows we randomly see following error: ` Generating builtins.link.clc-${ARCH}--.bc Generating builtins.link.libspirv-${ARCH}.bc error : The requested operation cannot be performed on a file with a user-mapped section open. ` I suspect that builtins.link.clc-${ARCH}--.bc file is been generated while it is been used in link_bc. This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first. >From a423c4d51b88dc51c5628eb9d4c0b7053a96f461 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 20 Mar 2025 22:01:55 -0700 Subject: [PATCH] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix Currently link_bc command depends on the bitcode file that is associated with custom target builtins.link.clc-arch_suffix. On windows we randomly see following error: ` Generating builtins.link.clc-${ARCH}--.bc Generating builtins.link.libspirv-${ARCH}.bc error : The requested operation cannot be performed on a file with a user-mapped section open. ` I suspect that builtins.link.clc-${ARCH}--.bc file is been generated while it is been used in link_bc. This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first. --- libclc/CMakeLists.txt| 2 +- libclc/cmake/modules/AddLibclc.cmake | 9 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 426f210a73fcc..3de7ee9b707a8 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -413,7 +413,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) GEN_FILES ${opencl_gen_files} ALIASES ${${d}_aliases} # Link in the CLC builtins and internalize their symbols - INTERNAL_LINK_DEPENDENCIES $ + INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix} ) endforeach( d ) endforeach( t ) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..0808b39e06555 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -211,8 +211,9 @@ endfunction() # * ALIASES ... # List of aliases # * INTERNAL_LINK_DEPENDENCIES ... -# A list of extra bytecode files to link into the builtin library. Symbols -# from these link dependencies will be internalized during linking. +# A list of extra bytecode file's targets. The bitcode files will be linked +# into the builtin library. Symbols from these link dependencies will be +# internalized during linking. function(add_libclc_builtin_set) cmake_parse_arguments(ARG "CLC_INTERNAL" @@ -313,8 +314,8 @@ function(add_libclc_builtin_set) INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -${ARG_INTERNAL_LINK_DEPENDENCIES} - DEPENDENCIES ${builtins_link_lib_tmp_tgt} +$ + DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} ) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
@@ -342,22 +342,32 @@ function(add_libclc_builtin_set) set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} ) - # Add opt target - add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc -COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc - ${builtins_link_lib} -DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt} - ) - add_custom_target( ${builtins_opt_lib_tgt} -ALL DEPENDS ${builtins_opt_lib_tgt}.bc - ) + if( ${ARG_OPT_FLAGS} STREQUAL "" ) wenju-he wrote: just curious would this Pr unifies the this code and avoid the early exit and duplicate code for prepare target? https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/132338 >From 6ce54aa767f8cdff2f938cdce8656e495a1346f0 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 20 Mar 2025 22:01:55 -0700 Subject: [PATCH 1/3] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix Currently link_bc command depends on the bitcode file that is associated with custom target builtins.link.clc-arch_suffix. On windows we randomly see following error: ` Generating builtins.link.clc-${ARCH}--.bc Generating builtins.link.libspirv-${ARCH}.bc error : The requested operation cannot be performed on a file with a user-mapped section open. ` I suspect that builtins.link.clc-${ARCH}--.bc file is being generated while it is being used in link_bc. This PR adds target-level dependency to ensure builtins.link.clc-${ARCH}--.bc is generated first. --- libclc/CMakeLists.txt| 2 +- libclc/cmake/modules/AddLibclc.cmake | 9 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 426f210a73fcc..3de7ee9b707a8 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -413,7 +413,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) GEN_FILES ${opencl_gen_files} ALIASES ${${d}_aliases} # Link in the CLC builtins and internalize their symbols - INTERNAL_LINK_DEPENDENCIES $ + INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix} ) endforeach( d ) endforeach( t ) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..0808b39e06555 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -211,8 +211,9 @@ endfunction() # * ALIASES ... # List of aliases # * INTERNAL_LINK_DEPENDENCIES ... -# A list of extra bytecode files to link into the builtin library. Symbols -# from these link dependencies will be internalized during linking. +# A list of extra bytecode file's targets. The bitcode files will be linked +# into the builtin library. Symbols from these link dependencies will be +# internalized during linking. function(add_libclc_builtin_set) cmake_parse_arguments(ARG "CLC_INTERNAL" @@ -313,8 +314,8 @@ function(add_libclc_builtin_set) INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -${ARG_INTERNAL_LINK_DEPENDENCIES} - DEPENDENCIES ${builtins_link_lib_tmp_tgt} +$ + DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} ) endif() >From 7b9a65f8dac3ab5e13fcabade3e9ed4d384c5b92 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 21 Mar 2025 01:29:51 -0700 Subject: [PATCH 2/3] update comment, fix files to link --- libclc/cmake/modules/AddLibclc.cmake | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 0808b39e06555..29d728494cd3e 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -210,7 +210,7 @@ endfunction() # Optimization options (for opt) # * ALIASES ... # List of aliases -# * INTERNAL_LINK_DEPENDENCIES ... +# * INTERNAL_LINK_DEPENDENCIES ... # A list of extra bytecode file's targets. The bitcode files will be linked # into the builtin library. Symbols from these link dependencies will be # internalized during linking. @@ -310,11 +310,15 @@ function(add_libclc_builtin_set) INPUTS ${bytecode_files} DEPENDENCIES ${builtins_comp_lib_tgt} ) +set( internal_link_depend_files ) +foreach( tgt ${ARG_INTERNAL_LINK_DEPENDENCIES} ) + list( APPEND internal_link_depend_files $ ) +endforeach() link_bc( INTERNALIZE TARGET ${builtins_link_lib_tgt} INPUTS $ -$ +${internal_link_depend_files} DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES} ) endif() >From 7097315c4dbf474a9d0e4adbca18bf868a503436 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 21 Mar 2025 02:05:20 -0700 Subject: [PATCH 3/3] fix --- libclc/cmake/modules/AddLibclc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 29d728494cd3e..fe7151e61b466 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -312,7 +312,7 @@ function(add_libclc_builtin_set) ) set( internal_link_depend_files ) foreach( tgt ${ARG_INTERNAL_LINK_DEPENDENCIES} ) - list( APPEND internal_link_depend_files $ ) + list( APPEND internal_link_depend_files $ ) endforeach() link_bc( INTERNALIZE ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
wenju-he wrote: @frasercrmck should we check CMAKE_VERSION and use DEPENDS_EXPLICIT_ONLY if the version is 3.27 or higher? I suppose DEPENDS_EXPLICIT_ONLY would be more light-weighted. And we need to keep both DEPENDS_EXPLICIT_ONLY and adding new target path, until llvm uplifts cmake version to 3.27. https://github.com/llvm/llvm-project/pull/130755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add 'cl' to enable OpenCL kernel file formatting (PR #134529)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/134529 None >From ac389b8b92fbb77c8884515d8f7293b4af17dfa5 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Sun, 6 Apr 2025 18:30:42 +0800 Subject: [PATCH] [clang-format] Add 'cl' to enable OpenCL kernel file formatting --- clang/tools/clang-format/git-clang-format | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format index 85eff4761e289..ba324b14ab80d 100755 --- a/clang/tools/clang-format/git-clang-format +++ b/clang/tools/clang-format/git-clang-format @@ -126,6 +126,7 @@ def main(): "pb.txt", "textproto", "asciipb", # TextProto +"cl", # OpenCL ] ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add 'cl' to enable OpenCL kernel file formatting (PR #134529)
https://github.com/wenju-he edited https://github.com/llvm/llvm-project/pull/134529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/130755 >From 1f8b5bfbfea6b562e9cae088256e8e5dddf0a335 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 04:24:36 -0700 Subject: [PATCH 1/4] [libclc] Fix commands in compile_to_bc are executed sequentially In libclc, we observe that compiling OpenCL source files to bitcode is executed sequentially on Windows, which increases debug build time by about an hour. add_custom_command may introduce additional implicit dependencies, see https://gitlab.kitware.com/cmake/cmake/-/issues/17097 This PR adds a target for each command and enables parallel builds of OpenCL source files. --- libclc/cmake/modules/AddLibclc.cmake | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 911559ff4bfa9..9dc328fcd489c 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -1,6 +1,8 @@ # Compiles an OpenCL C - or assembles an LL file - to bytecode # # Arguments: +# * TARGET +# Custom target to create # * TRIPLE # Target triple for which to compile the bytecode file. # * INPUT @@ -17,7 +19,7 @@ function(compile_to_bc) cmake_parse_arguments(ARG "" -"TRIPLE;INPUT;OUTPUT" +"TARGET;TRIPLE;INPUT;OUTPUT" "EXTRA_OPTS;DEPENDENCIES" ${ARGN} ) @@ -60,9 +62,11 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} - ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) + add_custom_target( ${ARG_TARGET} +DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} + ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( @@ -70,6 +74,7 @@ function(compile_to_bc) COMMAND ${llvm-as_exe} -o ${ARG_OUTPUT} ${ARG_OUTPUT}${TMP_SUFFIX} DEPENDS ${llvm-as_target} ${ARG_OUTPUT}${TMP_SUFFIX} ) +add_custom_target( ${ARG_TARGET}-as DEPENDS ${ARG_OUTPUT} ) endif() endfunction() @@ -227,6 +232,7 @@ function(add_libclc_builtin_set) set( bytecode_files ) set( bytecode_ir_files ) + set( compile_tgts ) foreach( file IN LISTS ARG_GEN_FILES ARG_LIB_FILES ) # We need to take each file and produce an absolute input file, as well # as a unique architecture-specific output file. We deal with a mix of @@ -256,7 +262,11 @@ function(add_libclc_builtin_set) get_filename_component( file_dir ${file} DIRECTORY ) +string( REPLACE "/" "-" replaced ${file} ) +set( tgt compile_tgt-${ARG_ARCH_SUFFIX}${replaced}) + compile_to_bc( + TARGET ${tgt} TRIPLE ${ARG_TRIPLE} INPUT ${input_file} OUTPUT ${output_file} @@ -264,11 +274,13 @@ function(add_libclc_builtin_set) "${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} DEPENDENCIES ${input_file_dep} ) +list( APPEND compile_tgts ${tgt} ) # Collect all files originating in LLVM IR separately get_filename_component( file_ext ${file} EXT ) if( ${file_ext} STREQUAL ".ll" ) list( APPEND bytecode_ir_files ${output_file} ) + list( APPEND compile_tgts ${tgt}-as ) else() list( APPEND bytecode_files ${output_file} ) endif() @@ -283,7 +295,7 @@ function(add_libclc_builtin_set) set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} ) add_custom_target( ${builtins_comp_lib_tgt} -DEPENDS ${bytecode_files} +DEPENDS ${compile_tgts} ) set_target_properties( ${builtins_comp_lib_tgt} PROPERTIES FOLDER "libclc/Device IR/Comp" ) >From 318148023265ea8e71d7c1d65e932748bacd417a Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 11 Mar 2025 06:04:41 -0700 Subject: [PATCH 2/4] revert ARG_DEPENDENCIES change --- libclc/cmake/modules/AddLibclc.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index 9dc328fcd489c..fba3b0110aaec 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -62,11 +62,10 @@ function(compile_to_bc) DEPENDS ${clang_target} ${ARG_INPUT} + ${ARG_DEPENDENCIES} DEPFILE ${ARG_OUTPUT}.d ) - add_custom_target( ${ARG_TARGET} -DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ${ARG_DEPENDENCIES} - ) + add_custom_target( ${ARG_TARGET} DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} ) if( ${FILE_EXT} STREQUAL ".ll" ) add_custom_command( >From ea2f503e3c8ea76de06dccf125f985a862535ae8 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Mar 2025 03:14:41 -0700 Subject: [PATCH 3/4] add FIXME about DEPENDS_EXPLICIT_ONLY --- libclc/cmake/modules/AddLibclc.cmake | 5 + 1 file changed, 5 insertions(+) diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake index fba3b0110aaec..5d03acc73b3d0 100644 --- a/libclc/cmake/modules/AddLibclc.cmake +++ b/libclc/cmake/modules/AddLibclc.cmake @@ -65,6 +65,11 @@ funct
[libclc] [libclc] Fix commands in compile_to_bc are executed sequentially (PR #130755)
@@ -283,7 +294,7 @@ function(add_libclc_builtin_set) set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} ) add_custom_target( ${builtins_comp_lib_tgt} -DEPENDS ${bytecode_files} +DEPENDS ${compile_tgts} wenju-he wrote: thanks, I'll add ${bytecode_files} depends back https://github.com/llvm/llvm-project/pull/130755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [NFC][libclc] Merge atomic extension built-ins with identical name into a single file (PR #134489)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/134489 Similar to how cl_khr_fp64 and cl_khr_fp16 implementations are put in a same file for math built-ins, this PR do the same to atom_* built-ins. The main motivation is to prevent that two files with same base name implementats different built-ins. In a follow-up PR, I'd like to relax libclc_configure_lib_source to only compare filename instead of path for overriding, since in our downstream the same category of built-ins, e.g. math, are organized in several different folders. >From 310f537cb36fdb6cfe208860ad9c149c4a0c372a Mon Sep 17 00:00:00 2001 From: Wenju He Date: Sat, 5 Apr 2025 02:08:28 -0700 Subject: [PATCH] [NFC][libclc] Merge atomic extension built-ins with identical name into a single file Similar to how cl_khr_fp64 and cl_khr_fp16 implementations are put in a same file for math built-ins, this PR do the same to atom_* built-ins. The main motivation is to prevent that two files with same base name implementats different built-ins. In a follow-up PR, I'd like to relax libclc_configure_lib_source to only compare filename instead of path for overriding, since in our downstream the same category of built-ins, e.g. math, are organized in several different folders. --- .../atom_add.h| 12 +++- .../atom_and.h| 12 +++- .../generic/include/clc/atomic/atom_cmpxchg.h | 36 +++ .../atom_dec.h| 15 - .../clc/{ => atomic}/atom_decl_int32.inc | 7 +- .../clc/{ => atomic}/atom_decl_int64.inc | 7 +- .../atom_inc.h| 15 - .../atom_max.h| 13 +++- .../atom_min.h| 12 +++- .../atom_or.h | 12 +++- .../atom_sub.h| 12 +++- .../atom_xchg.h | 12 +++- .../atom_xor.h| 12 +++- .../atom_cmpxchg.h| 10 --- .../atom_dec.h| 10 --- .../atom_inc.h| 10 --- .../clc/cl_khr_int64_base_atomics/atom_add.h | 10 --- .../cl_khr_int64_base_atomics/atom_cmpxchg.h | 12 .../clc/cl_khr_int64_base_atomics/atom_sub.h | 10 --- .../clc/cl_khr_int64_base_atomics/atom_xchg.h | 10 --- .../cl_khr_int64_extended_atomics/atom_and.h | 10 --- .../cl_khr_int64_extended_atomics/atom_max.h | 10 --- .../cl_khr_int64_extended_atomics/atom_min.h | 10 --- .../cl_khr_int64_extended_atomics/atom_or.h | 10 --- .../cl_khr_int64_extended_atomics/atom_xor.h | 10 --- .../atom_add.h| 11 .../atom_cmpxchg.h| 10 --- .../atom_dec.h| 10 --- .../atom_inc.h| 10 --- .../atom_sub.h| 11 .../atom_xchg.h | 11 .../atom_and.h| 11 .../atom_max.h| 11 .../atom_min.h| 11 .../atom_or.h | 11 .../atom_xor.h| 11 libclc/generic/include/clc/clc.h | 64 +-- libclc/generic/lib/SOURCES| 46 - .../atom_add.cl | 14 +++- .../atom_and.cl | 14 +++- .../atom_cmpxchg.cl | 25 +++- .../atom_dec.cl | 26 +++- .../atom_inc.cl | 26 +++- .../lib/{ => atomic}/atom_int32_binary.inc| 9 +-- .../atom_max.cl | 14 +++- .../atom_min.cl | 14 +++- .../atom_or.cl| 12 +++- .../atom_sub.cl | 14 +++- .../atom_xchg.cl | 14 +++- .../atom_xor.cl | 12 +++- .../atom_add.cl | 11 .../atom_cmpxchg.cl | 17 - .../atom_dec.cl | 17 - .../atom_inc.cl | 17 - .../atom_sub.cl | 11 .../atom_xchg.cl | 11 .../atom_and.cl | 11 .../atom_max.cl | 11 .../atom_min.cl | 11 .../atom_or.cl| 11 .../atom_xor.cl | 11 .../atom_add.cl | 11 .../atom_cmpxchg.cl | 17 - .../atom_dec.cl | 17 - .../atom_inc.cl
[libclc] [NFC][libclc] Merge atomic extension built-ins with identical name into a single file (PR #134489)
wenju-he wrote: @frasercrmck could you please review, thanks. https://github.com/llvm/llvm-project/pull/134489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits