[clang] [Clang][NFC] Add test for CWG2285 "Issues with structured bindings" (PR #126421)
https://github.com/cor3ntin approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/126421 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add test for CWG2285 "Issues with structured bindings" (PR #126421)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/126421 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
@@ -68,7 +68,7 @@ class RISCVTargetInfo : public TargetInfo { return TargetInfo::VoidPtrBuiltinVaList; } - std::string_view getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return "~{vl},~{vtype}"; } wangpc-pp wrote: ```suggestion std::string_view getClobbers() const override { if (ISAInfo->hasExtension("zve32x")) return "~{vl},~{vtype}"; return ""; } ``` https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
https://github.com/wangpc-pp commented: I see. But what's the difference if we add `vl/vtype` to the list of clobbered registers explicitly in C/C++ asm statements? https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
https://github.com/wangpc-pp edited https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [NVPTX] Convert vector function nvvm.annotations to attributes (PR #127736)
https://github.com/grypp approved this pull request. https://github.com/llvm/llvm-project/pull/127736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] Enable module splitting by default (PR #128509)
@@ -708,6 +712,34 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D, options::OPT_m_amdgpu_Features_Group); } +static unsigned GetFullLTOPartitions(const Driver &D, const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_flto_partitions_EQ); + // In the absence of an option, use the number of available threads with a cap + // at 16 partitions. More than 16 partitions rarely benefits code splitting + // and can lead to more empty/small modules each with their own overhead. + if (!A) +return std::max(16u, llvm::hardware_concurrency().compute_thread_count()); jmmartinez wrote: "More than 16 partitions rarely benefits code splitting" -> In that case shouldn't it be the std::min between 16 and thread_count ? https://github.com/llvm/llvm-project/pull/128509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Fuchsia] Support PGO (PR #128680)
https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/128680 >From 0662cddc6837c281c102995e2789bb0f81adb415 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Fri, 7 Feb 2025 08:49:18 -0800 Subject: [PATCH 1/2] [Fuchsia] Support PGO Enable 2-stage builds with PGO. --- .../caches/Fuchsia-stage2-instrumented.cmake | 44 clang/cmake/caches/Fuchsia.cmake | 106 +- 2 files changed, 119 insertions(+), 31 deletions(-) create mode 100644 clang/cmake/caches/Fuchsia-stage2-instrumented.cmake diff --git a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake new file mode 100644 index 0..b3c3b63066363 --- /dev/null +++ b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake @@ -0,0 +1,44 @@ +# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build. + +include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake) + +if(NOT APPLE) + set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") +endif() + +set(CLANG_BOOTSTRAP_TARGETS + check-all + check-clang + check-lld + check-llvm + clang + clang-test-depends + toolchain-distribution + install-toolchain-distribution + install-toolchain-distribution-stripped + install-toolchain-distribution-toolchain + lld-test-depends + llvm-config + llvm-test-depends + test-depends + test-suite CACHE STRING "") + +get_cmake_property(variableNames VARIABLES) +foreach(variableName ${variableNames}) + if(variableName MATCHES "^STAGE2_") +string(REPLACE "STAGE2_" "" new_name ${variableName}) +list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}") + endif() +endforeach() + +set(CLANG_PGO_TRAINING_DEPS + builtins + runtimes + CACHE STRING "") + +# Setup the bootstrap build. +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS + ${EXTRA_ARGS} + -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake + CACHE STRING "") diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake index 83336589da305..1bb6f9105dce9 100644 --- a/clang/cmake/caches/Fuchsia.cmake +++ b/clang/cmake/caches/Fuchsia.cmake @@ -126,6 +126,16 @@ else() set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") set(LIBCXX_HARDENING_MODE "none" CACHE STRING "") set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") + set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "") + set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "") + set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "") + set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "") + set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") + set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "") + set(SANITIZER_CXX_ABI "libc++" CACHE STRING "") + set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") + set(SANITIZER_TEST_CXX "libc++" CACHE STRING "") + set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "") set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "") endif() @@ -164,34 +174,57 @@ endif() set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") +set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "") -set(_FUCHSIA_BOOTSTRAP_TARGETS - check-all - check-clang - check-lld - check-llvm - check-polly - llvm-config - clang-test-depends - lld-test-depends - llvm-test-depends - test-suite - test-depends - toolchain-distribution - install-toolchain-distribution - install-toolchain-distribution-stripped - install-toolchain-distribution-toolchain - clang) - -if(FUCHSIA_ENABLE_LLDB) - list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) - list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS -check-lldb -lldb-test-depends -debugger-distribution -install-debugger-distribution -install-debugger-distribution-stripped -install-debugger-distribution-toolchain) +if(FUCHSIA_ENABLE_PGO) + set(_FUCHSIA_BOOTSTRAP_TARGETS +generate-profdata +stage2 +stage2-toolchain-distribution +stage2-install-toolchain-distribution +stage2-install-toolchain-distribution-stripped +stage2-install-toolchain-distribution-toolchain +stage2-check-all +stage2-check-lld +stage2-check-llvm +stage2-check-clang +stage2-test-suite) + if(FUCHSIA_ENABLE_LLDB) +list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) +list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS + stage2-check-lldb + stage2-debugger-distribution + stage2-install-debugger-distribution + stage2-install-debugger-distribution-stripped + stage2-install-debugger-distribution-toolchain) + endif() +else() + set(_FUCHSIA_BOOTSTRAP_TARGETS + check-all + check-clang + check-lld + check-llvm + llvm-config + clang + clang-test-depends + lld-test-depends + llvm-test-depends + test-suite + test-depends + toolchain-distribution + install-toolchain-distribution + install-toolcha
[clang] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF (PR #128679)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) Changes Add a new WebKit checker to validate the correct use of RetainPtr constructor as well as adoptNS and adoptCF functions. adoptNS and adoptCf are used for +1 semantics and RetainPtr constructor is used for +0 semantics. --- Patch is 29.52 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/128679.diff 9 Files Affected: - (modified) clang/docs/analyzer/checkers.rst (+20) - (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+4) - (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (+1) - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp (+4-3) - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h (+2-1) - (added) clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp (+347) - (modified) clang/test/Analysis/Checkers/WebKit/objc-mock-types.h (+132-14) - (added) clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm (+85) - (added) clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm (+85) ``diff diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index c1eedb33e74d2..4cbd31f44d3f6 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -3713,6 +3713,26 @@ Here are some examples of situations that we warn about as they *might* be poten NSObject* unretained = retained.get(); // warn } +webkit.RetainPtrCtorAdoptChecker + +The goal of this rule is to make sure the constructor of RetinPtr as well as adoptNS and adoptCF are used correctly. +When creating a RetainPtr with +1 semantics, adoptNS or adoptCF should be used, and in +0 semantics, RetainPtr constructor should be used. +Warn otherwise. + +These are examples of cases that we consider correct: + + .. code-block:: cpp + +RetainPtr ptr = adoptNS([[NSObject alloc] init]); // ok +RetainPtr ptr = CGImageGetColorSpace(image); // ok + +Here are some examples of cases that we consider incorrect use of RetainPtr constructor and adoptCF + + .. code-block:: cpp + +RetainPtr ptr = [[NSObject alloc] init]; // warn +auto ptr = adoptCF(CGImageGetColorSpace(image)); // warn + Debug Checkers --- diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 410f841630660..9aa696d8803b1 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -1786,4 +1786,8 @@ def UnretainedLocalVarsChecker : Checker<"UnretainedLocalVarsChecker">, HelpText<"Check unretained local variables.">, Documentation; +def RetainPtrCtorAdoptChecker : Checker<"RetainPtrCtorAdoptChecker">, + HelpText<"Check for correct use of RetainPtr constructor, adoptNS, and adoptCF">, + Documentation; + } // end alpha.webkit diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt index 5910043440987..0b6b169d7b447 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -133,6 +133,7 @@ add_clang_library(clangStaticAnalyzerCheckers WebKit/MemoryUnsafeCastChecker.cpp WebKit/PtrTypesSemantics.cpp WebKit/RefCntblBaseVirtualDtorChecker.cpp + WebKit/RetainPtrCtorAdoptChecker.cpp WebKit/RawPtrRefCallArgsChecker.cpp WebKit/UncountedLambdaCapturesChecker.cpp WebKit/RawPtrRefLocalVarsChecker.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 7899b19854806..7e7bd49ca0bdb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -225,15 +225,16 @@ void RetainTypeChecker::visitTypedef(const TypedefDecl *TD) { return; for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) { -if (Redecl->getAttr()) { +if (Redecl->getAttr() || +Redecl->getAttr()) { CFPointees.insert(RT); return; } } } -bool RetainTypeChecker::isUnretained(const QualType QT) { - if (ento::cocoa::isCocoaObjectRef(QT) && !IsARCEnabled) +bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) { + if (ento::cocoa::isCocoaObjectRef(QT) && (!IsARCEnabled || ignoreARC)) return true; auto CanonicalType = QT.getCanonicalType(); auto PointeeType = CanonicalType->getPointeeType(); diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h index fcc1a41dba78b..f69d374cbbf90 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h @@ -75,7 +
[clang] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF (PR #128679)
https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/128679 Add a new WebKit checker to validate the correct use of RetainPtr constructor as well as adoptNS and adoptCF functions. adoptNS and adoptCf are used for +1 semantics and RetainPtr constructor is used for +0 semantics. >From b4001f95cf6d35f59ef8af6df8f2bdbe043da380 Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Tue, 25 Feb 2025 00:47:45 -0800 Subject: [PATCH] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF Add a new WebKit checker to validate the correct use of RetainPtr constructor as well as adoptNS and adoptCF functions. adoptNS and adoptCf are used for +1 semantics and RetainPtr constructor is used for +0 semantics. --- clang/docs/analyzer/checkers.rst | 20 + .../clang/StaticAnalyzer/Checkers/Checkers.td | 4 + .../StaticAnalyzer/Checkers/CMakeLists.txt| 1 + .../Checkers/WebKit/PtrTypesSemantics.cpp | 7 +- .../Checkers/WebKit/PtrTypesSemantics.h | 3 +- .../WebKit/RetainPtrCtorAdoptChecker.cpp | 347 ++ .../Checkers/WebKit/objc-mock-types.h | 146 +++- .../WebKit/retain-ptr-ctor-adopt-use-arc.mm | 85 + .../WebKit/retain-ptr-ctor-adopt-use.mm | 85 + 9 files changed, 680 insertions(+), 18 deletions(-) create mode 100644 clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp create mode 100644 clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm create mode 100644 clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index c1eedb33e74d2..4cbd31f44d3f6 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -3713,6 +3713,26 @@ Here are some examples of situations that we warn about as they *might* be poten NSObject* unretained = retained.get(); // warn } +webkit.RetainPtrCtorAdoptChecker + +The goal of this rule is to make sure the constructor of RetinPtr as well as adoptNS and adoptCF are used correctly. +When creating a RetainPtr with +1 semantics, adoptNS or adoptCF should be used, and in +0 semantics, RetainPtr constructor should be used. +Warn otherwise. + +These are examples of cases that we consider correct: + + .. code-block:: cpp + +RetainPtr ptr = adoptNS([[NSObject alloc] init]); // ok +RetainPtr ptr = CGImageGetColorSpace(image); // ok + +Here are some examples of cases that we consider incorrect use of RetainPtr constructor and adoptCF + + .. code-block:: cpp + +RetainPtr ptr = [[NSObject alloc] init]; // warn +auto ptr = adoptCF(CGImageGetColorSpace(image)); // warn + Debug Checkers --- diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 410f841630660..9aa696d8803b1 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -1786,4 +1786,8 @@ def UnretainedLocalVarsChecker : Checker<"UnretainedLocalVarsChecker">, HelpText<"Check unretained local variables.">, Documentation; +def RetainPtrCtorAdoptChecker : Checker<"RetainPtrCtorAdoptChecker">, + HelpText<"Check for correct use of RetainPtr constructor, adoptNS, and adoptCF">, + Documentation; + } // end alpha.webkit diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt index 5910043440987..0b6b169d7b447 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -133,6 +133,7 @@ add_clang_library(clangStaticAnalyzerCheckers WebKit/MemoryUnsafeCastChecker.cpp WebKit/PtrTypesSemantics.cpp WebKit/RefCntblBaseVirtualDtorChecker.cpp + WebKit/RetainPtrCtorAdoptChecker.cpp WebKit/RawPtrRefCallArgsChecker.cpp WebKit/UncountedLambdaCapturesChecker.cpp WebKit/RawPtrRefLocalVarsChecker.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 7899b19854806..7e7bd49ca0bdb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -225,15 +225,16 @@ void RetainTypeChecker::visitTypedef(const TypedefDecl *TD) { return; for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) { -if (Redecl->getAttr()) { +if (Redecl->getAttr() || +Redecl->getAttr()) { CFPointees.insert(RT); return; } } } -bool RetainTypeChecker::isUnretained(const QualType QT) { - if (ento::cocoa::isCocoaObjectRef(QT) && !IsARCEnabled) +bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) { + if (ento::cocoa::isCocoaObjectRef(
[clang] [Fuchsia] Support PGO (PR #128680)
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/128680 Enable 2-stage builds with PGO. >From 0662cddc6837c281c102995e2789bb0f81adb415 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Fri, 7 Feb 2025 08:49:18 -0800 Subject: [PATCH 1/2] [Fuchsia] Support PGO Enable 2-stage builds with PGO. --- .../caches/Fuchsia-stage2-instrumented.cmake | 44 clang/cmake/caches/Fuchsia.cmake | 106 +- 2 files changed, 119 insertions(+), 31 deletions(-) create mode 100644 clang/cmake/caches/Fuchsia-stage2-instrumented.cmake diff --git a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake new file mode 100644 index 0..b3c3b63066363 --- /dev/null +++ b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake @@ -0,0 +1,44 @@ +# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build. + +include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake) + +if(NOT APPLE) + set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") +endif() + +set(CLANG_BOOTSTRAP_TARGETS + check-all + check-clang + check-lld + check-llvm + clang + clang-test-depends + toolchain-distribution + install-toolchain-distribution + install-toolchain-distribution-stripped + install-toolchain-distribution-toolchain + lld-test-depends + llvm-config + llvm-test-depends + test-depends + test-suite CACHE STRING "") + +get_cmake_property(variableNames VARIABLES) +foreach(variableName ${variableNames}) + if(variableName MATCHES "^STAGE2_") +string(REPLACE "STAGE2_" "" new_name ${variableName}) +list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}") + endif() +endforeach() + +set(CLANG_PGO_TRAINING_DEPS + builtins + runtimes + CACHE STRING "") + +# Setup the bootstrap build. +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS + ${EXTRA_ARGS} + -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake + CACHE STRING "") diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake index 83336589da305..1bb6f9105dce9 100644 --- a/clang/cmake/caches/Fuchsia.cmake +++ b/clang/cmake/caches/Fuchsia.cmake @@ -126,6 +126,16 @@ else() set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") set(LIBCXX_HARDENING_MODE "none" CACHE STRING "") set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") + set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "") + set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "") + set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "") + set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "") + set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") + set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "") + set(SANITIZER_CXX_ABI "libc++" CACHE STRING "") + set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") + set(SANITIZER_TEST_CXX "libc++" CACHE STRING "") + set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "") set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "") endif() @@ -164,34 +174,57 @@ endif() set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") +set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "") -set(_FUCHSIA_BOOTSTRAP_TARGETS - check-all - check-clang - check-lld - check-llvm - check-polly - llvm-config - clang-test-depends - lld-test-depends - llvm-test-depends - test-suite - test-depends - toolchain-distribution - install-toolchain-distribution - install-toolchain-distribution-stripped - install-toolchain-distribution-toolchain - clang) - -if(FUCHSIA_ENABLE_LLDB) - list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) - list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS -check-lldb -lldb-test-depends -debugger-distribution -install-debugger-distribution -install-debugger-distribution-stripped -install-debugger-distribution-toolchain) +if(FUCHSIA_ENABLE_PGO) + set(_FUCHSIA_BOOTSTRAP_TARGETS +generate-profdata +stage2 +stage2-toolchain-distribution +stage2-install-toolchain-distribution +stage2-install-toolchain-distribution-stripped +stage2-install-toolchain-distribution-toolchain +stage2-check-all +stage2-check-lld +stage2-check-llvm +stage2-check-clang +stage2-test-suite) + if(FUCHSIA_ENABLE_LLDB) +list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) +list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS + stage2-check-lldb + stage2-debugger-distribution + stage2-install-debugger-distribution + stage2-install-debugger-distribution-stripped + stage2-install-debugger-distribution-toolchain) + endif() +else() + set(_FUCHSIA_BOOTSTRAP_TARGETS + check-all + check-clang + check-lld + check-llvm + llvm-config + clang + clang-test-depends + lld-test-depends + llvm-test-depends + test-suite + test-depends + toolchain-distribution + install-toolchain
[clang] [Fuchsia] Support PGO (PR #128680)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Petr Hosek (petrhosek) Changes Enable 2-stage builds with PGO. --- Full diff: https://github.com/llvm/llvm-project/pull/128680.diff 2 Files Affected: - (added) clang/cmake/caches/Fuchsia-stage2-instrumented.cmake (+44) - (modified) clang/cmake/caches/Fuchsia.cmake (+76-31) ``diff diff --git a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake new file mode 100644 index 0..b3c3b63066363 --- /dev/null +++ b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake @@ -0,0 +1,44 @@ +# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build. + +include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake) + +if(NOT APPLE) + set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") +endif() + +set(CLANG_BOOTSTRAP_TARGETS + check-all + check-clang + check-lld + check-llvm + clang + clang-test-depends + toolchain-distribution + install-toolchain-distribution + install-toolchain-distribution-stripped + install-toolchain-distribution-toolchain + lld-test-depends + llvm-config + llvm-test-depends + test-depends + test-suite CACHE STRING "") + +get_cmake_property(variableNames VARIABLES) +foreach(variableName ${variableNames}) + if(variableName MATCHES "^STAGE2_") +string(REPLACE "STAGE2_" "" new_name ${variableName}) +list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}") + endif() +endforeach() + +set(CLANG_PGO_TRAINING_DEPS + builtins + runtimes + CACHE STRING "") + +# Setup the bootstrap build. +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS + ${EXTRA_ARGS} + -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake + CACHE STRING "") diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake index 83336589da305..4a46157d050a0 100644 --- a/clang/cmake/caches/Fuchsia.cmake +++ b/clang/cmake/caches/Fuchsia.cmake @@ -126,6 +126,16 @@ else() set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") set(LIBCXX_HARDENING_MODE "none" CACHE STRING "") set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") + set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "") + set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "") + set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "") + set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "") + set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") + set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "") + set(SANITIZER_CXX_ABI "libc++" CACHE STRING "") + set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") + set(SANITIZER_TEST_CXX "libc++" CACHE STRING "") + set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "") set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "") endif() @@ -165,33 +175,57 @@ endif() set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") -set(_FUCHSIA_BOOTSTRAP_TARGETS - check-all - check-clang - check-lld - check-llvm - check-polly - llvm-config - clang-test-depends - lld-test-depends - llvm-test-depends - test-suite - test-depends - toolchain-distribution - install-toolchain-distribution - install-toolchain-distribution-stripped - install-toolchain-distribution-toolchain - clang) - -if(FUCHSIA_ENABLE_LLDB) - list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) - list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS -check-lldb -lldb-test-depends -debugger-distribution -install-debugger-distribution -install-debugger-distribution-stripped -install-debugger-distribution-toolchain) +if(FUCHSIA_ENABLE_PGO) + set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "") + + set(_FUCHSIA_BOOTSTRAP_TARGETS +generate-profdata +stage2 +stage2-toolchain-distribution +stage2-install-toolchain-distribution +stage2-install-toolchain-distribution-stripped +stage2-install-toolchain-distribution-toolchain +stage2-check-all +stage2-check-lld +stage2-check-llvm +stage2-check-clang +stage2-test-suite) + if(FUCHSIA_ENABLE_LLDB) +list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) +list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS + stage2-check-lldb + stage2-debugger-distribution + stage2-install-debugger-distribution + stage2-install-debugger-distribution-stripped + stage2-install-debugger-distribution-toolchain) + endif() +else() + set(_FUCHSIA_BOOTSTRAP_TARGETS + check-all + check-clang + check-lld + check-llvm + llvm-config + clang + clang-test-depends + lld-test-depends + llvm-test-depends + test-suite + test-depends + toolchain-distribution + install-toolchain-distribution + install-toolchain-distribution-stripped + install-toolchain-distribution-toolchain) + if(FUCHSIA_ENABLE_LLDB) + list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) + list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS + check-
[clang] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF (PR #128679)
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 b335d5a8303250cb49901ecae7570adf61abbd3c b4001f95cf6d35f59ef8af6df8f2bdbe043da380 --extensions cpp,h -- clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h clang/test/Analysis/Checkers/WebKit/objc-mock-types.h `` View the diff from clang-format here. ``diff diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp index 8727f89826..1f4fc0dd4b 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp @@ -12,12 +12,12 @@ #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/StmtVisitor.h" +#include "clang/Analysis/RetainSummaryManager.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "clang/Analysis/RetainSummaryManager.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SetVector.h" #include @@ -37,8 +37,7 @@ private: public: RetainPtrCtorAdoptChecker() - : Bug(this, -"Correct use of RetainPtr, adoptNS, and adoptCF", + : Bug(this, "Correct use of RetainPtr, adoptNS, and adoptCF", "WebKit coding guidelines") {} void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR, @@ -68,7 +67,7 @@ public: DeclWithIssue = D; return Base::TraverseDecl(D); } - + bool TraverseClassTemplateDecl(ClassTemplateDecl *CTD) { if (safeGetName(CTD) == "RetainPtr") return true; // Skip the contents of RetainPtr. @@ -95,8 +94,9 @@ public: }; LocalVisitor visitor(this); -Summaries = std::make_unique(TUD->getASTContext(), -true /* trackObjCAndCFObjects */, false /* trackOSObjects */); +Summaries = std::make_unique( +TUD->getASTContext(), true /* trackObjCAndCFObjects */, +false /* trackOSObjects */); RTC.visitTranslationUnitDecl(TUD); visitor.TraverseDecl(const_cast(TUD)); } @@ -112,7 +112,7 @@ public: return Name == "adoptNS" || Name == "adoptNSArc"; } - void visitCallExpr(const CallExpr *CE, const Decl* DeclWithIssue) const { + void visitCallExpr(const CallExpr *CE, const Decl *DeclWithIssue) const { if (BR->getSourceManager().isInSystemHeader(CE->getExprLoc())) return; @@ -138,7 +138,7 @@ public: } void visitConstructExpr(const CXXConstructExpr *CE, - const Decl* DeclWithIssue) const { + const Decl *DeclWithIssue) const { if (BR->getSourceManager().isInSystemHeader(CE->getExprLoc())) return; @@ -215,20 +215,20 @@ public: auto Summary = Summaries->getSummary(AnyCall(ObjCMsgExpr)); auto RetEffect = Summary->getRetEffect(); switch (RetEffect.getKind()) { - case RetEffect::NoRet: -return IsOwnedResult::Unknown; - case RetEffect::OwnedSymbol: -return IsOwnedResult::Owned; - case RetEffect::NotOwnedSymbol: -return IsOwnedResult::NotOwned; - case RetEffect::OwnedWhenTrackedReceiver: -if (auto *Receiver = ObjCMsgExpr->getInstanceReceiver()) { - E = Receiver->IgnoreParenCasts(); - continue; -} -return IsOwnedResult::Unknown; - case RetEffect::NoRetHard: -return IsOwnedResult::Unknown; +case RetEffect::NoRet: + return IsOwnedResult::Unknown; +case RetEffect::OwnedSymbol: + return IsOwnedResult::Owned; +case RetEffect::NotOwnedSymbol: + return IsOwnedResult::NotOwned; +case RetEffect::OwnedWhenTrackedReceiver: + if (auto *Receiver = ObjCMsgExpr->getInstanceReceiver()) { +E = Receiver->IgnoreParenCasts(); +continue; + } + return IsOwnedResult::Unknown; +case RetEffect::NoRetHard: + return IsOwnedResult::Unknown; } } if (auto *CXXCE = dyn_cast(E)) { @@ -262,16 +262,16 @@ public: auto Summary = Summaries->getSummary(AnyCall(CE)); auto RetEffect = Summary->getRetEffect(); switch (RetEffect.getKind()) { - case RetEffect::NoRet: -return IsOwnedResult::Unknown; - case RetEffect::OwnedSymbol: -
[clang] [clang][x86] Support -masm=intel in cpuid.h (PR #127331)
Alcaro wrote: So what's going on here? What's the next step? Who's waiting for who? https://github.com/llvm/llvm-project/pull/127331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)
https://github.com/Fznamznon approved this pull request. https://github.com/llvm/llvm-project/pull/125671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] libclc: Stop using asm declarations for r600 on amdgcn for get_global_size (PR #128692)
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/128692 Comparing the case where each dimension is used alone, the only codegen difference is a missed addressing mode fold for the constant offset in the old version due to an ancient bug. >From a6b39981322eb0d603852e8330776756f740db5b Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 25 Feb 2025 17:28:27 +0700 Subject: [PATCH] libclc: Stop using asm declarations for r600 on amdgcn for get_global_size Comparing the case where each dimension is used alone, the only codegen difference is a missed addressing mode fold for the constant offset in the old version due to an ancient bug. --- libclc/amdgcn/lib/workitem/get_global_size.cl | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libclc/amdgcn/lib/workitem/get_global_size.cl b/libclc/amdgcn/lib/workitem/get_global_size.cl index 2f28ca6066654..0fec7e24966fd 100644 --- a/libclc/amdgcn/lib/workitem/get_global_size.cl +++ b/libclc/amdgcn/lib/workitem/get_global_size.cl @@ -1,17 +1,13 @@ #include -uint __clc_amdgcn_get_global_size_x(void) __asm("llvm.r600.read.global.size.x"); -uint __clc_amdgcn_get_global_size_y(void) __asm("llvm.r600.read.global.size.y"); -uint __clc_amdgcn_get_global_size_z(void) __asm("llvm.r600.read.global.size.z"); - _CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { switch (dim) { case 0: -return __clc_amdgcn_get_global_size_x(); +return __builtin_amdgcn_grid_size_x(); case 1: -return __clc_amdgcn_get_global_size_y(); +return __builtin_amdgcn_grid_size_y(); case 2: -return __clc_amdgcn_get_global_size_z(); +return __builtin_amdgcn_grid_size_z(); default: return 1; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] libclc: Stop using asm declarations for r600 on amdgcn for get_global_size (PR #128692)
arsenm wrote: * **#128692** https://app.graphite.dev/github/pr/llvm/llvm-project/128692?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/128692?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/128692 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] libclc: Stop using asm declarations for r600 on amdgcn for get_global_size (PR #128692)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/128692 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Coroutines] Mark parameter allocas with coro.outside.frame metadata (PR #127653)
zmodem wrote: > Re: sroa/mem2reg, that's a valid concern with Hans's intrinsic approach. Is it still a concern in the latest version, which makes mem2reg aware of the intrinsic? I don't have a good feel for whether putting a flag on `AllocaInst` or using an intrinsic is less disruptive. Happy to take input on that one. > Going back to the beginning, why do we end up in a UAF situation? IIUC, the > ramp function should do the following: > * store the bytes of the trivial abi argument into an alloca > * call the move ctor into the coro frame > * co_return > * destroy the coro frame objects, matching the move ctor call > * destroy the alloca, matching the construction from earlier in the caller > > What is coro split doing that breaks this? It sounds like it's rewriting the > second destructor to destroy the variable in the frame, but that's incorrect. The problem is that the "parameter alloca" (first bullet point) incorrectly gets "promoted" to the coroutine frame. CoroSplit assumes it may be accessed across suspension points (I think it has to, as the address escapes via the "src" argument in the move ctor call). > What's different between the case where we suspend and the case where there > are no suspend points? The parameter's destructor runs at the end of the ramp function (last bullet point). If we're suspending, the coro frame is still alive at this point (for use when resuming). If the coro finished without suspending, the coro frame has been destroyed at this point, and we get UAF. https://github.com/llvm/llvm-project/pull/127653 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] libclc: Stop using asm declarations for r600 on amdgcn for get_global_size (PR #128692)
arsenm wrote: Actually the old codegen looks totally busted, loading from a constant offset from null https://github.com/llvm/llvm-project/pull/128692 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move log/log2/log10 to CLC library (PR #128540)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/128540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move logb/ilogb to CLC library; optimize (PR #128028)
@@ -0,0 +1,73 @@ +#if __CLC_FPSIZE == 32 + +_CLC_OVERLOAD _CLC_DEF __CLC_INTN __clc_ilogb(__CLC_GENTYPE x) { + __CLC_UINTN ux = __CLC_AS_UINTN(x); frasercrmck wrote: Yeah, I'm not sure using `frexp` is currently better given that there's no native path for it. We talked about allowing that in [the frexp PR](https://github.com/llvm/llvm-project/pull/127836#pullrequestreview-2628596638). But yeah even in that case, if we use the builtin/intrinsic for `frexp` it's not necessarily the case that it's faster than this implementation for `ilogb`. So I think the logb/ilogb-specific utility function would be the way to go. I don't think we've got canonical examples of target-specific code paths for utility functions in libclc. We could do it with the `SOURCES` system, or [preprocessor defines](https://github.com/llvm/llvm-project/blob/main/libclc/clc/include/clc/math/math.h#L41-L48) or some other system. I'm not yet sure. https://github.com/llvm/llvm-project/pull/128028 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] libclc: Stop using asm declarations for r600 on amdgcn for get_global_size (PR #128692)
https://github.com/frasercrmck approved this pull request. https://github.com/llvm/llvm-project/pull/128692 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF (PR #128679)
llvmbot wrote: @llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) Changes Add a new WebKit checker to validate the correct use of RetainPtr constructor as well as adoptNS and adoptCF functions. adoptNS and adoptCf are used for +1 semantics and RetainPtr constructor is used for +0 semantics. --- Patch is 29.52 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/128679.diff 9 Files Affected: - (modified) clang/docs/analyzer/checkers.rst (+20) - (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+4) - (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (+1) - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp (+4-3) - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h (+2-1) - (added) clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp (+347) - (modified) clang/test/Analysis/Checkers/WebKit/objc-mock-types.h (+132-14) - (added) clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm (+85) - (added) clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm (+85) ``diff diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index c1eedb33e74d2..4cbd31f44d3f6 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -3713,6 +3713,26 @@ Here are some examples of situations that we warn about as they *might* be poten NSObject* unretained = retained.get(); // warn } +webkit.RetainPtrCtorAdoptChecker + +The goal of this rule is to make sure the constructor of RetinPtr as well as adoptNS and adoptCF are used correctly. +When creating a RetainPtr with +1 semantics, adoptNS or adoptCF should be used, and in +0 semantics, RetainPtr constructor should be used. +Warn otherwise. + +These are examples of cases that we consider correct: + + .. code-block:: cpp + +RetainPtr ptr = adoptNS([[NSObject alloc] init]); // ok +RetainPtr ptr = CGImageGetColorSpace(image); // ok + +Here are some examples of cases that we consider incorrect use of RetainPtr constructor and adoptCF + + .. code-block:: cpp + +RetainPtr ptr = [[NSObject alloc] init]; // warn +auto ptr = adoptCF(CGImageGetColorSpace(image)); // warn + Debug Checkers --- diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 410f841630660..9aa696d8803b1 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -1786,4 +1786,8 @@ def UnretainedLocalVarsChecker : Checker<"UnretainedLocalVarsChecker">, HelpText<"Check unretained local variables.">, Documentation; +def RetainPtrCtorAdoptChecker : Checker<"RetainPtrCtorAdoptChecker">, + HelpText<"Check for correct use of RetainPtr constructor, adoptNS, and adoptCF">, + Documentation; + } // end alpha.webkit diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt index 5910043440987..0b6b169d7b447 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -133,6 +133,7 @@ add_clang_library(clangStaticAnalyzerCheckers WebKit/MemoryUnsafeCastChecker.cpp WebKit/PtrTypesSemantics.cpp WebKit/RefCntblBaseVirtualDtorChecker.cpp + WebKit/RetainPtrCtorAdoptChecker.cpp WebKit/RawPtrRefCallArgsChecker.cpp WebKit/UncountedLambdaCapturesChecker.cpp WebKit/RawPtrRefLocalVarsChecker.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 7899b19854806..7e7bd49ca0bdb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -225,15 +225,16 @@ void RetainTypeChecker::visitTypedef(const TypedefDecl *TD) { return; for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) { -if (Redecl->getAttr()) { +if (Redecl->getAttr() || +Redecl->getAttr()) { CFPointees.insert(RT); return; } } } -bool RetainTypeChecker::isUnretained(const QualType QT) { - if (ento::cocoa::isCocoaObjectRef(QT) && !IsARCEnabled) +bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) { + if (ento::cocoa::isCocoaObjectRef(QT) && (!IsARCEnabled || ignoreARC)) return true; auto CanonicalType = QT.getCanonicalType(); auto PointeeType = CanonicalType->getPointeeType(); diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h index fcc1a41dba78b..f69d374cbbf90 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSema
[clang] [clang-format] Allow breaking before kw___attribute (PR #128623)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/128623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AMDGPU] Enable module splitting by default (PR #128509)
https://github.com/Pierre-vh updated https://github.com/llvm/llvm-project/pull/128509 >From cae772441c0d87a017f5cc2cb0b9c970c6b7fcde Mon Sep 17 00:00:00 2001 From: pvanhout Date: Mon, 24 Feb 2025 14:21:49 +0100 Subject: [PATCH 1/3] [clang][AMDGPU] Enable module splitting by default The default number of partitions is the number of cores on the machine with a cap at 16, as going above 16 is unlikely to be useful in the common case. Adds a flto-partitions option to override the number of partitions easily (without having to use -Xoffload-linker). Setting it to 1 effectively disables module splitting. Fixes SWDEV-506214 --- clang/include/clang/Driver/Options.td | 6 ++-- clang/lib/Driver/ToolChains/AMDGPU.cpp| 36 +-- clang/lib/Driver/ToolChains/AMDGPU.h | 2 ++ clang/lib/Driver/ToolChains/HIPAMD.cpp| 2 ++ clang/test/Driver/amdgpu-toolchain.c | 20 +-- .../hip-toolchain-rdc-flto-partitions.hip | 35 ++ .../Driver/hip-toolchain-rdc-static-lib.hip | 2 ++ clang/test/Driver/hip-toolchain-rdc.hip | 1 + 8 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 clang/test/Driver/hip-toolchain-rdc-flto-partitions.hip diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e521cbf678d93..6cb2fd1b755c1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1393,6 +1393,8 @@ def fhip_emit_relocatable : Flag<["-"], "fhip-emit-relocatable">, HelpText<"Compile HIP source to relocatable">; def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">, HelpText<"Do not override toolchain to compile HIP source to relocatable">; +def flto_partitions_EQ : Joined<["--"], "flto-partitions=">, Group, + HelpText<"Number of partitions to use for parallel full LTO codegen. Use 1 to disable partitioning.">; } // Clang specific/exclusive options for OpenACC. @@ -3158,7 +3160,7 @@ def modules_reduced_bmi : Flag<["-"], "fmodules-reduced-bmi">, HelpText<"Generate the reduced BMI">, MarshallingInfoFlag>; -def experimental_modules_reduced_bmi : Flag<["-"], "fexperimental-modules-reduced-bmi">, +def experimental_modules_reduced_bmi : Flag<["-"], "fexperimental-modules-reduced-bmi">, Group, Visibility<[ClangOption, CC1Option]>, Alias; def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">, @@ -7417,7 +7419,7 @@ def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfie def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">, HelpText<"Turn off Type Based Alias Analysis">, MarshallingInfoFlag>; -defm pointer_tbaa: BoolOption<"", "pointer-tbaa", CodeGenOpts<"PointerTBAA">, +defm pointer_tbaa: BoolOption<"", "pointer-tbaa", CodeGenOpts<"PointerTBAA">, DefaultTrue, PosFlag, NegFlag, diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 6a35a2feabc9b..820a335a4b384 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -21,6 +21,7 @@ #include "llvm/Support/LineIterator.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include "llvm/Support/Threading.h" #include "llvm/Support/VirtualFileSystem.h" #include "llvm/TargetParser/Host.h" #include @@ -630,8 +631,11 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, getToolChain().AddFilePathLibArgs(Args, CmdArgs); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); if (C.getDriver().isUsingLTO()) { -addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0], - C.getDriver().getLTOMode() == LTOK_Thin); +const bool ThinLTO = (C.getDriver().getLTOMode() == LTOK_Thin); +addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0], ThinLTO); + +if (!ThinLTO) + addFullLTOPartitionOption(C.getDriver(), Args, CmdArgs); } else if (Args.hasArg(options::OPT_mcpu_EQ)) { CmdArgs.push_back(Args.MakeArgString( "-plugin-opt=mcpu=" + @@ -708,6 +712,34 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D, options::OPT_m_amdgpu_Features_Group); } +static unsigned GetFullLTOPartitions(const Driver &D, const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_flto_partitions_EQ); + // In the absence of an option, use the number of available threads with a cap + // at 16 partitions. More than 16 partitions rarely benefits code splitting + // and can lead to more empty/small modules each with their own overhead. + if (!A) +return std::max(16u, llvm::hardware_concurrency().compute_thread_count()); + int Value; + if (StringRef(A->getValue()).getAsInteger(10, Value) || (Value < 1)) { +D.Diag(diag::err_drv_invalid_int_value) +<< A->getAsString(Args) << A->getValue(); +return 1; + } + + return Value; +} + +void amdgpu::addFullLTOPartitionO
[libclc] [libclc] Stop installing CLC headers (PR #126908)
frasercrmck wrote: ping. Are the discussions above blocking the PR? If clang's internal headers are unsuitable must we fix those before landing this, or temporarily fix the installation of libclc's headers instead? https://github.com/llvm/llvm-project/pull/126908 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF (PR #128679)
https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/128679 >From b4001f95cf6d35f59ef8af6df8f2bdbe043da380 Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Tue, 25 Feb 2025 00:47:45 -0800 Subject: [PATCH 1/2] [alpha.webkit.webkit.RetainPtrCtorAdoptChecker] Add a new WebKit checker for correct use of RetainPtr, adoptNS, and adoptCF Add a new WebKit checker to validate the correct use of RetainPtr constructor as well as adoptNS and adoptCF functions. adoptNS and adoptCf are used for +1 semantics and RetainPtr constructor is used for +0 semantics. --- clang/docs/analyzer/checkers.rst | 20 + .../clang/StaticAnalyzer/Checkers/Checkers.td | 4 + .../StaticAnalyzer/Checkers/CMakeLists.txt| 1 + .../Checkers/WebKit/PtrTypesSemantics.cpp | 7 +- .../Checkers/WebKit/PtrTypesSemantics.h | 3 +- .../WebKit/RetainPtrCtorAdoptChecker.cpp | 347 ++ .../Checkers/WebKit/objc-mock-types.h | 146 +++- .../WebKit/retain-ptr-ctor-adopt-use-arc.mm | 85 + .../WebKit/retain-ptr-ctor-adopt-use.mm | 85 + 9 files changed, 680 insertions(+), 18 deletions(-) create mode 100644 clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp create mode 100644 clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm create mode 100644 clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index c1eedb33e74d2..4cbd31f44d3f6 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -3713,6 +3713,26 @@ Here are some examples of situations that we warn about as they *might* be poten NSObject* unretained = retained.get(); // warn } +webkit.RetainPtrCtorAdoptChecker + +The goal of this rule is to make sure the constructor of RetinPtr as well as adoptNS and adoptCF are used correctly. +When creating a RetainPtr with +1 semantics, adoptNS or adoptCF should be used, and in +0 semantics, RetainPtr constructor should be used. +Warn otherwise. + +These are examples of cases that we consider correct: + + .. code-block:: cpp + +RetainPtr ptr = adoptNS([[NSObject alloc] init]); // ok +RetainPtr ptr = CGImageGetColorSpace(image); // ok + +Here are some examples of cases that we consider incorrect use of RetainPtr constructor and adoptCF + + .. code-block:: cpp + +RetainPtr ptr = [[NSObject alloc] init]; // warn +auto ptr = adoptCF(CGImageGetColorSpace(image)); // warn + Debug Checkers --- diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 410f841630660..9aa696d8803b1 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -1786,4 +1786,8 @@ def UnretainedLocalVarsChecker : Checker<"UnretainedLocalVarsChecker">, HelpText<"Check unretained local variables.">, Documentation; +def RetainPtrCtorAdoptChecker : Checker<"RetainPtrCtorAdoptChecker">, + HelpText<"Check for correct use of RetainPtr constructor, adoptNS, and adoptCF">, + Documentation; + } // end alpha.webkit diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt index 5910043440987..0b6b169d7b447 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -133,6 +133,7 @@ add_clang_library(clangStaticAnalyzerCheckers WebKit/MemoryUnsafeCastChecker.cpp WebKit/PtrTypesSemantics.cpp WebKit/RefCntblBaseVirtualDtorChecker.cpp + WebKit/RetainPtrCtorAdoptChecker.cpp WebKit/RawPtrRefCallArgsChecker.cpp WebKit/UncountedLambdaCapturesChecker.cpp WebKit/RawPtrRefLocalVarsChecker.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 7899b19854806..7e7bd49ca0bdb 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -225,15 +225,16 @@ void RetainTypeChecker::visitTypedef(const TypedefDecl *TD) { return; for (auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) { -if (Redecl->getAttr()) { +if (Redecl->getAttr() || +Redecl->getAttr()) { CFPointees.insert(RT); return; } } } -bool RetainTypeChecker::isUnretained(const QualType QT) { - if (ento::cocoa::isCocoaObjectRef(QT) && !IsARCEnabled) +bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) { + if (ento::cocoa::isCocoaObjectRef(QT) && (!IsARCEnabled || ignoreARC)) return true; auto CanonicalType = QT.getCanonicalType(); auto PointeeType = CanonicalType->getPointeeType(); diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTyp
[clang] [lld] [llvm] Integrated Distributed ThinLTO (DTLTO): Initial support (PR #126654)
https://github.com/bd1976bris edited https://github.com/llvm/llvm-project/pull/126654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 547a8bc - [clang][x86] Support -masm=intel in cpuid.h (#127331)
Author: Alcaro Date: 2025-02-25T15:25:26+05:30 New Revision: 547a8bc2365d9f1dc7bce52580a3ab64d69c80ed URL: https://github.com/llvm/llvm-project/commit/547a8bc2365d9f1dc7bce52580a3ab64d69c80ed DIFF: https://github.com/llvm/llvm-project/commit/547a8bc2365d9f1dc7bce52580a3ab64d69c80ed.diff LOG: [clang][x86] Support -masm=intel in cpuid.h (#127331) Fixes #127271 Testing mostly done in Compiler Explorer https://godbolt.org/z/q1h3ohxr7 Added: Modified: clang/lib/Headers/cpuid.h clang/test/Headers/cpuid.c Removed: diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h index 2601aa5724f05..52addb7bfa856 100644 --- a/clang/lib/Headers/cpuid.h +++ b/clang/lib/Headers/cpuid.h @@ -267,18 +267,18 @@ : "0"(__leaf), "2"(__count)) #else /* x86-64 uses %rbx as the base register, so preserve it. */ -#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ -__asm(" xchgq %%rbx,%q1\n" \ - " cpuid\n" \ - " xchgq %%rbx,%q1" \ -: "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ +#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ +" cpuid\n" \ +" xchg{q|} {%%|}rbx,%q1" \ +: "=a"(__eax), "=r"(__ebx), "=c"(__ecx), "=d"(__edx) \ : "0"(__leaf)) -#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ -__asm(" xchgq %%rbx,%q1\n" \ - " cpuid\n" \ - " xchgq %%rbx,%q1" \ -: "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ +#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ +" cpuid\n" \ +" xchg{q|} {%%|}rbx,%q1" \ +: "=a"(__eax), "=r"(__ebx), "=c"(__ecx), "=d"(__edx) \ : "0"(__leaf), "2"(__count)) #endif @@ -289,20 +289,22 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf, #ifdef __i386__ int __cpuid_supported; -__asm(" pushfl\n" - " popl %%eax\n" - " movl %%eax,%%ecx\n" - " xorl $0x0020,%%eax\n" - " pushl %%eax\n" - " popfl\n" - " pushfl\n" - " popl %%eax\n" - " movl $0,%0\n" - " cmpl %%eax,%%ecx\n" +__asm(" pushf{l|d}\n" + " pop{l|} {%%|}eax\n" + " mov{l|} {%%eax,%%ecx|ecx,eax}\n" + " xor{l|} {$0x0020,%%eax|eax,0x0020}\n" + " push{l|} {%%|}eax\n" + " popf{l|d}\n" + " pushf{l|d}\n" + " pop{l|} {%%|}eax\n" + " mov{l|} {$0,%0|%0,0}\n" + " cmp{l|} {%%eax,%%ecx|ecx,eax}\n" " je 1f\n" - " movl $1,%0\n" + " mov{l|} {$1,%0|%0,1}\n" "1:" -: "=r" (__cpuid_supported) : : "eax", "ecx"); + : "=r"(__cpuid_supported) + : + : "eax", "ecx"); if (!__cpuid_supported) return 0; #endif diff --git a/clang/test/Headers/cpuid.c b/clang/test/Headers/cpuid.c index 6ed12eca7a61d..1c4f29dc52938 100644 --- a/clang/test/Headers/cpuid.c +++ b/clang/test/Headers/cpuid.c @@ -4,9 +4,9 @@ #include #include // Make sure multiple inclusion protection works. -// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm " xchgq %rbx,${1:q}\0A cpuid\0A xchgq %rbx,${1:q}", "={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}) -// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm " xchgq %rbx,${1:q}\0A cpuid\0A xchgq %rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}}) -// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm " xchgq %rbx,${1:q}\0A cpuid\0A xchgq %rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}}) +// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm " xchg$(q$|$) $(%$|$)rbx,${1:q}\0A cpuid\0A xchg$(q$|$) $(%$|$)rbx,${1:q}", "={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}) +// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm " xchg$(q$|$) $(%$|$)rbx,${1:q}\0A cpuid\0A xchg$(q$|$) $(%$|$)rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}}) +// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm " xchg$(q$|$) $(%$|$)rbx,${1:q}\0A cpuid\0A xchg$(q$|$) $(%$|$)rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}}) // CHECK-32: {{.*}} call { i32,
[clang] [clang][x86] Support -masm=intel in cpuid.h (PR #127331)
https://github.com/abhishek-kaushik22 closed https://github.com/llvm/llvm-project/pull/127331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move log/log2/log10 to CLC library (PR #128540)
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/128540 >From 0417fefc8b1d6b65941e48a1c2c4c700f601b38b Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 24 Feb 2025 17:27:59 + Subject: [PATCH 1/2] [libclc] Move log/log2/log10 to CLC library No changes to codegen for AMDGPU/Nvidia targets. Note that for simplicity this commit doesn't try to refactor or optimize the implementations. Notably, each log is only implementated for scalar types; vector types are scalarized. It doesn't look too difficult to make the implementations suitable for vector codegen, so I'll try that in a future commit. There's also an unused implementation of log in clc_log_base.h, whereas the implementation currently used by libclc targets re-uses log2 with an additional multiplication. That should also be cleaned up as on first inspection it looks a more optimal implementation, though it would have to be checked against the OpenCL CTS for good measure. --- libclc/clc/include/clc/math/clc_log.h | 12 + libclc/clc/include/clc/math/clc_log10.h| 12 + libclc/clc/include/clc/math/clc_log2.h | 12 + libclc/clc/lib/generic/SOURCES | 3 + libclc/clc/lib/generic/math/clc_log.cl | 38 +++ libclc/clc/lib/generic/math/clc_log10.cl | 47 +++ libclc/clc/lib/generic/math/clc_log2.cl| 47 +++ libclc/clc/lib/generic/math/clc_log_base.h | 339 + libclc/generic/include/clc/math/log10.h| 2 - libclc/generic/lib/math/log.cl | 26 +- libclc/generic/lib/math/log10.cl | 47 +-- libclc/generic/lib/math/log2.cl| 47 +-- libclc/generic/lib/math/log_base.h | 316 --- 13 files changed, 522 insertions(+), 426 deletions(-) create mode 100644 libclc/clc/include/clc/math/clc_log.h create mode 100644 libclc/clc/include/clc/math/clc_log10.h create mode 100644 libclc/clc/include/clc/math/clc_log2.h create mode 100644 libclc/clc/lib/generic/math/clc_log.cl create mode 100644 libclc/clc/lib/generic/math/clc_log10.cl create mode 100644 libclc/clc/lib/generic/math/clc_log2.cl create mode 100644 libclc/clc/lib/generic/math/clc_log_base.h delete mode 100644 libclc/generic/lib/math/log_base.h diff --git a/libclc/clc/include/clc/math/clc_log.h b/libclc/clc/include/clc/math/clc_log.h new file mode 100644 index 0..c4ca1359e9510 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_log.h @@ -0,0 +1,12 @@ +#ifndef __CLC_MATH_CLC_LOG_H__ +#define __CLC_MATH_CLC_LOG_H__ + +#define __CLC_FUNCTION __clc_log +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_LOG_H__ diff --git a/libclc/clc/include/clc/math/clc_log10.h b/libclc/clc/include/clc/math/clc_log10.h new file mode 100644 index 0..05926928687f7 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_log10.h @@ -0,0 +1,12 @@ +#ifndef __CLC_MATH_CLC_LOG10_H__ +#define __CLC_MATH_CLC_LOG10_H__ + +#define __CLC_FUNCTION __clc_log10 +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_LOG10_H__ diff --git a/libclc/clc/include/clc/math/clc_log2.h b/libclc/clc/include/clc/math/clc_log2.h new file mode 100644 index 0..8b750bd6dffb5 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_log2.h @@ -0,0 +1,12 @@ +#ifndef __CLC_MATH_CLC_LOG2_H__ +#define __CLC_MATH_CLC_LOG2_H__ + +#define __CLC_FUNCTION __clc_log2 +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_LOG2_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 54b0cd23f1650..13667cebe02b9 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -23,6 +23,9 @@ math/clc_fabs.cl math/clc_fma.cl math/clc_floor.cl math/clc_frexp.cl +math/clc_log.cl +math/clc_log10.cl +math/clc_log2.cl math/clc_mad.cl math/clc_modf.cl math/clc_nan.cl diff --git a/libclc/clc/lib/generic/math/clc_log.cl b/libclc/clc/lib/generic/math/clc_log.cl new file mode 100644 index 0..81302c1722e6f --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_log.cl @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +/* + *log(x) = log2(x) * (1/log2(e)) + */ + +_CLC_OVERLOAD _CLC_DEF float __clc_log(float x) { + return __clc_log2(x) * (1.0f / M_LOG2E_F); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __clc_log, float); + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double __clc_log(double x) { + return __clc_log2(x) * (1.0 / M_LOG2E); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __clc_log, double); + +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half __clc_log(half x) { + return (half)__clc_log2((float)x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_log, half); + +#endif // cl_khr_fp16 diff --
[clang] [CIR] Upstream type `bool` (PR #128601)
@@ -266,6 +266,22 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr", }]; } +//===--===// +// BoolType +//===--===// + +def CIR_BoolType : +CIR_Type<"Bool", "bool", + [DeclareTypeInterfaceMethods]> { + + let summary = "CIR bool type"; + let description = [{ +`cir.bool` represents C++ bool type. + }]; + + let hasCustomAssemblyFormat = 1; xlauko wrote: Custom assembly format and related `BoolType::print`, `BoolType::parse` are unnecessary here as default printer/parser generates `!cir.bool` anyway. I cleaned this in incubator in https://github.com/llvm/clangir/pull/1407 https://github.com/llvm/llvm-project/pull/128601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move log/log2/log10 to CLC library (PR #128540)
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/128540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
@@ -0,0 +1,72 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s + +; CHECK: %dx.types.i32c = type { i32, i1 } + +define noundef i32 @test_UAddc(i32 noundef %a, i32 noundef %b) { +; CHECK-LABEL: define noundef i32 @test_UAddc( +; CHECK-SAME: i32 noundef [[A:%.*]], i32 noundef [[B:%.*]]) { +; CHECK-NEXT:[[UADDC1:%.*]] = call [[DX_TYPES_I32C:%.*]] @[[DX_OP_BINARYWITHCARRYORBORROW_I32:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]](i32 44, i32 [[A]], i32 [[B]]) #[[ATTR0:[0-9]+]] bogner wrote: Please don't use `update_test_checks` and then edit the output. `update_test_checks` needs to be idempotent to be useful at all. If we really want to edit this output we *must* remove the "Assertions have been autogenerated" note at the top of the file and manually maintain this test forever rather than using the script, and if we wanted to do that we just shouldn't use the script at all. https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move log/log2/log10 to CLC library (PR #128540)
@@ -0,0 +1,339 @@ +/* + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + +/* + Algorithm: + + Based on: + Ping-Tak Peter Tang + "Table-driven implementation of the logarithm function in IEEE + floating-point arithmetic" + ACM Transactions on Mathematical Software (TOMS) + Volume 16, Issue 4 (December 1990) + + + x very close to 1.0 is handled differently, for x everywhere else + a brief explanation is given below + + x = (2^m)*A + x = (2^m)*(G+g) with (1 <= G < 2) and (g <= 2^(-8)) + x = (2^m)*2*(G/2+g/2) + x = (2^m)*2*(F+f) with (0.5 <= F < 1) and (f <= 2^(-9)) + + Y = (2^(-1))*(2^(-m))*(2^m)*A + Now, range of Y is: 0.5 <= Y < 1 + + F = 0x80 + (first 7 mantissa bits) + (8th mantissa bit) + Now, range of F is: 128 <= F <= 256 + F = F / 256 + Now, range of F is: 0.5 <= F <= 1 + + f = -(Y-F), with (f <= 2^(-9)) + + log(x) = m*log(2) + log(2) + log(F-f) + log(x) = m*log(2) + log(2) + log(F) + log(1-(f/F)) + log(x) = m*log(2) + log(2*F) + log(1-r) + + r = (f/F), with (r <= 2^(-8)) + r = f*(1/F) with (1/F) precomputed to avoid division + + log(x) = m*log(2) + log(G) - poly + + log(G) is precomputed + poly = (r + (r^2)/2 + (r^3)/3 + (r^4)/4) + (r^5)/5)) + + log(2) and log(G) need to be maintained in extra precision + to avoid losing precision in the calculations + + + For x close to 1.0, we employ the following technique to + ensure faster convergence. + + log(x) = log((1+s)/(1-s)) = 2*s + (2/3)*s^3 + (2/5)*s^5 + (2/7)*s^7 + x = ((1+s)/(1-s)) + x = 1 + r + s = r/(2+r) + +*/ + +_CLC_OVERLOAD _CLC_DEF float +#if defined(COMPILING_LOG2) +__clc_log2(float x) +#elif defined(COMPILING_LOG10) +__clc_log10(float x) +#else +__clc_log(float x) +#endif +{ + +#if defined(COMPILING_LOG2) + const float LOG2E = 0x1.715476p+0f; // 1.4426950408889634 + const float LOG2E_HEAD = 0x1.70p+0f; // 1.4375 + const float LOG2E_TAIL = 0x1.547652p-8f; // 0.00519504072 +#elif defined(COMPILING_LOG10) + const float LOG10E = 0x1.bcb7b2p-2f;// 0.43429448190325182 + const float LOG10E_HEAD = 0x1.bcp-2f; // 0.43359375 + const float LOG10E_TAIL = 0x1.6f62a4p-11f; // 0.0007007319 + const float LOG10_2_HEAD = 0x1.34p-2f; // 0.30078125 + const float LOG10_2_TAIL = 0x1.04d426p-12f; // 0.000248745637 +#else + const float LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const float LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.319461833 +#endif + + uint xi = __clc_as_uint(x); + uint ax = xi & EXSIGNBIT_SP32; + + // Calculations for |x-1| < 2^-4 + float r = x - 1.0f; + int near1 = __clc_fabs(r) < 0x1.0p-4f; + float u2 = MATH_DIVIDE(r, 2.0f + r); + float corr = u2 * r; + float u = u2 + u2; + float v = u * u; + float znear1, z1, z2; + + // 2/(5 * 2^5), 2/(3 * 2^3) + z2 = __clc_mad(u, __clc_mad(v, 0x1.9ap-7f, 0x1.56p-4f) * v, -corr); + +#if defined(COMPILING_LOG2) + z1 = __clc_as_float(__clc_as_int(r) & 0x); + z2 = z2 + (r - z1); + znear1 = __clc_mad( + z1, LOG2E_HEAD, + __clc_mad(z2, LOG2E_HEAD, __clc_mad(z1, LOG2E_TAIL, z2 * LOG2E_TAIL))); +#elif defined(COMPILING_LOG10) + z1 = __clc_as_float(__clc_as_int(r) & 0x); + z2 = z2 + (r - z1); + znear1 = __clc_mad( + z1, LOG10E_HEAD, + __clc_mad(z2, LOG10E_HEAD, __clc_mad(z1, LOG10E_TAIL, z2 * LOG10E_TAIL))); +#else + znear1 = z2 + r; +#endif + + // Calculations for x not near 1 + int m = (int)(xi >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + + // Normalize subnormal + uint xis = __clc_as_uint(__clc_as_float(xi | 0x3f80) - 1.0f); + int ms = (int)(xis >> EXPSHIFTBITS_SP32) - 253; + int c = m == -127; + m = c ? ms : m; + uint xin = c ? xis : xi; + + float mf = (float)m; + uint indx = (xin & 0x007f) + ((xin & 0x8000) << 1); + + // F - Y + float f = __clc_as_float(0
[libclc] [libclc] Move log/log2/log10 to CLC library (PR #128540)
@@ -0,0 +1,339 @@ +/* + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + +/* + Algorithm: + + Based on: + Ping-Tak Peter Tang + "Table-driven implementation of the logarithm function in IEEE + floating-point arithmetic" + ACM Transactions on Mathematical Software (TOMS) + Volume 16, Issue 4 (December 1990) + + + x very close to 1.0 is handled differently, for x everywhere else + a brief explanation is given below + + x = (2^m)*A + x = (2^m)*(G+g) with (1 <= G < 2) and (g <= 2^(-8)) + x = (2^m)*2*(G/2+g/2) + x = (2^m)*2*(F+f) with (0.5 <= F < 1) and (f <= 2^(-9)) + + Y = (2^(-1))*(2^(-m))*(2^m)*A + Now, range of Y is: 0.5 <= Y < 1 + + F = 0x80 + (first 7 mantissa bits) + (8th mantissa bit) + Now, range of F is: 128 <= F <= 256 + F = F / 256 + Now, range of F is: 0.5 <= F <= 1 + + f = -(Y-F), with (f <= 2^(-9)) + + log(x) = m*log(2) + log(2) + log(F-f) + log(x) = m*log(2) + log(2) + log(F) + log(1-(f/F)) + log(x) = m*log(2) + log(2*F) + log(1-r) + + r = (f/F), with (r <= 2^(-8)) + r = f*(1/F) with (1/F) precomputed to avoid division + + log(x) = m*log(2) + log(G) - poly + + log(G) is precomputed + poly = (r + (r^2)/2 + (r^3)/3 + (r^4)/4) + (r^5)/5)) + + log(2) and log(G) need to be maintained in extra precision + to avoid losing precision in the calculations + + + For x close to 1.0, we employ the following technique to + ensure faster convergence. + + log(x) = log((1+s)/(1-s)) = 2*s + (2/3)*s^3 + (2/5)*s^5 + (2/7)*s^7 + x = ((1+s)/(1-s)) + x = 1 + r + s = r/(2+r) + +*/ + +_CLC_OVERLOAD _CLC_DEF float +#if defined(COMPILING_LOG2) +__clc_log2(float x) +#elif defined(COMPILING_LOG10) +__clc_log10(float x) +#else +__clc_log(float x) +#endif +{ + +#if defined(COMPILING_LOG2) + const float LOG2E = 0x1.715476p+0f; // 1.4426950408889634 + const float LOG2E_HEAD = 0x1.70p+0f; // 1.4375 + const float LOG2E_TAIL = 0x1.547652p-8f; // 0.00519504072 +#elif defined(COMPILING_LOG10) + const float LOG10E = 0x1.bcb7b2p-2f;// 0.43429448190325182 + const float LOG10E_HEAD = 0x1.bcp-2f; // 0.43359375 + const float LOG10E_TAIL = 0x1.6f62a4p-11f; // 0.0007007319 + const float LOG10_2_HEAD = 0x1.34p-2f; // 0.30078125 + const float LOG10_2_TAIL = 0x1.04d426p-12f; // 0.000248745637 +#else + const float LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 + const float LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.319461833 +#endif + + uint xi = __clc_as_uint(x); + uint ax = xi & EXSIGNBIT_SP32; + + // Calculations for |x-1| < 2^-4 + float r = x - 1.0f; + int near1 = __clc_fabs(r) < 0x1.0p-4f; + float u2 = MATH_DIVIDE(r, 2.0f + r); + float corr = u2 * r; + float u = u2 + u2; + float v = u * u; + float znear1, z1, z2; + + // 2/(5 * 2^5), 2/(3 * 2^3) + z2 = __clc_mad(u, __clc_mad(v, 0x1.9ap-7f, 0x1.56p-4f) * v, -corr); + +#if defined(COMPILING_LOG2) + z1 = __clc_as_float(__clc_as_int(r) & 0x); + z2 = z2 + (r - z1); + znear1 = __clc_mad( + z1, LOG2E_HEAD, + __clc_mad(z2, LOG2E_HEAD, __clc_mad(z1, LOG2E_TAIL, z2 * LOG2E_TAIL))); +#elif defined(COMPILING_LOG10) + z1 = __clc_as_float(__clc_as_int(r) & 0x); + z2 = z2 + (r - z1); + znear1 = __clc_mad( + z1, LOG10E_HEAD, + __clc_mad(z2, LOG10E_HEAD, __clc_mad(z1, LOG10E_TAIL, z2 * LOG10E_TAIL))); +#else + znear1 = z2 + r; +#endif + + // Calculations for x not near 1 + int m = (int)(xi >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; + + // Normalize subnormal frasercrmck wrote: Thanks, I'll make a note. https://github.com/llvm/llvm-project/pull/128540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Thread Safety Analysis: Improved pointer handling (PR #127396)
AaronBallman wrote: > I need to commit this by end of day Wednesday - if I should wait a little > longer, let me know so I can plan around it. Thanks. Sorry, but I'm at C standards meetings this week, so I don't think I'll be able to review it by then. CC @aaronpuchert who maybe can help? https://github.com/llvm/llvm-project/pull/127396 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add Xqccmp Assembly Support (PR #128731)
https://github.com/lenary updated https://github.com/llvm/llvm-project/pull/128731 >From 6f8c6d152033505db6f6b1f8a424c01fcfc05c0d Mon Sep 17 00:00:00 2001 From: Sam Elliott Date: Mon, 24 Feb 2025 23:07:05 -0800 Subject: [PATCH 1/6] [RISCV] Add Xqccmp Assembly Support Xqccmp is a new spec by Qualcomm that makes a vendor-specific effort to solve the push/pop + frame pointers issue. Broadly, it takes the Zcmp instructions and reverse the order they push/pop registers in, which ends up matching the frame pointer convention. This extension adds a new instruction not present in Xqccmp, `qc.cm.pushfp`, which will set `fp` to the incoming `sp` value after it has pushed the registers in rlist. This change duplicates the Zcmp implementation, with minor changes to mnemonics (for the `qc.` prefix), predicates, and the addition of `qc.cm.pushfp`. There is also new logic to prevent combining Xqccmp and Zcmp. Xqccmp is kept separate to Xqci for decoding/encoding etc, as the specs are separate today. Specification: https://github.com/quic/riscv-unified-db/releases/tag/Xqccmp_extension-0.1.0 --- .../Driver/print-supported-extensions-riscv.c | 1 + .../Target/RISCV/AsmParser/RISCVAsmParser.cpp | 2 +- .../RISCV/Disassembler/RISCVDisassembler.cpp | 2 + llvm/lib/Target/RISCV/RISCVFeatures.td| 8 + llvm/lib/Target/RISCV/RISCVInstrInfo.td | 1 + llvm/lib/Target/RISCV/RISCVInstrInfoXqccmp.td | 95 + llvm/lib/TargetParser/RISCVISAInfo.cpp| 5 + llvm/test/MC/RISCV/rv32xqccmp-invalid.s | 35 ++ llvm/test/MC/RISCV/rv32xqccmp-valid.s | 353 ++ llvm/test/MC/RISCV/rv64e-xqccmp-valid.s | 85 + llvm/test/MC/RISCV/rv64xqccmp-invalid.s | 35 ++ llvm/test/MC/RISCV/rv64xqccmp-valid.s | 181 + .../TargetParser/RISCVISAInfoTest.cpp | 6 + 13 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoXqccmp.td create mode 100644 llvm/test/MC/RISCV/rv32xqccmp-invalid.s create mode 100644 llvm/test/MC/RISCV/rv32xqccmp-valid.s create mode 100644 llvm/test/MC/RISCV/rv64e-xqccmp-valid.s create mode 100644 llvm/test/MC/RISCV/rv64xqccmp-invalid.s create mode 100644 llvm/test/MC/RISCV/rv64xqccmp-valid.s diff --git a/clang/test/Driver/print-supported-extensions-riscv.c b/clang/test/Driver/print-supported-extensions-riscv.c index fcd820464e2d1..1c29ae98c96f0 100644 --- a/clang/test/Driver/print-supported-extensions-riscv.c +++ b/clang/test/Driver/print-supported-extensions-riscv.c @@ -193,6 +193,7 @@ // CHECK-NEXT: smctr1.0 'Smctr' (Control Transfer Records Machine Level) // CHECK-NEXT: ssctr1.0 'Ssctr' (Control Transfer Records Supervisor Level) // CHECK-NEXT: svukte 0.3 'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses) +// CHECK-NEXT: xqccmp 0.1 'Xqccmp' (Qualcomm 16-bit Push/Pop and Double Moves) // CHECK-NEXT: xqcia0.2 'Xqcia' (Qualcomm uC Arithmetic Extension) // CHECK-NEXT: xqciac 0.3 'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension) // CHECK-NEXT: xqcicli 0.2 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 650ad48e50de0..697dfac48e4a0 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -3640,7 +3640,7 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst, } } - if (Opcode == RISCV::CM_MVSA01) { + if (Opcode == RISCV::CM_MVSA01 || Opcode == RISCV::QC_CM_MVSA01) { MCRegister Rd1 = Inst.getOperand(0).getReg(); MCRegister Rd2 = Inst.getOperand(1).getReg(); if (Rd1 == Rd2) { diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index 8c07d87680d65..c17e0de111a85 100644 --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -745,6 +745,8 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size, "Qualcomm uC Conditional Move 16bit"); TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXqciint, DecoderTableXqciint16, "Qualcomm uC Interrupts 16bit"); + TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXqccmp, DecoderTableXqccmp16, +"Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)"); TRY_TO_DECODE_AND_ADD_SP(STI.hasFeature(RISCV::FeatureVendorXwchc), DecoderTableXwchc16, "WCH QingKe XW"); TRY_TO_DECODE_AND_ADD_SP(true, DecoderTable16, diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 1a93371a4d9
[clang] [llvm] [RISCV] Add Xqccmp Assembly Support (PR #128731)
@@ -0,0 +1,95 @@ +//=== RISCVInstrInfoXqccmp.td --*- tablegen -*-===// +// +// 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 +// +//===--===// +// +// This file describes Qualcomm's Xqccmp extension. +// +// Xqccmp is broadly equivalent to (and incompatible with) Zcmp except the +// following changes: +// +// - The registers are pushed in the opposite order, so `ra` and `fp` are +// closest to the incoming stack pointer (to be compatible with the +// frame-pointer convention), and +// +// - There is a new `qc.cm.pushfp` instruction which is `qc.cm.push` but it sets +// `fp` to the incoming stack pointer value, as expected by the frame-pointer +// convention. +// +//===--===// + +//===--===// +// Operand and SDNode transformation definitions. +//===--===// + +//===--===// +// Instruction Formats +//===--===// + +//===--===// +// Instruction Class Templates +//===--===// + +//===--===// +// Instructions +//===--===// + +// Zcmp lenary wrote: Done https://github.com/llvm/llvm-project/pull/128731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
https://github.com/Icohedron edited https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
https://github.com/Icohedron edited https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Fix performance-move-const-arg false negative in ternary… (PR #128402)
https://github.com/RiverDave edited https://github.com/llvm/llvm-project/pull/128402 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)
erichkeane wrote: also-also: A bug report to improve the diagnostic for `-Wmismatched-dealloc` based on this being in the AST would be appreciated. If you could file one, it would be greatly appreciated. Again, sorry for the delay on this one, we managed to drop the ball on this review. https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Function type return type improvements (PR #128787)
https://github.com/dkolsen-pgi created https://github.com/llvm/llvm-project/pull/128787 When a C or C++ function has a return type of `void`, the function type is now represented in MLIR as having no return type rather than having a return type of `!cir.void`. This avoids breaking MLIR invariants that require the number of return types and the number of return values to match. Change the assembly format for `cir::FuncType` from having a leading return type to having a trailing return type. In other words, change ``` !cir.func ``` to ``` !cir.func<(!argTypes) -> !returnType)> ``` Unless the function returns `void`, in which case change ``` !cir.func ``` to ``` !cir.func<(!argTypes)> ``` >From 3e396ab2f69d0dcf98605179f69411f04da68f49 Mon Sep 17 00:00:00 2001 From: David Olsen Date: Tue, 25 Feb 2025 15:21:30 -0800 Subject: [PATCH] [CIR] Function type return type improvements When a C or C++ function has a return type of `void`, the function type is now represented in MLIR as having no return type rather than having a return type of `!cir.void`. This avoids breaking MLIR invariants that require the number of return types and the number of return values to match. Change the assembly format for `cir::FuncType` from having a leading return type to having a trailing return type. In other words, change ``` !cir.func ``` to ``` !cir.func<(!argTypes) -> !returnType)> ``` Unless the function returns `void`, in which case change ``` !cir.func ``` to ``` !cir.func<(!argTypes)> ``` --- .../include/clang/CIR/Dialect/IR/CIRTypes.td | 40 -- clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 2 +- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 4 + clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 125 +- clang/test/CIR/IR/func.cir| 8 +- clang/test/CIR/IR/global.cir | 12 +- clang/test/CIR/func-simple.cpp| 4 +- clang/test/CIR/global-var-simple.cpp | 6 +- 8 files changed, 141 insertions(+), 60 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index fc8edbcf3e166..c2d45ebeefe63 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -287,32 +287,43 @@ def CIR_BoolType : def CIR_FuncType : CIR_Type<"Func", "func"> { let summary = "CIR function type"; let description = [{ -The `!cir.func` is a function type. It consists of a single return type, a -list of parameter types and can optionally be variadic. +The `!cir.func` is a function type. It consists of an optional return type, +a list of parameter types and can optionally be variadic. Example: ```mlir -!cir.func -!cir.func -!cir.func +!cir.func<()> +!cir.func<() -> bool> +!cir.func<(!s8i, !s8i)> +!cir.func<(!s8i, !s8i) -> !s32i> +!cir.func<(!s32i, ...) -> !s32i> ``` }]; let parameters = (ins ArrayRefParameter<"mlir::Type">:$inputs, -"mlir::Type":$returnType, "bool":$varArg); +"mlir::Type":$optionalReturnType, "bool":$varArg); + // Use a custom parser to handle the argument types and optional return let assemblyFormat = [{ -`<` $returnType ` ` `(` custom($inputs, $varArg) `>` +`<` custom($optionalReturnType, $inputs, $varArg) `>` }]; let builders = [ +// Create a FuncType, converting the return type from C-style to +// MLIR-style. If the given return type is `cir::VoidType`, ignore it +// and create the FuncType with no return type, which is how MLIR +// represents function types. TypeBuilderWithInferredContext<(ins "llvm::ArrayRef":$inputs, "mlir::Type":$returnType, CArg<"bool", "false">:$isVarArg), [{ - return $_get(returnType.getContext(), inputs, returnType, isVarArg); +return $_get(returnType.getContext(), inputs, + mlir::isa(returnType) ? nullptr : returnType, + isVarArg); }]> ]; + let genVerifyDecl = 1; + let extraClassDeclaration = [{ /// Returns whether the function is variadic. bool isVarArg() const { return getVarArg(); } @@ -323,12 +334,17 @@ def CIR_FuncType : CIR_Type<"Func", "func"> { /// Returns the number of arguments to the function. unsigned getNumInputs() const { return getInputs().size(); } -/// Returns the result type of the function as an ArrayRef, enabling better -/// integration with generic MLIR utilities. +/// Get the C-style return type of the function, which is !cir.void if the +/// function returns nothing and the actual return type otherwise. +mlir::Type getReturnType() const; + +/// Get the MLIR-style return type of the function, which is an empty +/// ArrayRef if the function returns nothing and a single-element ArrayRef +/// with the actual return type otherwise. llvm::ArrayRef getReturnTypes() co
[clang] [CIR] Function type return type improvements (PR #128787)
llvmbot wrote: @llvm/pr-subscribers-clangir Author: David Olsen (dkolsen-pgi) Changes When a C or C++ function has a return type of `void`, the function type is now represented in MLIR as having no return type rather than having a return type of `!cir.void`. This avoids breaking MLIR invariants that require the number of return types and the number of return values to match. Change the assembly format for `cir::FuncType` from having a leading return type to having a trailing return type. In other words, change ``` !cir.func ``` to ``` !cir.func<(!argTypes) -> !returnType)> ``` Unless the function returns `void`, in which case change ``` !cir.func ``` to ``` !cir.func<(!argTypes)> ``` --- Full diff: https://github.com/llvm/llvm-project/pull/128787.diff 8 Files Affected: - (modified) clang/include/clang/CIR/Dialect/IR/CIRTypes.td (+28-12) - (modified) clang/lib/CIR/CodeGen/CIRGenTypes.cpp (+1-1) - (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+4) - (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+93-32) - (modified) clang/test/CIR/IR/func.cir (+4-4) - (modified) clang/test/CIR/IR/global.cir (+6-6) - (modified) clang/test/CIR/func-simple.cpp (+2-2) - (modified) clang/test/CIR/global-var-simple.cpp (+3-3) ``diff diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index fc8edbcf3e166..c2d45ebeefe63 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -287,32 +287,43 @@ def CIR_BoolType : def CIR_FuncType : CIR_Type<"Func", "func"> { let summary = "CIR function type"; let description = [{ -The `!cir.func` is a function type. It consists of a single return type, a -list of parameter types and can optionally be variadic. +The `!cir.func` is a function type. It consists of an optional return type, +a list of parameter types and can optionally be variadic. Example: ```mlir -!cir.func -!cir.func -!cir.func +!cir.func<()> +!cir.func<() -> bool> +!cir.func<(!s8i, !s8i)> +!cir.func<(!s8i, !s8i) -> !s32i> +!cir.func<(!s32i, ...) -> !s32i> ``` }]; let parameters = (ins ArrayRefParameter<"mlir::Type">:$inputs, -"mlir::Type":$returnType, "bool":$varArg); +"mlir::Type":$optionalReturnType, "bool":$varArg); + // Use a custom parser to handle the argument types and optional return let assemblyFormat = [{ -`<` $returnType ` ` `(` custom($inputs, $varArg) `>` +`<` custom($optionalReturnType, $inputs, $varArg) `>` }]; let builders = [ +// Create a FuncType, converting the return type from C-style to +// MLIR-style. If the given return type is `cir::VoidType`, ignore it +// and create the FuncType with no return type, which is how MLIR +// represents function types. TypeBuilderWithInferredContext<(ins "llvm::ArrayRef":$inputs, "mlir::Type":$returnType, CArg<"bool", "false">:$isVarArg), [{ - return $_get(returnType.getContext(), inputs, returnType, isVarArg); +return $_get(returnType.getContext(), inputs, + mlir::isa(returnType) ? nullptr : returnType, + isVarArg); }]> ]; + let genVerifyDecl = 1; + let extraClassDeclaration = [{ /// Returns whether the function is variadic. bool isVarArg() const { return getVarArg(); } @@ -323,12 +334,17 @@ def CIR_FuncType : CIR_Type<"Func", "func"> { /// Returns the number of arguments to the function. unsigned getNumInputs() const { return getInputs().size(); } -/// Returns the result type of the function as an ArrayRef, enabling better -/// integration with generic MLIR utilities. +/// Get the C-style return type of the function, which is !cir.void if the +/// function returns nothing and the actual return type otherwise. +mlir::Type getReturnType() const; + +/// Get the MLIR-style return type of the function, which is an empty +/// ArrayRef if the function returns nothing and a single-element ArrayRef +/// with the actual return type otherwise. llvm::ArrayRef getReturnTypes() const; -/// Returns whether the function is returns void. -bool isVoid() const; +/// Does the function type return nothing? +bool hasVoidReturn() const; /// Returns a clone of this function type with the given argument /// and result types. diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index 16aec10fda81e..dcfaaedc2ef57 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -60,7 +60,7 @@ bool CIRGenTypes::isFuncTypeConvertible(const FunctionType *ft) { mlir::Type CIRGenTypes::convertFunctionTypeInternal(QualType qft) { assert(qft.isCanonical()); const FunctionType *ft = cast(qft
[clang] [clang modules] Setting `DebugCompilationDir` when it is safe to ignore current working directory (PR #128446)
https://github.com/cyndyishida edited https://github.com/llvm/llvm-project/pull/128446 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
https://github.com/Icohedron edited https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Function type return type improvements (PR #128787)
dkolsen-pgi wrote: This combines https://github.com/llvm/clangir/pull/1249 (fix handling of void return) and https://github.com/llvm/clangir/pull/1391(trailing return type) into a single upstream PR. https://github.com/llvm/llvm-project/pull/128787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ubsan] Remove -fsanitizer=vptr from -fsanitizer=undefined (PR #121115)
@@ -214,13 +214,14 @@ Available checks are: the wrong dynamic type, or that its lifetime has not begun or has ended. Incompatible with ``-fno-rtti``. Link must be performed by ``clang++``, not ``clang``, to make sure C++-specific parts of the runtime library and C++ - standard libraries are present. + standard libraries are present. The check is not a part of the ``undefined`` thurstond wrote: Is it necessary to mention here that it's not part of the "undefined" group, instead of just in the check groups section below? There's several other checks in this list that aren't part of "undefined" but don't call out the group membership. https://github.com/llvm/llvm-project/pull/121115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CMake][Release] Statically link libz (PR #128788)
https://github.com/tstellar created https://github.com/llvm/llvm-project/pull/128788 This will make the binaries more portable. >From c778a3369e3435b6b08b3ef41c6f628ead50f876 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 25 Feb 2025 23:41:11 + Subject: [PATCH] [CMake][Release] Statically link libz This will make the binaries more portable. --- clang/cmake/caches/Release.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index aedbd1a25fb38..0725960367a97 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -146,3 +146,4 @@ set_final_stage_var(CPACK_ARCHIVE_THREADS "0" STRING) if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") set_final_stage_var(LLVM_USE_STATIC_ZSTD "ON" BOOL) endif() +set_final_stage_var(ZLIB_USE_STATIC_LIBS "ON" BOOL) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Integrated Distributed ThinLTO (DTLTO): Initial support (PR #126654)
@@ -1702,6 +1703,37 @@ static uint8_t getOsAbi(const Triple &t) { } } +// Check if an archive file is a thin archive. +static bool isThinArchive(Ctx &ctx, StringRef archiveFilePath) { + const size_t thinArchiveMagicLen = sizeof(ThinArchiveMagic) - 1; + + ErrorOr> memBufferOrError = + MemoryBuffer::getFileSlice(archiveFilePath, thinArchiveMagicLen, 0); + if (std::error_code ec = memBufferOrError.getError()) { +ErrAlways(ctx) << "cannot open " << archiveFilePath << ": " << ec.message(); +return false; + } + + MemoryBufferRef memBufRef = *memBufferOrError.get(); + return memBufRef.getBuffer().starts_with(ThinArchiveMagic); +} + +// Compute a thin archive member full file path. +static std::string +computeThinArchiveMemberFullPath(const StringRef modulePath, bd1976bris wrote: I have simplified the code as we discussed. I also record which archives are thin when files are added to the link in `LinkerDriver::addFile` and then pass this information into the `BitcodeFile` constructor. This removes the hack where I was reopening the archive files and checking the magic bytes to determine if they were thin. The implementation is much improved now. Thanks. https://github.com/llvm/llvm-project/pull/126654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ubsan] Remove -fsanitizer=vptr from -fsanitizer=undefined (PR #121115)
@@ -214,13 +214,14 @@ Available checks are: the wrong dynamic type, or that its lifetime has not begun or has ended. Incompatible with ``-fno-rtti``. Link must be performed by ``clang++``, not ``clang``, to make sure C++-specific parts of the runtime library and C++ - standard libraries are present. + standard libraries are present. The check is not a part of the ``undefined`` vitalybuka wrote: Unnecessary, but probably usefull https://github.com/llvm/llvm-project/pull/121115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move sqrt to CLC library (PR #128748)
@@ -21,19 +21,17 @@ */ #if __CLC_FPSIZE == 64 -#define __CLC_NAN __builtin_nan("") -#define ZERO 0.0 +#define __CLC_NAN DBL_NAN #elif __CLC_FPSIZE == 32 -#define __CLC_NAN NAN -#define ZERO 0.0f +#define __CLC_NAN FLT_NAN #elif __CLC_FPSIZE == 16 -#define __CLC_NAN (half)NAN -#define ZERO 0.0h +#define __CLC_NAN HALF_NAN #endif -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_sqrt(__CLC_GENTYPE val) { - return val < ZERO ? __CLC_NAN : __clc_llvm_intr_sqrt(val); +__attribute__((weak)) _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE +__clc_sqrt(__CLC_GENTYPE val) { + return val < __CLC_FP_LIT(0.0) ? (__CLC_GENTYPE)__CLC_NAN + : __builtin_elementwise_sqrt(val); arsenm wrote: This pre-filtering of the argument is unnecessary. Many years ago the sqrt intrinsic officially did not handle the nan cases, but that has been fixed. This can be the raw builtin call https://github.com/llvm/llvm-project/pull/128748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move sqrt to CLC library (PR #128748)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/128748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] more useful error message for decomposition declaration missing initializer (PR #127924)
https://github.com/shafik commented: Please provide more details than a link to the github issue. The summary is what goes in the git log and folks downstream often use git log as a first line in analyzing issues. Summaries w/o detailed summary are not useful. https://github.com/llvm/llvm-project/pull/127924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
wangpc-pp wrote: > I think what @wangpc-pp advocated here (please correct me if I'm wrong) was > that user should be responsible annotating these registers as clobbered so > that we have more freedom on scheduling when the inline assembly is not using > any vector instructions. While other approaches -- regardless of marking them > as clobber or implicit-def these two registers in RISCVInsertVSETVLI -- are > taking a more conservative path to ensure correctness. Yes this is exactly what I meant! > > It's a shame that we're not able to analyze the instructions within inline > assembly to make a better decision. Personally I think we should prioritize > correctness, therefore I'm more incline to the latter approaches. I do agree > that we probably should only do it when vector instructions are present, as > pointed out by one of the review comments by @wangpc-pp. I am not opposed to this. But I have to say, the use case is not so common. We don't mix assemblies with RVV instructions and RVV intrinsics in the same code. In this scenarios, we should write all RVV instructions in asm statements or just use RVV intrinsics. Even for these rare cases, the user can achieve the same effect if they put `vl/vtype` into clobbered registers explicitly. And let me quote @kito-cheng's comments: https://github.com/llvm/llvm-project/pull/97794#issuecomment-2228482748, there are some other approaches. https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Xqcia 0.4 Spec renamed qc.(sla/sll)sat to qc.(shl/shlu)sat (PR #128710)
https://github.com/svs-quic approved this pull request. LGTM. Please remove "[RISCV] Xqcia 0.4 Spec renamed qc.(sla/sll)sat to qc.(shl/shlu)sat" from the commit message body before merging. https://github.com/llvm/llvm-project/pull/128710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang modules] Setting `DebugCompilationDir` when it is safe to ignore current working directory (PR #128446)
https://github.com/qiongsiwu updated https://github.com/llvm/llvm-project/pull/128446 >From c8eda8b9192cf4bdad4121063336beeb14cbe689 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Sun, 23 Feb 2025 16:47:18 -0800 Subject: [PATCH 1/6] Initial commit --- .../DependencyScanning/ModuleDepCollector.cpp | 17 +- clang/test/ClangScanDeps/modules-debug-dir.c | 22 +++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 clang/test/ClangScanDeps/modules-debug-dir.c diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp index 1c5f4c4b50ab6..8a94535d3806c 100644 --- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -492,8 +492,23 @@ static std::string getModuleContextHash(const ModuleDeps &MD, auto &FSOpts = const_cast(CI.getFileSystemOpts()); if (CWD && !IgnoreCWD) HashBuilder.add(*CWD); - else + else { FSOpts.WorkingDir.clear(); +auto &CGOpts = const_cast(CI.getCodeGenOpts()); +if (CGOpts.DwarfVersion && CWD) { + // It is necessary to explicitly set the DebugCompilationDir + // to a common directory (e.g. root) if IgnoreCWD is true. + // When IgnoreCWD is true, the module's content should not depend + // on the current working directory. However, if dwarf information + // is needed (when CGOpts.DwarfVersion is non-zero), and if + // CGOpts.DebugCompilationDir is not explicitly set, + // the current working directory will be automatically embedded + // in the dwarf information in the pcm, contradicting the assumption + // that it is safe to ignore the CWD. Thus in such cases, + // CGOpts.DebugCompilationDir is explicitly set to a common directory. + CGOpts.DebugCompilationDir = llvm::sys::path::root_path(*CWD); +} + } // Hash the BuildInvocation without any input files. SmallString<0> ArgVec; diff --git a/clang/test/ClangScanDeps/modules-debug-dir.c b/clang/test/ClangScanDeps/modules-debug-dir.c new file mode 100644 index 0..580f72205e68f --- /dev/null +++ b/clang/test/ClangScanDeps/modules-debug-dir.c @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json +// RUN: clang-scan-deps -compilation-database %t/cdb.json -format \ +// RUN: experimental-full > %t/result.json + +//--- cdb.json.in +[{ + "directory": "DIR", + "command": "clang -g -fdebug-info-for-profiling DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", + "file": "DIR/tu.c" +}] + +//--- include/module.modulemap +module mod { + header "mod.h" +} + +//--- include/mod.h + +//--- tu.c +#include "mod.h" >From 4b29c19ebc360ec80a8c16e1ac485bbac78a9062 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Mon, 24 Feb 2025 09:34:56 -0800 Subject: [PATCH 2/6] Fix the test. --- clang/test/ClangScanDeps/modules-debug-dir.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/test/ClangScanDeps/modules-debug-dir.c b/clang/test/ClangScanDeps/modules-debug-dir.c index 580f72205e68f..1ac518985471d 100644 --- a/clang/test/ClangScanDeps/modules-debug-dir.c +++ b/clang/test/ClangScanDeps/modules-debug-dir.c @@ -3,11 +3,12 @@ // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json // RUN: clang-scan-deps -compilation-database %t/cdb.json -format \ // RUN: experimental-full > %t/result.json +// RUN: cat %t/result.json | FileCheck %s //--- cdb.json.in [{ "directory": "DIR", - "command": "clang -g -fdebug-info-for-profiling DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", + "command": "clang -c -g -gmodules DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -fdebug-compilation-dir=DIR -o DIR/tu.o", "file": "DIR/tu.c" }] @@ -20,3 +21,10 @@ module mod { //--- tu.c #include "mod.h" + +// Check the -fdebug-compilation-dir used for the module is the root +// directory when current working directory optimization is in effect. +// CHECK: "modules": [ +// CHECK: "command-line": [ +// CHECK: "-fdebug-compilation-dir={{\/|C:|\/\/net}}", +// CHECK: "translation-units": [ >From 5c53c84d33ad4ceec4e79dc36638e827607709ca Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Mon, 24 Feb 2025 10:34:35 -0800 Subject: [PATCH 3/6] Try to fix the test on windows. --- clang/test/ClangScanDeps/modules-debug-dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/ClangScanDeps/modules-debug-dir.c b/clang/test/ClangScanDeps/modules-debug-dir.c index 1ac518985471d..87f1bc141c73a 100644 --- a/clang/test/ClangScanDeps/modules-debug-dir.c +++ b/clang/test/ClangScanDeps/modules-debug-dir.c @@ -8,7 +8,7 @@ //--- cdb.json.in [{ "directory": "DIR", - "command": "clang -c -g -gmodules DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -fdebug-
[clang] 8fc8a84 - [clang-format] Allow breaking before kw___attribute (#128623)
Author: Owen Pan Date: 2025-02-25T19:44:54-08:00 New Revision: 8fc8a84e23471fe56214e68706addc712b5a2949 URL: https://github.com/llvm/llvm-project/commit/8fc8a84e23471fe56214e68706addc712b5a2949 DIFF: https://github.com/llvm/llvm-project/commit/8fc8a84e23471fe56214e68706addc712b5a2949.diff LOG: [clang-format] Allow breaking before kw___attribute (#128623) Fixes #74784 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index d29c299768a68..2ffaee93b70ea 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -6202,6 +6202,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, TT_ClassHeadName, tok::kw_operator)) { return true; } + if (Right.isAttribute()) +return true; if (Left.is(TT_PointerOrReference)) return false; if (Right.isTrailingComment()) { @@ -6346,9 +6348,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, tok::less, tok::coloncolon); } - if (Right.isAttribute()) -return true; - if (Right.is(tok::l_square) && Right.is(TT_AttributeSquare)) return Left.isNot(TT_AttributeSquare); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index fe0e47080a577..39266d17f824f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -12613,6 +12613,9 @@ TEST_F(FormatTest, UnderstandsAttributes) { verifyFormat("a __attribute__((unused))\n" "aaa(int i);"); verifyFormat("__attribute__((nodebug)) ::qualified_type f();"); + verifyFormat( + "RenderWidgetHostViewCocoa *\n" + "__attribute__((objc_precise_lifetime)) keepSelfAlive = self;"); FormatStyle AfterType = getLLVMStyle(); AfterType.BreakAfterReturnType = FormatStyle::RTBS_All; verifyFormat("__attribute__((nodebug)) void\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Allow breaking before kw___attribute (PR #128623)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/128623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
https://github.com/HankChang736 updated https://github.com/llvm/llvm-project/pull/128636 >From d7718e9ed9f03990895f0d89b87808d8c96bb67c Mon Sep 17 00:00:00 2001 From: Hank Chang Date: Sun, 23 Feb 2025 23:59:23 +0800 Subject: [PATCH 1/2] [RISCV] Mark {vl, vtype} as clobber in inline assembly This patch use the hook getClobbers() in RISCV target and mark {vl, type} as clobber to prevent Post-RA scheduler move vsetvl across inline assembly. --- clang/lib/Basic/Targets/RISCV.h | 2 +- .../CodeGen/RISCV/riscv-inline-asm-clobber.c | 48 ++- .../test/CodeGen/RISCV/riscv-inline-asm-rvv.c | 8 ++-- clang/test/CodeGen/RISCV/riscv-inline-asm.c | 42 .../rvv/vsetvl-cross-inline-asm-clobber.ll| 37 ++ .../RISCV/rvv/vsetvl-cross-inline-asm.ll | 37 ++ 6 files changed, 136 insertions(+), 38 deletions(-) create mode 100644 llvm/test/CodeGen/RISCV/rvv/vsetvl-cross-inline-asm-clobber.ll create mode 100644 llvm/test/CodeGen/RISCV/rvv/vsetvl-cross-inline-asm.ll diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h index c26aa19080162..5590aa9d03c75 100644 --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -68,7 +68,7 @@ class RISCVTargetInfo : public TargetInfo { return TargetInfo::VoidPtrBuiltinVaList; } - std::string_view getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return "~{vl},~{vtype}"; } StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override { diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c index 8aa80386f205f..65cfc081fe26d 100644 --- a/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c +++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c @@ -7,38 +7,62 @@ // Test RISC-V specific clobbered registers in inline assembly. -// CHECK-LABEL: define {{.*}} void @test_fflags -// CHECK:tail call void asm sideeffect "", "~{fflags}"() +// CHECK-LABEL: define dso_local void @test_fflags( +// CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void asm sideeffect "", "~{fflags},~{vl},~{vtype}"() #[[ATTR1:[0-9]+]], !srcloc [[META6:![0-9]+]] +// CHECK-NEXT:ret void +// void test_fflags(void) { asm volatile ("" :::"fflags"); } -// CHECK-LABEL: define {{.*}} void @test_frm -// CHECK:tail call void asm sideeffect "", "~{frm}"() +// CHECK-LABEL: define dso_local void @test_frm( +// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void asm sideeffect "", "~{frm},~{vl},~{vtype}"() #[[ATTR1]], !srcloc [[META7:![0-9]+]] +// CHECK-NEXT:ret void +// void test_frm(void) { asm volatile ("" :::"frm"); } -// CHECK-LABEL: define {{.*}} void @test_vtype -// CHECK:tail call void asm sideeffect "", "~{vtype}"() +// CHECK-LABEL: define dso_local void @test_vtype( +// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void asm sideeffect "", "~{vtype},~{vl},~{vtype}"() #[[ATTR1]], !srcloc [[META8:![0-9]+]] +// CHECK-NEXT:ret void +// void test_vtype(void) { asm volatile ("" :::"vtype"); } -// CHECK-LABEL: define {{.*}} void @test_vl -// CHECK:tail call void asm sideeffect "", "~{vl}"() +// CHECK-LABEL: define dso_local void @test_vl( +// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void asm sideeffect "", "~{vl},~{vl},~{vtype}"() #[[ATTR1]], !srcloc [[META9:![0-9]+]] +// CHECK-NEXT:ret void +// void test_vl(void) { asm volatile ("" :::"vl"); } -// CHECK-LABEL: define {{.*}} void @test_vxsat -// CHECK:tail call void asm sideeffect "", "~{vxsat}"() +// CHECK-LABEL: define dso_local void @test_vxsat( +// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void asm sideeffect "", "~{vxsat},~{vl},~{vtype}"() #[[ATTR1]], !srcloc [[META10:![0-9]+]] +// CHECK-NEXT:ret void +// void test_vxsat(void) { asm volatile ("" :::"vxsat"); } -// CHECK-LABEL: define {{.*}} void @test_vxrm -// CHECK:tail call void asm sideeffect "", "~{vxrm}"() +// CHECK-LABEL: define dso_local void @test_vxrm( +// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:tail call void asm sideeffect "", "~{vxrm},~{vl},~{vtype}"() #[[ATTR1]], !srcloc [[META11:![0-9]+]] +// CHECK-NEXT:ret void +// void test_vxrm(void) { asm volatile ("" :::"vxrm"); } diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c b/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c index 879fb1238d83a..e9444c6a76d87 100644 --- a/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c +++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c @@ -18,12 +18,12 @@ void test_v_reg() { :
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
@@ -68,7 +68,7 @@ class RISCVTargetInfo : public TargetInfo { return TargetInfo::VoidPtrBuiltinVaList; } - std::string_view getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return "~{vl},~{vtype}"; } HankChang736 wrote: I think this implementation is better, just update it with your implementation. https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ubsan] Remove -fsanitizer=vptr from -fsanitizer=undefined (PR #121115)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/121115 >From bca319184733b4bad1eb6b83aaac18a75be40b8c Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 25 Dec 2024 14:22:10 -0800 Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- clang/test/Driver/sanitizer-ld.c | 303 ++- 1 file changed, 174 insertions(+), 129 deletions(-) diff --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c index 8f2f7a5997ab4..0c36da1773c9f 100644 --- a/clang/test/Driver/sanitizer-ld.c +++ b/clang/test/Driver/sanitizer-ld.c @@ -1,14 +1,17 @@ // Test sanitizers ld flags. +// RUN: export FILECHECK_OPTS="--implicit-check-not=\"/libclang_rt\"" + // RUN: %clang -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld -fsanitize=address \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX %s // -// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" // CHECK-ASAN-LINUX-NOT: "-lc" -// CHECK-ASAN-LINUX: libclang_rt.asan.a" +// CHECK-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan_static.a" "--no-whole-archive" +// CHECK-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive" // CHECK-ASAN-LINUX-NOT: "--export-dynamic" // CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan.a.syms" // CHECK-ASAN-LINUX-NOT: "--export-dynamic" @@ -23,17 +26,16 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s // -// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan_static-x86_64 -// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64 +// CHECK-ASAN-NO-LINK-RUNTIME-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" -// RUN: %clang -fsanitize=address -fno-sanitize-link-runtime -### %s 2>&1 \ +// RUN: %clang -fsanitize=address -fsanitize-link-runtime -### %s 2>&1 \ // RUN: --target=arm64e-apple-macosx -fuse-ld=ld \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-DARWIN %s // -// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.asan_static -// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.asan +// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN: /libclang_rt.asan_osx_dynamic.dylib +// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN: /libclang_rt.osx.a // RUN: %clang -fsanitize=address -### %s 2>&1 \ // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ @@ -41,8 +43,9 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-EXECUTABLE-LINUX %s // -// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan_static -// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan +// CHECK-ASAN-EXECUTABLE-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan_static.a" "--no-whole-archive" +// CHECK-ASAN-EXECUTABLE-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive" +// CHECK-ASAN-EXECUTABLE-LINUX: "--dynamic-list={{.*}}libclang_rt.asan.a.syms" // RUN: %clang -fsanitize=address -shared -### %s 2>&1 \ // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ @@ -51,7 +54,6 @@ // RUN: | FileCheck --check-prefix=CHECK-ASAN-SHARED-LINUX %s // // CHECK-ASAN-SHARED-LINUX: libclang_rt.asan_static -// CHECK-ASAN-SHARED-LINUX-NOT: libclang_rt.asan // RUN: %clang -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \ @@ -72,11 +74,11 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s // -// CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" // CHECK-SHARED-ASAN-LINUX-NOT: "-lc" -// CHECK-SHARED-ASAN-LINUX-NOT: libclang_rt.asan.a" // CHECK-SHARED-ASAN-LINUX: libclang_rt.asan.so" // CHECK-SHARED-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan-preinit.a" "--no-whole-archive" +// CHECK-SHARED-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan_static.a" "--no-whole-archive" // CHECK-SHARED-ASAN-LINUX-NOT: "-lpthread" // CHECK-SHARED-ASAN-LINUX-NOT: "-lrt" // CHECK-SHARED-ASAN-LINUX-NOT: "-ldl" @@ -90,11 +92,10 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-ASAN-LINUX %s // -// CHECK-DSO-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-DSO-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lc" -// CHECK-DSO-SHARED-ASAN-LINUX-NOT: libclang_rt.asan.a" -// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "libclang_rt
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
topperc wrote: > Even for these rare cases, the user can achieve the same effect if they put > `vl/vtype` into clobbered registers explicitly. They can, but will they? clobbers are a relatively uncommon feature I suspect many people don't know about it. I think maybe we need documentation of how to use RVV with inline assembly. I've seen a lot of things that aren't technically correct, but usually work. For example, one statement per instruction with hand allocated vector registers and no clobbers. The vector register aren't technically alive between the statements as far as the compiler is concerned. https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Mark {vl, vtype} as clobber in inline assembly (PR #128636)
@@ -68,7 +68,7 @@ class RISCVTargetInfo : public TargetInfo { return TargetInfo::VoidPtrBuiltinVaList; } - std::string_view getClobbers() const override { return ""; } + std::string_view getClobbers() const override { return "~{vl},~{vtype}"; } topperc wrote: That doesn't work with the `target` attribute. https://github.com/llvm/llvm-project/pull/128636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] React to breaking change to DataLayoutTypeInterface (PR #128772)
lanza wrote: > @bcardosolopes @lanza You will run into this same problem with the next > incubator rebase. The fix should be the same, though there will be more > `getPreferredAlignment` functions to delete. Nice, thanks for the heads up. https://github.com/llvm/llvm-project/pull/128772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][MC] Add assembler support for XRivosVisni (PR #128773)
https://github.com/lenary commented: Only one nit, otherwise looks good I think. I didn't closely inspect the encodings. https://github.com/llvm/llvm-project/pull/128773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][MC] Add assembler support for XRivosVisni (PR #128773)
https://github.com/lenary edited https://github.com/llvm/llvm-project/pull/128773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
https://github.com/Icohedron updated https://github.com/llvm/llvm-project/pull/127137 >From 4fae5642c6e8e305cdc687b4968ba5eabaa44b50 Mon Sep 17 00:00:00 2001 From: Icohedron Date: Mon, 27 Jan 2025 11:18:09 -0800 Subject: [PATCH 01/12] Add the AddUint64 HLSL builtin function - Defines the AddUint64 HLSL builtin function - Implements the UAddc DXIL op to lower AddUint64 to DXIL --- clang/include/clang/Basic/Builtins.td | 6 ++ .../clang/Basic/DiagnosticSemaKinds.td| 2 + clang/lib/CodeGen/CGBuiltin.cpp | 45 clang/lib/Headers/hlsl/hlsl_intrinsics.h | 21 ++ clang/lib/Sema/SemaHLSL.cpp | 47 .../test/CodeGenHLSL/builtins/AddUint64.hlsl | 71 +++ .../SemaHLSL/BuiltIns/AddUint64-errors.hlsl | 41 +++ llvm/lib/Target/DirectX/DXIL.td | 13 llvm/lib/Target/DirectX/DXILOpBuilder.cpp | 14 llvm/lib/Target/DirectX/DXILOpBuilder.h | 3 + llvm/lib/Target/DirectX/DXILOpLowering.cpp| 22 -- llvm/test/CodeGen/DirectX/UAddc.ll| 40 +++ llvm/test/CodeGen/DirectX/UAddc_errors.ll | 30 13 files changed, 348 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGenHLSL/builtins/AddUint64.hlsl create mode 100644 clang/test/SemaHLSL/BuiltIns/AddUint64-errors.hlsl create mode 100644 llvm/test/CodeGen/DirectX/UAddc.ll create mode 100644 llvm/test/CodeGen/DirectX/UAddc_errors.ll diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 29939242596ba..2433427a89429 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -4753,6 +4753,12 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> { } // HLSL +def HLSLAddUint64: LangBuiltin<"HLSL_LANG"> { + let Spellings = ["__builtin_hlsl_adduint64"]; + let Attributes = [NoThrow, Const]; + let Prototype = "void(...)"; +} + def HLSLResourceGetPointer : LangBuiltin<"HLSL_LANG"> { let Spellings = ["__builtin_hlsl_resource_getpointer"]; let Attributes = [NoThrow]; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 2fce5e88ba8a0..e78339ee924ff 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10655,6 +10655,8 @@ def err_second_argument_to_cwsc_not_pointer : Error< def err_vector_incorrect_num_elements : Error< "%select{too many|too few}0 elements in vector %select{initialization|operand}3 (expected %1 elements, have %2)">; +def err_invalid_even_odd_vector_element_count : Error< + "invalid element count of %0 in vector %select{initialization|operand}4 (expected an %select{even|odd}3 element count in the range of %1 and %2)">; def err_altivec_empty_initializer : Error<"expected initializer">; def err_invalid_neon_type_code : Error< diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 361e4c4bf2e2e..5322b38458b26 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -19445,6 +19445,51 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, return nullptr; switch (BuiltinID) { + case Builtin::BI__builtin_hlsl_adduint64: { +Value *OpA = EmitScalarExpr(E->getArg(0)); +Value *OpB = EmitScalarExpr(E->getArg(1)); +assert(E->getArg(0)->getType()->hasIntegerRepresentation() && + E->getArg(1)->getType()->hasIntegerRepresentation() && + "AddUint64 operands must have an integer representation"); +assert(((E->getArg(0)->getType()->castAs()->getNumElements() == + 2 && + E->getArg(1)->getType()->castAs()->getNumElements() == + 2) || +(E->getArg(0)->getType()->castAs()->getNumElements() == + 4 && + E->getArg(1)->getType()->castAs()->getNumElements() == + 4)) && + "input vectors must have 2 or 4 elements each"); + +llvm::Value *Result = PoisonValue::get(OpA->getType()); +uint64_t NumElements = +E->getArg(0)->getType()->castAs()->getNumElements(); +for (uint64_t i = 0; i < NumElements / 2; ++i) { + + // Obtain low and high words of inputs A and B + llvm::Value *LowA = Builder.CreateExtractElement(OpA, 2 * i + 0); + llvm::Value *HighA = Builder.CreateExtractElement(OpA, 2 * i + 1); + llvm::Value *LowB = Builder.CreateExtractElement(OpB, 2 * i + 0); + llvm::Value *HighB = Builder.CreateExtractElement(OpB, 2 * i + 1); + + // Use an uadd_with_overflow to compute the sum of low words and obtain a + // carry value + llvm::Value *Carry; + llvm::Value *LowSum = EmitOverflowIntrinsic( + *this, llvm::Intrinsic::uadd_with_overflow, LowA, LowB, Carry); + llvm::Value *ZExtCarry = Builder.CreateZExt(Carry, HighA->getType()); + + // Sum the high words and the carr
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
Icohedron wrote: > The SPIRV test case isn't sufficent. Two reasons. > > 1. Since you are not using `__builtin_addc ` Your codegen path for > `uadd.with.overflow` is custom to HLSL. Your emitter is in > `EmitHLSLBuiltinExpr`. > 2. `llvm/test/CodeGen/SPIRV/llvm-intrinsics/uadd.with.overflow.ll` only tests > `spirv32` and `spirv64` targets when HLSL uses the `spirv` target > > You can add a `spirv` target to `uadd.with.overflow.ll`. Make sure nothing > blows up if we use our target. Second a test case in the hlsl_intrinsics > directory is warranted to make sure the custom things you are doing like > `CreateShuffleVector` doesn't trigger problems for spirv codegen or for the > spirv validator `spirv-val`. I added `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/AddUint64.ll` to test the lowering of the AddUint64 implementation to SPIRV. I couldn't add the spirv target to the existing `llvm/test/CodeGen/SPIRV/llvm-intrinsics/uadd.with.overflow.ll` test because doing so results in an error when the test is executed: `error: line 41: Operand 2 of Decorate requires one of these capabilities: Kernel OpDecorate %a FuncParamAttr Zext` https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
https://github.com/Icohedron edited https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][MC] Add assembler support for XRivosVisni (PR #128773)
@@ -1376,6 +1376,13 @@ def HasVendorXqcilo // Rivos Extension(s) +def FeatureVendorXRivosVisni +: RISCVExperimentalExtension<0, 1, "Rivos Vector Small Integer New">; +def HasVendorXRivosVisni +: Predicate<"Subtarget->hasVendorXRivosVisni()">, + AssemblerPredicate<(all_of FeatureVendorXRivosVisni), + "'XRivosVizisni' (Rivos Vector Small Integer New)">; mshockwave wrote: Also I think it might be 'XRivosVisni' rather than 'XRivosVizisni'? https://github.com/llvm/llvm-project/pull/128773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang] Replace createRef with createDup (PR #126683)
vitalybuka wrote: > Requesting changes just to be sure none of the changes from `createRef()` to > `createDup()` would have generated a `StringRef` holding a null pointer. I'd > be surprised if they did, but a second set of eyes would be helpful. I am not sure how to proceed here. This change was requested by @efriedma-quic on #125020 I see 3 options: 1. Land as-is, but then we would not differentiate `createNull()` vs `createEmpty()` vs `createDup()`. No idea if this difference is important. 2. Move checks into `createDup()`, but then `createDup()` is not always a "Dup". Also no idead if this is important. 3. Just abandon the patch. WDYT? https://github.com/llvm/llvm-project/pull/126683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang modules] Setting `DebugCompilationDir` when it is safe to ignore current working directory (PR #128446)
https://github.com/qiongsiwu updated https://github.com/llvm/llvm-project/pull/128446 >From c8eda8b9192cf4bdad4121063336beeb14cbe689 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Sun, 23 Feb 2025 16:47:18 -0800 Subject: [PATCH 1/5] Initial commit --- .../DependencyScanning/ModuleDepCollector.cpp | 17 +- clang/test/ClangScanDeps/modules-debug-dir.c | 22 +++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 clang/test/ClangScanDeps/modules-debug-dir.c diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp index 1c5f4c4b50ab6..8a94535d3806c 100644 --- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -492,8 +492,23 @@ static std::string getModuleContextHash(const ModuleDeps &MD, auto &FSOpts = const_cast(CI.getFileSystemOpts()); if (CWD && !IgnoreCWD) HashBuilder.add(*CWD); - else + else { FSOpts.WorkingDir.clear(); +auto &CGOpts = const_cast(CI.getCodeGenOpts()); +if (CGOpts.DwarfVersion && CWD) { + // It is necessary to explicitly set the DebugCompilationDir + // to a common directory (e.g. root) if IgnoreCWD is true. + // When IgnoreCWD is true, the module's content should not depend + // on the current working directory. However, if dwarf information + // is needed (when CGOpts.DwarfVersion is non-zero), and if + // CGOpts.DebugCompilationDir is not explicitly set, + // the current working directory will be automatically embedded + // in the dwarf information in the pcm, contradicting the assumption + // that it is safe to ignore the CWD. Thus in such cases, + // CGOpts.DebugCompilationDir is explicitly set to a common directory. + CGOpts.DebugCompilationDir = llvm::sys::path::root_path(*CWD); +} + } // Hash the BuildInvocation without any input files. SmallString<0> ArgVec; diff --git a/clang/test/ClangScanDeps/modules-debug-dir.c b/clang/test/ClangScanDeps/modules-debug-dir.c new file mode 100644 index 0..580f72205e68f --- /dev/null +++ b/clang/test/ClangScanDeps/modules-debug-dir.c @@ -0,0 +1,22 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json +// RUN: clang-scan-deps -compilation-database %t/cdb.json -format \ +// RUN: experimental-full > %t/result.json + +//--- cdb.json.in +[{ + "directory": "DIR", + "command": "clang -g -fdebug-info-for-profiling DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", + "file": "DIR/tu.c" +}] + +//--- include/module.modulemap +module mod { + header "mod.h" +} + +//--- include/mod.h + +//--- tu.c +#include "mod.h" >From 4b29c19ebc360ec80a8c16e1ac485bbac78a9062 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Mon, 24 Feb 2025 09:34:56 -0800 Subject: [PATCH 2/5] Fix the test. --- clang/test/ClangScanDeps/modules-debug-dir.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/test/ClangScanDeps/modules-debug-dir.c b/clang/test/ClangScanDeps/modules-debug-dir.c index 580f72205e68f..1ac518985471d 100644 --- a/clang/test/ClangScanDeps/modules-debug-dir.c +++ b/clang/test/ClangScanDeps/modules-debug-dir.c @@ -3,11 +3,12 @@ // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json // RUN: clang-scan-deps -compilation-database %t/cdb.json -format \ // RUN: experimental-full > %t/result.json +// RUN: cat %t/result.json | FileCheck %s //--- cdb.json.in [{ "directory": "DIR", - "command": "clang -g -fdebug-info-for-profiling DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -o DIR/tu.o", + "command": "clang -c -g -gmodules DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -fdebug-compilation-dir=DIR -o DIR/tu.o", "file": "DIR/tu.c" }] @@ -20,3 +21,10 @@ module mod { //--- tu.c #include "mod.h" + +// Check the -fdebug-compilation-dir used for the module is the root +// directory when current working directory optimization is in effect. +// CHECK: "modules": [ +// CHECK: "command-line": [ +// CHECK: "-fdebug-compilation-dir={{\/|C:|\/\/net}}", +// CHECK: "translation-units": [ >From 5c53c84d33ad4ceec4e79dc36638e827607709ca Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Mon, 24 Feb 2025 10:34:35 -0800 Subject: [PATCH 3/5] Try to fix the test on windows. --- clang/test/ClangScanDeps/modules-debug-dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/ClangScanDeps/modules-debug-dir.c b/clang/test/ClangScanDeps/modules-debug-dir.c index 1ac518985471d..87f1bc141c73a 100644 --- a/clang/test/ClangScanDeps/modules-debug-dir.c +++ b/clang/test/ClangScanDeps/modules-debug-dir.c @@ -8,7 +8,7 @@ //--- cdb.json.in [{ "directory": "DIR", - "command": "clang -c -g -gmodules DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -IDIR/include/ -fdebug-
[clang] [libclang] Replace createRef with createDup (PR #126683)
erichkeane wrote: > > Requesting changes just to be sure none of the changes from `createRef()` > > to `createDup()` would have generated a `StringRef` holding a null pointer. > > I'd be surprised if they did, but a second set of eyes would be helpful. > > I am not sure how to proceed here. This change was requested by > @efriedma-quic on #125020 > > I see 3 options: > > 1. Land as-is, but then we would not differentiate `createNull()` vs > `createEmpty()` vs `createDup()`. No idea if this difference is important. > > 2. Move checks into `createDup()`, but then `createDup()` is not always a > "Dup". Also no idead if this is important. > > 3. Just abandon the patch. > > > WDYT? Aaron is away this week, but: I believe he was asking for an analysis of all of the uses to make sure they don't use a null-StringRef anywhere. IMO, an assert of some sort in the createDup interface would be sufficient to long-term prevent the problem. https://github.com/llvm/llvm-project/pull/126683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Function type return type improvements (PR #128787)
@@ -424,6 +424,10 @@ LogicalResult cir::FuncOp::verifyType() { if (!isa(type)) return emitOpError("requires '" + getFunctionTypeAttrName().str() + "' attribute of function type"); + if (auto rt = type.getReturnTypes(); erichkeane wrote: Is there anywhere that we check that `rt.size() == 1` as a part of the verifier? https://github.com/llvm/llvm-project/pull/128787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Function type return type improvements (PR #128787)
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/128787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm:ir] Add support for constant data exceeding 4GiB (PR #126481)
@@ -617,15 +617,15 @@ class ConstantDataSequential : public ConstantData { /// If this is a sequential container of integers (of any size), return the /// specified element in the low bits of a uint64_t. - uint64_t getElementAsInteger(unsigned i) const; + uint64_t getElementAsInteger(uint64_t i) const; /// If this is a sequential container of integers (of any size), return the /// specified element as an APInt. APInt getElementAsAPInt(unsigned i) const; efriedma-quic wrote: For consistency, I'm going to ask you change the rest of the getElementAs*. (I agree this change shouldn't grow indefinitely, so I'm not going to request anything beyond that. But having half the accessors use "unsigned" and the other half use "uint64_t" is confusing.) https://github.com/llvm/llvm-project/pull/126481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm:ir] Add support for constant data exceeding 4GiB (PR #126481)
@@ -644,7 +644,7 @@ class ConstantDataSequential : public ConstantData { Type *getElementType() const; /// Return the number of elements in the array or vector. - unsigned getNumElements() const; + uint64_t getNumElements() const; efriedma-quic wrote: Adding a python script as a regression test isn't necessarily an issue, but I assume it would take an excessively large amount of time/memory to process a 4GB file. We don't really have any place in-tree for a test like that. Leaving it out is probably fine... it's here for reference if we need it in the future. https://github.com/llvm/llvm-project/pull/126481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Function type return type improvements (PR #128787)
@@ -287,32 +287,43 @@ def CIR_BoolType : def CIR_FuncType : CIR_Type<"Func", "func"> { let summary = "CIR function type"; let description = [{ -The `!cir.func` is a function type. It consists of a single return type, a -list of parameter types and can optionally be variadic. +The `!cir.func` is a function type. It consists of an optional return type, +a list of parameter types and can optionally be variadic. Example: ```mlir -!cir.func -!cir.func -!cir.func +!cir.func<()> +!cir.func<() -> bool> +!cir.func<(!s8i, !s8i)> +!cir.func<(!s8i, !s8i) -> !s32i> +!cir.func<(!s32i, ...) -> !s32i> ``` }]; let parameters = (ins ArrayRefParameter<"mlir::Type">:$inputs, -"mlir::Type":$returnType, "bool":$varArg); +"mlir::Type":$optionalReturnType, "bool":$varArg); + // Use a custom parser to handle the argument types and optional return erichkeane wrote: ```suggestion // Use a custom parser to handle the argument types and optional return. ``` https://github.com/llvm/llvm-project/pull/128787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Function type return type improvements (PR #128787)
https://github.com/erichkeane commented: couple small suggestions, else Im happy when the CIR folks are. https://github.com/llvm/llvm-project/pull/128787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)
aaronpuchert wrote: Good question. Which AST nodes could we visit here? Let's see some examples of initializing function pointers/references: ```c++ void f(); void (*fp)() = f; void (*fp2)() = &f; void (*fp3)() = fp; void (&fr)() = f; ``` The (simplified) AST: ``` TranslationUnitDecl 0x55edc65d3778 |-FunctionDecl 0x55edc661d910 used f 'void ()' |-VarDecl 0x55edc661dac0 used fp 'void (*)()' cinit | `-ImplicitCastExpr 'void (*)()' | `-DeclRefExpr 'void ()' lvalue Function 0x55edc661d910 'f' 'void ()' |-VarDecl 0x55edc661dbe8 fp2 'void (*)()' cinit | `-UnaryOperator 'void (*)()' prefix '&' cannot overflow | `-DeclRefExpr 'void ()' lvalue Function 0x55edc661d910 'f' 'void ()' |-VarDecl 0x55edc661dd48 fp3 'void (*)()' cinit | `-ImplicitCastExpr 'void (*)()' | `-DeclRefExpr 'void (*)()' lvalue Var 0x55edc661dac0 'fp' 'void (*)()' `-VarDecl 0x55edc661dea0 fr 'void (&)()' cinit `-DeclRefExpr 'void ()' lvalue Function 0x55edc661d910 'f' 'void ()' ``` The third and fourth declarations are tricky. I don't see an AST node that we could attach to for finding this. Perhaps we should adapt Sema to add casts for the attributes? Then we could always attach to the `ImplicitCastExpr`. (Note that the `LValueToRValue` cast is orthogonal and not relevant for this, it simply means we're reading `fp`.) https://github.com/llvm/llvm-project/pull/67095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Fix false negative `modernize-use-ranges` when using getter function (PR #127377)
https://github.com/Andrewyuan34 edited https://github.com/llvm/llvm-project/pull/127377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Fix false negative `modernize-use-ranges` when using getter function (PR #127377)
Andrewyuan34 wrote: ping https://github.com/llvm/llvm-project/pull/127377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Fix invalid fixit from modernize-use-ranges for nullptr used with std::unique_ptr (PR #127162)
https://github.com/Andrewyuan34 updated https://github.com/llvm/llvm-project/pull/127162 >From 5bbd811547440e56eb3c2ed387833b41ce6232e3 Mon Sep 17 00:00:00 2001 From: Andrewyuan34 Date: Thu, 13 Feb 2025 22:35:36 -0500 Subject: [PATCH] [clang-tidy] Fix invalid fixit from modernize-use-ranges for nullptr used with std::unique_ptr --- .../clang-tidy/utils/UseRangesCheck.cpp | 13 ++ clang-tools-extra/docs/ReleaseNotes.rst | 4 +++ .../checkers/modernize/use-ranges.cpp | 26 --- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp index aba4d17ccd035..2667099b52639 100644 --- a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp @@ -215,6 +215,19 @@ void UseRangesCheck::check(const MatchFinder::MatchResult &Result) { const auto *Call = Result.Nodes.getNodeAs(Buffer); if (!Call) continue; + +// FIXME: This check specifically handles `CXXNullPtrLiteralExpr`, but +// a more general solution might be needed. +if (Function->getName() == "find") { + const unsigned ValueArgIndex = 2; + if (Call->getNumArgs() <= ValueArgIndex) +continue; + const Expr *ValueExpr = + Call->getArg(ValueArgIndex)->IgnoreParenImpCasts(); + if (isa(ValueExpr)) +return; +} + auto Diag = createDiag(*Call); if (auto ReplaceName = Replacer->getReplaceName(*Function)) Diag << FixItHint::CreateReplacement(Call->getCallee()->getSourceRange(), diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 6b8fe22242417..4fdb5aa367c68 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -109,6 +109,10 @@ Changes in existing checks - Improved :doc:`misc-redundant-expression ` check by providing additional examples and fixing some macro related false positives. + +- Improved :doc:`modernize-use-ranges + ` check by updating suppress + warnings logic for ``nullptr`` in ``std::find``. Removed checks ^^ diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp index b022efebfdf4d..5aa026038b1cd 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp @@ -1,14 +1,25 @@ -// RUN: %check_clang_tidy -std=c++20 %s modernize-use-ranges %t -- -- -I %S/Inputs/use-ranges/ -// RUN: %check_clang_tidy -std=c++23 %s modernize-use-ranges %t -check-suffixes=,CPP23 -- -I %S/Inputs/use-ranges/ +// RUN: %check_clang_tidy -std=c++20 %s modernize-use-ranges %t -- -- -I %S/Inputs/ +// RUN: %check_clang_tidy -std=c++23 %s modernize-use-ranges %t -check-suffixes=,CPP23 -- -I %S/Inputs/ +// Example: ./check_clang_tidy.py -std=c++20 checkers/modernize/use-ranges.cpp modernize-use-ranges temp.txt -- -- -I ~/llvm-project/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/ // CHECK-FIXES: #include // CHECK-FIXES-CPP23: #include // CHECK-FIXES: #include -#include "fake_std.h" +#include "use-ranges/fake_std.h" +#include "smart-ptr/unique_ptr.h" void Positives() { std::vector I, J; + std::vector> K; + + // Expect to have no check messages + std::find(K.begin(), K.end(), nullptr); + + std::find(K.begin(), K.end(), std::unique_ptr()); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm + // CHECK-FIXES: std::ranges::find(K, std::unique_ptr()); + std::find(I.begin(), I.end(), 0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm // CHECK-FIXES: std::ranges::find(I, 0); @@ -76,6 +87,15 @@ void Positives() { void Reverse(){ std::vector I, J; + std::vector> K; + + // Expect to have no check messages + std::find(K.rbegin(), K.rend(), nullptr); + + std::find(K.rbegin(), K.rend(), std::unique_ptr()); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm + // CHECK-FIXES: std::ranges::find(std::ranges::reverse_view(K), std::unique_ptr()); + std::find(I.rbegin(), I.rend(), 0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a ranges version of this algorithm // CHECK-FIXES: std::ranges::find(std::ranges::reverse_view(I), 0); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Thread Safety Analysis: Support warning on taking address of guarded variables (PR #123063)
aaronpuchert wrote: > One thought --- you could consider an attribute that could be put on pointer > arguments to functions that says "yes, I dereference this and read or write > it". GCC [has such an attribute](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-access-function-attribute), independent of Thread Safety Analysis. But I don't think we have an equivalent. However, as I wrote above, it's probably the rule and not the exception that pointers passed into a function are dereferenced at some point. So we're probably fine if we always warn. And as @melver pointed out, the experience with reference passing in C++ has been pretty good, and it's probably transferable to pointers. https://github.com/llvm/llvm-project/pull/123063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][MC] Add assembler support for XRivosVisni (PR #128773)
@@ -1376,6 +1376,13 @@ def HasVendorXqcilo // Rivos Extension(s) +def FeatureVendorXRivosVisni +: RISCVExperimentalExtension<0, 1, "Rivos Vector Small Integer New">; +def HasVendorXRivosVisni +: Predicate<"Subtarget->hasVendorXRivosVisni()">, + AssemblerPredicate<(all_of FeatureVendorXRivosVisni), + "'XRivosVizisni' (Rivos Vector Small Integer New)">; mshockwave wrote: nit: the spec uses "Vector Integer Small New", should it be consistent here as well? https://github.com/llvm/llvm-project/pull/128773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add Xqccmp Assembly Support (PR #128731)
@@ -0,0 +1,35 @@ +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-xqccmp -M no-aliases -show-encoding < %s 2>&1 \ +# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s + +# CHECK-ERROR: error: invalid operand for instruction +qc.cm.mvsa01 a1, a2 + +# CHECK-ERROR: error: rs1 and rs2 must be different +qc.cm.mvsa01 s0, s0 + +# CHECK-ERROR: error: invalid operand for instruction +qc.cm.mva01s a1, a2 + +# CHECK-ERROR: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported +qc.cm.popretz {ra, s0-s10}, 112 + +# CHECK-ERROR: error: stack adjustment is invalid for this instruction and register list; refer to Zc spec for a detailed range of stack adjustment topperc wrote: I think I'm ok with it for the purposes of this patch. I may see about generating a better error that doesn't point to a spec. https://github.com/llvm/llvm-project/pull/128731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add Xqccmp Assembly Support (PR #128731)
https://github.com/topperc approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/128731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)
@@ -4122,6 +4122,9 @@ def RestrictDocs : Documentation { The ``malloc`` attribute indicates that the function acts like a system memory allocation function, returning a pointer to allocated storage disjoint from the storage for any other object accessible to the caller. + +The form of ``malloc`` with one or two arguments (supported by GCC 11) is +currently ignored by Clang. erichkeane wrote: I would like it if we updated the documentation here to be something more like: ``` The ``malloc`` attribute has two forms with different functionality. The first is when it is used without arguments, where it marks that a function acts like a system memory allocation function, returning a pointer to allocated storage that does not alias storage from any other object accessible to the caller. The second form is when ``malloc`` takes one or two arguments. The first argument names a function that should be associated with this function as its deallocation function. When this form is used, it enables the compiler to diagnose when the incorrect deallocation function is used with this variable. However the associated warning, spelled `-Wmismatched-dealloc` in GCC, is not yet implemented in clang. ``` https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)
@@ -2064,13 +2064,87 @@ static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { QualType ResultType = getFunctionOrMethodResultType(D); - if (ResultType->isAnyPointerType() || ResultType->isBlockPointerType()) { + if (!ResultType->isAnyPointerType() && !ResultType->isBlockPointerType()) { +S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) +<< AL << getFunctionOrMethodResultSourceRange(D); +return; + } + + if (AL.getNumArgs() == 0) { D->addAttr(::new (S.Context) RestrictAttr(S.Context, AL)); return; } - S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) - << AL << getFunctionOrMethodResultSourceRange(D); + if (AL.getAttributeSpellingListIndex() == RestrictAttr::Declspec_restrict) { +// __declspec(restrict) accepts no arguments +S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 0; +return; + } + + // [[gnu::malloc(deallocator)]] with args specifies a deallocator function + Expr *DeallocE = AL.getArgAsExpr(0); + SourceLocation DeallocLoc = DeallocE->getExprLoc(); + FunctionDecl *DeallocFD = nullptr; + DeclarationNameInfo DeallocNI; + + if (auto *DRE = dyn_cast(DeallocE)) { +DeallocFD = dyn_cast(DRE->getDecl()); +DeallocNI = DRE->getNameInfo(); +if (!DeallocFD) { + S.Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function) + << 1 << DeallocNI.getName(); + return; +} + } else if (auto *ULE = dyn_cast(DeallocE)) { +DeallocFD = S.ResolveSingleFunctionTemplateSpecialization(ULE, true); +DeallocNI = ULE->getNameInfo(); +if (!DeallocFD) { + S.Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function) + << 2 << DeallocNI.getName(); + if (ULE->getType() == S.Context.OverloadTy) +S.NoteAllOverloadCandidates(ULE); + return; +} + } else { +S.Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function) << 0; +return; + } + + // 2nd arg of [[gnu::malloc(deallocator, 2)]] with args specifies the param + // of deallocator that deallocates the pointer (defaults to 1) + ParamIdx DeallocPtrIdx; + if (AL.getNumArgs() == 1) { +DeallocPtrIdx = ParamIdx(1, DeallocFD); + +if (!DeallocPtrIdx.isValid() || +!getFunctionOrMethodParamType(DeallocFD, DeallocPtrIdx.getASTIndex()) + .getCanonicalType() + ->isPointerType()) { + S.Diag(DeallocLoc, + diag::err_attribute_malloc_arg_not_function_with_pointer_arg) + << DeallocNI.getName(); + return; +} + } else { +if (!checkFunctionOrMethodParameterIndex(S, DeallocFD, AL, 2, + AL.getArgAsExpr(1), DeallocPtrIdx, + /* CanIndexImplicitThis=*/false)) + return; + +QualType DeallocPtrArgType = +getFunctionOrMethodParamType(DeallocFD, DeallocPtrIdx.getASTIndex()); +if (!DeallocPtrArgType.getCanonicalType()->isPointerType()) { + S.Diag(DeallocLoc, + diag::err_attribute_malloc_arg_refers_to_non_pointer_type) + << DeallocPtrIdx.getSourceIndex() << DeallocPtrArgType + << DeallocNI.getName(); + return; +} + } + + // FIXME: we should add this attribute to Clang's AST, so that clang-analyzer erichkeane wrote: I think we SHOULD still add this to the AST anyway, as it represents code still. However we should teach `CGCall.cpp` to no longer emit the 'no-alias'. https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)
https://github.com/erichkeane commented: Note that this just came up in another bug report (see discussion here: https://github.com/llvm/llvm-project/issues/128026). it seems we let this go, so I was hoping we could get this merged!. @aloisklink : I see you're still around github, but seem to have moved onto other projects. If you're still interested in working on this, please make the changes suggested and we can merge this. If you're not, please let me know and I'll commander this. Sorry for the delay! https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
@@ -0,0 +1,88 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; Code here is an excerpt of clang/test/CodeGenHLSL/builtins/AddUint64.hlsl compiled for spirv using the following command +; clang -cc1 -finclude-default-header -triple spirv-unknown-vulkan-compute clang/test/CodeGenHLSL/builtins/AddUint64.hlsl -emit-llvm -disable-llvm-passes -o llvm/test/CodeGen/SPIRV/hlsl-intrinsics/uadd_with_overflow.ll + +; CHECK-DAG: %[[#int_32:]] = OpTypeInt 32 0 +; CHECK-DAG: %[[#vec2_int_32:]] = OpTypeVector %[[#int_32]] 2 +; CHECK-DAG: %[[#bool:]] = OpTypeBool +; CHECK-DAG: %[[#const_i32_1:]] = OpConstant %[[#int_32]] 1 +; CHECK-DAG: %[[#struct_i32_i32:]] = OpTypeStruct %[[#int_32]] %[[#int_32]] +; CHECK-DAG: %[[#func_v2i32_v2i32_v2i32:]] = OpTypeFunction %[[#vec2_int_32]] %[[#vec2_int_32]] %[[#vec2_int_32]] +; CHECK-DAG: %[[#const_i32_0:]] = OpConstant %[[#int_32]] 0 +; CHECK-DAG: %[[#undef_v2i32:]] = OpUndef %[[#vec2_int_32]] +; CHECK-DAG: %[[#vec4_int_32:]] = OpTypeVector %[[#int_32]] 4 +; CHECK-DAG: %[[#vec2_bool:]] = OpTypeVector %[[#bool]] 2 +; CHECK-DAG: %[[#const_v2i32_0_0:]] = OpConstantComposite %[[#vec2_int_32]] %[[#const_i32_0]] %[[#const_i32_0]] +; CHECK-DAG: %[[#const_v2i32_1_1:]] = OpConstantComposite %[[#vec2_int_32]] %[[#const_i32_1]] %[[#const_i32_1]] +; CHECK-DAG: %[[#struct_v2i32_v2i32:]] = OpTypeStruct %[[#vec2_int_32]] %[[#vec2_int_32]] +; CHECK-DAG: %[[#func_v4i32_v4i32_v4i32:]] = OpTypeFunction %[[#vec4_int_32]] %[[#vec4_int_32]] %[[#vec4_int_32]] +; CHECK-DAG: %[[#undef_v4i32:]] = OpUndef %[[#vec4_int_32]] + + +define spir_func <2 x i32> @test_AddUint64_uint2(<2 x i32> %a, <2 x i32> %b) { +entry: +; CHECK: %[[#a:]] = OpFunctionParameter %[[#vec2_int_32]] +; CHECK: %[[#b:]] = OpFunctionParameter %[[#vec2_int_32]] +; CHECK: %[[#a_low:]] = OpCompositeExtract %[[#int_32]] %[[#a]] 0 +; CHECK: %[[#a_high:]] = OpCompositeExtract %[[#int_32]] %[[#a]] 1 +; CHECK: %[[#b_low:]] = OpCompositeExtract %[[#int_32]] %[[#b]] 0 +; CHECK: %[[#b_high:]] = OpCompositeExtract %[[#int_32]] %[[#b]] 1 +; CHECK: %[[#iaddcarry:]] = OpIAddCarry %[[#struct_i32_i32]] %[[#a_low]] %[[#b_low]] +; CHECK: %[[#lowsum:]] = OpCompositeExtract %[[#int_32]] %[[#iaddcarry]] 0 +; CHECK: %[[#carry:]] = OpCompositeExtract %[[#int_32]] %[[#iaddcarry]] 1 +; CHECK: %[[#carry_ne0:]] = OpINotEqual %[[#bool]] %[[#carry]] %[[#const_i32_0]] +; CHECK: %[[#select_1_or_0:]] = OpSelect %[[#int_32]] %[[#carry_ne0]] %[[#const_i32_1]] %[[#const_i32_0]] Icohedron wrote: If I switch `-O0` to `-O1` or higher, this select still does not go away. It seems that the SPIRV backend doesn't know `OpIAddCarry`'s second return value is always an i32 0 or 1. https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] [DXIL] Implement the AddUint64 HLSL function and the UAddc DXIL op (PR #127137)
https://github.com/Icohedron edited https://github.com/llvm/llvm-project/pull/127137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ubsan] Remove -fsanitizer=vptr from -fsanitizer=undefined (PR #121115)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/121115 >From bca319184733b4bad1eb6b83aaac18a75be40b8c Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 25 Dec 2024 14:22:10 -0800 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- clang/test/Driver/sanitizer-ld.c | 303 ++- 1 file changed, 174 insertions(+), 129 deletions(-) diff --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c index 8f2f7a5997ab4..0c36da1773c9f 100644 --- a/clang/test/Driver/sanitizer-ld.c +++ b/clang/test/Driver/sanitizer-ld.c @@ -1,14 +1,17 @@ // Test sanitizers ld flags. +// RUN: export FILECHECK_OPTS="--implicit-check-not=\"/libclang_rt\"" + // RUN: %clang -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld -fsanitize=address \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX %s // -// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" // CHECK-ASAN-LINUX-NOT: "-lc" -// CHECK-ASAN-LINUX: libclang_rt.asan.a" +// CHECK-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan_static.a" "--no-whole-archive" +// CHECK-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive" // CHECK-ASAN-LINUX-NOT: "--export-dynamic" // CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan.a.syms" // CHECK-ASAN-LINUX-NOT: "--export-dynamic" @@ -23,17 +26,16 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s // -// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan_static-x86_64 -// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64 +// CHECK-ASAN-NO-LINK-RUNTIME-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" -// RUN: %clang -fsanitize=address -fno-sanitize-link-runtime -### %s 2>&1 \ +// RUN: %clang -fsanitize=address -fsanitize-link-runtime -### %s 2>&1 \ // RUN: --target=arm64e-apple-macosx -fuse-ld=ld \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-DARWIN %s // -// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.asan_static -// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN-NOT: libclang_rt.asan +// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN: /libclang_rt.asan_osx_dynamic.dylib +// CHECK-ASAN-NO-LINK-RUNTIME-DARWIN: /libclang_rt.osx.a // RUN: %clang -fsanitize=address -### %s 2>&1 \ // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ @@ -41,8 +43,9 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-EXECUTABLE-LINUX %s // -// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan_static -// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan +// CHECK-ASAN-EXECUTABLE-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan_static.a" "--no-whole-archive" +// CHECK-ASAN-EXECUTABLE-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive" +// CHECK-ASAN-EXECUTABLE-LINUX: "--dynamic-list={{.*}}libclang_rt.asan.a.syms" // RUN: %clang -fsanitize=address -shared -### %s 2>&1 \ // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ @@ -51,7 +54,6 @@ // RUN: | FileCheck --check-prefix=CHECK-ASAN-SHARED-LINUX %s // // CHECK-ASAN-SHARED-LINUX: libclang_rt.asan_static -// CHECK-ASAN-SHARED-LINUX-NOT: libclang_rt.asan // RUN: %clang -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \ @@ -72,11 +74,11 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s // -// CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" // CHECK-SHARED-ASAN-LINUX-NOT: "-lc" -// CHECK-SHARED-ASAN-LINUX-NOT: libclang_rt.asan.a" // CHECK-SHARED-ASAN-LINUX: libclang_rt.asan.so" // CHECK-SHARED-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan-preinit.a" "--no-whole-archive" +// CHECK-SHARED-ASAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.asan_static.a" "--no-whole-archive" // CHECK-SHARED-ASAN-LINUX-NOT: "-lpthread" // CHECK-SHARED-ASAN-LINUX-NOT: "-lrt" // CHECK-SHARED-ASAN-LINUX-NOT: "-ldl" @@ -90,11 +92,10 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-ASAN-LINUX %s // -// CHECK-DSO-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-DSO-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lc" -// CHECK-DSO-SHARED-ASAN-LINUX-NOT: libclang_rt.asan.a" -// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "libclang_rt
[clang] [clang][analysis] Fix flaky clang/test/Analysis/live-stmts.cpp test (2nd attempt) (PR #127406)
tstellar wrote: /cherry-pick f378e52ed3c6f8da4973f97f1ef043c2eb0da721 https://github.com/llvm/llvm-project/pull/127406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analysis] Fix flaky clang/test/Analysis/live-stmts.cpp test (2nd attempt) (PR #127406)
https://github.com/tstellar milestoned https://github.com/llvm/llvm-project/pull/127406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analysis] Fix flaky clang/test/Analysis/live-stmts.cpp test (2nd attempt) (PR #127406)
llvmbot wrote: Failed to cherry-pick: f378e52ed3c6f8da4973f97f1ef043c2eb0da721 https://github.com/llvm/llvm-project/actions/runs/13534670364 Please manually backport the fix and push it to your github fork. Once this is done, please create a [pull request](https://github.com/llvm/llvm-project/compare) https://github.com/llvm/llvm-project/pull/127406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits