[clang] [HLSL] Adjust resource binding diagnostic flags code (PR #106657)
https://github.com/hekota closed https://github.com/llvm/llvm-project/pull/106657 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1545,6 +1605,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } case Builtin::BI__builtin_hlsl_elementwise_saturate: coopp wrote: Did you mean for 'Builtin::BI__builtin_hlsl_elementwise_saturate' to fall through into 'Builtin::BI__builtin_hlsl_select' logic in this switch( ) statement? https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1545,6 +1605,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } case Builtin::BI__builtin_hlsl_elementwise_saturate: spall wrote: No I did not; It is supposed to fall through to the next case, so I will reorder these. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Introduce -defer-thinlto-prelink-coro-split that skips Coro passes in ThinLTO pre-link pipeline (PR #107153)
mtrofin wrote: What's the scenario in which we do ThinLTO prelink and then go to codegen (i.e. skip thinlto post-link)? https://github.com/llvm/llvm-project/pull/107153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Adjust resource binding diagnostic flags code (PR #106657)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clangd-ubuntu-tsan` running on `clangd-ubuntu-clang` while building `clang` at step 6 "test-build-clangd-clangd-index-server-clangd-indexer-check-clangd". Full details are available at: https://lab.llvm.org/buildbot/#/builders/134/builds/4614 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-clangd-clangd-index-server-clangd-indexer-check-clangd) failure: test (failure) TEST 'Clangd :: target_info.test' FAILED Exit Code: 66 Command Output (stderr): -- RUN: at line 5: rm -rf /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir && mkdir -p /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir + rm -rf /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir + mkdir -p /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir RUN: at line 7: echo '[{"directory": "/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir", "command": "/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir/armv7-clang -x c++ the-file.cpp -v", "file": "the-file.cpp"}]' > /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir/compile_commands.json + echo '[{"directory": "/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir", "command": "/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir/armv7-clang -x c++ the-file.cpp -v", "file": "the-file.cpp"}]' RUN: at line 9: sed -e "s|INPUT_DIR|/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir|g" /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/target_info.test > /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test.1 + sed -e 's|INPUT_DIR|/vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.dir|g' /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/target_info.test RUN: at line 12: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test.1 > /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test + sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test.1 RUN: at line 14: clangd -lit-test < /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test 2>&1 | /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck -strict-whitespace /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test + clangd -lit-test + /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck -strict-whitespace /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test/Output/target_info.test.tmp.test -- ``` https://github.com/llvm/llvm-project/pull/106657 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
https://github.com/rnk created https://github.com/llvm/llvm-project/pull/107154 Follow-up to c19f4f8069722f6804086d4438a0254104242c46 to handle corner case of exported inline variables. Should fix #56485 >From cfb2cea5a4d4e0c1712e038692c4c5acee6b1f27 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 3 Sep 2024 21:16:40 + Subject: [PATCH] [MS] Put dllexported inline global initializers in a comdat Follow-up to c19f4f8069722f6804086d4438a0254104242c46 to handle corner case of exported inline variables. Should fix #56485 --- clang/lib/CodeGen/CGDeclCXX.cpp | 2 +- clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 2f56355cff90ec..c9e0fb0d8afaba 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -586,7 +586,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, PrioritizedCXXGlobalInits.size()); PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn)); } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || - getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR || + !isUniqueGVALinkage(getContext().GetGVALinkageForVariable(D)) || D->hasAttr()) { // C++ [basic.start.init]p2: // Definitions of explicitly specialized class template static data diff --git a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp index 60b48abca2f89a..871551240debfd 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp @@ -49,8 +49,6 @@ struct X { static T ioo; static T init(); }; -// template specialized static data don't need in llvm.used, -// the static init routine get call from _GLOBAL__sub_I_ routines. template <> int X::ioo = X::init(); template struct X; class a { @@ -87,5 +85,6 @@ struct S1 int foo(); inline int zoo = foo(); inline static int boo = foo(); +inline __declspec(dllexport) A exported_inline{}; -// CHECK: @llvm.used = appending global [8 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" +// CHECK: @llvm.used = appending global [10 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?ioo@?$X@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?exported_inline@@3UA@@A", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Adjust resource binding diagnostic flags code (PR #106657)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-hip-vega20` running on `hip-vega20-0` while building `clang` at step 3 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/4830 Here is the relevant piece of the build log for the reference ``` Step 3 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure) ... [38/40] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 -DNDEBUG External/HIP/CMakeFiles/memmove-hip-6.0.2.dir/memmove.hip.o -o External/HIP/memmove-hip-6.0.2 --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt -unwindlib=libgcc -frtlib-add-rpath && cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /usr/local/bin/cmake -E create_symlink /buildbot/llvm-test-suite/External/HIP/memmove.reference_output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/memmove.reference_output-hip-6.0.2 [39/40] /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -DNDEBUG -O3 -DNDEBUG -w -Werror=date-time --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --offload-arch=gfx908 --offload-arch=gfx90a --offload-arch=gfx1030 --offload-arch=gfx1100 -xhip -mfma -MD -MT External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o -MF External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o.d -o External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o -c /buildbot/llvm-test-suite/External/HIP/workload/ray-tracing/TheNextWeek/main.cc [40/40] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 -DNDEBUG External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o -o External/HIP/TheNextWeek-hip-6.0.2 --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt -unwindlib=libgcc -frtlib-add-rpath && cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /usr/local/bin/cmake -E create_symlink /buildbot/llvm-test-suite/External/HIP/TheNextWeek.reference_output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/TheNextWeek.reference_output-hip-6.0.2 + build_step 'Testing HIP test-suite' + echo '@@@BUILD_STEP Testing HIP test-suite@@@' @@@BUILD_STEP Testing HIP test-suite@@@ + ninja -v check-hip-simple [0/1] cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test memmove-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test blender.test -- Testing: 7 tests, 7 workers -- Testing: 0.. 10.. 20.. 30.. 40 FAIL: test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test (4 of 7) TEST 'test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test' FAILED /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/timeit-target --timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 --limit-rss-size 838860800 --append-exitstatus --redirect-output /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out --redirect-input /dev/null --summary /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.time /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend-hip-6.0.2 cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP ; /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out InOneWeekend.reference_output-hip-6.0.2 + cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP + /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out InOneWeekend.reference_output-hip-6.0.2 /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target: Comparison failed, textual difference between 'M' and 'i' /usr/bin/strip: /bin/bash.stripped: Bad file descriptor Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Failed Tests (1): test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test Testing Time: 346.50s Total Discovered Tests: 7 Passed: 6 (85.71%) Failed: 1 (14.29%) FAILED: External/HIP/CMakeFiles/check-hip-simple-hip-6.0.2 cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test memmove-hip-6.0.2.test InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Reid Kleckner (rnk) Changes Follow-up to c19f4f8069722f6804086d4438a0254104242c46 to handle corner case of exported inline variables. Should fix #56485 --- Full diff: https://github.com/llvm/llvm-project/pull/107154.diff 2 Files Affected: - (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+1-1) - (modified) clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp (+2-3) ``diff diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 2f56355cff90ec..c9e0fb0d8afaba 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -586,7 +586,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, PrioritizedCXXGlobalInits.size()); PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn)); } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || - getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR || + !isUniqueGVALinkage(getContext().GetGVALinkageForVariable(D)) || D->hasAttr()) { // C++ [basic.start.init]p2: // Definitions of explicitly specialized class template static data diff --git a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp index 60b48abca2f89a..871551240debfd 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp @@ -49,8 +49,6 @@ struct X { static T ioo; static T init(); }; -// template specialized static data don't need in llvm.used, -// the static init routine get call from _GLOBAL__sub_I_ routines. template <> int X::ioo = X::init(); template struct X; class a { @@ -87,5 +85,6 @@ struct S1 int foo(); inline int zoo = foo(); inline static int boo = foo(); +inline __declspec(dllexport) A exported_inline{}; -// CHECK: @llvm.used = appending global [8 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" +// CHECK: @llvm.used = appending global [10 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?ioo@?$X@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?exported_inline@@3UA@@A", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" `` https://github.com/llvm/llvm-project/pull/107154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -18695,6 +18695,50 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getSaturateIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.saturate"); } + case Builtin::BI__builtin_hlsl_select: { +Value *OpCond = EmitScalarExpr(E->getArg(0)); +Value *OpTrue = EmitScalarExpr(E->getArg(1)); +Value *OpFalse = EmitScalarExpr(E->getArg(2)); +llvm::Type *TCond = OpCond->getType(); + +// if cond is a bool emit a select instruction +if (TCond->isIntegerTy(1)) + return Builder.CreateSelect(OpCond, OpTrue, OpFalse, "hlsl.select"); + +// if cond is a vector of bools lower to a shufflevector +// todo check if that true and false are vectors spall wrote: I likely just forgot to remove them; because yes they were for my own bookkeeping. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -18695,6 +18695,50 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getSaturateIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.saturate"); } + case Builtin::BI__builtin_hlsl_select: { +Value *OpCond = EmitScalarExpr(E->getArg(0)); +Value *OpTrue = EmitScalarExpr(E->getArg(1)); +Value *OpFalse = EmitScalarExpr(E->getArg(2)); +llvm::Type *TCond = OpCond->getType(); + +// if cond is a bool emit a select instruction +if (TCond->isIntegerTy(1)) + return Builder.CreateSelect(OpCond, OpTrue, OpFalse, "hlsl.select"); + +// if cond is a vector of bools lower to a shufflevector +// todo check if that true and false are vectors coopp wrote: Very cool.. I do the same. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1545,6 +1605,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } case Builtin::BI__builtin_hlsl_elementwise_saturate: + case Builtin::BI__builtin_hlsl_select: { bharadwajy wrote: This addition splits the existing common case code for `BI__builtin_hlsl_elemetwise_saturate` and `BI__builtin_hlsl_elemetwise_rcp` - and would result in incorrect behavior for `BI__builtin_hlsl_elemetwise_saturate`. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b2dabd2 - [Sema] Fix warnings
Author: Kazu Hirata Date: 2024-09-03T14:31:11-07:00 New Revision: b2dabd2b06cb0ca5ea534bafe33c5cff5521be18 URL: https://github.com/llvm/llvm-project/commit/b2dabd2b06cb0ca5ea534bafe33c5cff5521be18 DIFF: https://github.com/llvm/llvm-project/commit/b2dabd2b06cb0ca5ea534bafe33c5cff5521be18.diff LOG: [Sema] Fix warnings This patch fixes: clang/lib/Sema/SemaHLSL.cpp:838:12: error: unused variable 'TheVarDecl' [-Werror,-Wunused-variable] clang/lib/Sema/SemaHLSL.cpp:840:19: error: unused variable 'CBufferOrTBuffer' [-Werror,-Wunused-variable] Added: Modified: clang/lib/Sema/SemaHLSL.cpp Removed: diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 05d2bdf8a57a27..778d524a005482 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -843,6 +843,8 @@ static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc, assert(((TheVarDecl && !CBufferOrTBuffer) || (!TheVarDecl && CBufferOrTBuffer)) && "either TheVarDecl or CBufferOrTBuffer should be set"); + (void)TheVarDecl; + (void)CBufferOrTBuffer; RegisterBindingFlags Flags = HLSLFillRegisterBindingFlags(S, TheDecl); assert((int)Flags.Other + (int)Flags.Resource + (int)Flags.Basic + ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Introduce -defer-thinlto-prelink-coro-split that skips Coro passes in ThinLTO pre-link pipeline (PR #107153)
apolloww wrote: > What's the scenario in which we do ThinLTO prelink and then go to codegen > (i.e. skip thinlto post-link)? In #104525, one use case is that pre-link output was used directly by `llc`. I think it's hard to control where it's going to be used due to this is a split phase workflow, so guarding it with a flag may be a better approach when user knows what to expect. https://github.com/llvm/llvm-project/pull/107153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr, return false; } +static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) { philnik777 wrote: Would it make sense to split this into (1) a diagnostic about a name being reserved and (2) a diagnostic about a name being reserved in a future standard? https://github.com/llvm/llvm-project/pull/106036 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Adjust modulemap to mark mm3dnow as textual header. (PR #107155)
https://github.com/jyknight created https://github.com/llvm/llvm-project/pull/107155 This avoids issuing the deprecation diagnostic when building the module. Not building it into a module shouldn't cause any negative impacts, since it no longer has any declarations other than the header guard. It's also very rarely included by anything. Addresses https://github.com/llvm/llvm-project/pull/96246#issuecomment-2322453809 >From 861906e432651966238ea764f5a3ac61f0d55c0a Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 3 Sep 2024 17:03:49 -0400 Subject: [PATCH] Adjust modulemap to mark mm3dnow as textual header. This avoids issuing the deprecation diagnostic when building the module. Not building it into a module shouldn't cause any negative impacts, since it no longer has any declarations other than the header guard. It's also very rarely included by anything. Addresses https://github.com/llvm/llvm-project/pull/96246#issuecomment-2322453809 --- clang/lib/Headers/module.modulemap | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index 9ffc249c8d1a23..dcaf09e8f2c558 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/lib/Headers/module.modulemap @@ -66,6 +66,8 @@ module _Builtin_intrinsics [system] [extern_c] { textual header "__wmmintrin_aes.h" textual header "__wmmintrin_pclmul.h" +textual header "mm3dnow.h" + explicit module mm_malloc { requires !freestanding header "mm_malloc.h" @@ -122,10 +124,6 @@ module _Builtin_intrinsics [system] [extern_c] { header "popcntintrin.h" } -explicit module mm3dnow { - header "mm3dnow.h" -} - explicit module aes_pclmul { header "wmmintrin.h" export aes ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Adjust modulemap to mark mm3dnow as textual header. (PR #107155)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: James Y Knight (jyknight) Changes This avoids issuing the deprecation diagnostic when building the module. Not building it into a module shouldn't cause any negative impacts, since it no longer has any declarations other than the header guard. It's also very rarely included by anything. Addresses https://github.com/llvm/llvm-project/pull/96246#issuecomment-2322453809 --- Full diff: https://github.com/llvm/llvm-project/pull/107155.diff 1 Files Affected: - (modified) clang/lib/Headers/module.modulemap (+2-4) ``diff diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index 9ffc249c8d1a23..dcaf09e8f2c558 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/lib/Headers/module.modulemap @@ -66,6 +66,8 @@ module _Builtin_intrinsics [system] [extern_c] { textual header "__wmmintrin_aes.h" textual header "__wmmintrin_pclmul.h" +textual header "mm3dnow.h" + explicit module mm_malloc { requires !freestanding header "mm_malloc.h" @@ -122,10 +124,6 @@ module _Builtin_intrinsics [system] [extern_c] { header "popcntintrin.h" } -explicit module mm3dnow { - header "mm3dnow.h" -} - explicit module aes_pclmul { header "wmmintrin.h" export aes `` https://github.com/llvm/llvm-project/pull/107155 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Adjust modulemap to mark mm3dnow as textual header. (PR #107155)
ian-twilightcoder wrote: Does anything rely on the header guard? It would be good if we could remove it since textual headers are not generally expected to declare anything, even macros. https://github.com/llvm/llvm-project/pull/107155 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Fix type for atomic float incdec operators (PR #107075)
https://github.com/RKSimon approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/107075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Adjust resource binding diagnostic flags code (PR #106657)
kazutakahirata wrote: I've fixed the warnings from this PR with b2dabd2b06cb0ca5ea534bafe33c5cff5521be18. Now, I'm not familiar with the code here, but is it still important to do the consistency check on these two variables if you don't use them in `DiagnoseHLSLRegisterAttribute` at all other than in the `assert`? If not, you might want to just remove the block of code. Thanks! ``` // Samplers, UAVs, and SRVs are VarDecl types VarDecl *TheVarDecl = dyn_cast(TheDecl); // Cbuffers and Tbuffers are HLSLBufferDecl types HLSLBufferDecl *CBufferOrTBuffer = dyn_cast(TheDecl); // exactly one of these two types should be set assert(((TheVarDecl && !CBufferOrTBuffer) || (!TheVarDecl && CBufferOrTBuffer)) && "either TheVarDecl or CBufferOrTBuffer should be set"); (void)TheVarDecl; (void)CBufferOrTBuffer;``` https://github.com/llvm/llvm-project/pull/106657 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
https://github.com/spall updated https://github.com/llvm/llvm-project/pull/107129 >From 3e0cd3c450eb4aa28742c4879733987e9e2692e7 Mon Sep 17 00:00:00 2001 From: Sarah Spall Date: Wed, 28 Aug 2024 01:44:35 + Subject: [PATCH 1/4] implement select intrinsic --- clang/include/clang/Basic/Builtins.td| 6 ++ clang/lib/CodeGen/CGBuiltin.cpp | 41 clang/lib/Headers/hlsl/hlsl_intrinsics.h | 24 +++ clang/lib/Sema/SemaHLSL.cpp | 84 4 files changed, 155 insertions(+) diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 8668b25661dec8..7e89f84319877b 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -4751,6 +4751,12 @@ def HLSLSaturate : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } +def HLSLSelect : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_select"]; + let Attributes = [NoThrow, Const]; + let Prototype = "void(...)"; +} + // Builtins for XRay. def XRayCustomEvent : Builtin { let Spellings = ["__xray_customevent"]; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index e4d169d2ad6030..7fe198c207ce22 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18695,6 +18695,47 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getSaturateIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.saturate"); } + case Builtin::BI__builtin_hlsl_select: { +Value *OpCond = EmitScalarExpr(E->getArg(0)); +Value *OpTrue = EmitScalarExpr(E->getArg(1)); +Value *OpFalse = EmitScalarExpr(E->getArg(2)); +llvm::Type *TCond = OpCond->getType(); + +// if cond is a bool emit a select instruction +if (TCond->isIntegerTy(1)) + return Builder.CreateSelect(OpCond, OpTrue, OpFalse); + +// if cond is a vector of bools lower to a shufflevector +// todo check if that true and false are vectors +// todo check that the size of true and false and cond are the same +if (TCond->isVectorTy() && + E->getArg(0)->getType()->getAs()->isBooleanType()) { + assert(OpTrue->getType()->isVectorTy() && OpFalse->getType()->isVectorTy() && +"Select's second and third operands must be vectors if first operand is a vector."); + + auto *VecTyTrue = E->getArg(1)->getType()->getAs(); + auto *VecTyFalse = E->getArg(2)->getType()->getAs(); + + assert(VecTyTrue->getElementType() == VecTyFalse->getElementType() && +"Select's second and third vectors need the same element types."); + + const unsigned N = VecTyTrue->getNumElements(); + assert(N == VecTyFalse->getNumElements() && +N == E->getArg(0)->getType()->getAs()->getNumElements() && +"Select requires vectors to be of the same size."); + + llvm::SmallVector Mask; + for (unsigned I = 0; I < N; I++) { + Value *Index = ConstantInt::get(IntTy, I); + Value *IndexBool = Builder.CreateExtractElement(OpCond, Index); + Mask.push_back(Builder.CreateSelect(IndexBool, Index, ConstantInt::get(IntTy, I + N))); + } + + return Builder.CreateShuffleVector(OpTrue, OpFalse, BuildVector(Mask)); +} + +llvm_unreachable("Select requires a bool or vector of bools as its first operand."); + } case Builtin::BI__builtin_hlsl_wave_get_lane_index: { return EmitRuntimeCall(CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, {}, false), "__hlsl_wave_get_lane_index", diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h index 6d38b668fe770e..4319d9775c4bae 100644 --- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -1603,6 +1603,30 @@ double3 saturate(double3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate) double4 saturate(double4); +//===--===// +// select builtins +//===--===// + +/// \fn T select(bool Cond, T TrueVal, T FalseVal) +/// \brief ternary operator. +/// \param Cond The Condition input value. +/// \param TrueVal The Value returned if Cond is true. +/// \param FalseVal The Value returned if Cond is false. + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) +template +T select(bool, T, T); + +/// \fn vector select(vector Conds, vector TrueVals, vector, FalseVals) +/// \brief ternary operator for vectors. All vectors must be the same size. +/// \param Conds The Condition input values. +/// \param TrueVals The vector values are chosen from when conditions are true. +/// \param FalseVals The vector values are chosen from when conditions are false. + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) +template +vector select(vector, vector, vector); + //===
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1545,6 +1605,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { break; } case Builtin::BI__builtin_hlsl_elementwise_saturate: coopp wrote: Sounds good. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] set alwaysinline on HLSL functions (PR #106588)
@@ -290,8 +290,6 @@ struct BuiltinTypeDeclBuilder { SourceLocation())); MethodDecl->setLexicalDeclContext(Record); MethodDecl->setAccess(AccessSpecifier::AS_public); -MethodDecl->addAttr(AlwaysInlineAttr::CreateImplicit( -AST, SourceRange(), AlwaysInlineAttr::CXX11_clang_always_inline)); llvm-beanz wrote: We don't really have a workflow in Clang implemented yet for separate compilation. The analog in DXC would be something like `-T lib_6_x -default-linkage=external`. In that case we would still want these functions to be inlined, and we can accomplish that with this attribute. https://github.com/llvm/llvm-project/pull/106588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer] Model overflow builtins (PR #102602)
https://github.com/pskrgag updated https://github.com/llvm/llvm-project/pull/102602 >From 7b4f999b39f4308cab253204e6be41ea7a70f695 Mon Sep 17 00:00:00 2001 From: Pavel Skripkin Date: Fri, 9 Aug 2024 14:37:47 +0300 Subject: [PATCH 1/9] clang/csa: add initial support for builtin overflow --- .../Checkers/BuiltinFunctionChecker.cpp | 124 +- clang/test/Analysis/builtin_overflow.c| 65 + .../test/Analysis/out-of-bounds-diagnostics.c | 17 +++ 3 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 clang/test/Analysis/builtin_overflow.c diff --git a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp index b198b1c2ff4d11..0c8b9fa3d947b0 100644 --- a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp @@ -21,16 +21,67 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h" #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" using namespace clang; using namespace ento; namespace { +QualType getOverflowBuiltinResultType(const CallEvent &Call) { + assert(Call.getNumArgs() == 3); + + return Call.getArgExpr(2)->getType()->getPointeeType(); +} + +QualType getOverflowBuiltinResultType(const CallEvent &Call, CheckerContext &C, + unsigned BI) { + assert(Call.getNumArgs() == 3); + + ASTContext &Ast = C.getASTContext(); + + switch (BI) { + case Builtin::BI__builtin_smul_overflow: + case Builtin::BI__builtin_ssub_overflow: + case Builtin::BI__builtin_sadd_overflow: +return Ast.IntTy; + case Builtin::BI__builtin_smull_overflow: + case Builtin::BI__builtin_ssubl_overflow: + case Builtin::BI__builtin_saddl_overflow: +return Ast.LongTy; + case Builtin::BI__builtin_smulll_overflow: + case Builtin::BI__builtin_ssubll_overflow: + case Builtin::BI__builtin_saddll_overflow: +return Ast.LongLongTy; + case Builtin::BI__builtin_umul_overflow: + case Builtin::BI__builtin_usub_overflow: + case Builtin::BI__builtin_uadd_overflow: +return Ast.UnsignedIntTy; + case Builtin::BI__builtin_umull_overflow: + case Builtin::BI__builtin_usubl_overflow: + case Builtin::BI__builtin_uaddl_overflow: +return Ast.UnsignedLongTy; + case Builtin::BI__builtin_umulll_overflow: + case Builtin::BI__builtin_usubll_overflow: + case Builtin::BI__builtin_uaddll_overflow: +return Ast.UnsignedLongLongTy; + case Builtin::BI__builtin_mul_overflow: + case Builtin::BI__builtin_sub_overflow: + case Builtin::BI__builtin_add_overflow: +return getOverflowBuiltinResultType(Call); + default: +assert(false && "Unknown overflow builtin"); + } +} + class BuiltinFunctionChecker : public Checker { public: bool evalCall(const CallEvent &Call, CheckerContext &C) const; + void HandleOverflowBuiltin(const CallEvent &Call, CheckerContext &C, + BinaryOperator::Opcode Op, + QualType ResultType) const; private: // From: clang/include/clang/Basic/Builtins.def @@ -50,6 +101,44 @@ class BuiltinFunctionChecker : public Checker { } // namespace +void BuiltinFunctionChecker::HandleOverflowBuiltin(const CallEvent &Call, + CheckerContext &C, + BinaryOperator::Opcode Op, + QualType ResultType) const { + // All __builtin_*_overflow functions take 3 argumets. + assert(Call.getNumArgs() == 3); + + ProgramStateRef State = C.getState(); + SValBuilder &SVB = C.getSValBuilder(); + const Expr *CE = Call.getOriginExpr(); + + SVal Arg1 = Call.getArgSVal(0); + SVal Arg2 = Call.getArgSVal(1); + + SVal RetVal = SVB.evalBinOp(State, Op, Arg1, Arg2, ResultType); + + // TODO: Handle overflows with values that known to overflow. Like INT_MAX + 1 + // should not produce state for non-overflow case and threat it as + // unreachable. + + // Handle non-overflow case. + { +ProgramStateRef StateSuccess = +State->BindExpr(CE, C.getLocationContext(), SVB.makeTruthVal(false)); + +if (auto L = Call.getArgSVal(2).getAs()) + StateSuccess = StateSuccess->bindLoc(*L, RetVal, C.getLocationContext()); + +C.addTransition(StateSuccess); + } + + // Handle overflow case. + { +C.addTransition( +State->BindExpr(CE, C.getLocationContext(), SVB.makeTruthVal(true))); + } +} + bool BuiltinFunctionChecker::isBuiltinLikeFunction( const CallEvent &Call) const { const auto *FD = llvm::dyn_cast_or_null(Call.getDecl()); @@ -82,10 +171,41 @@ bool BuiltinFunctionChe
[clang] [analyzer] Model overflow builtins (PR #102602)
@@ -50,6 +118,75 @@ class BuiltinFunctionChecker : public Checker { } // namespace +std::pair +BuiltinFunctionChecker::checkOverflow(CheckerContext &C, SVal RetVal, + QualType Res) const { + ProgramStateRef State = C.getState(); + SValBuilder &SVB = C.getSValBuilder(); + ASTContext &ACtx = C.getASTContext(); + + // Calling a builtin with a non-integer type result produces compiler error. + assert(Res->isIntegerType()); + + unsigned BitWidth = ACtx.getIntWidth(Res); + auto MinVal = + llvm::APSInt::getMinValue(BitWidth, Res->isUnsignedIntegerType()); + auto MaxVal = + llvm::APSInt::getMaxValue(BitWidth, Res->isUnsignedIntegerType()); + + SVal IsLeMax = + SVB.evalBinOp(State, BO_LE, RetVal, nonloc::ConcreteInt(MaxVal), Res); + SVal IsGeMin = + SVB.evalBinOp(State, BO_GE, RetVal, nonloc::ConcreteInt(MinVal), Res); + + auto [MayNotOverflow, MayOverflow] = + State->assume(IsLeMax.castAs()); + auto [MayNotUnderflow, MayUnderflow] = + State->assume(IsGeMin.castAs()); + + return {MayOverflow || MayUnderflow, MayNotOverflow && MayNotUnderflow}; +} + +void BuiltinFunctionChecker::handleOverflowBuiltin(const CallEvent &Call, + CheckerContext &C, + BinaryOperator::Opcode Op, + QualType ResultType) const { + // Calling a builtin with an incorrect argument count produces compiler error. + assert(Call.getNumArgs() == 3); + + ProgramStateRef State = C.getState(); + SValBuilder &SVB = C.getSValBuilder(); + const Expr *CE = Call.getOriginExpr(); + + SVal Arg1 = Call.getArgSVal(0); + SVal Arg2 = Call.getArgSVal(1); + + SVal RetValMax = SVB.evalBinOp(State, Op, Arg1, Arg2, + getSufficientTypeForOverflowOp(C, ResultType)); + SVal RetVal = SVB.evalBinOp(State, Op, Arg1, Arg2, ResultType); + + auto [Overflow, NotOverflow] = checkOverflow(C, RetValMax, ResultType); + if (NotOverflow) { +ProgramStateRef StateNoOverflow = +State->BindExpr(CE, C.getLocationContext(), SVB.makeTruthVal(false)); + +if (auto L = Call.getArgSVal(2).getAs()) { + StateNoOverflow = + StateNoOverflow->bindLoc(*L, RetVal, C.getLocationContext()); + + // Propagate taint if any of the argumets were tainted + if (isTainted(State, Arg1) || isTainted(State, Arg2)) +StateNoOverflow = addTaint(StateNoOverflow, *L); +} + +C.addTransition(StateNoOverflow); pskrgag wrote: Added notes for overflow case with prunable flag in the latest version, thanks! https://github.com/llvm/llvm-project/pull/102602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
https://github.com/spall updated https://github.com/llvm/llvm-project/pull/107129 >From 3e0cd3c450eb4aa28742c4879733987e9e2692e7 Mon Sep 17 00:00:00 2001 From: Sarah Spall Date: Wed, 28 Aug 2024 01:44:35 + Subject: [PATCH 1/5] implement select intrinsic --- clang/include/clang/Basic/Builtins.td| 6 ++ clang/lib/CodeGen/CGBuiltin.cpp | 41 clang/lib/Headers/hlsl/hlsl_intrinsics.h | 24 +++ clang/lib/Sema/SemaHLSL.cpp | 84 4 files changed, 155 insertions(+) diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 8668b25661dec8..7e89f84319877b 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -4751,6 +4751,12 @@ def HLSLSaturate : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } +def HLSLSelect : LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_select"]; + let Attributes = [NoThrow, Const]; + let Prototype = "void(...)"; +} + // Builtins for XRay. def XRayCustomEvent : Builtin { let Spellings = ["__xray_customevent"]; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index e4d169d2ad6030..7fe198c207ce22 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18695,6 +18695,47 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getSaturateIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.saturate"); } + case Builtin::BI__builtin_hlsl_select: { +Value *OpCond = EmitScalarExpr(E->getArg(0)); +Value *OpTrue = EmitScalarExpr(E->getArg(1)); +Value *OpFalse = EmitScalarExpr(E->getArg(2)); +llvm::Type *TCond = OpCond->getType(); + +// if cond is a bool emit a select instruction +if (TCond->isIntegerTy(1)) + return Builder.CreateSelect(OpCond, OpTrue, OpFalse); + +// if cond is a vector of bools lower to a shufflevector +// todo check if that true and false are vectors +// todo check that the size of true and false and cond are the same +if (TCond->isVectorTy() && + E->getArg(0)->getType()->getAs()->isBooleanType()) { + assert(OpTrue->getType()->isVectorTy() && OpFalse->getType()->isVectorTy() && +"Select's second and third operands must be vectors if first operand is a vector."); + + auto *VecTyTrue = E->getArg(1)->getType()->getAs(); + auto *VecTyFalse = E->getArg(2)->getType()->getAs(); + + assert(VecTyTrue->getElementType() == VecTyFalse->getElementType() && +"Select's second and third vectors need the same element types."); + + const unsigned N = VecTyTrue->getNumElements(); + assert(N == VecTyFalse->getNumElements() && +N == E->getArg(0)->getType()->getAs()->getNumElements() && +"Select requires vectors to be of the same size."); + + llvm::SmallVector Mask; + for (unsigned I = 0; I < N; I++) { + Value *Index = ConstantInt::get(IntTy, I); + Value *IndexBool = Builder.CreateExtractElement(OpCond, Index); + Mask.push_back(Builder.CreateSelect(IndexBool, Index, ConstantInt::get(IntTy, I + N))); + } + + return Builder.CreateShuffleVector(OpTrue, OpFalse, BuildVector(Mask)); +} + +llvm_unreachable("Select requires a bool or vector of bools as its first operand."); + } case Builtin::BI__builtin_hlsl_wave_get_lane_index: { return EmitRuntimeCall(CGM.CreateRuntimeFunction( llvm::FunctionType::get(IntTy, {}, false), "__hlsl_wave_get_lane_index", diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h index 6d38b668fe770e..4319d9775c4bae 100644 --- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -1603,6 +1603,30 @@ double3 saturate(double3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate) double4 saturate(double4); +//===--===// +// select builtins +//===--===// + +/// \fn T select(bool Cond, T TrueVal, T FalseVal) +/// \brief ternary operator. +/// \param Cond The Condition input value. +/// \param TrueVal The Value returned if Cond is true. +/// \param FalseVal The Value returned if Cond is false. + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) +template +T select(bool, T, T); + +/// \fn vector select(vector Conds, vector TrueVals, vector, FalseVals) +/// \brief ternary operator for vectors. All vectors must be the same size. +/// \param Conds The Condition input values. +/// \param TrueVals The vector values are chosen from when conditions are true. +/// \param FalseVals The vector values are chosen from when conditions are false. + +_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select) +template +vector select(vector, vector, vector); + //===
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
efriedma-quic wrote: What's the interaction here with the standard's ordering guarantees? The comment in the code indicates that we can't make a separate comdat for ordered initialization... but inline variables do require partial ordering. Please update the comment as appropriate. https://github.com/llvm/llvm-project/pull/107154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclc] [llvm] [libclc] More cross compilation fixes (PR #97811)
hvdijk wrote: Both buildbot failures appear to be unrelated to this PR: neither fails in libclc, the first has resolved itself and passes in later attempts, the second looks like the builder has just run out of disk space. If I am wrong and there is something I should look into please let me know, otherwise I will leave it. https://github.com/llvm/llvm-project/pull/97811 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee Message-ID: In-Reply-To: dmpolukhin wrote: > Got it. I am pretty interested use case for modules. And from your commit > history, it looks like you prefer header units than named modules? Yes, we prefer header units for the time being because it can be implemented with minimal sources changes and gives moderate compile time improvements. Also it should open future path to named modules. Also with header units we have some flexibility how to compose modules. In our experiments build time perforce significantly depends on number of modules required for compilation number of AST nodes that are merged. https://github.com/llvm/llvm-project/pull/104512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
https://github.com/coopp approved this pull request. This looks good to me. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC) (PR #107158)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107158 I'm planning to deprecate DenseMap::FindAndConstruct in favor of DenseMap::operator[]. >From e64e76f869af9d37625979dca68e1ee4f76b5bbc Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 3 Sep 2024 15:00:28 -0700 Subject: [PATCH] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC) I'm planning to deprecate DenseMap::FindAndConstruct in favor of DenseMap::operator[]. --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 21 +++-- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 34120486996fb1..23b977be816025 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1149,10 +1149,8 @@ void CGOpenMPRuntime::emitUserDefinedReduction( /*IsCombiner=*/false); } UDRMap.try_emplace(D, Combiner, Initializer); - if (CGF) { -auto &Decls = FunctionUDRMap.FindAndConstruct(CGF->CurFn); -Decls.second.push_back(D); - } + if (CGF) +FunctionUDRMap[CGF->CurFn].push_back(D); } std::pair @@ -1432,10 +1430,8 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF, ThreadID = CGF.EmitLoadOfScalar(LVal, Loc); // If value loaded in entry block, cache it and use it everywhere in // function. -if (CGF.Builder.GetInsertBlock() == TopBlock) { - auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn); - Elem.second.ThreadID = ThreadID; -} +if (CGF.Builder.GetInsertBlock() == TopBlock) + OpenMPLocThreadIDMap[CGF.CurFn].ThreadID = ThreadID; return ThreadID; } } @@ -8640,8 +8636,7 @@ class MappableExprsHandler { const MapData &BaseData = CI == CE ? L : L1; OMPClauseMappableExprCommon::MappableExprComponentListRef SubData = SI == SE ? Components : Components1; - auto &OverlappedElements = OverlappedData.FindAndConstruct(&BaseData); - OverlappedElements.getSecond().push_back(SubData); + OverlappedData[&BaseData].push_back(SubData); } } } @@ -9316,10 +9311,8 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D, MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true); MapperCGF.FinishFunction(); UDMMap.try_emplace(D, Fn); - if (CGF) { -auto &Decls = FunctionUDMMap.FindAndConstruct(CGF->CurFn); -Decls.second.push_back(D); - } + if (CGF) +FunctionUDMMap[CGF->CurFn].push_back(D); } /// Emit the array initialization or deletion portion for user-defined mapper ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC) (PR #107158)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) Changes I'm planning to deprecate DenseMap::FindAndConstruct in favor of DenseMap::operator[]. --- Full diff: https://github.com/llvm/llvm-project/pull/107158.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+7-14) ``diff diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 34120486996fb1..23b977be816025 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1149,10 +1149,8 @@ void CGOpenMPRuntime::emitUserDefinedReduction( /*IsCombiner=*/false); } UDRMap.try_emplace(D, Combiner, Initializer); - if (CGF) { -auto &Decls = FunctionUDRMap.FindAndConstruct(CGF->CurFn); -Decls.second.push_back(D); - } + if (CGF) +FunctionUDRMap[CGF->CurFn].push_back(D); } std::pair @@ -1432,10 +1430,8 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF, ThreadID = CGF.EmitLoadOfScalar(LVal, Loc); // If value loaded in entry block, cache it and use it everywhere in // function. -if (CGF.Builder.GetInsertBlock() == TopBlock) { - auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn); - Elem.second.ThreadID = ThreadID; -} +if (CGF.Builder.GetInsertBlock() == TopBlock) + OpenMPLocThreadIDMap[CGF.CurFn].ThreadID = ThreadID; return ThreadID; } } @@ -8640,8 +8636,7 @@ class MappableExprsHandler { const MapData &BaseData = CI == CE ? L : L1; OMPClauseMappableExprCommon::MappableExprComponentListRef SubData = SI == SE ? Components : Components1; - auto &OverlappedElements = OverlappedData.FindAndConstruct(&BaseData); - OverlappedElements.getSecond().push_back(SubData); + OverlappedData[&BaseData].push_back(SubData); } } } @@ -9316,10 +9311,8 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D, MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true); MapperCGF.FinishFunction(); UDMMap.try_emplace(D, Fn); - if (CGF) { -auto &Decls = FunctionUDMMap.FindAndConstruct(CGF->CurFn); -Decls.second.push_back(D); - } + if (CGF) +FunctionUDMMap[CGF->CurFn].push_back(D); } /// Emit the array initialization or deletion portion for user-defined mapper `` https://github.com/llvm/llvm-project/pull/107158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC) (PR #107158)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Kazu Hirata (kazutakahirata) Changes I'm planning to deprecate DenseMap::FindAndConstruct in favor of DenseMap::operator[]. --- Full diff: https://github.com/llvm/llvm-project/pull/107158.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+7-14) ``diff diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 34120486996fb1..23b977be816025 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1149,10 +1149,8 @@ void CGOpenMPRuntime::emitUserDefinedReduction( /*IsCombiner=*/false); } UDRMap.try_emplace(D, Combiner, Initializer); - if (CGF) { -auto &Decls = FunctionUDRMap.FindAndConstruct(CGF->CurFn); -Decls.second.push_back(D); - } + if (CGF) +FunctionUDRMap[CGF->CurFn].push_back(D); } std::pair @@ -1432,10 +1430,8 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF, ThreadID = CGF.EmitLoadOfScalar(LVal, Loc); // If value loaded in entry block, cache it and use it everywhere in // function. -if (CGF.Builder.GetInsertBlock() == TopBlock) { - auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn); - Elem.second.ThreadID = ThreadID; -} +if (CGF.Builder.GetInsertBlock() == TopBlock) + OpenMPLocThreadIDMap[CGF.CurFn].ThreadID = ThreadID; return ThreadID; } } @@ -8640,8 +8636,7 @@ class MappableExprsHandler { const MapData &BaseData = CI == CE ? L : L1; OMPClauseMappableExprCommon::MappableExprComponentListRef SubData = SI == SE ? Components : Components1; - auto &OverlappedElements = OverlappedData.FindAndConstruct(&BaseData); - OverlappedElements.getSecond().push_back(SubData); + OverlappedData[&BaseData].push_back(SubData); } } } @@ -9316,10 +9311,8 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D, MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true); MapperCGF.FinishFunction(); UDMMap.try_emplace(D, Fn); - if (CGF) { -auto &Decls = FunctionUDMMap.FindAndConstruct(CGF->CurFn); -Decls.second.push_back(D); - } + if (CGF) +FunctionUDMMap[CGF->CurFn].push_back(D); } /// Emit the array initialization or deletion portion for user-defined mapper `` https://github.com/llvm/llvm-project/pull/107158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC) (PR #107158)
https://github.com/alexey-bataev approved this pull request. https://github.com/llvm/llvm-project/pull/107158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][C23] Support N3029 Improved Normal Enumerations (PR #103917)
@@ -19553,17 +19555,18 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, // If we're not in C++, diagnose the overflow of enumerator values, // which in C99 means that the enumerator value is not representable in -// an int (C99 6.7.2.2p2). However, we support GCC's extension that -// permits enumerator values that are representable in some larger -// integral type. -if (!getLangOpts().CPlusPlus && !T.isNull()) +// an int (C99 6.7.2.2p2). However C23 permits enumerator values that +// are representable in some larger integral type and we allow it in +// older language modes as an extension. +if (!getLangOpts().CPlusPlus && !getLangOpts().C23 && !T.isNull()) Diag(IdLoc, diag::warn_enum_value_overflow); efriedma-quic wrote: Should warn_enum_value_overflow also be updated to mention C23? https://github.com/llvm/llvm-project/pull/103917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota created https://github.com/llvm/llvm-project/pull/107160 Fixes #104861 >From 337a9ed1d5e7c71fb5be5741afe7726f5b76af7b Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Tue, 3 Sep 2024 15:30:50 -0700 Subject: [PATCH] [HLSL] Apply resource attributes to the resource type rather than the handle member (#6) --- clang/include/clang/AST/TypeLoc.h | 8 + clang/include/clang/Basic/Attr.td | 6 +- .../clang/Basic/DiagnosticSemaKinds.td| 1 + clang/include/clang/Sema/SemaHLSL.h | 21 ++- clang/lib/AST/TypePrinter.cpp | 9 +- clang/lib/CodeGen/CGHLSLRuntime.cpp | 10 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 25 ++- clang/lib/Sema/SemaDeclAttr.cpp | 6 - clang/lib/Sema/SemaHLSL.cpp | 177 -- clang/lib/Sema/TreeTransform.h| 22 ++- clang/test/AST/HLSL/RWBuffer-AST.hlsl | 10 +- ...a-attribute-supported-attributes-list.test | 2 - clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl | 17 +- .../ParserHLSL/hlsl_is_rov_attr_error.hlsl| 21 ++- .../ParserHLSL/hlsl_resource_class_attr.hlsl | 48 ++--- .../hlsl_resource_class_attr_error.hlsl | 29 +-- .../hlsl_resource_handle_attrs.hlsl | 17 +- .../SemaHLSL/resource_binding_attr_error.hlsl | 2 +- .../resource_binding_attr_error_resource.hlsl | 10 +- .../resource_binding_attr_error_udt.hlsl | 10 +- 20 files changed, 284 insertions(+), 167 deletions(-) diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 5db39eb3aefa74..03fbdcf60140df 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -951,12 +951,20 @@ class HLSLAttributedResourceTypeLoc HLSLAttributedResourceLocInfo> { public: TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); } + + TypeLoc getContainedLoc() const { +return TypeLoc(getTypePtr()->getContainedType(), getNonLocalData()); + } + void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; } SourceRange getLocalSourceRange() const { return getLocalData()->Range; } void initializeLocal(ASTContext &Context, SourceLocation loc) { setSourceRange(SourceRange()); } QualType getInnerType() const { return getTypePtr()->getWrappedType(); } + unsigned getLocalDataSize() const { +return sizeof(HLSLAttributedResourceLocInfo); + } }; struct ObjCObjectTypeLocInfo { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 8d2a362abc3c32..0c98f8e25a6fbb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4643,16 +4643,14 @@ def HLSLResource : InheritableAttr { let Documentation = [InternalOnly]; } -def HLSLROV : InheritableAttr { +def HLSLROV : TypeAttr { let Spellings = [CXX11<"hlsl", "is_rov">]; - let Subjects = SubjectList<[Struct]>; let LangOpts = [HLSL]; let Documentation = [InternalOnly]; } -def HLSLResourceClass : InheritableAttr { +def HLSLResourceClass : TypeAttr { let Spellings = [CXX11<"hlsl", "resource_class">]; - let Subjects = SubjectList<[Field]>; let LangOpts = [HLSL]; let Args = [ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index dcb49d8a67604a..4f522f68f080aa 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12364,6 +12364,7 @@ def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross regi def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match alignment %0 required by %1">; def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupported in HLSL">; +def err_missing_resource_class : Error<"HLSL resource needs to have [[hlsl::resource_class()]] attribute">; def err_hlsl_operator_unsupported : Error< "the '%select{&|*|->}0' operator is unsupported in HLSL">; diff --git a/clang/include/clang/Sema/SemaHLSL.h b/clang/include/clang/Sema/SemaHLSL.h index d79ca9a4fa18d1..5131458863e20b 100644 --- a/clang/include/clang/Sema/SemaHLSL.h +++ b/clang/include/clang/Sema/SemaHLSL.h @@ -15,8 +15,11 @@ #include "clang/AST/ASTFwd.h" #include "clang/AST/Attr.h" +#include "clang/AST/Type.h" +#include "clang/AST/TypeLoc.h" #include "clang/Basic/SourceLocation.h" #include "clang/Sema/SemaBase.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/TargetParser/Triple.h" #include @@ -59,8 +62,6 @@ class SemaHLSL : public SemaBase { void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL); void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL); void handleShaderAttr(Decl *D, const ParsedAttr &AL); - void handleROVAttr(Decl *D, const ParsedAttr &AL); - void handleResourceClassAttr(
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 18cf14efe3e82b2343817fd174bcac48244c8f50 337a9ed1d5e7c71fb5be5741afe7726f5b76af7b --extensions h,cpp -- clang/include/clang/AST/TypeLoc.h clang/include/clang/Sema/SemaHLSL.h clang/lib/AST/TypePrinter.cpp clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/Sema/HLSLExternalSemaSource.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaHLSL.cpp clang/lib/Sema/TreeTransform.h `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Sema/SemaHLSL.h b/clang/include/clang/Sema/SemaHLSL.h index 5131458863..29480d8f3e 100644 --- a/clang/include/clang/Sema/SemaHLSL.h +++ b/clang/include/clang/Sema/SemaHLSL.h @@ -89,9 +89,10 @@ public: private: // HLSL resource type attributes need to be processed all at once. // This is a list to collect them. - llvm::SmallVector HLSLResourcesTypeAttrs; + llvm::SmallVector HLSLResourcesTypeAttrs; - /// SourceRanges corresponding to HLSLAttributedResourceTypeLocs that we have not yet populated. + /// SourceRanges corresponding to HLSLAttributedResourceTypeLocs that we have + /// not yet populated. llvm::DenseMap LocsForHLSLAttributedResources; }; diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp index 0716406933..37d24eefb5 100644 --- a/clang/lib/Sema/HLSLExternalSemaSource.cpp +++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp @@ -124,13 +124,13 @@ struct BuiltinTypeDeclBuilder { // add handle member with resource type attributes QualType AttributedResTy = QualType(); -SmallVector Attrs = { - HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC), - IsROV ? HLSLROVAttr::CreateImplicit(Record->getASTContext()) : nullptr -}; +SmallVector Attrs = { +HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC), +IsROV ? HLSLROVAttr::CreateImplicit(Record->getASTContext()) : nullptr}; Attr *ResourceAttr = HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK); -if (SemaHLSL::CreateHLSLAttributedResourceType(S, Ty, Attrs, AttributedResTy)) { +if (SemaHLSL::CreateHLSLAttributedResourceType(S, Ty, Attrs, + AttributedResTy)) { addMemberVariable("h", AttributedResTy, {ResourceAttr}, Access); } return *this; diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 69f4382e46..e2ec89ef6e 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -562,7 +562,9 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -bool SemaHLSL::CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, llvm::SmallVector &AttrList, QualType &ResType) { +bool SemaHLSL::CreateHLSLAttributedResourceType( +Sema &S, QualType Wrapped, llvm::SmallVector &AttrList, +QualType &ResType) { assert(AttrList.size() && "expected list of resource attributes"); QualType Contained = QualType(); @@ -574,7 +576,8 @@ bool SemaHLSL::CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, llvm: continue; switch (Attr->getKind()) { case attr::HLSLResourceClass: { - llvm::dxil::ResourceClass RC = dyn_cast(Attr)->getResourceClass(); + llvm::dxil::ResourceClass RC = + dyn_cast(Attr)->getResourceClass(); if (!hasResourceClass) { ResAttrs.ResourceClass = RC; hasResourceClass = true; @@ -593,11 +596,13 @@ bool SemaHLSL::CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, llvm: } if (!hasResourceClass) { -S.Diag(AttrList.back()->getRange().getEnd(), diag::err_missing_resource_class); +S.Diag(AttrList.back()->getRange().getEnd(), + diag::err_missing_resource_class); return false; } - ResType = S.getASTContext().getHLSLAttributedResourceType(Wrapped, Contained, ResAttrs); + ResType = S.getASTContext().getHLSLAttributedResourceType(Wrapped, Contained, +ResAttrs); return true; } @@ -651,8 +656,10 @@ QualType SemaHLSL::ProcessResourceTypeAttributes(QualType CurrentType) { return CurrentType; QualType QT = CurrentType; - if (CreateHLSLAttributedResourceType(SemaRef, CurrentType, HLSLResourcesTypeAttrs, QT)) { -const HLSLAttributedResourceType *RT = dyn_cast(QT.getTypePtr()); + if (CreateHLSLAttributedResourceType(SemaRef, CurrentType, + HLSLResourcesTypeAttrs, QT)) { +const HLSLAttributedResourceType *RT = +dyn_cast(QT.getTypePtr()); SourceLocation Loc = HLSLResourcesTypeAttrs[0]->getLoc(); LocsForHLSLAttributedResources.insert(std::pair(RT, Loc)); } @@ -726,7 +733,8 @@ static void updateResourc
[clang] [flang] Allow disabling of types from the command line (PR #107126)
https://github.com/Renaud-K updated https://github.com/llvm/llvm-project/pull/107126 >From 8a1c51bdd290fc47cac359646aeb01623574231f Mon Sep 17 00:00:00 2001 From: Renaud-K Date: Tue, 3 Sep 2024 09:34:09 -0700 Subject: [PATCH 1/3] Allow disabling of types from the command line --- clang/include/clang/Driver/Options.td| 6 ++ flang/include/flang/Frontend/TargetOptions.h | 6 ++ flang/include/flang/Tools/TargetSetup.h | 11 ++- flang/lib/Frontend/CompilerInvocation.cpp| 17 ++--- flang/tools/bbc/bbc.cpp | 5 +++-- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 83cf753e824845..8bc47fea5196e7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6761,6 +6761,12 @@ def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group, HelpText<"Set the default integer and logical kind to an 8 byte wide type">; def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group, HelpText<"Set the default real kind to an 8 byte wide type">; +def fdisable_real_3 : Flag<["-"],"fdisable-real-3">, Group, + Flags<[HelpHidden]>; +def fdisable_real_10 : Flag<["-"],"fdisable-real-10">, Group, + Flags<[HelpHidden]>; +def fdisable_integer_16 : Flag<["-"],"fdisable-integer-16">, Group, + Flags<[HelpHidden]>; def flarge_sizes : Flag<["-"],"flarge-sizes">, Group, HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">; diff --git a/flang/include/flang/Frontend/TargetOptions.h b/flang/include/flang/Frontend/TargetOptions.h index fa72c77a028a1c..b0b64ae583d16c 100644 --- a/flang/include/flang/Frontend/TargetOptions.h +++ b/flang/include/flang/Frontend/TargetOptions.h @@ -38,6 +38,12 @@ class TargetOptions { /// The list of target specific features to enable or disable, as written on /// the command line. std::vector featuresAsWritten; + + /// The real KINDs disabled for this target + std::vector disabledRealKinds; + + /// The integer KINDs disabled for this target + std::vector disabledIntegerKinds; }; } // end namespace Fortran::frontend diff --git a/flang/include/flang/Tools/TargetSetup.h b/flang/include/flang/Tools/TargetSetup.h index 238d66c9241dd0..b112b6b4d80578 100644 --- a/flang/include/flang/Tools/TargetSetup.h +++ b/flang/include/flang/Tools/TargetSetup.h @@ -10,6 +10,7 @@ #define FORTRAN_TOOLS_TARGET_SETUP_H #include "flang/Evaluate/target.h" +#include "flang/Frontend/TargetOptions.h" #include "llvm/Target/TargetMachine.h" namespace Fortran::tools { @@ -17,6 +18,7 @@ namespace Fortran::tools { [[maybe_unused]] inline static void setUpTargetCharacteristics( Fortran::evaluate::TargetCharacteristics &targetCharacteristics, const llvm::TargetMachine &targetMachine, +const Fortran::frontend::TargetOptions &targetOptions, const std::string &compilerVersion, const std::string &compilerOptions) { const llvm::Triple &targetTriple{targetMachine.getTargetTriple()}; @@ -24,7 +26,14 @@ namespace Fortran::tools { if (targetTriple.getArch() != llvm::Triple::ArchType::x86_64) targetCharacteristics.DisableType( Fortran::common::TypeCategory::Real, /*kind=*/10); - + for (auto realKind : targetOptions.disabledRealKinds) { +targetCharacteristics.DisableType( +common::TypeCategory::Real, realKind); + } + for (auto intKind : targetOptions.disabledIntegerKinds) { +targetCharacteristics.DisableType( +common::TypeCategory::Integer, intKind); + } targetCharacteristics.set_compilerOptionsString(compilerOptions) .set_compilerVersionString(compilerVersion); diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 1d73397d330178..5676947c2b1016 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -438,8 +438,19 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) { for (const llvm::opt::Arg *currentArg : args.filtered(clang::driver::options::OPT_target_feature)) opts.featuresAsWritten.emplace_back(currentArg->getValue()); -} + if (args.hasArg(clang::driver::options::OPT_fdisable_real_10)) { +opts.disabledRealKinds.push_back(10); + } + + if (args.hasArg(clang::driver::options::OPT_fdisable_real_3)) { +opts.disabledRealKinds.push_back(3); + } + + if (args.hasArg(clang::driver::options::OPT_fdisable_integer_16)) { +opts.disabledIntegerKinds.push_back(16); + } +} // Tweak the frontend configuration based on the frontend action static void setUpFrontendBasedOnAction(FrontendOptions &opts) { if (opts.programAction == DebugDumpParsingLog) @@ -1529,8 +1540,8 @@ CompilerInvocation::getSemanticsCtx( std::string compilerVersion = Fortran::common::getFlangFullVersion(); Fortran::tools::setUpTargetCharacteristics( - semantic
[clang] [clang, hexagon] Update copyright, license text (PR #107161)
https://github.com/androm3da created https://github.com/llvm/llvm-project/pull/107161 When this file was first contributed - `28b01c59c93d ([hexagon] Add {hvx,}hexagon_{protos,circ_brev...}, 2021-06-30)` - I incorrectly included a QuIC copyright statement with "All rights reserved". I should have contributed this file with the `Apache+LLVM exception` license. >From b4705aa71a261e58930f08056d1fd79c6537a50d Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 3 Sep 2024 15:37:08 -0700 Subject: [PATCH] [clang, hexagon] Update copyright, license text When this file was first contributed - `28b01c59c93d ([hexagon] Add {hvx,}hexagon_{protos,circ_brev...}, 2021-06-30)` - I incorrectly included a QuIC copyright statement with "All rights reserved". I should have contributed this file with the `Apache+LLVM exception` license. --- clang/lib/Headers/hexagon_types.h | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/lib/Headers/hexagon_types.h b/clang/lib/Headers/hexagon_types.h index 029727cc48176b..8e73fad4bcd424 100644 --- a/clang/lib/Headers/hexagon_types.h +++ b/clang/lib/Headers/hexagon_types.h @@ -1,7 +1,11 @@ -/**/ -/* (c) 2020 Qualcomm Innovation Center, Inc. All rights reserved. */ -/* */ -/**/ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + #ifndef HEXAGON_TYPES_H #define HEXAGON_TYPES_H ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang, hexagon] Update copyright, license text (PR #107161)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Brian Cain (androm3da) Changes When this file was first contributed - `28b01c59c93d ([hexagon] Add {hvx,}hexagon_{protos,circ_brev...}, 2021-06-30)` - I incorrectly included a QuIC copyright statement with "All rights reserved". I should have contributed this file with the `Apache+LLVM exception` license. --- Full diff: https://github.com/llvm/llvm-project/pull/107161.diff 1 Files Affected: - (modified) clang/lib/Headers/hexagon_types.h (+8-4) ``diff diff --git a/clang/lib/Headers/hexagon_types.h b/clang/lib/Headers/hexagon_types.h index 029727cc48176b..8e73fad4bcd424 100644 --- a/clang/lib/Headers/hexagon_types.h +++ b/clang/lib/Headers/hexagon_types.h @@ -1,7 +1,11 @@ -/**/ -/* (c) 2020 Qualcomm Innovation Center, Inc. All rights reserved. */ -/* */ -/**/ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + #ifndef HEXAGON_TYPES_H #define HEXAGON_TYPES_H `` https://github.com/llvm/llvm-project/pull/107161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang, hexagon] Update copyright, license text (PR #107161)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Brian Cain (androm3da) Changes When this file was first contributed - `28b01c59c93d ([hexagon] Add {hvx,}hexagon_{protos,circ_brev...}, 2021-06-30)` - I incorrectly included a QuIC copyright statement with "All rights reserved". I should have contributed this file with the `Apache+LLVM exception` license. --- Full diff: https://github.com/llvm/llvm-project/pull/107161.diff 1 Files Affected: - (modified) clang/lib/Headers/hexagon_types.h (+8-4) ``diff diff --git a/clang/lib/Headers/hexagon_types.h b/clang/lib/Headers/hexagon_types.h index 029727cc48176b..8e73fad4bcd424 100644 --- a/clang/lib/Headers/hexagon_types.h +++ b/clang/lib/Headers/hexagon_types.h @@ -1,7 +1,11 @@ -/**/ -/* (c) 2020 Qualcomm Innovation Center, Inc. All rights reserved. */ -/* */ -/**/ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + #ifndef HEXAGON_TYPES_H #define HEXAGON_TYPES_H `` https://github.com/llvm/llvm-project/pull/107161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang, hexagon] Update copyright, license text (PR #107161)
androm3da wrote: Note that this was the only source file from the original commit without the correct header. https://github.com/llvm/llvm-project/pull/107161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -0,0 +1,76 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK + +// CHECK: %hlsl.select = select i1 +// CHECK: ret i32 %hlsl.select +int test_select_bool_int(bool cond0, int tVal, int fVal) { return select(cond0, tVal, fVal); } damyanp wrote: nit: https://llvm.org/docs/CodingStandards.html#source-code-width these would be easier to read in the github PR UI if it were formatted to 80 columns. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1544,6 +1604,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_select: { damyanp wrote: This implementation has quite a different shape to the other builtins in this function. I'm trying to figure out if there's something special about `select` that makes this necessary, or if this validation can be expressed using the existing CheckXXX functions in here. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -0,0 +1,90 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected + +int test_no_arg() { + return select(); + // expected-error@-1 {{no matching function for call to 'select'}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 0 were provided}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 0 were provided}} +} + +int test_too_few_args(bool p0) { + return select(p0); + // expected-error@-1 {{no matching function for call to 'select'}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 1 was provided}} +} + +int test_too_many_args(bool p0, int t0, int f0, int g0) { + return select(p0, t0, f0, g0); + // expected-error@-1 {{no matching function for call to 'select'}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires 3 arguments, but 4 were provided}} +} + +int test_select_first_arg_wrong_type(vector p0, int t0, int f0) { + return select(p0, t0, f0); + // expected-error@-1 {{no matching function for call to 'select'}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: no known conversion from 'vector' (vector of 1 'int' value) to 'bool' for 1st argument}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector' against 'int'}} +} + +vector test_select_bool_vals_diff_vecs(bool p0, vector t0, vector f0) { + return select >(p0, t0, f0); + // expected-warning@-1 {{implicit conversion truncates vector: 'vector' (vector of 2 'int' values) to 'vector' (vector of 1 'int' value)}} +} + +vector test_select_vector_vals_not_vecs(vector p0, int t0, int f0) { + return select(p0, t0, f0); + // expected-error@-1 {{no matching function for call to 'select'}} + // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could not match 'vector' against 'int'}} damyanp wrote: I'm looking at some of these errors here and wondering if you've managed to actually exercise all of the diagnostics emitted from SemaHLSL? I think that most of these diagnostics are actually caught by standard C++ rules for function lookup. I wonder if some tests that directly call `__builtin_hlsl_select` with invalid parameters are really required here to have complete coverage? https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1544,6 +1604,30 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_select: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; +QualType ArgTy = TheCall->getArg(0)->getType(); +if (ArgTy->isBooleanType()) { + if (CheckBoolSelect(&SemaRef, TheCall)) + return true; +} else if (ArgTy->isVectorType() && + ArgTy->getAs()->getElementType()->isBooleanType()) { + if (CheckVectorSelect(&SemaRef, TheCall)) + return true; +} else { // first operand is not a bool or a vector of bools. + SemaRef.Diag(TheCall->getArg(0)->getBeginLoc(), + diag::err_typecheck_convert_incompatible) + << TheCall->getArg(0)->getType() << getASTContext().BoolTy + << 1 << 0 << 0; + SemaRef.Diag(TheCall->getArg(0)->getBeginLoc(), + diag::err_builtin_non_vector_type) + << "First" << "__builtin_hlsl_select" << TheCall->getArg(0)->getType() + << TheCall->getArg(0)->getSourceRange(); + return true; damyanp wrote: Wondering why this case doesn't also use a helper function and instead inlines the detection and diagnostic code here. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -1512,6 +1512,66 @@ void SetElementTypeAsReturnType(Sema *S, CallExpr *TheCall, TheCall->setType(ReturnType); } +bool CheckBoolSelect(Sema *S, CallExpr *TheCall) { damyanp wrote: nit: it'd be good for these helpers that are only used from this cpp file to be marked as static. (I see that the ones above are not marked as static...I'd be tempted to fix them as well in another PR). https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
rnk wrote: I think there is no change here in our conformance on inline variable initialization order, except that non-discardable inline variables (achieved in this instance with dllexport, but perhaps there are other ways to do this. The classic case is explicit instantiation, which is unordered) are now treated the same as regular inline variables. My reading of the code is that we are currently technically non-conforming. There is some back and forth on whether this is good or bad elsewhere in the issue tracker, but I'd have to dig it up. https://github.com/llvm/llvm-project/pull/107154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt][rtsan] Introduce rtsan_interface.h and ScopedDisabler (PR #106736)
cjappl wrote: Just saw the test failure, but it is unrelated: ``` _bk;t=1725300551284FAIL: lld :: ELF/avr-reloc.s (84796 of 87084) _bk;t=1725300551284 TEST 'lld :: ELF/avr-reloc.s' FAILED ``` https://github.com/llvm/llvm-project/pull/106736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
efriedma-quic wrote: If there isn't a way to emit conforming code, then I think it's fine to emit non-conforming code, as long as there's an appropriate comment. Breaking the ABI is clearly worse. Does this impact non-MS targets? https://github.com/llvm/llvm-project/pull/107154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/107160 >From 337a9ed1d5e7c71fb5be5741afe7726f5b76af7b Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Tue, 3 Sep 2024 15:30:50 -0700 Subject: [PATCH 1/2] [HLSL] Apply resource attributes to the resource type rather than the handle member (#6) --- clang/include/clang/AST/TypeLoc.h | 8 + clang/include/clang/Basic/Attr.td | 6 +- .../clang/Basic/DiagnosticSemaKinds.td| 1 + clang/include/clang/Sema/SemaHLSL.h | 21 ++- clang/lib/AST/TypePrinter.cpp | 9 +- clang/lib/CodeGen/CGHLSLRuntime.cpp | 10 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 25 ++- clang/lib/Sema/SemaDeclAttr.cpp | 6 - clang/lib/Sema/SemaHLSL.cpp | 177 -- clang/lib/Sema/TreeTransform.h| 22 ++- clang/test/AST/HLSL/RWBuffer-AST.hlsl | 10 +- ...a-attribute-supported-attributes-list.test | 2 - clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl | 17 +- .../ParserHLSL/hlsl_is_rov_attr_error.hlsl| 21 ++- .../ParserHLSL/hlsl_resource_class_attr.hlsl | 48 ++--- .../hlsl_resource_class_attr_error.hlsl | 29 +-- .../hlsl_resource_handle_attrs.hlsl | 17 +- .../SemaHLSL/resource_binding_attr_error.hlsl | 2 +- .../resource_binding_attr_error_resource.hlsl | 10 +- .../resource_binding_attr_error_udt.hlsl | 10 +- 20 files changed, 284 insertions(+), 167 deletions(-) diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 5db39eb3aefa74..03fbdcf60140df 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -951,12 +951,20 @@ class HLSLAttributedResourceTypeLoc HLSLAttributedResourceLocInfo> { public: TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); } + + TypeLoc getContainedLoc() const { +return TypeLoc(getTypePtr()->getContainedType(), getNonLocalData()); + } + void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; } SourceRange getLocalSourceRange() const { return getLocalData()->Range; } void initializeLocal(ASTContext &Context, SourceLocation loc) { setSourceRange(SourceRange()); } QualType getInnerType() const { return getTypePtr()->getWrappedType(); } + unsigned getLocalDataSize() const { +return sizeof(HLSLAttributedResourceLocInfo); + } }; struct ObjCObjectTypeLocInfo { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 8d2a362abc3c32..0c98f8e25a6fbb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4643,16 +4643,14 @@ def HLSLResource : InheritableAttr { let Documentation = [InternalOnly]; } -def HLSLROV : InheritableAttr { +def HLSLROV : TypeAttr { let Spellings = [CXX11<"hlsl", "is_rov">]; - let Subjects = SubjectList<[Struct]>; let LangOpts = [HLSL]; let Documentation = [InternalOnly]; } -def HLSLResourceClass : InheritableAttr { +def HLSLResourceClass : TypeAttr { let Spellings = [CXX11<"hlsl", "resource_class">]; - let Subjects = SubjectList<[Field]>; let LangOpts = [HLSL]; let Args = [ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index dcb49d8a67604a..4f522f68f080aa 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12364,6 +12364,7 @@ def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross regi def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match alignment %0 required by %1">; def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupported in HLSL">; +def err_missing_resource_class : Error<"HLSL resource needs to have [[hlsl::resource_class()]] attribute">; def err_hlsl_operator_unsupported : Error< "the '%select{&|*|->}0' operator is unsupported in HLSL">; diff --git a/clang/include/clang/Sema/SemaHLSL.h b/clang/include/clang/Sema/SemaHLSL.h index d79ca9a4fa18d1..5131458863e20b 100644 --- a/clang/include/clang/Sema/SemaHLSL.h +++ b/clang/include/clang/Sema/SemaHLSL.h @@ -15,8 +15,11 @@ #include "clang/AST/ASTFwd.h" #include "clang/AST/Attr.h" +#include "clang/AST/Type.h" +#include "clang/AST/TypeLoc.h" #include "clang/Basic/SourceLocation.h" #include "clang/Sema/SemaBase.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/TargetParser/Triple.h" #include @@ -59,8 +62,6 @@ class SemaHLSL : public SemaBase { void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL); void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL); void handleShaderAttr(Decl *D, const ParsedAttr &AL); - void handleROVAttr(Decl *D, const ParsedAttr &AL); - void handleResourceClassAttr(Decl *D, con
[clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] [polly] [NFC] Add explicit #include llvm-config.h where its macros are used. (PR #106810)
https://github.com/dfukalov updated https://github.com/llvm/llvm-project/pull/106810 >From 0221e97459534f0f7396e7970663e1a4f1f98cca Mon Sep 17 00:00:00 2001 From: dfukalov Date: Sat, 31 Aug 2024 01:45:27 +0200 Subject: [PATCH 1/2] [NFC] Add explicit #include llvm-config.h where its macros are used, part 2. Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects. For example, `clagd` may report even `llvm-config.h` as "no used" in case it defines a macro, that is expicitly used with #ifdef. It is actually amplified with different build configs which use different set of macros. --- bolt/include/bolt/Core/BinaryBasicBlock.h | 1 + clang-tools-extra/clangd/Feature.cpp | 1 + clang-tools-extra/clangd/unittests/ClangdTests.cpp| 1 + clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp | 1 + clang-tools-extra/clangd/unittests/SerializationTests.cpp | 1 + clang/include/clang/Interpreter/Value.h | 1 + clang/lib/Driver/ToolChains/Cuda.cpp | 1 + clang/lib/Driver/ToolChains/MinGW.cpp | 1 + clang/lib/Driver/ToolChains/WebAssembly.cpp | 1 + clang/lib/Frontend/FrontendActions.cpp| 1 + clang/tools/driver/driver.cpp | 2 ++ clang/unittests/Driver/GCCVersionTest.cpp | 1 + lld/ELF/OutputSections.cpp| 2 +- lldb/source/API/SBDebugger.cpp| 1 + lldb/source/Host/common/Host.cpp | 1 + .../Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 1 + .../Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 1 + lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 1 + lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 1 + lldb/unittests/Host/MainLoopTest.cpp | 1 + llvm/include/llvm/Debuginfod/HTTPClient.h | 1 + llvm/include/llvm/Debuginfod/HTTPServer.h | 1 + llvm/include/llvm/Support/ErrorHandling.h | 1 + llvm/lib/Analysis/DevelopmentModeInlineAdvisor.cpp| 1 + llvm/lib/Analysis/InlineAdvisor.cpp | 1 + llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp | 1 + llvm/lib/Analysis/ModelUnderTrainingRunner.cpp| 1 + llvm/lib/Analysis/TFLiteUtils.cpp | 1 + llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp | 1 + llvm/lib/CodeGen/MLRegAllocPriorityAdvisor.cpp| 1 + llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 1 + llvm/lib/CodeGen/RegAllocPriorityAdvisor.cpp | 1 + llvm/lib/DebugInfo/PDB/PDB.cpp| 1 + llvm/lib/Debuginfod/HTTPClient.cpp| 1 + llvm/lib/Debuginfod/HTTPServer.cpp| 1 + llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp | 1 + llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderVTune.cpp | 1 + llvm/lib/IR/Core.cpp | 1 + llvm/lib/MC/SPIRVObjectWriter.cpp | 1 + llvm/lib/Support/CRC.cpp | 1 + llvm/lib/Support/Compression.cpp | 1 + llvm/lib/Support/Z3Solver.cpp | 1 + llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 1 + llvm/lib/TargetParser/Unix/Host.inc | 1 + llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp| 1 + llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp| 1 + .../Analysis/InlineAdvisorPlugin/InlineAdvisorPlugin.cpp | 4 ++-- .../Analysis/InlineOrderPlugin/InlineOrderPlugin.cpp | 4 ++-- llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp | 1 + llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp | 1 + llvm/unittests/Debuginfod/HTTPServerTests.cpp | 1 + llvm/unittests/Passes/Plugins/PluginsTest.cpp | 1 + llvm/unittests/Support/CompressionTest.cpp| 1 + llvm/unittests/TargetParser/Host.cpp | 2 +- llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp| 1 + mlir/include/mlir/Bytecode/BytecodeWriter.h | 1 + mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp| 1 + mlir/unittests/Target/LLVM/SerializeNVVMTarget.cpp| 1 + polly/lib/Support/RegisterPasses.cpp | 1 + 59 files changed, 62 insertions(+), 6 deletions(-) diff --git a/bolt/include/bolt/Core/BinaryBasicBlock.h b/bolt/include/bolt/Core/BinaryBasicBlock.h index 9a9d7b8735d714..b4f31cf2bae6f6 100644 --- a/bolt/include/bolt/Core/BinaryBasicBlock.h +++
[clang] [llvm] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/104544 >From 6d5f8991a4ef9e79bc1bed30addf7b29b7ed0d2e Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Thu, 15 Aug 2024 19:03:29 -0700 Subject: [PATCH 01/12] Implement `__builtin_is_intangible` --- clang/include/clang/Basic/TokenKinds.def | 3 ++ clang/include/clang/Sema/SemaHLSL.h | 3 ++ clang/lib/Sema/SemaExprCXX.cpp | 8 clang/lib/Sema/SemaHLSL.cpp | 49 4 files changed, 63 insertions(+) diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index d683106bb0e298..f4fc7c321d9c5a 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -660,6 +660,9 @@ KEYWORD(out , KEYHLSL) #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) KEYWORD(Name, KEYHLSL) #include "clang/Basic/HLSLIntangibleTypes.def" +// HLSL Type traits +TYPE_TRAIT_1(__builtin_is_intangible, IsIntangibleType, KEYHLSL) + // OpenMP Type Traits UNARY_EXPR_OR_TYPE_TRAIT(__builtin_omp_required_simd_align, OpenMPRequiredSimdAlign, KEYALL) diff --git a/clang/include/clang/Sema/SemaHLSL.h b/clang/include/clang/Sema/SemaHLSL.h index d60cb2a57d4918..13e75a79ec6bf0 100644 --- a/clang/include/clang/Sema/SemaHLSL.h +++ b/clang/include/clang/Sema/SemaHLSL.h @@ -62,6 +62,9 @@ class SemaHLSL : public SemaBase { void handleParamModifierAttr(Decl *D, const ParsedAttr &AL); bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + + // HLSL Type trait implementations + bool IsIntangibleType(QualType T1) const; }; } // namespace clang diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 5356bcf172f752..f3f8d511a6e568 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -39,6 +39,7 @@ #include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" #include "clang/Sema/SemaCUDA.h" +#include "clang/Sema/SemaHLSL.h" #include "clang/Sema/SemaInternal.h" #include "clang/Sema/SemaLambda.h" #include "clang/Sema/SemaObjC.h" @@ -5683,6 +5684,13 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return true; return false; } + case UTT_IsIntangibleType: +if (!T->isVoidType() && !T->isIncompleteArrayType()) + if (Self.RequireCompleteType(TInfo->getTypeLoc().getBeginLoc(), T, + diag::err_incomplete_type)) +return true; +DiagnoseVLAInCXXTypeTrait(Self, TInfo, tok::kw___builtin_is_intangible); +return Self.HLSL().IsIntangibleType(T); } } diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index e3e926465e799e..5978c14399ba32 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -12,6 +12,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/Type.h" #include "clang/Basic/DiagnosticSema.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/TargetInfo.h" @@ -1154,3 +1155,51 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +bool SemaHLSL::IsIntangibleType(QualType Ty) const { + if (Ty.isNull()) +return false; + + Ty = Ty.getCanonicalType().getUnqualifiedType(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSpecificType(); + + llvm::SmallVector TypesToScan; + TypesToScan.push_back(Ty); + while (!TypesToScan.empty()) { +QualType T = TypesToScan.pop_back_val(); +assert(T == T.getCanonicalType().getUnqualifiedType() && "expected sugar-free type"); +assert(!isa(T) && "Matrix types not yet supported in HLSL"); + +if (const auto *AT = dyn_cast(T)) { + QualType ElTy = AT->getElementType().getCanonicalType().getUnqualifiedType(); + if (ElTy->isBuiltinType()) +return ElTy->isHLSLSpecificType(); + TypesToScan.push_back(ElTy); + continue; +} + +if (const auto *VT = dyn_cast(T)) { + QualType ElTy = VT->getElementType().getCanonicalType().getUnqualifiedType(); + assert(ElTy->isBuiltinType() && "vectors can only contain builtin types"); + if (ElTy->isHLSLSpecificType()) +return true; + continue; +} + +if (const auto *RT = dyn_cast(T)) { + const RecordDecl *RD = RT->getDecl(); + for (const auto *FD : RD->fields()) { +QualType FieldTy = FD->getType().getCanonicalType().getUnqualifiedType(); +if (FieldTy->isBuiltinType()) { + if (FieldTy->isHLSLSpecificType()) +return true; +} else { + TypesToScan.push_back(FieldTy); +} + } + continue; +} + } + return false; +} >From d21ca2e2891acbd6c89864b57d864d881a8a8b96 Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Thu, 15 Aug 2024 20:52:24 -0700 Subject: [PATCH 02/12] add caching --- clang/include/clang/Sema/SemaHLSL.h | 5 +++
[clang] [llvm] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/104544 >From 6d5f8991a4ef9e79bc1bed30addf7b29b7ed0d2e Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Thu, 15 Aug 2024 19:03:29 -0700 Subject: [PATCH 01/12] Implement `__builtin_is_intangible` --- clang/include/clang/Basic/TokenKinds.def | 3 ++ clang/include/clang/Sema/SemaHLSL.h | 3 ++ clang/lib/Sema/SemaExprCXX.cpp | 8 clang/lib/Sema/SemaHLSL.cpp | 49 4 files changed, 63 insertions(+) diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index d683106bb0e298..f4fc7c321d9c5a 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -660,6 +660,9 @@ KEYWORD(out , KEYHLSL) #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) KEYWORD(Name, KEYHLSL) #include "clang/Basic/HLSLIntangibleTypes.def" +// HLSL Type traits +TYPE_TRAIT_1(__builtin_is_intangible, IsIntangibleType, KEYHLSL) + // OpenMP Type Traits UNARY_EXPR_OR_TYPE_TRAIT(__builtin_omp_required_simd_align, OpenMPRequiredSimdAlign, KEYALL) diff --git a/clang/include/clang/Sema/SemaHLSL.h b/clang/include/clang/Sema/SemaHLSL.h index d60cb2a57d4918..13e75a79ec6bf0 100644 --- a/clang/include/clang/Sema/SemaHLSL.h +++ b/clang/include/clang/Sema/SemaHLSL.h @@ -62,6 +62,9 @@ class SemaHLSL : public SemaBase { void handleParamModifierAttr(Decl *D, const ParsedAttr &AL); bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + + // HLSL Type trait implementations + bool IsIntangibleType(QualType T1) const; }; } // namespace clang diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 5356bcf172f752..f3f8d511a6e568 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -39,6 +39,7 @@ #include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" #include "clang/Sema/SemaCUDA.h" +#include "clang/Sema/SemaHLSL.h" #include "clang/Sema/SemaInternal.h" #include "clang/Sema/SemaLambda.h" #include "clang/Sema/SemaObjC.h" @@ -5683,6 +5684,13 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return true; return false; } + case UTT_IsIntangibleType: +if (!T->isVoidType() && !T->isIncompleteArrayType()) + if (Self.RequireCompleteType(TInfo->getTypeLoc().getBeginLoc(), T, + diag::err_incomplete_type)) +return true; +DiagnoseVLAInCXXTypeTrait(Self, TInfo, tok::kw___builtin_is_intangible); +return Self.HLSL().IsIntangibleType(T); } } diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index e3e926465e799e..5978c14399ba32 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -12,6 +12,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/Type.h" #include "clang/Basic/DiagnosticSema.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/TargetInfo.h" @@ -1154,3 +1155,51 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +bool SemaHLSL::IsIntangibleType(QualType Ty) const { + if (Ty.isNull()) +return false; + + Ty = Ty.getCanonicalType().getUnqualifiedType(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSpecificType(); + + llvm::SmallVector TypesToScan; + TypesToScan.push_back(Ty); + while (!TypesToScan.empty()) { +QualType T = TypesToScan.pop_back_val(); +assert(T == T.getCanonicalType().getUnqualifiedType() && "expected sugar-free type"); +assert(!isa(T) && "Matrix types not yet supported in HLSL"); + +if (const auto *AT = dyn_cast(T)) { + QualType ElTy = AT->getElementType().getCanonicalType().getUnqualifiedType(); + if (ElTy->isBuiltinType()) +return ElTy->isHLSLSpecificType(); + TypesToScan.push_back(ElTy); + continue; +} + +if (const auto *VT = dyn_cast(T)) { + QualType ElTy = VT->getElementType().getCanonicalType().getUnqualifiedType(); + assert(ElTy->isBuiltinType() && "vectors can only contain builtin types"); + if (ElTy->isHLSLSpecificType()) +return true; + continue; +} + +if (const auto *RT = dyn_cast(T)) { + const RecordDecl *RD = RT->getDecl(); + for (const auto *FD : RD->fields()) { +QualType FieldTy = FD->getType().getCanonicalType().getUnqualifiedType(); +if (FieldTy->isBuiltinType()) { + if (FieldTy->isHLSLSpecificType()) +return true; +} else { + TypesToScan.push_back(FieldTy); +} + } + continue; +} + } + return false; +} >From d21ca2e2891acbd6c89864b57d864d881a8a8b96 Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Thu, 15 Aug 2024 20:52:24 -0700 Subject: [PATCH 02/12] add caching --- clang/include/clang/Sema/SemaHLSL.h | 5 +++
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
https://github.com/damyanp edited https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/76838 >From 7cc2e01a4a272934861e0d36791985e9604d9794 Mon Sep 17 00:00:00 2001 From: prabhukr Date: Mon, 4 Dec 2023 08:54:14 -0800 Subject: [PATCH] [UEFI] X86_64 UEFI Clang Driver Introduce changes necessary for UEFI X86_64 target Clang driver. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D159541 --- clang/lib/Basic/Targets.cpp | 3 + clang/lib/Basic/Targets/OSTargets.h | 15 clang/lib/Basic/Targets/X86.h | 37 ++ clang/lib/Driver/CMakeLists.txt | 1 + clang/lib/Driver/Driver.cpp | 4 ++ clang/lib/Driver/ToolChains/UEFI.cpp | 88 +++ clang/lib/Driver/ToolChains/UEFI.h| 61 clang/test/CodeGen/target-data.c | 4 ++ clang/test/Driver/uefi-constructed-args.c | 13 clang/test/Driver/uefi-data-layout.c | 3 + clang/unittests/Driver/ToolChainTest.cpp | 21 ++ 11 files changed, 250 insertions(+) create mode 100644 clang/lib/Driver/ToolChains/UEFI.cpp create mode 100644 clang/lib/Driver/ToolChains/UEFI.h create mode 100644 clang/test/Driver/uefi-constructed-args.c create mode 100644 clang/test/Driver/uefi-data-layout.c diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 0b8e565345b6a4..4917ef015941be 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -613,6 +613,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, case llvm::Triple::Solaris: return std::make_unique>(Triple, Opts); +case llvm::Triple::UEFI: + return std::make_unique(Triple, Opts); + case llvm::Triple::Win32: { switch (Triple.getEnvironment()) { case llvm::Triple::Cygnus: diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 0a4f06967fff5a..a83d6464e789d6 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -778,6 +778,21 @@ class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo { } }; +// UEFI target +template +class LLVM_LIBRARY_VISIBILITY UEFITargetInfo : public OSTargetInfo { +protected: + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, +MacroBuilder &Builder) const override {} + +public: + UEFITargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : OSTargetInfo(Triple, Opts) { +this->WCharType = TargetInfo::UnsignedShort; +this->WIntType = TargetInfo::UnsignedShort; + } +}; + void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts, MacroBuilder &Builder); diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 79fd5867cf6673..a99ae62984c7d5 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -814,6 +814,43 @@ class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo { } }; +// x86-64 UEFI target +class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo +: public UEFITargetInfo { +public: + UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : UEFITargetInfo(Triple, Opts) { +this->TheCXXABI.set(TargetCXXABI::Microsoft); +this->MaxTLSAlign = 8192u * this->getCharWidth(); +this->resetDataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-" + "i64:64-i128:128-f80:128-n8:16:32:64-S128"); + } + + void getTargetDefines(const LangOptions &Opts, +MacroBuilder &Builder) const override { +getOSDefines(Opts, X86TargetInfo::getTriple(), Builder); + } + + BuiltinVaListKind getBuiltinVaListKind() const override { +return TargetInfo::CharPtrBuiltinVaList; + } + + CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { +switch (CC) { +case CC_C: +case CC_Win64: + return CCCR_OK; +default: + return CCCR_Warning; +} + } + + TargetInfo::CallingConvKind + getCallingConvKind(bool ClangABICompat4) const override { +return CCK_MicrosoftWin64; + } +}; + // x86-64 Windows target class LLVM_LIBRARY_VISIBILITY WindowsX86_64TargetInfo : public WindowsTargetInfo { diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 32a4378ab499fa..4fd10bf671512f 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -78,6 +78,7 @@ add_clang_library(clangDriver ToolChains/Solaris.cpp ToolChains/SPIRV.cpp ToolChains/TCE.cpp + ToolChains/UEFI.cpp ToolChains/VEToolchain.cpp ToolChains/WebAssembly.cpp ToolChains/XCore.cpp diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..18d5cef79b05c8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -45,6 +45,7 @@ #include "ToolCha
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -819,6 +819,43 @@ class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo { } }; +// x86-64 UEFI target +class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo +: public UEFITargetInfo { +public: + UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : UEFITargetInfo(Triple, Opts) { Prabhuk wrote: Please see `clang/Driver/unittests/ToolchainTest.cpp` https://github.com/llvm/llvm-project/pull/76838/files#diff-2a39548e3b4a62a12affcb6dbe9e8f563cddc2aa50aa7e24b94a1de0bb91be1eR578 https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr, return false; } +static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) { jwakely wrote: > I think they absolutely should, but those names are not portable to other > compilers. They _should_ be. GCC has always accepted `__attribute__((__foo__))` as well as the `foo` spelling, and uses the same rule for `[[...]]` attributes. I assume Intel compilers do the same for compatibility. Maybe MSVC doesn't? Seems like something they might support if asked to though. https://github.com/llvm/llvm-project/pull/106036 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,92 @@ +//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "UEFI.h" +#include "CommonArgs.h" +#include "Darwin.h" +#include "clang/Basic/CharInfo.h" +#include "clang/Basic/Version.h" +#include "clang/Config/config.h" +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +#include "clang/Driver/Options.h" +#include "clang/Driver/SanitizerArgs.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/VirtualFileSystem.h" +#include "llvm/TargetParser/Host.h" + +using namespace clang::driver; +using namespace clang::driver::toolchains; +using namespace clang; +using namespace llvm::opt; + +UEFI::UEFI(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) +: ToolChain(D, Triple, Args) { + getProgramPaths().push_back(getDriver().getInstalledDir()); + if (getDriver().getInstalledDir() != getDriver().Dir) +getProgramPaths().push_back(getDriver().Dir); +} + +Tool *UEFI::buildLinker() const { return new tools::uefi::Linker(*this); } + +void tools::uefi::Linker::ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, + const InputInfoList &Inputs, + const ArgList &Args, + const char *LinkingOutput) const { + ArgStringList CmdArgs; + auto &TC = static_cast(getToolChain()); + + assert((Output.isFilename() || Output.isNothing()) && "invalid output"); + if (Output.isFilename()) +CmdArgs.push_back( +Args.MakeArgString(std::string("-out:") + Output.getFilename())); + + CmdArgs.push_back("-nologo"); + + // TODO: Other UEFI binary subsystems that are currently unsupported: + // efi_boot_service_driver, efi_rom, efi_runtime_driver. + CmdArgs.push_back("-subsystem:efi_application"); + + // Default entry function name according to the TianoCore reference + // implementation is EfiMain. + // TODO: Provide a flag to override the entry function name. + CmdArgs.push_back("-entry:EfiMain"); + + // "Terminal Service Aware" flag is not needed for UEFI applications. + CmdArgs.push_back("-tsaware:no"); + + // EFI_APPLICATION to be linked as DLL by default. + CmdArgs.push_back("-dll"); + + if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7)) +CmdArgs.push_back("-debug"); + + Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link); + + AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA); + + // This should ideally be handled by ToolChain::GetLinkerPath but we need + // to special case some linker paths. In the case of lld, we need to + // translate 'lld' into 'lld-link'. + StringRef Linker = + Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER); + if (Linker.empty() || Linker.equals("lld")) Prabhuk wrote: Done. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [lldb] [llvm] Rename Sanitizer Coverage => Coverage Sanitizer (PR #106505)
https://github.com/medismailben approved this pull request. LGTM for lldb's part https://github.com/llvm/llvm-project/pull/106505 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,92 @@ +//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "UEFI.h" +#include "CommonArgs.h" +#include "Darwin.h" +#include "clang/Basic/CharInfo.h" +#include "clang/Basic/Version.h" +#include "clang/Config/config.h" +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +#include "clang/Driver/Options.h" +#include "clang/Driver/SanitizerArgs.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/VirtualFileSystem.h" +#include "llvm/TargetParser/Host.h" + +using namespace clang::driver; +using namespace clang::driver::toolchains; +using namespace clang; +using namespace llvm::opt; + +UEFI::UEFI(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) +: ToolChain(D, Triple, Args) { + getProgramPaths().push_back(getDriver().getInstalledDir()); + if (getDriver().getInstalledDir() != getDriver().Dir) Prabhuk wrote: Made changes to reflect removal of getInstalledDir. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
https://github.com/jwakely edited https://github.com/llvm/llvm-project/pull/106036 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
@@ -0,0 +1,92 @@ +//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "UEFI.h" +#include "CommonArgs.h" +#include "Darwin.h" +#include "clang/Basic/CharInfo.h" +#include "clang/Basic/Version.h" +#include "clang/Config/config.h" +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +#include "clang/Driver/Options.h" +#include "clang/Driver/SanitizerArgs.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/VirtualFileSystem.h" +#include "llvm/TargetParser/Host.h" + +using namespace clang::driver; +using namespace clang::driver::toolchains; +using namespace clang; +using namespace llvm::opt; + +UEFI::UEFI(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) +: ToolChain(D, Triple, Args) { + getProgramPaths().push_back(getDriver().getInstalledDir()); + if (getDriver().getInstalledDir() != getDriver().Dir) +getProgramPaths().push_back(getDriver().Dir); +} + +Tool *UEFI::buildLinker() const { return new tools::uefi::Linker(*this); } + +void tools::uefi::Linker::ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, + const InputInfoList &Inputs, + const ArgList &Args, + const char *LinkingOutput) const { + ArgStringList CmdArgs; + auto &TC = static_cast(getToolChain()); + + assert((Output.isFilename() || Output.isNothing()) && "invalid output"); + if (Output.isFilename()) +CmdArgs.push_back( +Args.MakeArgString(std::string("-out:") + Output.getFilename())); + + CmdArgs.push_back("-nologo"); + + // TODO: Other UEFI binary subsystems that are currently unsupported: + // efi_boot_service_driver, efi_rom, efi_runtime_driver. + CmdArgs.push_back("-subsystem:efi_application"); + + // Default entry function name according to the TianoCore reference + // implementation is EfiMain. + // TODO: Provide a flag to override the entry function name. + CmdArgs.push_back("-entry:EfiMain"); + + // "Terminal Service Aware" flag is not needed for UEFI applications. + CmdArgs.push_back("-tsaware:no"); + + // EFI_APPLICATION to be linked as DLL by default. + CmdArgs.push_back("-dll"); + + if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7)) +CmdArgs.push_back("-debug"); + + Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link); Prabhuk wrote: Please see `clang/test/Driver/uefi-constructed-args.c`. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [UEFI] X86_64 UEFI Clang Driver (PR #76838)
Prabhuk wrote: > Some older toolchains were probably contributed with a lot of > `CmdArgs.push_back` uncovered by tests. They are not good examples to follow. > For new toolchains, we do want all constructed `CmdArgs.push_back` to be > covered. This allows refactoring by someone who is unfamiliar with your usage > pattern. Thank you! I believe the test in `clang/test/Driver/uefi-constructed-args.c` covers all constructed args. PTAL. https://github.com/llvm/llvm-project/pull/76838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
https://github.com/rnk updated https://github.com/llvm/llvm-project/pull/107154 >From cfb2cea5a4d4e0c1712e038692c4c5acee6b1f27 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 3 Sep 2024 21:16:40 + Subject: [PATCH 1/2] [MS] Put dllexported inline global initializers in a comdat Follow-up to c19f4f8069722f6804086d4438a0254104242c46 to handle corner case of exported inline variables. Should fix #56485 --- clang/lib/CodeGen/CGDeclCXX.cpp | 2 +- clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 2f56355cff90ec..c9e0fb0d8afaba 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -586,7 +586,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, PrioritizedCXXGlobalInits.size()); PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn)); } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || - getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR || + !isUniqueGVALinkage(getContext().GetGVALinkageForVariable(D)) || D->hasAttr()) { // C++ [basic.start.init]p2: // Definitions of explicitly specialized class template static data diff --git a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp index 60b48abca2f89a..871551240debfd 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp @@ -49,8 +49,6 @@ struct X { static T ioo; static T init(); }; -// template specialized static data don't need in llvm.used, -// the static init routine get call from _GLOBAL__sub_I_ routines. template <> int X::ioo = X::init(); template struct X; class a { @@ -87,5 +85,6 @@ struct S1 int foo(); inline int zoo = foo(); inline static int boo = foo(); +inline __declspec(dllexport) A exported_inline{}; -// CHECK: @llvm.used = appending global [8 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" +// CHECK: @llvm.used = appending global [10 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?ioo@?$X@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?exported_inline@@3UA@@A", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" >From 3cb368a8c01f99a7b12ece55e5b2145650d4f89d Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 3 Sep 2024 23:38:51 + Subject: [PATCH 2/2] Update comment block on why vague linkage global initialization is different --- clang/lib/CodeGen/CGDeclCXX.cpp | 41 - 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index c9e0fb0d8afaba..1ae8a2674df20d 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -588,29 +588,48 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || !isUniqueGVALinkage(getContext().GetGVALinkageForVariable(D)) || D->hasAttr()) { +// For vague linkage globals, put the initializer into its own global_ctors +// entry with the global as a comdat key. This ensures at most one +// initializer per DSO runs during DSO dynamic initialization. +// +// For ELF platforms, this is an important code size and startup time +// optimization. For dynamic, non-hidden symbols, the weak guard variable +// remains to ensure that other DSOs do not re-initialize the global. +// +// For PE-COFF platforms, there is no guard variable, and COMDAT associativity +// is the only way to ensure vauge linkage globals are initialized exactly +// once. +// +// MachO is the only remaining platform with no comdats that doesn't +// benefit from this optimization. The rest are mainly modeled on ELF +// behavior. +// +// C++ requires that inline global variables are initialized in source +// order, but this requirement does not exist for templated entities. +// llvm.global_ctors does not guarantee initialization order, so in +// general, Clang does not fully conform to the ordering requirement. +// However, in practice, LLVM emits global_ctors in the provided order, and +// users typically don't rel
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
rnk wrote: Yeah, I should've explicitly said I was working on updating the comment block. It needed significant surgery. Actually, this code could probably use more significant refactoring, but let's set that aside for now. > Does this impact non-MS targets? At the moment, I can't think of a good way to make an inline global `weak_odr` on non-MS targets without using templates, which would hit the existing `isTemplateInstantiation` check. I want to say "no" with ~85% confidence. https://github.com/llvm/llvm-project/pull/107154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 24b6b82487f15dd9d6cbe8a716dd13a6808a2528 3cb368a8c01f99a7b12ece55e5b2145650d4f89d --extensions cpp -- clang/lib/CodeGen/CGDeclCXX.cpp clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1ae8a2674d..8dcb5f6100 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -596,9 +596,9 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, // optimization. For dynamic, non-hidden symbols, the weak guard variable // remains to ensure that other DSOs do not re-initialize the global. // -// For PE-COFF platforms, there is no guard variable, and COMDAT associativity -// is the only way to ensure vauge linkage globals are initialized exactly -// once. +// For PE-COFF platforms, there is no guard variable, and COMDAT +// associativity is the only way to ensure vauge linkage globals are +// initialized exactly once. // // MachO is the only remaining platform with no comdats that doesn't // benefit from this optimization. The rest are mainly modeled on ELF `` https://github.com/llvm/llvm-project/pull/107154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/107160 >From 337a9ed1d5e7c71fb5be5741afe7726f5b76af7b Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Tue, 3 Sep 2024 15:30:50 -0700 Subject: [PATCH 1/3] [HLSL] Apply resource attributes to the resource type rather than the handle member (#6) --- clang/include/clang/AST/TypeLoc.h | 8 + clang/include/clang/Basic/Attr.td | 6 +- .../clang/Basic/DiagnosticSemaKinds.td| 1 + clang/include/clang/Sema/SemaHLSL.h | 21 ++- clang/lib/AST/TypePrinter.cpp | 9 +- clang/lib/CodeGen/CGHLSLRuntime.cpp | 10 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 25 ++- clang/lib/Sema/SemaDeclAttr.cpp | 6 - clang/lib/Sema/SemaHLSL.cpp | 177 -- clang/lib/Sema/TreeTransform.h| 22 ++- clang/test/AST/HLSL/RWBuffer-AST.hlsl | 10 +- ...a-attribute-supported-attributes-list.test | 2 - clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl | 17 +- .../ParserHLSL/hlsl_is_rov_attr_error.hlsl| 21 ++- .../ParserHLSL/hlsl_resource_class_attr.hlsl | 48 ++--- .../hlsl_resource_class_attr_error.hlsl | 29 +-- .../hlsl_resource_handle_attrs.hlsl | 17 +- .../SemaHLSL/resource_binding_attr_error.hlsl | 2 +- .../resource_binding_attr_error_resource.hlsl | 10 +- .../resource_binding_attr_error_udt.hlsl | 10 +- 20 files changed, 284 insertions(+), 167 deletions(-) diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 5db39eb3aefa74..03fbdcf60140df 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -951,12 +951,20 @@ class HLSLAttributedResourceTypeLoc HLSLAttributedResourceLocInfo> { public: TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); } + + TypeLoc getContainedLoc() const { +return TypeLoc(getTypePtr()->getContainedType(), getNonLocalData()); + } + void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; } SourceRange getLocalSourceRange() const { return getLocalData()->Range; } void initializeLocal(ASTContext &Context, SourceLocation loc) { setSourceRange(SourceRange()); } QualType getInnerType() const { return getTypePtr()->getWrappedType(); } + unsigned getLocalDataSize() const { +return sizeof(HLSLAttributedResourceLocInfo); + } }; struct ObjCObjectTypeLocInfo { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 8d2a362abc3c32..0c98f8e25a6fbb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4643,16 +4643,14 @@ def HLSLResource : InheritableAttr { let Documentation = [InternalOnly]; } -def HLSLROV : InheritableAttr { +def HLSLROV : TypeAttr { let Spellings = [CXX11<"hlsl", "is_rov">]; - let Subjects = SubjectList<[Struct]>; let LangOpts = [HLSL]; let Documentation = [InternalOnly]; } -def HLSLResourceClass : InheritableAttr { +def HLSLResourceClass : TypeAttr { let Spellings = [CXX11<"hlsl", "resource_class">]; - let Subjects = SubjectList<[Field]>; let LangOpts = [HLSL]; let Args = [ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index dcb49d8a67604a..4f522f68f080aa 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12364,6 +12364,7 @@ def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross regi def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match alignment %0 required by %1">; def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupported in HLSL">; +def err_missing_resource_class : Error<"HLSL resource needs to have [[hlsl::resource_class()]] attribute">; def err_hlsl_operator_unsupported : Error< "the '%select{&|*|->}0' operator is unsupported in HLSL">; diff --git a/clang/include/clang/Sema/SemaHLSL.h b/clang/include/clang/Sema/SemaHLSL.h index d79ca9a4fa18d1..5131458863e20b 100644 --- a/clang/include/clang/Sema/SemaHLSL.h +++ b/clang/include/clang/Sema/SemaHLSL.h @@ -15,8 +15,11 @@ #include "clang/AST/ASTFwd.h" #include "clang/AST/Attr.h" +#include "clang/AST/Type.h" +#include "clang/AST/TypeLoc.h" #include "clang/Basic/SourceLocation.h" #include "clang/Sema/SemaBase.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/TargetParser/Triple.h" #include @@ -59,8 +62,6 @@ class SemaHLSL : public SemaBase { void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL); void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL); void handleShaderAttr(Decl *D, const ParsedAttr &AL); - void handleROVAttr(Decl *D, const ParsedAttr &AL); - void handleResourceClassAttr(Decl *D, con
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota ready_for_review https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Helena Kotas (hekota) Changes Converts existing resource attributes `[[hlsl::resource_class(..)]]` and `[[is_rov]]` to from declaration attributes to type attributes. During type attribute processing all HLSL resource type attributes are validated and collected by `SemaHLSL` (`SemaHLSL::handleResourceTypeAttr`). At the end of the declaration they are be combined into a single `HLSLAttributedResourceType` instance (`SemaHLSL::ProcessResourceTypeAttributes`) that wraps the original type and stores all of the necessary information about the resource. `SemaHLSL` will also need to short-term-store the `TypeLoc` information for the newly created type that will be grabbed by `TypeSpecLocFiller` soon after it is created. Updates all places that expected resource attributes on declarations like resource binding diagnostic, builtin types in HLSLExternalSemaSource, or codegen. Also includes implementation of `TreeTransform::TransformHLSLAttributedResourceType` that enables the use of attributed resource types inside templates. Fixes #104861 --- Patch is 36.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/107160.diff 20 Files Affected: - (modified) clang/include/clang/AST/TypeLoc.h (+8) - (modified) clang/include/clang/Basic/Attr.td (+2-4) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1) - (modified) clang/include/clang/Sema/SemaHLSL.h (+19-2) - (modified) clang/lib/AST/TypePrinter.cpp (+6-3) - (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+5-4) - (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+15-10) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (-6) - (modified) clang/lib/Sema/SemaHLSL.cpp (+120-54) - (modified) clang/lib/Sema/TreeTransform.h (+20-2) - (modified) clang/test/AST/HLSL/RWBuffer-AST.hlsl (+4-6) - (modified) clang/test/Misc/pragma-attribute-supported-attributes-list.test (-2) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl (+12-5) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr_error.hlsl (+11-10) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl (+24-24) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr_error.hlsl (+15-14) - (modified) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+9-8) - (modified) clang/test/SemaHLSL/resource_binding_attr_error.hlsl (+1-1) - (modified) clang/test/SemaHLSL/resource_binding_attr_error_resource.hlsl (+5-5) - (modified) clang/test/SemaHLSL/resource_binding_attr_error_udt.hlsl (+5-5) ``diff diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 5db39eb3aefa74..03fbdcf60140df 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -951,12 +951,20 @@ class HLSLAttributedResourceTypeLoc HLSLAttributedResourceLocInfo> { public: TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); } + + TypeLoc getContainedLoc() const { +return TypeLoc(getTypePtr()->getContainedType(), getNonLocalData()); + } + void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; } SourceRange getLocalSourceRange() const { return getLocalData()->Range; } void initializeLocal(ASTContext &Context, SourceLocation loc) { setSourceRange(SourceRange()); } QualType getInnerType() const { return getTypePtr()->getWrappedType(); } + unsigned getLocalDataSize() const { +return sizeof(HLSLAttributedResourceLocInfo); + } }; struct ObjCObjectTypeLocInfo { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 8d2a362abc3c32..0c98f8e25a6fbb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4643,16 +4643,14 @@ def HLSLResource : InheritableAttr { let Documentation = [InternalOnly]; } -def HLSLROV : InheritableAttr { +def HLSLROV : TypeAttr { let Spellings = [CXX11<"hlsl", "is_rov">]; - let Subjects = SubjectList<[Struct]>; let LangOpts = [HLSL]; let Documentation = [InternalOnly]; } -def HLSLResourceClass : InheritableAttr { +def HLSLResourceClass : TypeAttr { let Spellings = [CXX11<"hlsl", "resource_class">]; - let Subjects = SubjectList<[Field]>; let LangOpts = [HLSL]; let Args = [ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index dcb49d8a67604a..4f522f68f080aa 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12364,6 +12364,7 @@ def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross regi def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match alignment %0 required by %1">; def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupporte
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
llvmbot wrote: @llvm/pr-subscribers-hlsl Author: Helena Kotas (hekota) Changes Converts existing resource attributes `[[hlsl::resource_class(..)]]` and `[[is_rov]]` to from declaration attributes to type attributes. During type attribute processing all HLSL resource type attributes are validated and collected by `SemaHLSL` (`SemaHLSL::handleResourceTypeAttr`). At the end of the declaration they are be combined into a single `HLSLAttributedResourceType` instance (`SemaHLSL::ProcessResourceTypeAttributes`) that wraps the original type and stores all of the necessary information about the resource. `SemaHLSL` will also need to short-term-store the `TypeLoc` information for the newly created type that will be grabbed by `TypeSpecLocFiller` soon after it is created. Updates all places that expected resource attributes on declarations like resource binding diagnostic, builtin types in HLSLExternalSemaSource, or codegen. Also includes implementation of `TreeTransform::TransformHLSLAttributedResourceType` that enables the use of attributed resource types inside templates. Fixes #104861 --- Patch is 36.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/107160.diff 20 Files Affected: - (modified) clang/include/clang/AST/TypeLoc.h (+8) - (modified) clang/include/clang/Basic/Attr.td (+2-4) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1) - (modified) clang/include/clang/Sema/SemaHLSL.h (+19-2) - (modified) clang/lib/AST/TypePrinter.cpp (+6-3) - (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+5-4) - (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+15-10) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (-6) - (modified) clang/lib/Sema/SemaHLSL.cpp (+120-54) - (modified) clang/lib/Sema/TreeTransform.h (+20-2) - (modified) clang/test/AST/HLSL/RWBuffer-AST.hlsl (+4-6) - (modified) clang/test/Misc/pragma-attribute-supported-attributes-list.test (-2) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl (+12-5) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr_error.hlsl (+11-10) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl (+24-24) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr_error.hlsl (+15-14) - (modified) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+9-8) - (modified) clang/test/SemaHLSL/resource_binding_attr_error.hlsl (+1-1) - (modified) clang/test/SemaHLSL/resource_binding_attr_error_resource.hlsl (+5-5) - (modified) clang/test/SemaHLSL/resource_binding_attr_error_udt.hlsl (+5-5) ``diff diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 5db39eb3aefa74..03fbdcf60140df 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -951,12 +951,20 @@ class HLSLAttributedResourceTypeLoc HLSLAttributedResourceLocInfo> { public: TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); } + + TypeLoc getContainedLoc() const { +return TypeLoc(getTypePtr()->getContainedType(), getNonLocalData()); + } + void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; } SourceRange getLocalSourceRange() const { return getLocalData()->Range; } void initializeLocal(ASTContext &Context, SourceLocation loc) { setSourceRange(SourceRange()); } QualType getInnerType() const { return getTypePtr()->getWrappedType(); } + unsigned getLocalDataSize() const { +return sizeof(HLSLAttributedResourceLocInfo); + } }; struct ObjCObjectTypeLocInfo { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 8d2a362abc3c32..0c98f8e25a6fbb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4643,16 +4643,14 @@ def HLSLResource : InheritableAttr { let Documentation = [InternalOnly]; } -def HLSLROV : InheritableAttr { +def HLSLROV : TypeAttr { let Spellings = [CXX11<"hlsl", "is_rov">]; - let Subjects = SubjectList<[Struct]>; let LangOpts = [HLSL]; let Documentation = [InternalOnly]; } -def HLSLResourceClass : InheritableAttr { +def HLSLResourceClass : TypeAttr { let Spellings = [CXX11<"hlsl", "resource_class">]; - let Subjects = SubjectList<[Field]>; let LangOpts = [HLSL]; let Args = [ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index dcb49d8a67604a..4f522f68f080aa 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12364,6 +12364,7 @@ def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross regi def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match alignment %0 required by %1">; def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupported in HLSL
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Helena Kotas (hekota) Changes Converts existing resource attributes `[[hlsl::resource_class(..)]]` and `[[is_rov]]` to from declaration attributes to type attributes. During type attribute processing all HLSL resource type attributes are validated and collected by `SemaHLSL` (`SemaHLSL::handleResourceTypeAttr`). At the end of the declaration they are be combined into a single `HLSLAttributedResourceType` instance (`SemaHLSL::ProcessResourceTypeAttributes`) that wraps the original type and stores all of the necessary information about the resource. `SemaHLSL` will also need to short-term-store the `TypeLoc` information for the newly created type that will be grabbed by `TypeSpecLocFiller` soon after it is created. Updates all places that expected resource attributes on declarations like resource binding diagnostic, builtin types in HLSLExternalSemaSource, or codegen. Also includes implementation of `TreeTransform::TransformHLSLAttributedResourceType` that enables the use of attributed resource types inside templates. Fixes #104861 --- Patch is 36.80 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/107160.diff 20 Files Affected: - (modified) clang/include/clang/AST/TypeLoc.h (+8) - (modified) clang/include/clang/Basic/Attr.td (+2-4) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1) - (modified) clang/include/clang/Sema/SemaHLSL.h (+19-2) - (modified) clang/lib/AST/TypePrinter.cpp (+6-3) - (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+5-4) - (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+15-10) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (-6) - (modified) clang/lib/Sema/SemaHLSL.cpp (+120-54) - (modified) clang/lib/Sema/TreeTransform.h (+20-2) - (modified) clang/test/AST/HLSL/RWBuffer-AST.hlsl (+4-6) - (modified) clang/test/Misc/pragma-attribute-supported-attributes-list.test (-2) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl (+12-5) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr_error.hlsl (+11-10) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl (+24-24) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr_error.hlsl (+15-14) - (modified) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+9-8) - (modified) clang/test/SemaHLSL/resource_binding_attr_error.hlsl (+1-1) - (modified) clang/test/SemaHLSL/resource_binding_attr_error_resource.hlsl (+5-5) - (modified) clang/test/SemaHLSL/resource_binding_attr_error_udt.hlsl (+5-5) ``diff diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 5db39eb3aefa74..03fbdcf60140df 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -951,12 +951,20 @@ class HLSLAttributedResourceTypeLoc HLSLAttributedResourceLocInfo> { public: TypeLoc getWrappedLoc() const { return getInnerTypeLoc(); } + + TypeLoc getContainedLoc() const { +return TypeLoc(getTypePtr()->getContainedType(), getNonLocalData()); + } + void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; } SourceRange getLocalSourceRange() const { return getLocalData()->Range; } void initializeLocal(ASTContext &Context, SourceLocation loc) { setSourceRange(SourceRange()); } QualType getInnerType() const { return getTypePtr()->getWrappedType(); } + unsigned getLocalDataSize() const { +return sizeof(HLSLAttributedResourceLocInfo); + } }; struct ObjCObjectTypeLocInfo { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 8d2a362abc3c32..0c98f8e25a6fbb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4643,16 +4643,14 @@ def HLSLResource : InheritableAttr { let Documentation = [InternalOnly]; } -def HLSLROV : InheritableAttr { +def HLSLROV : TypeAttr { let Spellings = [CXX11<"hlsl", "is_rov">]; - let Subjects = SubjectList<[Struct]>; let LangOpts = [HLSL]; let Documentation = [InternalOnly]; } -def HLSLResourceClass : InheritableAttr { +def HLSLResourceClass : TypeAttr { let Spellings = [CXX11<"hlsl", "resource_class">]; - let Subjects = SubjectList<[Field]>; let LangOpts = [HLSL]; let Args = [ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index dcb49d8a67604a..4f522f68f080aa 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12364,6 +12364,7 @@ def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross regi def err_hlsl_packoffset_alignment_mismatch : Error<"packoffset at 'y' not match alignment %0 required by %1">; def err_hlsl_pointers_unsupported : Error< "%select{pointers|references}0 are unsupported in HLS
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)
https://github.com/rnk updated https://github.com/llvm/llvm-project/pull/107154 >From cfb2cea5a4d4e0c1712e038692c4c5acee6b1f27 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 3 Sep 2024 21:16:40 + Subject: [PATCH 1/3] [MS] Put dllexported inline global initializers in a comdat Follow-up to c19f4f8069722f6804086d4438a0254104242c46 to handle corner case of exported inline variables. Should fix #56485 --- clang/lib/CodeGen/CGDeclCXX.cpp | 2 +- clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 2f56355cff90ec..c9e0fb0d8afaba 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -586,7 +586,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, PrioritizedCXXGlobalInits.size()); PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn)); } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || - getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR || + !isUniqueGVALinkage(getContext().GetGVALinkageForVariable(D)) || D->hasAttr()) { // C++ [basic.start.init]p2: // Definitions of explicitly specialized class template static data diff --git a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp index 60b48abca2f89a..871551240debfd 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp @@ -49,8 +49,6 @@ struct X { static T ioo; static T init(); }; -// template specialized static data don't need in llvm.used, -// the static init routine get call from _GLOBAL__sub_I_ routines. template <> int X::ioo = X::init(); template struct X; class a { @@ -87,5 +85,6 @@ struct S1 int foo(); inline int zoo = foo(); inline static int boo = foo(); +inline __declspec(dllexport) A exported_inline{}; -// CHECK: @llvm.used = appending global [8 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" +// CHECK: @llvm.used = appending global [10 x ptr] [ptr @"?x@selectany_init@@3HA", ptr @"?x1@selectany_init@@3HA", ptr @"?x@?$A@H@explicit_template_instantiation@@2HA", ptr @"?ioo@?$X_@H@@2HA", ptr @"?ioo@?$X@H@@2HA", ptr @"?aoo@S1@@2UA@@A", ptr @"?zoo@@3HA", ptr @"?exported_inline@@3UA@@A", ptr @"?s@?$ExportedTemplate@H@@2US@@A", ptr @"?x@?$A@H@implicit_template_instantiation@@2HA"], section "llvm.metadata" >From 3cb368a8c01f99a7b12ece55e5b2145650d4f89d Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 3 Sep 2024 23:38:51 + Subject: [PATCH 2/3] Update comment block on why vague linkage global initialization is different --- clang/lib/CodeGen/CGDeclCXX.cpp | 41 - 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index c9e0fb0d8afaba..1ae8a2674df20d 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -588,29 +588,48 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || !isUniqueGVALinkage(getContext().GetGVALinkageForVariable(D)) || D->hasAttr()) { +// For vague linkage globals, put the initializer into its own global_ctors +// entry with the global as a comdat key. This ensures at most one +// initializer per DSO runs during DSO dynamic initialization. +// +// For ELF platforms, this is an important code size and startup time +// optimization. For dynamic, non-hidden symbols, the weak guard variable +// remains to ensure that other DSOs do not re-initialize the global. +// +// For PE-COFF platforms, there is no guard variable, and COMDAT associativity +// is the only way to ensure vauge linkage globals are initialized exactly +// once. +// +// MachO is the only remaining platform with no comdats that doesn't +// benefit from this optimization. The rest are mainly modeled on ELF +// behavior. +// +// C++ requires that inline global variables are initialized in source +// order, but this requirement does not exist for templated entities. +// llvm.global_ctors does not guarantee initialization order, so in +// general, Clang does not fully conform to the ordering requirement. +// However, in practice, LLVM emits global_ctors in the provided order, and +// users typically don't rel
[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)
https://github.com/yronglin created https://github.com/llvm/llvm-project/pull/107168 None >From fb028015b8f86f87b6d1643e91c21531c768a198 Mon Sep 17 00:00:00 2001 From: yronglin Date: Sat, 17 Aug 2024 16:54:26 +0800 Subject: [PATCH 1/2] [Clang] Add peekNextPPToken, makes peek next token without side-effects Signed-off-by: yronglin --- clang/include/clang/Lex/Lexer.h| 10 clang/include/clang/Lex/Preprocessor.h | 8 ++- clang/include/clang/Lex/TokenLexer.h | 7 +++--- clang/lib/Lex/Lexer.cpp| 21 + clang/lib/Lex/PPMacroExpansion.cpp | 32 -- clang/lib/Lex/TokenLexer.cpp | 10 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h index b6ecc7e5ded9e2..1e665c13b392f2 100644 --- a/clang/include/clang/Lex/Lexer.h +++ b/clang/include/clang/Lex/Lexer.h @@ -124,7 +124,7 @@ class Lexer : public PreprocessorLexer { //======// // Context that changes as the file is lexed. // NOTE: any state that mutates when in raw mode must have save/restore code - // in Lexer::isNextPPTokenLParen. + // in Lexer::peekNextPPToken. // BufferPtr - Current pointer into the buffer. This is the next character // to be lexed. @@ -629,10 +629,10 @@ class Lexer : public PreprocessorLexer { BufferPtr = TokEnd; } - /// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a - /// tok::l_paren token, 0 if it is something else and 2 if there are no more - /// tokens in the buffer controlled by this lexer. - unsigned isNextPPTokenLParen(); + /// peekNextPPToken - Return std::nullopt if there are no more tokens in the + /// buffer controlled by this lexer, otherwise return the next unexpanded + /// token. + std::optional peekNextPPToken(); //======// // Lexer character reading interfaces. diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 1307659e27d137..0ab138974aeb20 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2650,10 +2650,16 @@ class Preprocessor { void removeCachedMacroExpandedTokensOfLastLexer(); + /// Peek the next token. If so, return the token, if not, this + /// method should have no observable side-effect on the lexed tokens. + std::optional peekNextPPToken(); + /// Determine whether the next preprocessor token to be /// lexed is a '('. If so, consume the token and return true, if not, this /// method should have no observable side-effect on the lexed tokens. - bool isNextPPTokenLParen(); + bool isNextPPTokenLParen() { +return peekNextPPToken().value_or(Token{}).is(tok::l_paren); + } /// After reading "MACRO(", this method is invoked to read all of the formal /// arguments specified for the macro invocation. Returns null on error. diff --git a/clang/include/clang/Lex/TokenLexer.h b/clang/include/clang/Lex/TokenLexer.h index 4d229ae6106743..777b4e6266c714 100644 --- a/clang/include/clang/Lex/TokenLexer.h +++ b/clang/include/clang/Lex/TokenLexer.h @@ -139,10 +139,9 @@ class TokenLexer { void Init(const Token *TokArray, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens, bool IsReinject); - /// If the next token lexed will pop this macro off the - /// expansion stack, return 2. If the next unexpanded token is a '(', return - /// 1, otherwise return 0. - unsigned isNextTokenLParen() const; + /// If the next token lexed will pop this macro off the expansion stack, + /// return std::nullopt, otherwise return the next unexpanded token. + std::optional peekNextPPToken() const; /// Lex and return a token from this macro stream. bool Lex(Token &Tok); diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index ef1e1f4bd9aeb4..af533b3874cf5d 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -3193,18 +3193,19 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { return PP->HandleEndOfFile(Result, isPragmaLexer()); } -/// isNextPPTokenLParen - Return 1 if the next unexpanded token lexed from -/// the specified lexer will return a tok::l_paren token, 0 if it is something -/// else and 2 if there are no more tokens in the buffer controlled by the -/// lexer. -unsigned Lexer::isNextPPTokenLParen() { +/// peekNextPPToken - Return std::nullopt if there are no more tokens in the +/// buffer controlled by this lexer, otherwise return the next unexpanded +/// token. +std::optional Lexer::peekNextPPToken() { assert(!LexingRawMode && "How can we expand a macro from a skipping buffer?"); if (isDependencyDirectivesLexer()) { if (NextDepDirectiveTokenIndex == DepDirectives.front().Tokens.size()) - return 2; -return DepDirectiv
[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 448d8fa880be5cae0f63c3b248f07f647013a5a4 b7b4e2549a5fb723b455768f2bcf75bfab6cab04 --extensions h,cpp -- clang/include/clang/Basic/IdentifierTable.h clang/include/clang/Lex/Lexer.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Lex/Token.h clang/include/clang/Lex/TokenLexer.h clang/include/clang/Parse/Parser.h clang/lib/Basic/IdentifierTable.cpp clang/lib/Lex/DependencyDirectivesScanner.cpp clang/lib/Lex/Lexer.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Lex/TokenLexer.cpp clang/lib/Parse/Parser.cpp clang/unittests/Lex/DependencyDirectivesScannerTest.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index a9acde7ac5..d8b0d4a540 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -400,7 +400,7 @@ private: /// Whether the last token we lexed was an '@'. bool LastTokenWasAt = false; - + struct ExportContextualKeywordInfo { Token ExportTok; bool TokAtPhysicalStartOfLine; @@ -1847,7 +1847,8 @@ public: /// This consumes the import, module directive, modifies the /// lexer/preprocessor state, and advances the lexer(s) so that the next token /// read is the correct one. - bool HandleModuleContextualKeyword(Token &Result, bool TokAtPhysicalStartOfLine); + bool HandleModuleContextualKeyword(Token &Result, + bool TokAtPhysicalStartOfLine); void HandleModuleDirective(Token &ModuleOrImportKeyword); void LexAfterModuleImport(SmallVectorImpl &Suffix, bool IsImport); diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 10ed86d5d5..d44f553e59 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -457,7 +457,7 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const { CASE( 6, 'd', 'f', define); CASE( 6, 'i', 'n', ifndef); CASE( 6, 'i', 'p', import); - CASE( 6, 'm', 'd', module); + CASE(6, 'm', 'd', module); CASE( 6, 'p', 'a', pragma); CASE( 7, 'd', 'f', defined); diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp index 58e92977f9..245ce25b82 100644 --- a/clang/lib/Lex/DependencyDirectivesScanner.cpp +++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp @@ -857,7 +857,8 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) { if (*First == '@') return lexAt(First, End); - // if (!LangOpts.CPlusPlusModules && (*First == 'i' || *First == 'e' || *First == 'm')) + // if (!LangOpts.CPlusPlusModules && (*First == 'i' || *First == 'e' || *First + // == 'm')) // return lexModule(First, End); if (*First == '_') { @@ -871,7 +872,7 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) { TheLexer.setParsingPreprocessorDirective(true); auto ScEx2 = make_scope_exit( [&]() { TheLexer.setParsingPreprocessorDirective(false); }); - if (*First == 'i' || *First == 'e' || *First == 'm') + if (*First == 'i' || *First == 'e' || *First == 'm') return lexModule(First, End); // Lex '#'. const dependency_directives_scan::Token &HashTok = lexToken(First, End); diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index b40de9d918..7cce869662 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -4023,12 +4023,13 @@ void Preprocessor::HandleEmbedDirective(SourceLocation HashLoc, Token &EmbedTok, HandleEmbedDirectiveImpl(HashLoc, *Params, BinaryContents); } -void Preprocessor::LexAfterModuleImport(SmallVectorImpl &Suffix, bool IsImport) { +void Preprocessor::LexAfterModuleImport(SmallVectorImpl &Suffix, +bool IsImport) { Token Result; Suffix.clear(); Retry: if (IsImport && getLangOpts().CPlusPlusModules) { -(void) LexHeaderName(Result); +(void)LexHeaderName(Result); if (Result.is(tok::colon) && ModuleDeclState.isNamedModule()) { std::string Name = ModuleDeclState.getPrimaryName().str(); Name += ":"; @@ -4172,8 +4173,7 @@ Retry: // We don't/shouldn't load the standard c++20 modules when preprocessing. if (getLangOpts().Modules && !isInImportingCXXNamedModules()) { Imported = TheModuleLoader.loadModule(ModuleImportLoc, - NamedModuleImportPath, - Module::Hidden, + NamedModuleImportPath, Module::Hidden, /*IsInclusionDirective=*/false); if (Imported) makeModule
[clang] eaa95a1 - [clang] Add test for CWG2486 (`noexcept` and function pointer conversion) (#107131)
Author: Vlad Serebrennikov Date: 2024-09-04T04:10:46+04:00 New Revision: eaa95a1c2bd38332c1a4e634595f29d22b28ffea URL: https://github.com/llvm/llvm-project/commit/eaa95a1c2bd38332c1a4e634595f29d22b28ffea DIFF: https://github.com/llvm/llvm-project/commit/eaa95a1c2bd38332c1a4e634595f29d22b28ffea.diff LOG: [clang] Add test for CWG2486 (`noexcept` and function pointer conversion) (#107131) [CWG2486](https://cplusplus.github.io/CWG/issues/2486.html) "Call to `noexcept` function via `noexcept(false)` pointer/lvalue" allows `noexcept` functions to be called via `noexcept(false)` pointers or values. There appears to be no implementation divergence whatsoever: https://godbolt.org/z/3afTfeEM8. That said, in C++14 and earlier we do not issue all the diagnostics we issue in C++17 and newer, so I'm specifying the status of the issue accordingly. Added: Modified: clang/test/CXX/drs/cwg24xx.cpp clang/www/cxx_dr_status.html Removed: diff --git a/clang/test/CXX/drs/cwg24xx.cpp b/clang/test/CXX/drs/cwg24xx.cpp index 00b6bb5a865dfe..79e9d031ef41c0 100644 --- a/clang/test/CXX/drs/cwg24xx.cpp +++ b/clang/test/CXX/drs/cwg24xx.cpp @@ -1,15 +1,11 @@ -// RUN: %clang_cc1 -std=c++98 -pedantic-errors %s -verify=expected -// RUN: %clang_cc1 -std=c++11 -pedantic-errors %s -verify=expected -// RUN: %clang_cc1 -std=c++14 -pedantic-errors %s -verify=expected +// RUN: %clang_cc1 -std=c++98 -pedantic-errors %s -verify=expected,cxx98-14 +// RUN: %clang_cc1 -std=c++11 -pedantic-errors %s -verify=expected,cxx98-14 +// RUN: %clang_cc1 -std=c++14 -pedantic-errors %s -verify=expected,cxx98-14 // RUN: %clang_cc1 -std=c++17 -pedantic-errors %s -verify=expected,since-cxx17 // RUN: %clang_cc1 -std=c++20 -pedantic-errors %s -verify=expected,since-cxx17 // RUN: %clang_cc1 -std=c++23 -pedantic-errors %s -verify=expected,since-cxx17 // RUN: %clang_cc1 -std=c++2c -pedantic-errors %s -verify=expected,since-cxx17 -#if __cplusplus <= 201402L -// expected-no-diagnostics -#endif - namespace cwg2406 { // cwg2406: 5 #if __cplusplus >= 201703L void fallthrough(int n) { @@ -186,3 +182,36 @@ namespace cwg2445 { // cwg2445: 19 } #endif } + +namespace cwg2486 { // cwg2486: 4 c++17 +struct C { + void fn() throw(); +}; + +static void call(C& c, void (C::*f)()) { + (c.*f)(); +} + +static void callNE(C& c, void (C::*f)() throw()) { +// cxx98-14-warning@-1 {{mangled name of 'callNE' will change in C++17 due to non-throwing exception specification in function signature}} + (c.*f)(); +} + +void ref() { + C c; + call(c, &C::fn); // <= implicit cast removes noexcept + callNE(c, &C::fn); +} + +void (*p)(); +void (*pp)() throw() = p; +// since-cxx17-error@-1 {{cannot initialize a variable of type 'void (*)() throw()' with an lvalue of type 'void (*)()': diff erent exception specifications}} + +struct S { + typedef void (*p)(); + operator p(); // #cwg2486-conv +}; +void (*q)() throw() = S(); +// since-cxx17-error@-1 {{no viable conversion from 'S' to 'void (*)() throw()'}} +// since-cxx17-note@#cwg2486-conv {{candidate function}} +} // namespace cwg2486 diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 4f4d8d0a97d43f..ca25776823cfa5 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -14751,7 +14751,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/2486.html";>2486 CD6 Call to noexcept function via noexcept(false) pointer/lvalue -Unknown +Clang 4 (C++17 onwards) https://cplusplus.github.io/CWG/issues/2487.html";>2487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add test for CWG2486 (`noexcept` and function pointer conversion) (PR #107131)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/107131 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/damyanp edited https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
@@ -77,6 +77,23 @@ class SemaHLSL : public SemaBase { ExprResult ActOnOutParamExpr(ParmVarDecl *Param, Expr *Arg); QualType getInoutParameterType(QualType Ty); + + // FIXME: This can be hidden (as static function in SemaHLSL.cpp) once we no + // longer need to create builtin buffer types in HLSLExternalSemaSource. damyanp wrote: Does this need to be a static member of SemaHLSL? It sounds like it doesn't if we think it can be trivially made a file static. https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/damyanp commented: Typo in description: > Converts existing resource attributes [[hlsl::resource_class(..)]] and > [[is_rov]] ~~to~~ from declaration attributes to type attributes. There's many places in the existing tests where these attributes are being used in ways we don't really intend them to use. Maybe now would be the right time to fix them up? https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
@@ -1,32 +1,32 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s - -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} SRV -struct Eg1 { - [[hlsl::resource_class(SRV)]] int i; +// CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} {{.*}} struct MyBuffer definition +// CHECK: FieldDecl 0x{{[0-9a-f]+}} col:51 h '__hlsl_resource_t {{\[\[}}hlsl::resource_class(UAV)]]':'__hlsl_resource_t' +struct MyBuffer { + __hlsl_resource_t [[hlsl::resource_class(UAV)]] h; }; -Eg1 e1; - -// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} line:13:8 referenced struct Eg2 definition -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} UAV -struct Eg2 { - [[hlsl::resource_class(UAV)]] int i; -}; -Eg2 e2; +// CHECK: VarDecl 0x{{[0-9a-f]+}} col:49 res '__hlsl_resource_t {{\[\[}}hlsl::resource_class(SRV)]]':'__hlsl_resource_t' +__hlsl_resource_t [[hlsl::resource_class(SRV)]] res; -// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} line:20:8 referenced struct Eg3 definition -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} CBuffer -struct Eg3 { - [[hlsl::resource_class(CBuffer)]] int i; -}; -Eg3 e3; +// CHECK: FunctionDecl 0x{{[0-9a-f]+}} line:14:6 f 'void () +// CHECK: VarDecl 0x{{[0-9a-f]+}} col:55 r '__hlsl_resource_t {{\[\[}}hlsl::resource_class(Sampler)]]':'__hlsl_resource_t' +void f() { + __hlsl_resource_t [[hlsl::resource_class(Sampler)]] r; +} -// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} line:27:8 referenced struct Eg4 definition -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} Sampler -struct Eg4 { - [[hlsl::resource_class(Sampler)]] int i; +// CHECK: ClassTemplateDecl 0x{{[0-9a-f]+}} line:23:29 MyBuffer2 +// CHECK: TemplateTypeParmDecl 0x{{[0-9a-f]+}} col:19 referenced typename depth 0 index 0 T +// CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} line:23:29 struct MyBuffer2 definition +// CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} col:29 implicit struct MyBuffer2 +// CHECK: FieldDecl 0x{{[0-9a-f]+}} col:35 h 'T {{\[\[}}hlsl::resource_class(UAV)]]':'T' +template struct MyBuffer2 { + T [[hlsl::resource_class(UAV)]] h; damyanp wrote: Do we have special code supporting this scenario? Because I don't think it is one that we'd ever want to support. `h` should be a handle type, whereas `T` here is strongly suggested to be the element type of the buffer. `myBuffer2` below at least should using something more handle-type like. https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
@@ -556,46 +562,120 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { D->addAttr(NewAttr); } -void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) { - if (!AL.isArgIdent(0)) { -Diag(AL.getLoc(), diag::err_attribute_argument_type) -<< AL << AANT_ArgumentIdentifier; -return; - } +bool SemaHLSL::CreateHLSLAttributedResourceType( +Sema &S, QualType Wrapped, llvm::SmallVector &AttrList, +QualType &ResType) { + assert(AttrList.size() && "expected list of resource attributes"); - IdentifierLoc *Loc = AL.getArgAsIdent(0); - StringRef Identifier = Loc->Ident->getName(); - SourceLocation ArgLoc = Loc->Loc; + QualType Contained = QualType(); + HLSLAttributedResourceType::Attributes ResAttrs = {}; - // Validate. - llvm::dxil::ResourceClass RC; - if (!HLSLResourceClassAttr::ConvertStrToResourceClass(Identifier, RC)) { -Diag(ArgLoc, diag::warn_attribute_type_not_supported) -<< "ResourceClass" << Identifier; -return; + bool hasResourceClass = false; + for (auto *Attr : AttrList) { +if (!Attr) + continue; +switch (Attr->getKind()) { +case attr::HLSLResourceClass: { + llvm::dxil::ResourceClass RC = + dyn_cast(Attr)->getResourceClass(); + if (!hasResourceClass) { +ResAttrs.ResourceClass = RC; +hasResourceClass = true; + } else if (RC != ResAttrs.ResourceClass) { +S.Diag(Attr->getLocation(), diag::warn_duplicate_attribute) << Attr; +return false; + } + break; +} +case attr::HLSLROV: + ResAttrs.IsROV = true; + break; +default: + llvm_unreachable("unhandled resource attribute type"); +} } - D->addAttr(HLSLResourceClassAttr::Create(getASTContext(), RC, ArgLoc)); + if (!hasResourceClass) { +S.Diag(AttrList.back()->getRange().getEnd(), + diag::err_missing_resource_class); +return false; + } + + ResType = S.getASTContext().getHLSLAttributedResourceType(Wrapped, Contained, +ResAttrs); + return true; } -// Validates HLSL resource type attribute and adds it to the list to be -// processed into a single HLSLAttributedResourceType later on. -// Returns false if the attribute is invalid. +// Validates and creates an HLSL attribute that is applied as type attribute on +// HLSL resource. The attributes are collected in HLSLResourcesTypeAttrs and at +// the end of the declaration they are applied to the declaration type by +// wrapping it in HLSLAttributedResourceType. bool SemaHLSL::handleResourceTypeAttr(const ParsedAttr &AL) { - // FIXME: placeholder - not yet implemented + Attr *A = nullptr; + + // validate number of arguments + if (!AL.checkExactlyNumArgs(SemaRef, AL.getMinArgs())) +return false; + + switch (AL.getKind()) { + case ParsedAttr::AT_HLSLResourceClass: { +if (!AL.isArgIdent(0)) { + Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIdentifier; + return false; +} + +IdentifierLoc *Loc = AL.getArgAsIdent(0); +StringRef Identifier = Loc->Ident->getName(); +SourceLocation ArgLoc = Loc->Loc; + +// Validate resource class value +llvm::dxil::ResourceClass RC; +if (!HLSLResourceClassAttr::ConvertStrToResourceClass(Identifier, RC)) { + Diag(ArgLoc, diag::warn_attribute_type_not_supported) + << "ResourceClass" << Identifier; + return false; +} +A = HLSLResourceClassAttr::Create(getASTContext(), RC, AL.getLoc()); +break; + } + case ParsedAttr::AT_HLSLROV: +A = HLSLROVAttr::Create(getASTContext(), AL.getLoc()); +break; + default: +llvm_unreachable("unhandled HLSL attribute"); + } + + HLSLResourcesTypeAttrs.emplace_back(A); return true; } -// Combines all resource type attributes and create HLSLAttributedResourceType. +// Combines all resource type attributes and creates HLSLAttributedResourceType. QualType SemaHLSL::ProcessResourceTypeAttributes(QualType CurrentType) { - // FIXME: placeholder - not yet implemented - return CurrentType; + if (!HLSLResourcesTypeAttrs.size()) +return CurrentType; + + QualType QT = CurrentType; + if (CreateHLSLAttributedResourceType(SemaRef, CurrentType, + HLSLResourcesTypeAttrs, QT)) { +const HLSLAttributedResourceType *RT = +dyn_cast(QT.getTypePtr()); +SourceLocation Loc = HLSLResourcesTypeAttrs[0]->getLoc(); +LocsForHLSLAttributedResources.insert(std::pair(RT, Loc)); + } + HLSLResourcesTypeAttrs.clear(); + return QT; } // Returns source location for the HLSLAttributedResourceType SourceLocation SemaHLSL::TakeLocForHLSLAttribute(const HLSLAttributedResourceType *RT) { - // FIXME: placeholder - not yet implemented + auto I = LocsForHLSLAttributedResources.find(RT); + if (I != LocsForHLSLAttributedResources.end()) { +SourceLocation Loc = I->second; +LocsForHLSL
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
@@ -1,32 +1,32 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s - -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} SRV -struct Eg1 { - [[hlsl::resource_class(SRV)]] int i; +// CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} {{.*}} struct MyBuffer definition +// CHECK: FieldDecl 0x{{[0-9a-f]+}} col:51 h '__hlsl_resource_t {{\[\[}}hlsl::resource_class(UAV)]]':'__hlsl_resource_t' +struct MyBuffer { + __hlsl_resource_t [[hlsl::resource_class(UAV)]] h; }; -Eg1 e1; - -// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} line:13:8 referenced struct Eg2 definition -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} UAV -struct Eg2 { - [[hlsl::resource_class(UAV)]] int i; -}; -Eg2 e2; +// CHECK: VarDecl 0x{{[0-9a-f]+}} col:49 res '__hlsl_resource_t {{\[\[}}hlsl::resource_class(SRV)]]':'__hlsl_resource_t' +__hlsl_resource_t [[hlsl::resource_class(SRV)]] res; -// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} line:20:8 referenced struct Eg3 definition -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} CBuffer -struct Eg3 { - [[hlsl::resource_class(CBuffer)]] int i; -}; -Eg3 e3; +// CHECK: FunctionDecl 0x{{[0-9a-f]+}} line:14:6 f 'void () +// CHECK: VarDecl 0x{{[0-9a-f]+}} col:55 r '__hlsl_resource_t {{\[\[}}hlsl::resource_class(Sampler)]]':'__hlsl_resource_t' +void f() { + __hlsl_resource_t [[hlsl::resource_class(Sampler)]] r; +} -// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} line:27:8 referenced struct Eg4 definition -// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} Sampler -struct Eg4 { - [[hlsl::resource_class(Sampler)]] int i; +// CHECK: ClassTemplateDecl 0x{{[0-9a-f]+}} line:23:29 MyBuffer2 +// CHECK: TemplateTypeParmDecl 0x{{[0-9a-f]+}} col:19 referenced typename depth 0 index 0 T +// CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} line:23:29 struct MyBuffer2 definition +// CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} col:29 implicit struct MyBuffer2 +// CHECK: FieldDecl 0x{{[0-9a-f]+}} col:35 h 'T {{\[\[}}hlsl::resource_class(UAV)]]':'T' +template struct MyBuffer2 { + T [[hlsl::resource_class(UAV)]] h; damyanp wrote: There's multiple tests below (that are modifications of existing ones) that are still using this field with the element type rather than a handle type, but I won't put comments on all of them. https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)
https://github.com/FreddyLeaf closed https://github.com/llvm/llvm-project/pull/101603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][AVX10.2] Support AVX10.2-BF16 new instructions. (PR #101603)
@@ -153,7 +163,8 @@ const X86InstrFMA3Group *llvm::getFMA3Group(unsigned Opcode, uint64_t TSFlags) { ((TSFlags & X86II::EncodingMask) == X86II::EVEX && ((TSFlags & X86II::OpMapMask) == X86II::T8 || (TSFlags & X86II::OpMapMask) == X86II::T_MAP6)); - bool IsFMA3Prefix = (TSFlags & X86II::OpPrefixMask) == X86II::PD; + bool IsFMA3Prefix = ((TSFlags & X86II::OpPrefixMask) == X86II::PD) || + ((TSFlags & X86II::OpPrefixMask) == 0); // X86II::PS FreddyLeaf wrote: [a6c4fce](https://github.com/llvm/llvm-project/pull/101603/commits/a6c4fce4069fb81ab4a50d825fe6039d45827d63) https://github.com/llvm/llvm-project/pull/101603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
https://github.com/HighCommander4 requested changes to this pull request. (@zyn0217 I'm going to mark this as "Request changes" to reflect my understanding from the previous comment that the next step here is you splitting up the patch. If I've misunderstood and you'd like me to have a look at the current version, let me know!) https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] Allow disabling of types from the command line (PR #107126)
https://github.com/Renaud-K updated https://github.com/llvm/llvm-project/pull/107126 >From 8a1c51bdd290fc47cac359646aeb01623574231f Mon Sep 17 00:00:00 2001 From: Renaud-K Date: Tue, 3 Sep 2024 09:34:09 -0700 Subject: [PATCH 1/4] Allow disabling of types from the command line --- clang/include/clang/Driver/Options.td| 6 ++ flang/include/flang/Frontend/TargetOptions.h | 6 ++ flang/include/flang/Tools/TargetSetup.h | 11 ++- flang/lib/Frontend/CompilerInvocation.cpp| 17 ++--- flang/tools/bbc/bbc.cpp | 5 +++-- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 83cf753e824845..8bc47fea5196e7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6761,6 +6761,12 @@ def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group, HelpText<"Set the default integer and logical kind to an 8 byte wide type">; def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group, HelpText<"Set the default real kind to an 8 byte wide type">; +def fdisable_real_3 : Flag<["-"],"fdisable-real-3">, Group, + Flags<[HelpHidden]>; +def fdisable_real_10 : Flag<["-"],"fdisable-real-10">, Group, + Flags<[HelpHidden]>; +def fdisable_integer_16 : Flag<["-"],"fdisable-integer-16">, Group, + Flags<[HelpHidden]>; def flarge_sizes : Flag<["-"],"flarge-sizes">, Group, HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">; diff --git a/flang/include/flang/Frontend/TargetOptions.h b/flang/include/flang/Frontend/TargetOptions.h index fa72c77a028a1c..b0b64ae583d16c 100644 --- a/flang/include/flang/Frontend/TargetOptions.h +++ b/flang/include/flang/Frontend/TargetOptions.h @@ -38,6 +38,12 @@ class TargetOptions { /// The list of target specific features to enable or disable, as written on /// the command line. std::vector featuresAsWritten; + + /// The real KINDs disabled for this target + std::vector disabledRealKinds; + + /// The integer KINDs disabled for this target + std::vector disabledIntegerKinds; }; } // end namespace Fortran::frontend diff --git a/flang/include/flang/Tools/TargetSetup.h b/flang/include/flang/Tools/TargetSetup.h index 238d66c9241dd0..b112b6b4d80578 100644 --- a/flang/include/flang/Tools/TargetSetup.h +++ b/flang/include/flang/Tools/TargetSetup.h @@ -10,6 +10,7 @@ #define FORTRAN_TOOLS_TARGET_SETUP_H #include "flang/Evaluate/target.h" +#include "flang/Frontend/TargetOptions.h" #include "llvm/Target/TargetMachine.h" namespace Fortran::tools { @@ -17,6 +18,7 @@ namespace Fortran::tools { [[maybe_unused]] inline static void setUpTargetCharacteristics( Fortran::evaluate::TargetCharacteristics &targetCharacteristics, const llvm::TargetMachine &targetMachine, +const Fortran::frontend::TargetOptions &targetOptions, const std::string &compilerVersion, const std::string &compilerOptions) { const llvm::Triple &targetTriple{targetMachine.getTargetTriple()}; @@ -24,7 +26,14 @@ namespace Fortran::tools { if (targetTriple.getArch() != llvm::Triple::ArchType::x86_64) targetCharacteristics.DisableType( Fortran::common::TypeCategory::Real, /*kind=*/10); - + for (auto realKind : targetOptions.disabledRealKinds) { +targetCharacteristics.DisableType( +common::TypeCategory::Real, realKind); + } + for (auto intKind : targetOptions.disabledIntegerKinds) { +targetCharacteristics.DisableType( +common::TypeCategory::Integer, intKind); + } targetCharacteristics.set_compilerOptionsString(compilerOptions) .set_compilerVersionString(compilerVersion); diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 1d73397d330178..5676947c2b1016 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -438,8 +438,19 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) { for (const llvm::opt::Arg *currentArg : args.filtered(clang::driver::options::OPT_target_feature)) opts.featuresAsWritten.emplace_back(currentArg->getValue()); -} + if (args.hasArg(clang::driver::options::OPT_fdisable_real_10)) { +opts.disabledRealKinds.push_back(10); + } + + if (args.hasArg(clang::driver::options::OPT_fdisable_real_3)) { +opts.disabledRealKinds.push_back(3); + } + + if (args.hasArg(clang::driver::options::OPT_fdisable_integer_16)) { +opts.disabledIntegerKinds.push_back(16); + } +} // Tweak the frontend configuration based on the frontend action static void setUpFrontendBasedOnAction(FrontendOptions &opts) { if (opts.programAction == DebugDumpParsingLog) @@ -1529,8 +1540,8 @@ CompilerInvocation::getSemanticsCtx( std::string compilerVersion = Fortran::common::getFlangFullVersion(); Fortran::tools::setUpTargetCharacteristics( - semantic
[clang] Make PCH's respect any VFS specified. (PR #106577)
@@ -1115,13 +1115,13 @@ void ASTWriter::WriteBlockInfoBlock() { } /// Prepares a path for being written to an AST file by converting it -/// to an absolute path and removing nested './'s. +/// to an absolute path and removing nested './'s and '../'s. /// /// \return \c true if the path was changed. static bool cleanPathForOutput(FileManager &FileMgr, SmallVectorImpl &Path) { bool Changed = FileMgr.makeAbsolutePath(Path); - return Changed | llvm::sys::path::remove_dots(Path); + return Changed | llvm::sys::path::remove_dots(Path, true); llvm-beanz wrote: This looks right to me, but it doesn't seem like this is covered in your test. Can you add a test to make sure that we provide a path with `..` in it that needs to get resolved? https://github.com/llvm/llvm-project/pull/106577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Make PCH's respect any VFS specified. (PR #106577)
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl &Path) { Changed = true; } + // If we are generating a normal PCH (EG. not a C++ module). + if (!WritingModule) { +// Use the vfs overlay if it exists to translate paths. +auto &FileSys = +Context->getSourceManager().getFileManager().getVirtualFileSystem(); + +if (auto *RFS = dyn_cast(&FileSys)) { llvm-beanz wrote: If instead of calling `cleanPathForOutput` above we call `getRealPath` on the vfs, does that solve this problem? I'm just a little wary about needing to look into the vfs implementation because in theory the abstraction shouldn't require us to look through it. (cc @benlangmuir & @vsapsai who I believe have done work in this area) https://github.com/llvm/llvm-project/pull/106577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Treat default template argument as constant expressions (PR #107073)
@@ -97,3 +97,29 @@ void foo() { } #endif + +#if __cplusplus >= 202002L +void GH107048() { + constexpr int x{}; + const int y{}; + auto b = []{}; + using A = decltype([]{}); + + int z; // expected-note {{'z' declared here}} + auto c = []{ +// expected-error@-1 {{no matching function for call to object of type}} \ +// expected-error@-1 {{variable 'z' cannot be implicitly captured in a lambda with no capture-default specified}} \ +// expected-note@-1 {{lambda expression begins here}} \ +// expected-note@-1 4{{capture}} \ +// expected-note@-1 {{candidate template ignored: substitution failure: reference to local variable 'z' declared in enclosing function}} +return t; + }(); + + struct S {}; + constexpr S s; // expected-note {{'s' declared here}} + auto class_type = []{}; + // expected-error@-1 {{variable 's' cannot be implicitly captured in a lambda with no capture-default specified}} \ + // expected-note@-1 {{lambda expression begins here}} \ + // expected-note@-1 4{{capture}} shafik wrote: Curious about these cases: https://godbolt.org/z/xWbWYfnf3 ```cpp struct S {}; constexpr S s; void f() { auto class_type = []{}; } void h() { static constexpr S s; auto class_type = []{}; } template void g() {} ``` https://github.com/llvm/llvm-project/pull/107073 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Update clang tidy Contributing guide (PR #106672)
MichelleCDjunaidi wrote: Will open the issue soon (since mobile Github is accessible), but the additional new PR will be in a few days (no access to laptop currently) https://github.com/llvm/llvm-project/pull/106672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support outgoing calls in call hierarchy (PR #77556)
HighCommander4 wrote: @kadircet perhaps you might be able to pick up this review? Or, barring of a full review, your opinion on the directional question in [this comment](https://reviews.llvm.org/D93829#4654786) would be appreciated as well: > how would you feel about proceeding with the patch in its current state, with > the memory usage increase brought down from 8.2% to 2.5% thanks to the > combination of the simple lookup optimization + RefKind filtering, and > leaving the "deep lookup optimization" to be explored in a future change? https://github.com/llvm/llvm-project/pull/77556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)
topperc wrote: @JinjinLi868 are you still working on this? https://github.com/llvm/llvm-project/pull/89051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Apply resource attributes to the resource type rather than the handle member (PR #107160)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/107160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 99f02a8 - [clang] Add tests for CWG issues about language linkage (#107019)
Author: Vlad Serebrennikov Date: 2024-09-04T05:35:13+04:00 New Revision: 99f02a874984f2b79c3fbd8ae6bbceb7366521ad URL: https://github.com/llvm/llvm-project/commit/99f02a874984f2b79c3fbd8ae6bbceb7366521ad DIFF: https://github.com/llvm/llvm-project/commit/99f02a874984f2b79c3fbd8ae6bbceb7366521ad.diff LOG: [clang] Add tests for CWG issues about language linkage (#107019) This patch covers Core issues about language linkage during declaration matching resolved in [P1787R6](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html), namely [CWG563](https://cplusplus.github.io/CWG/issues/563.html) and [CWG1818](https://cplusplus.github.io/CWG/issues/1818.html). [CWG563](https://cplusplus.github.io/CWG/issues/563.html) "Linkage specification for objects" --- [P1787R6](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html): > [CWG563](https://cplusplus.github.io/CWG/issues/563.html) is resolved by simplifications that follow its suggestions. Wording ([[dcl.link]/5](https://eel.is/c++draft/dcl.link#5)): > In a [linkage-specification](https://eel.is/c++draft/dcl.link#nt:linkage-specification), the specified language linkage applies to the function types of all function declarators and to all functions and variables whose names have external linkage[.](https://eel.is/c++draft/dcl.link#5.sentence-5) Now the wording clearly says that linkage-specification applies to variables with external linkage. [CWG1818](https://cplusplus.github.io/CWG/issues/1818.html) "Visibility and inherited language linkage" [P1787R6](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html): > [CWG386](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#386), [CWG1839](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1839), [CWG1818](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1818), [CWG2058](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2058), [CWG1900](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1900), and Richard’s observation in [“are non-type names ignored in a class-head-name or enum-head-name?”](http://lists.isocpp.org/core/2017/01/1604.php) are resolved by describing the limited lookup that occurs for a declarator-id, including the changes in Richard’s [proposed resolution for CWG1839](http://wiki.edg.com/pub/Wg21cologne2019/CoreWorkingGroup/cwg1839.html) (which also resolves CWG1818 and what of CWG2058 was not resolved along with CWG2059) and rejecting the example from [CWG1477](http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1477). Wording ([[dcl.link]/6](https://eel.is/c++draft/dcl.link#6)): > A redeclaration of an entity without a linkage specification inherits the language linkage of the entity and (if applicable) its type[.](https://eel.is/c++draft/dcl.link#6.sentence-2). Answer to the question in the example is `extern "C"`, and not linkage mismatch. Further analysis of the example is provided as inline comments in the test itself. Note that https://eel.is/c++draft/dcl.link#7 does NOT apply in this example, as it's focused squarely at declarations that are already known to have C language linkage, and declarations of variables in the global scope. Added: clang/test/CXX/drs/cwg1818.cpp clang/test/CXX/drs/cwg563.cpp Modified: clang/test/CXX/drs/cwg18xx.cpp clang/test/CXX/drs/cwg5xx.cpp clang/www/cxx_dr_status.html Removed: diff --git a/clang/test/CXX/drs/cwg1818.cpp b/clang/test/CXX/drs/cwg1818.cpp new file mode 100644 index 00..bf2d12696a729c --- /dev/null +++ b/clang/test/CXX/drs/cwg1818.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s +// RUN: %clang_cc1 -std=c++11 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s +// RUN: %clang_cc1 -std=c++14 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s +// RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s +// RUN: %clang_cc1 -std=c++20 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s +// RUN: %clang_cc1 -std=c++23 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s +// RUN: %clang_cc1 -std=c++2c %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s + +// expected-no-diagnostics + +namespace cwg1818 { // cwg1818: 3.4 +extern "C" void f() { + // This declaration binds name 'g' in the scope of function 'f', + // but its target scope corresponds to namespace 'cwg1818' (_N4988_.[dcl.meaning]/3.5). + // Linkage specification of 'f' applies to 'g' per _N4988_.[dcl.link]/5. + void g(); +} +// Target scope of this declaration is naturally the o
[clang] [clang] Add tests for CWG issues about language linkage (PR #107019)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/107019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee Message-ID: In-Reply-To: ChuanqiXu9 wrote: > > Got it. I am pretty interested use case for modules. And from your commit > > history, it looks like you prefer header units than named modules? > > Yes, we prefer header units for the time being because it can be implemented > with minimal sources changes and gives moderate compile time improvements. > Also it should open future path to named modules. Also with header units we > have some flexibility how to compose modules. In our experiments build time > perforce significantly depends on number of modules required for compilation > number of AST nodes that are merged. Got it. Looking for your public reports : ) https://github.com/llvm/llvm-project/pull/104512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)
h-vetinari wrote: Given the state of the discussion on discourse, I looked at this PR again, and was curious about conflicts with main. I don't think I'm the right person to propose this as a PR, but if someone wants to take my attempt as a jumping-off point, I put the branch [here](https://github.com/h-vetinari/llvm-project/tree/flang_rename). https://github.com/llvm/llvm-project/pull/74377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement support for HLSL intrinsic - select (PR #107129)
@@ -0,0 +1,76 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s --check-prefixes=CHECK + +// CHECK: %hlsl.select = select i1 +// CHECK: ret i32 %hlsl.select +int test_select_bool_int(bool cond0, int tVal, int fVal) { return select(cond0, tVal, fVal); } llvm-beanz wrote: I agree with @damyanp, that these are easier to read if formatted. That said, clang doesn't require formatting test cases since formatting sometimes formatting matters to tests. That obviously isn't the case here, but formatting for readability is good. https://github.com/llvm/llvm-project/pull/107129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits