[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)
kbeyls wrote: I just checked if there indeed are big-endian bots which should pick up if a different hash gets produced on a big-endian system. I guess this bot (the only bot?) would pick it up: https://lab.llvm.org/buildbot/#/builders/231 I now also realize that there are no tests with this commit. I assume that later commits that test hash computation for a pointer authentication discriminator will implicitly test this. In the ideal world, it seems there should be a simple test, e.g. checking one 64 bit and one 128 bit hash as part of this commit? I don't think not having the test should block landing this PR, but if it would be straightforward to add a test, then I think it is still worthwhile to do it as part of this PR. https://github.com/llvm/llvm-project/pull/94394 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)
https://github.com/kbeyls approved this pull request. https://github.com/llvm/llvm-project/pull/94394 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [compiler-rt] [PAC][AArch64] Support init/fini array signing (PR #95203)
https://github.com/kovdan01 created https://github.com/llvm/llvm-project/pull/95203 If both `-fptrauth-init-fini` and `-fptrauth-calls` are passed, sign function pointers in `llvm.global_ctors` and `llvm.global_dtors` with constant discriminator 0xD9D4 (`ptrauth_string_discriminator("init_fini")`) and no address discrimination. >From 9880b6883cd73ab2dcd0efd9ae80805db862c595 Mon Sep 17 00:00:00 2001 From: Daniil Kovalev Date: Wed, 12 Jun 2024 10:28:08 +0300 Subject: [PATCH] [PAC][AArch64] Support init/fini array signing If both `-fptrauth-init-fini` and `-fptrauth-calls` are passed, sign function pointers in `llvm.global_ctors` and `llvm.global_dtors` with constant discriminator 0xD9D4 (`ptrauth_string_discriminator("init_fini")`) and no address discrimination. --- .../include/clang/Basic/PointerAuthOptions.h | 7 +++ clang/lib/CodeGen/CodeGenModule.cpp | 50 +++ clang/lib/Frontend/CompilerInvocation.cpp | 5 ++ clang/lib/Headers/ptrauth.h | 7 +++ clang/test/CodeGen/ptrauth-init-fini.c| 27 ++ compiler-rt/lib/builtins/crtbegin.c | 16 ++ 6 files changed, 92 insertions(+), 20 deletions(-) create mode 100644 clang/test/CodeGen/ptrauth-init-fini.c diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index 32b179e3f9460..dea8ae439a0eb 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -25,6 +25,10 @@ namespace clang { +/// Constant discriminator to be used with function pointers in .init_array and +/// .fini_array. The value is ptrauth_string_discriminator("init_fini") +constexpr uint16_t InitFiniPointerConstantDiscriminator = 0xD9D4; + constexpr unsigned PointerAuthKeyNone = -1; class PointerAuthSchema { @@ -152,6 +156,9 @@ class PointerAuthSchema { struct PointerAuthOptions { /// The ABI for C function pointers. PointerAuthSchema FunctionPointers; + + /// The ABI for function addresses in .init_array and .fini_array + PointerAuthSchema InitFiniPointers; }; } // end namespace clang diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e4774a587707a..6bc6c34a9f524 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2042,37 +2042,47 @@ void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority, void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) { if (Fns.empty()) return; - // Ctor function type is void()*. - llvm::FunctionType* CtorFTy = llvm::FunctionType::get(VoidTy, false); - llvm::Type *CtorPFTy = llvm::PointerType::get(CtorFTy, - TheModule.getDataLayout().getProgramAddressSpace()); + const PointerAuthSchema &InitFiniAuthSchema = + getCodeGenOpts().PointerAuth.InitFiniPointers; + assert(!InitFiniAuthSchema || !InitFiniAuthSchema.isAddressDiscriminated()); - // Get the type of a ctor entry, { i32, void ()*, i8* }. - llvm::StructType *CtorStructTy = llvm::StructType::get( - Int32Ty, CtorPFTy, VoidPtrTy); + // Ctor function type is ptr. + llvm::PointerType *PtrTy = llvm::PointerType::get( + getLLVMContext(), TheModule.getDataLayout().getProgramAddressSpace()); + + // Get the type of a ctor entry, { i32, ptr, ptr }. + llvm::StructType *CtorStructTy = llvm::StructType::get(Int32Ty, PtrTy, PtrTy); // Construct the constructor and destructor arrays. - ConstantInitBuilder builder(*this); - auto ctors = builder.beginArray(CtorStructTy); + ConstantInitBuilder Builder(*this); + auto Ctors = Builder.beginArray(CtorStructTy); for (const auto &I : Fns) { -auto ctor = ctors.beginStruct(CtorStructTy); -ctor.addInt(Int32Ty, I.Priority); -ctor.add(I.Initializer); +auto Ctor = Ctors.beginStruct(CtorStructTy); +Ctor.addInt(Int32Ty, I.Priority); +if (InitFiniAuthSchema) { + llvm::Constant *SignedCtorPtr = getConstantSignedPointer( + I.Initializer, InitFiniAuthSchema.getKey(), + /*StorageAddress=*/nullptr, + llvm::ConstantInt::get( + SizeTy, InitFiniAuthSchema.getConstantDiscrimination())); + Ctor.add(SignedCtorPtr); +} else { + Ctor.add(I.Initializer); +} if (I.AssociatedData) - ctor.add(I.AssociatedData); + Ctor.add(I.AssociatedData); else - ctor.addNullPointer(VoidPtrTy); -ctor.finishAndAddTo(ctors); + Ctor.addNullPointer(PtrTy); +Ctor.finishAndAddTo(Ctors); } - auto list = -ctors.finishAndCreateGlobal(GlobalName, getPointerAlign(), -/*constant*/ false, -llvm::GlobalValue::AppendingLinkage); + auto List = Ctors.finishAndCreateGlobal(GlobalName, getPointerAlign(), + /*constant*/ false, + llvm::GlobalValue::AppendingLinkage); // The LTO linker doesn
[llvm-branch-commits] [flang] d2522a0 - Revert "[Flang] Use PrintModulePass to print LLVM IR from the frontend (#95142)"
Author: Stephen Tozer Date: 2024-06-12T11:52:00+01:00 New Revision: d2522a01b4087f3b8c88b91a4ba20bf6654870bf URL: https://github.com/llvm/llvm-project/commit/d2522a01b4087f3b8c88b91a4ba20bf6654870bf DIFF: https://github.com/llvm/llvm-project/commit/d2522a01b4087f3b8c88b91a4ba20bf6654870bf.diff LOG: Revert "[Flang] Use PrintModulePass to print LLVM IR from the frontend (#95142)" This reverts commit 297b6dea8c7652b62933e78ef79e60ce59fc1ec0. Added: Modified: flang/lib/Frontend/FrontendActions.cpp flang/test/Transforms/debug-local-var-2.f90 Removed: diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index f8ca0cfd82e76..b1b6391f1439c 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -53,7 +53,6 @@ #include "llvm/IR/LLVMRemarkStreamer.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" -#include "llvm/IRPrinter/IRPrintingPasses.h" #include "llvm/IRReader/IRReader.h" #include "llvm/Object/OffloadBinary.h" #include "llvm/Passes/PassBuilder.h" @@ -996,8 +995,6 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) { if (action == BackendActionTy::Backend_EmitBC) mpm.addPass(llvm::BitcodeWriterPass(os)); - else if (action == BackendActionTy::Backend_EmitLL) -mpm.addPass(llvm::PrintModulePass(os)); // Run the passes. mpm.run(*llvmModule, mam); @@ -1273,8 +1270,13 @@ void CodeGenAction::executeAction() { // Run LLVM's middle-end (i.e. the optimizer). runOptimizationPipeline(ci.isOutputStreamNull() ? *os : ci.getOutputStream()); - if (action == BackendActionTy::Backend_EmitLL || - action == BackendActionTy::Backend_EmitBC) { + if (action == BackendActionTy::Backend_EmitLL) { +llvmModule->print(ci.isOutputStreamNull() ? *os : ci.getOutputStream(), + /*AssemblyAnnotationWriter=*/nullptr); +return; + } + + if (action == BackendActionTy::Backend_EmitBC) { // This action has effectively been completed in runOptimizationPipeline. return; } diff --git a/flang/test/Transforms/debug-local-var-2.f90 b/flang/test/Transforms/debug-local-var-2.f90 index 3b2873a1edaaf..0fe1b81c27e61 100644 --- a/flang/test/Transforms/debug-local-var-2.f90 +++ b/flang/test/Transforms/debug-local-var-2.f90 @@ -1,73 +1,57 @@ -! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --write-experimental-debuginfo=false -o - | FileCheck %s --check-prefixes=BOTH,INTRINSICS -! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --write-experimental-debuginfo=true -o - | FileCheck %s --check-prefixes=BOTH,RECORDS -! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --write-experimental-debuginfo=false -o - | FileCheck --check-prefix=LINEONLY %s -! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --write-experimental-debuginfo=true -o - | FileCheck --check-prefix=LINEONLY %s +! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s +! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck --check-prefix=LINEONLY %s ! This tests checks the debug information for local variables in llvm IR. -! BOTH-LABEL: define void @_QQmain -! BOTH-DAG: %[[AL11:.*]] = alloca i32 -! BOTH-DAG: %[[AL12:.*]] = alloca i64 -! BOTH-DAG: %[[AL13:.*]] = alloca i8 -! BOTH-DAG: %[[AL14:.*]] = alloca i32 -! BOTH-DAG: %[[AL15:.*]] = alloca float -! BOTH-DAG: %[[AL16:.*]] = alloca double -! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL11]], metadata ![[I4:.*]], metadata !DIExpression()) -! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL12]], metadata ![[I8:.*]], metadata !DIExpression()) -! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL13]], metadata ![[L1:.*]], metadata !DIExpression()) -! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL14]], metadata ![[L4:.*]], metadata !DIExpression()) -! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL15]], metadata ![[R4:.*]], metadata !DIExpression()) -! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL16]], metadata ![[R8:.*]], metadata !DIExpression()) -! RECORDS-DAG: #dbg_declare(ptr %[[AL11]], ![[I4:.*]], !DIExpression(), !{{.*}}) -! RECORDS-DAG: #dbg_declare(ptr %[[AL12]], ![[I8:.*]], !DIExpression(), !{{.*}}) -! RECORDS-DAG: #dbg_declare(ptr %[[AL13]], ![[L1:.*]], !DIExpression(), !{{.*}}) -! RECORDS-DAG: #dbg_declare(ptr %[[AL14]], ![[L4:.*]], !DIExpression(), !{{.*}}) -! RECORDS-DAG: #dbg_declare(ptr %[[AL15]], ![[R4:.*]], !DIExpression(), !{{.*}}) -! RECORDS-DAG: #dbg_declare(ptr %[[AL16]], ![[R8:.*]], !DIExpression(), !{{.*}}) -! BOTH-LABEL: } +! CHECK-LABEL: define void @_QQmain +! CHECK-DAG: %[[AL11:.*]] = alloca i32 +! CHECK-DAG: %[[AL12:.*]] = alloca i64 +! CHECK-DAG: %[[AL13
[llvm-branch-commits] [flang] [Flang][OpenMP] Update flang with changes to the OpenMP dialect (PR #92524)
@@ -1086,8 +1086,9 @@ static void genTargetDataClauses( // ordering. // TODO: Perhaps create a user provideable compiler option that will // re-introduce a hard-error rather than a warning in these cases. - promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(clauseOps, useDeviceTypes, -useDeviceLocs, useDeviceSyms); + promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr( + clauseOps.useDeviceAddrVars, clauseOps.useDevicePtrVars, useDeviceTypes, + useDeviceLocs, useDeviceSyms); skatrak wrote: The reason I made this change is that otherwise we'd have to change the `clauseOps` argument type received by the function to `TargetDataClauseOps`, which I feel is a bit too broad. I know `target` is currently the only construct that uses these clauses, but even if that's always going to be the case, it seems wrong to pass all `target` information to a function that only cares about `use_device_ptr` and `use_device_addr` clauses. Since information for these clauses is now split into independent structures, if we wanted to pass them as we did before without some unrelated `target` information (which would also restrict the function to only possibly ever apply to that construct), we'd have to pass both a `UseDevicePtrClauseOps` and a `UseDeviceAddrClauseOps` object reference. At that point passing structures made little sense and it was too verbose, and that's why I decided that just passing the lists would made a bit more sense. So, that's the thinking behind this change. It boils down to prioritizing the "principle" of what should be an argument of that function over what would reduce the size of the argument list by one element. I'm happy to change it back, though, if the general consensus is to do it the other way around. Just sharing my thought process here. https://github.com/llvm/llvm-project/pull/92524 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF EricWF wrote: @ldionne The implementation is attached to this comment (which was marked as resolved, unresolving for visibility.) https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) EricWF wrote: @ldionne You can find it in the [comment here](https://github.com/llvm/llvm-project/pull/94670/files#r1630389880). https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.
[llvm-branch-commits] [analyzer] Harden safeguards for Z3 query times (PR #95129)
steakhal wrote: I've tested this change on 200+ projects, and the overall effect is: - 0 new issues appear - 276 issues disappear (because we drop the report eqclass) The three most affected checker categories (all of them are spread across usually 20+ projects): - null-deref-like diagnostics (74) - OOBv2 (70) - uninit-read-like (55) This underpins the non-intrusive nature of this change. https://github.com/llvm/llvm-project/pull/95129 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [MLIR][OpenMP] Clause-based OpenMP operation definition (PR #92523)
skatrak wrote: Quick update about reduction clause descriptions @tblah: I updated the previous PR on the stack (#92521) to add a shared description that basically incorporates all of the information that was spread across the various operations using it. I updated the description of `omp.taskloop` in this PR as well to keep the additional related information it previously had while still inheriting the base description for the clause. Also, it's expected that this PR breaks buildbots because of some small reordering of operation arguments and assembly format normalization. The next PR in the stack (#92524) addresses this. https://github.com/llvm/llvm-project/pull/92523 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [Flang][OpenMP] Update flang with changes to the OpenMP dialect (PR #92524)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/92524 >From 33e726ed0d41dd2abb7b99eb413ea9bc014184d1 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Fri, 17 May 2024 11:38:36 +0100 Subject: [PATCH] [Flang][OpenMP] Update flang with changes to the OpenMP dialect This patch applies fixes after the updates to OpenMP clause operands, as well as updating some tests that were impacted by changes to the ordering or assembly format of some clauses in MLIR. --- flang/lib/Lower/OpenMP/ClauseProcessor.cpp| 4 ++-- flang/lib/Lower/OpenMP/ClauseProcessor.h | 4 ++-- flang/lib/Lower/OpenMP/OpenMP.cpp | 19 --- flang/test/Lower/OpenMP/atomic-capture.f90| 2 +- flang/test/Lower/OpenMP/copyin-order.f90 | 2 +- flang/test/Lower/OpenMP/parallel-wsloop.f90 | 2 +- flang/test/Lower/OpenMP/parallel.f90 | 24 +-- flang/test/Lower/OpenMP/simd.f90 | 2 +- flang/test/Lower/OpenMP/target.f90| 24 +-- .../use-device-ptr-to-use-device-addr.f90 | 2 +- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp index 371fe6db01255..7fe39029a1280 100644 --- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp +++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp @@ -990,7 +990,7 @@ bool ClauseProcessor::processEnter( } bool ClauseProcessor::processUseDeviceAddr( -mlir::omp::UseDeviceClauseOps &result, +mlir::omp::UseDeviceAddrClauseOps &result, llvm::SmallVectorImpl &useDeviceTypes, llvm::SmallVectorImpl &useDeviceLocs, llvm::SmallVectorImpl &useDeviceSyms) const { @@ -1002,7 +1002,7 @@ bool ClauseProcessor::processUseDeviceAddr( } bool ClauseProcessor::processUseDevicePtr( -mlir::omp::UseDeviceClauseOps &result, +mlir::omp::UseDevicePtrClauseOps &result, llvm::SmallVectorImpl &useDeviceTypes, llvm::SmallVectorImpl &useDeviceLocs, llvm::SmallVectorImpl &useDeviceSyms) const { diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h b/flang/lib/Lower/OpenMP/ClauseProcessor.h index e8b06a703fc03..1bf3aa1dbd19c 100644 --- a/flang/lib/Lower/OpenMP/ClauseProcessor.h +++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h @@ -127,12 +127,12 @@ class ClauseProcessor { mlir::omp::ReductionClauseOps &result) const; bool processTo(llvm::SmallVectorImpl &result) const; bool processUseDeviceAddr( - mlir::omp::UseDeviceClauseOps &result, + mlir::omp::UseDeviceAddrClauseOps &result, llvm::SmallVectorImpl &useDeviceTypes, llvm::SmallVectorImpl &useDeviceLocs, llvm::SmallVectorImpl &useDeviceSyms) const; bool processUseDevicePtr( - mlir::omp::UseDeviceClauseOps &result, + mlir::omp::UseDevicePtrClauseOps &result, llvm::SmallVectorImpl &useDeviceTypes, llvm::SmallVectorImpl &useDeviceLocs, llvm::SmallVectorImpl &useDeviceSyms) const; diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 9a8211711123e..4ad330c6b8dfa 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -244,7 +244,8 @@ createAndSetPrivatizedLoopVar(lower::AbstractConverter &converter, // clause. Support for such list items in a use_device_ptr clause // is deprecated." static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr( -mlir::omp::UseDeviceClauseOps &clauseOps, +llvm::SmallVectorImpl &useDeviceAddrVars, +llvm::SmallVectorImpl &useDevicePtrVars, llvm::SmallVectorImpl &useDeviceTypes, llvm::SmallVectorImpl &useDeviceLocs, llvm::SmallVectorImpl &useDeviceSymbols) { @@ -256,10 +257,9 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr( // Iterate over our use_device_ptr list and shift all non-cptr arguments into // use_device_addr. - for (auto *it = clauseOps.useDevicePtrVars.begin(); - it != clauseOps.useDevicePtrVars.end();) { + for (auto *it = useDevicePtrVars.begin(); it != useDevicePtrVars.end();) { if (!fir::isa_builtin_cptr_type(fir::unwrapRefType(it->getType( { - clauseOps.useDeviceAddrVars.push_back(*it); + useDeviceAddrVars.push_back(*it); // We have to shuffle the symbols around as well, to maintain // the correct Input -> BlockArg for use_device_ptr/use_device_addr. // NOTE: However, as map's do not seem to be included currently @@ -267,11 +267,11 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr( // future alterations. I believe the reason they are not currently // is that the BlockArg assign/lowering needs to be extended // to a greater set of types. - auto idx = std::distance(clauseOps.useDevicePtrVars.begin(), it); + auto idx = std::distance(useDevicePtrVars.begin(), it); moveElementToBack(idx, useDeviceTypes); moveElementToBack(idx, useDeviceLocs); moveElem
[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/95266 This tests timeouts with sanitizers, and takes more than 3 min even without sanitizers. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)
llvmbot wrote: @llvm/pr-subscribers-libcxx Author: Vitaly Buka (vitalybuka) Changes This tests timeouts with sanitizers, and takes more than 3 min even without sanitizers. --- Full diff: https://github.com/llvm/llvm-project/pull/95266.diff 1 Files Affected: - (modified) libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.local_time.pass.cpp (+2-2) ``diff diff --git a/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.local_time.pass.cpp b/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.local_time.pass.cpp index ec3e490c0ed79..69b5f3250f328 100644 --- a/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.local_time.pass.cpp +++ b/libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/get_info.local_time.pass.cpp @@ -5,14 +5,14 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===--===// +// +// REQUIRES: long_tests // UNSUPPORTED: c++03, c++11, c++14, c++17 // UNSUPPORTED: no-filesystem, no-localization, no-tzdb // XFAIL: libcpp-has-no-experimental-tzdb // XFAIL: availability-tzdb-missing -// Times out under HWASan -// UNSUPPORTED: hwasan // `` https://github.com/llvm/llvm-project/pull/95266 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)
https://github.com/vitalybuka edited https://github.com/llvm/llvm-project/pull/95266 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)
https://github.com/mordante commented: This looks like a duplicate of #95170. https://github.com/llvm/llvm-project/pull/95266 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
https://github.com/ahatanak updated https://github.com/llvm/llvm-project/pull/93906 >From 0e85001f6d53e63beca77a76eaba1875ec84000d Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 24 May 2024 20:23:36 -0700 Subject: [PATCH 1/3] [clang] Implement function pointer signing. Co-Authored-By: John McCall --- clang/include/clang/Basic/CodeGenOptions.h| 4 + .../clang/Basic/DiagnosticDriverKinds.td | 3 + clang/include/clang/Basic/LangOptions.h | 2 + .../include/clang/Basic/PointerAuthOptions.h | 136 ++ .../clang/Frontend/CompilerInvocation.h | 10 ++ clang/lib/CodeGen/CGBuiltin.cpp | 3 +- clang/lib/CodeGen/CGCall.cpp | 3 + clang/lib/CodeGen/CGCall.h| 28 +++- clang/lib/CodeGen/CGExpr.cpp | 17 +-- clang/lib/CodeGen/CGExprConstant.cpp | 19 ++- clang/lib/CodeGen/CGPointerAuth.cpp | 51 +++ clang/lib/CodeGen/CGPointerAuthInfo.h | 96 + clang/lib/CodeGen/CodeGenFunction.cpp | 58 clang/lib/CodeGen/CodeGenFunction.h | 10 ++ clang/lib/CodeGen/CodeGenModule.h | 34 + clang/lib/Frontend/CompilerInvocation.cpp | 36 + clang/lib/Headers/ptrauth.h | 34 + .../CodeGen/ptrauth-function-attributes.c | 13 ++ .../test/CodeGen/ptrauth-function-init-fail.c | 5 + clang/test/CodeGen/ptrauth-function-init.c| 31 .../CodeGen/ptrauth-function-lvalue-cast.c| 23 +++ clang/test/CodeGen/ptrauth-weak_import.c | 10 ++ clang/test/CodeGenCXX/ptrauth.cpp | 24 23 files changed, 633 insertions(+), 17 deletions(-) create mode 100644 clang/lib/CodeGen/CGPointerAuthInfo.h create mode 100644 clang/test/CodeGen/ptrauth-function-attributes.c create mode 100644 clang/test/CodeGen/ptrauth-function-init-fail.c create mode 100644 clang/test/CodeGen/ptrauth-function-init.c create mode 100644 clang/test/CodeGen/ptrauth-function-lvalue-cast.c create mode 100644 clang/test/CodeGen/ptrauth-weak_import.c create mode 100644 clang/test/CodeGenCXX/ptrauth.cpp diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 9469a424045bb..502722a6ec4eb 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -13,6 +13,7 @@ #ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H #define LLVM_CLANG_BASIC_CODEGENOPTIONS_H +#include "clang/Basic/PointerAuthOptions.h" #include "clang/Basic/Sanitizers.h" #include "clang/Basic/XRayInstr.h" #include "llvm/ADT/FloatingPointMode.h" @@ -388,6 +389,9 @@ class CodeGenOptions : public CodeGenOptionsBase { std::vector Reciprocals; + /// Configuration for pointer-signing. + PointerAuthOptions PointerAuth; + /// The preferred width for auto-vectorization transforms. This is intended to /// override default transforms based on the width of the architected vector /// registers. diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 773b234cd68fe..6cbb0c8401c15 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -351,6 +351,9 @@ def err_drv_omp_host_ir_file_not_found : Error< "target regions but cannot be found">; def err_drv_omp_host_target_not_supported : Error< "target '%0' is not a supported OpenMP host target">; +def err_drv_ptrauth_not_supported : Error< + "target '%0' does not support native pointer authentication">; + def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< "'-fopenmp-targets' must be used in conjunction with a '-fopenmp' option " "compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'">; diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 75e88afbd9705..5216822e45b1b 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -346,6 +346,8 @@ class LangOptionsBase { BKey }; + using PointerAuthenticationMode = ::clang::PointerAuthenticationMode; + enum class ThreadModelKind { /// POSIX Threads. POSIX, diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index e5cdcc31ebfb7..32b179e3f9460 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -14,10 +14,146 @@ #ifndef LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H #define LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H +#include "clang/Basic/LLVM.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetOptions.h" +#include +#include +#include +#include + namespace clang { constexpr unsigned PointerAuthKeyNone = -1; +class PointerAuthSchema { +public: + enum class Kind : unsigned { +
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
@@ -346,6 +346,8 @@ class LangOptionsBase { BKey }; + using PointerAuthenticationMode = ::clang::PointerAuthenticationMode; ahatanak wrote: I deleted it as it's not needed for this PR. https://github.com/llvm/llvm-project/pull/93906 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
@@ -75,3 +93,36 @@ CodeGen::getConstantSignedPointer(CodeGenModule &CGM, return CGM.getConstantSignedPointer(pointer, key, storageAddress, otherDiscriminator); } + +/// If applicable, sign a given constant function pointer with the ABI rules for +/// functionType. +llvm::Constant *CodeGenModule::getFunctionPointer(llvm::Constant *pointer, + QualType functionType, + GlobalDecl GD) { + assert(functionType->isFunctionType() || + functionType->isFunctionReferenceType() || + functionType->isFunctionPointerType()); + + if (auto pointerAuth = getFunctionPointerAuthInfo(functionType)) { +return getConstantSignedPointer( + pointer, pointerAuth.getKey(), nullptr, + cast_or_null(pointerAuth.getDiscriminator())); + } + + return pointer; +} + +llvm::Constant *CodeGenModule::getFunctionPointer(GlobalDecl GD, + llvm::Type *Ty) { + const FunctionDecl *FD = cast(GD.getDecl()); + + // Annoyingly, K&R functions have prototypes in the clang AST, but ahatanak wrote: I removed this piece of code as we can't test K&R functions until we have function pointer type discrimination. https://github.com/llvm/llvm-project/pull/93906 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
@@ -0,0 +1,96 @@ +//===- CGPointerAuthInfo.h - ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// Pointer auth info class. +// +//===--===// + +#ifndef LLVM_CLANG_LIB_CODEGEN_CGPOINTERAUTHINFO_H +#define LLVM_CLANG_LIB_CODEGEN_CGPOINTERAUTHINFO_H + +#include "clang/AST/Type.h" +#include "llvm/IR/Type.h" +#include "llvm/IR/Value.h" + +namespace clang { +namespace CodeGen { + +class CGPointerAuthInfo { +private: + PointerAuthenticationMode AuthenticationMode : 2; + bool IsIsaPointer : 1; + bool AuthenticatesNullValues : 1; + unsigned Key : 28; ahatanak wrote: Currently we only need 2 bits, but we'll need more when we add support for soft keys. I changed the size to 4 to match the size in `PointerAuthSchema`. https://github.com/llvm/llvm-project/pull/93906 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
@@ -104,10 +109,13 @@ class CGCallee { /// Construct a callee. Call this constructor directly when this /// isn't a direct call. - CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr) + CGCallee( + const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr, + const CGPointerAuthInfo &pointerAuthInfo = /*FIXME*/ CGPointerAuthInfo()) ahatanak wrote: The `CGPointerAuthInfo` parameter is going to be mandatory later. https://github.com/llvm/llvm-project/pull/93906 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
@@ -1458,6 +1458,39 @@ static void setPGOUseInstrumentor(CodeGenOptions &Opts, Opts.setProfileUse(CodeGenOptions::ProfileClangInstr); } +bool CompilerInvocation::setDefaultPointerAuthOptions( +PointerAuthOptions &Opts, const LangOptions &LangOpts, +const llvm::Triple &Triple) { + if (Triple.getArch() == llvm::Triple::aarch64) { +if (LangOpts.PointerAuthCalls) { + using Key = PointerAuthSchema::ARM8_3Key; + using Discrimination = PointerAuthSchema::Discrimination; + // If you change anything here, be sure to update . + Opts.FunctionPointers = + PointerAuthSchema(Key::ASIA, false, Discrimination::None); +} +return true; + } + + return false; +} + +static bool parsePointerAuthOptions(PointerAuthOptions &Opts, +ArgList &Args, ahatanak wrote: I removed `Args` as it wasn't used. https://github.com/llvm/llvm-project/pull/93906 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)
https://github.com/vitalybuka closed https://github.com/llvm/llvm-project/pull/95266 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Mark test as long_tests (PR #95266)
vitalybuka wrote: Thanks! Abandoning. https://github.com/llvm/llvm-project/pull/95266 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
https://github.com/ahatanak updated https://github.com/llvm/llvm-project/pull/93906 >From 0e85001f6d53e63beca77a76eaba1875ec84000d Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 24 May 2024 20:23:36 -0700 Subject: [PATCH 1/4] [clang] Implement function pointer signing. Co-Authored-By: John McCall --- clang/include/clang/Basic/CodeGenOptions.h| 4 + .../clang/Basic/DiagnosticDriverKinds.td | 3 + clang/include/clang/Basic/LangOptions.h | 2 + .../include/clang/Basic/PointerAuthOptions.h | 136 ++ .../clang/Frontend/CompilerInvocation.h | 10 ++ clang/lib/CodeGen/CGBuiltin.cpp | 3 +- clang/lib/CodeGen/CGCall.cpp | 3 + clang/lib/CodeGen/CGCall.h| 28 +++- clang/lib/CodeGen/CGExpr.cpp | 17 +-- clang/lib/CodeGen/CGExprConstant.cpp | 19 ++- clang/lib/CodeGen/CGPointerAuth.cpp | 51 +++ clang/lib/CodeGen/CGPointerAuthInfo.h | 96 + clang/lib/CodeGen/CodeGenFunction.cpp | 58 clang/lib/CodeGen/CodeGenFunction.h | 10 ++ clang/lib/CodeGen/CodeGenModule.h | 34 + clang/lib/Frontend/CompilerInvocation.cpp | 36 + clang/lib/Headers/ptrauth.h | 34 + .../CodeGen/ptrauth-function-attributes.c | 13 ++ .../test/CodeGen/ptrauth-function-init-fail.c | 5 + clang/test/CodeGen/ptrauth-function-init.c| 31 .../CodeGen/ptrauth-function-lvalue-cast.c| 23 +++ clang/test/CodeGen/ptrauth-weak_import.c | 10 ++ clang/test/CodeGenCXX/ptrauth.cpp | 24 23 files changed, 633 insertions(+), 17 deletions(-) create mode 100644 clang/lib/CodeGen/CGPointerAuthInfo.h create mode 100644 clang/test/CodeGen/ptrauth-function-attributes.c create mode 100644 clang/test/CodeGen/ptrauth-function-init-fail.c create mode 100644 clang/test/CodeGen/ptrauth-function-init.c create mode 100644 clang/test/CodeGen/ptrauth-function-lvalue-cast.c create mode 100644 clang/test/CodeGen/ptrauth-weak_import.c create mode 100644 clang/test/CodeGenCXX/ptrauth.cpp diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 9469a424045bb..502722a6ec4eb 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -13,6 +13,7 @@ #ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H #define LLVM_CLANG_BASIC_CODEGENOPTIONS_H +#include "clang/Basic/PointerAuthOptions.h" #include "clang/Basic/Sanitizers.h" #include "clang/Basic/XRayInstr.h" #include "llvm/ADT/FloatingPointMode.h" @@ -388,6 +389,9 @@ class CodeGenOptions : public CodeGenOptionsBase { std::vector Reciprocals; + /// Configuration for pointer-signing. + PointerAuthOptions PointerAuth; + /// The preferred width for auto-vectorization transforms. This is intended to /// override default transforms based on the width of the architected vector /// registers. diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 773b234cd68fe..6cbb0c8401c15 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -351,6 +351,9 @@ def err_drv_omp_host_ir_file_not_found : Error< "target regions but cannot be found">; def err_drv_omp_host_target_not_supported : Error< "target '%0' is not a supported OpenMP host target">; +def err_drv_ptrauth_not_supported : Error< + "target '%0' does not support native pointer authentication">; + def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< "'-fopenmp-targets' must be used in conjunction with a '-fopenmp' option " "compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'">; diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 75e88afbd9705..5216822e45b1b 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -346,6 +346,8 @@ class LangOptionsBase { BKey }; + using PointerAuthenticationMode = ::clang::PointerAuthenticationMode; + enum class ThreadModelKind { /// POSIX Threads. POSIX, diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index e5cdcc31ebfb7..32b179e3f9460 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -14,10 +14,146 @@ #ifndef LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H #define LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H +#include "clang/Basic/LLVM.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetOptions.h" +#include +#include +#include +#include + namespace clang { constexpr unsigned PointerAuthKeyNone = -1; +class PointerAuthSchema { +public: + enum class Kind : unsigned { +
[llvm-branch-commits] Use rc version suffix (PR #95295)
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/95295 None ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [workflows] Fix version-check.yml to work with the new minor release bump (PR #95296)
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/95296 (cherry picked from commit d5e69147b9d261bd53b4dd027f17131677be8613) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] Use rc version suffix (PR #95295)
https://github.com/vitalybuka closed https://github.com/llvm/llvm-project/pull/95295 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [workflows] Fix version-check.yml to work with the new minor release bump (PR #95296)
https://github.com/vitalybuka closed https://github.com/llvm/llvm-project/pull/95296 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] fe30a73 - Revert "[CLANG][DWARF] Handle DIE offset collision in DW_IDX_parent (#95039)"
Author: Florian Mayer Date: 2024-06-12T13:25:52-07:00 New Revision: fe30a734628b3028c086ce016b6f80440172f34f URL: https://github.com/llvm/llvm-project/commit/fe30a734628b3028c086ce016b6f80440172f34f DIFF: https://github.com/llvm/llvm-project/commit/fe30a734628b3028c086ce016b6f80440172f34f.diff LOG: Revert "[CLANG][DWARF] Handle DIE offset collision in DW_IDX_parent (#95039)" This reverts commit f59d9d538c7b580a93bee4afba0f098f7ddf09d9. Added: Modified: llvm/include/llvm/CodeGen/AccelTable.h llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp Removed: llvm/test/DebugInfo/X86/debug-names-types-die-offset-collision.ll diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h index 622fcf019aad6..cff8fcbaf2cd7 100644 --- a/llvm/include/llvm/CodeGen/AccelTable.h +++ b/llvm/include/llvm/CodeGen/AccelTable.h @@ -257,38 +257,18 @@ class AppleAccelTableData : public AccelTableData { /// Helper class to identify an entry in DWARF5AccelTable based on their DIE /// offset and UnitID. -struct OffsetAndUnitID { - uint64_t Offset = 0; - uint32_t UnitID = 0; - bool IsTU = false; - OffsetAndUnitID() = default; - OffsetAndUnitID(uint64_t Offset, uint32_t UnitID, bool IsTU) - : Offset(Offset), UnitID(UnitID), IsTU(IsTU) {} - uint64_t offset() const { return Offset; }; - uint32_t unitID() const { return UnitID; }; - bool isTU() const { return IsTU; } -}; +struct OffsetAndUnitID : std::pair { + using Base = std::pair; + OffsetAndUnitID(Base B) : Base(B) {} -template <> struct DenseMapInfo { - static inline OffsetAndUnitID getEmptyKey() { -OffsetAndUnitID Entry; -Entry.Offset = uint64_t(-1); -return Entry; - } - static inline OffsetAndUnitID getTombstoneKey() { -OffsetAndUnitID Entry; -Entry.Offset = uint64_t(-2); -return Entry; - } - static unsigned getHashValue(const OffsetAndUnitID &Val) { -return (unsigned)llvm::hash_combine(Val.offset(), Val.unitID(), Val.IsTU); - } - static bool isEqual(const OffsetAndUnitID &LHS, const OffsetAndUnitID &RHS) { -return LHS.offset() == RHS.offset() && LHS.unitID() == RHS.unitID() && - LHS.IsTU == RHS.isTU(); - } + OffsetAndUnitID(uint64_t Offset, uint32_t UnitID) : Base(Offset, UnitID) {} + uint64_t offset() const { return first; }; + uint32_t unitID() const { return second; }; }; +template <> +struct DenseMapInfo : DenseMapInfo {}; + /// The Data class implementation for DWARF v5 accelerator table. Unlike the /// Apple Data classes, this class is just a DIE wrapper, and does not know to /// serialize itself. The complete serialization logic is in the @@ -297,11 +277,12 @@ class DWARF5AccelTableData : public AccelTableData { public: static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); } - DWARF5AccelTableData(const DIE &Die, const uint32_t UnitID, const bool IsTU); + DWARF5AccelTableData(const DIE &Die, const uint32_t UnitID, + const bool IsTU = false); DWARF5AccelTableData(const uint64_t DieOffset, const std::optional DefiningParentOffset, const unsigned DieTag, const unsigned UnitID, - const bool IsTU) + const bool IsTU = false) : OffsetVal(DieOffset), ParentOffset(DefiningParentOffset), DieTag(DieTag), AbbrevNumber(0), IsTU(IsTU), UnitID(UnitID) {} @@ -315,7 +296,7 @@ class DWARF5AccelTableData : public AccelTableData { } OffsetAndUnitID getDieOffsetAndUnitID() const { -return {getDieOffset(), getUnitID(), isTU()}; +return {getDieOffset(), UnitID}; } unsigned getDieTag() const { return DieTag; } @@ -341,7 +322,7 @@ class DWARF5AccelTableData : public AccelTableData { assert(isNormalized() && "Accessing DIE Offset before normalizing."); if (!ParentOffset) return std::nullopt; -return OffsetAndUnitID(*ParentOffset, getUnitID(), isTU()); +return OffsetAndUnitID(*ParentOffset, getUnitID()); } /// Sets AbbrevIndex for an Entry. @@ -435,7 +416,7 @@ class DWARF5AccelTable : public AccelTable { for (auto *Data : Entry.second.getValues()) { addName(Entry.second.Name, Data->getDieOffset(), Data->getParentDieOffset(), Data->getDieTag(), -Data->getUnitID(), Data->isTU()); +Data->getUnitID(), true); } } } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 7de9432325d8a..b9c02aed848cc 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -3592,8 +3592,7 @@ void DwarfDebug::addAccelNameImpl( "Kind is TU but CU is being processed."); // The type unit can be di
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/EricWF edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
@@ -59,6 +59,8 @@ struct FlowFunction { /// The index of the entry block. uint64_t Entry{0}; uint64_t Sink{UINT64_MAX}; + // Matched execution count for the function. + uint64_t MatchedExecCount{0}; WenleiHe wrote: nit: I'd be careful about adding this to `FlowFunction` -- strictly speaking this doesn't belong to flow function, which just describe the CFG and if we add function level "attributes" to flow functions, we'd have a lot more here. https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
@@ -592,10 +599,15 @@ void preprocessUnreachableBlocks(FlowFunction &Func) { /// Decide if stale profile matching can be applied for a given function. /// Currently we skip inference for (very) large instances and for instances /// having "unexpected" control flow (e.g., having no sink basic blocks). -bool canApplyInference(const FlowFunction &Func) { +bool canApplyInference(const FlowFunction &Func, WenleiHe wrote: Header comment needs update. https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
@@ -614,6 +614,17 @@ - `--lite-threshold-pct=` + Threshold (in percent) of matched profile at which stale profile inference is + applied to functions. Argument corresponds to the sum of matched execution + counts of function blocks divided by the sum of execution counts of function + blocks. E.g if the sum of a function blocks' execution counts is 100, the sum + of the function blocks' matched execution counts is 10, and the argument is 15 + (15%), profile inference will not be applied to that function. A higher + threshold will correlate with fewer functions to process in cases of stale + profile. Default set to %5. WenleiHe wrote: nit: this is too verbose of a description. as you can see it's longer than most of other descriptions. :) https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
@@ -592,10 +599,15 @@ void preprocessUnreachableBlocks(FlowFunction &Func) { /// Decide if stale profile matching can be applied for a given function. /// Currently we skip inference for (very) large instances and for instances /// having "unexpected" control flow (e.g., having no sink basic blocks). -bool canApplyInference(const FlowFunction &Func) { +bool canApplyInference(const FlowFunction &Func, + const yaml::bolt::BinaryFunctionProfile &YamlBF) { if (Func.Blocks.size() > opts::StaleMatchingMaxFuncSize) return false; + if ((double)Func.MatchedExecCount / YamlBF.ExecCount >= + opts::MatchedProfileThreshold / 100.0) +return false; WenleiHe wrote: Trying to understand the rationale behind using dynamic counts to determine whether profile inference is safe. The way I see it is, we have two graph that we try to match, if we have many nodes in the graph that we have exact match, chances are higher that we can infer the correct match for the rest of the nodes. With that, we care about more how many nodes we can match statically. Say if we have 5 blocks with count distribution of 1M, 1K, 1K, 1k, 1K, if we have exact match for the 4 1K node (80% exact match), we should feel reasonably confident about inferring the remaining 1 node, even though if we look at counts, we have exact match for only <1%. WDYT? https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
WenleiHe wrote: cc @wlei-llvm https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
@@ -592,10 +599,15 @@ void preprocessUnreachableBlocks(FlowFunction &Func) { /// Decide if stale profile matching can be applied for a given function. /// Currently we skip inference for (very) large instances and for instances /// having "unexpected" control flow (e.g., having no sink basic blocks). -bool canApplyInference(const FlowFunction &Func) { +bool canApplyInference(const FlowFunction &Func, + const yaml::bolt::BinaryFunctionProfile &YamlBF) { if (Func.Blocks.size() > opts::StaleMatchingMaxFuncSize) return false; + if ((double)Func.MatchedExecCount / YamlBF.ExecCount >= + opts::MatchedProfileThreshold / 100.0) +return false; aaupov wrote: It's a tricky question how to define the cutoff in terms of sufficient matching. I first thought of defining a block count based cutoff (if we matched >5% of blocks, proceed with matching), but then what if these are cold blocks covering <1% of exec count? In this case we'd end up guessing/propagating most samples. For block-based matching, the threshold should be higher than 5%, perhaps closer to a half? For exec count based matching, I'd feel comfortable with 5% as threshold. https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)
vitalybuka wrote: ping https://github.com/llvm/llvm-project/pull/94882 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)
@@ -3356,6 +3356,37 @@ struct MemorySanitizerVisitor : public InstVisitor { setOriginForNaryOp(I); } + Value *convertBlendvToSelectMask(IRBuilder<> &IRB, Value *C) { +C = CreateAppToShadowCast(IRB, C); +FixedVectorType *FVT = cast(C->getType()); +unsigned ElSize = FVT->getElementType()->getPrimitiveSizeInBits(); +C = IRB.CreateAShr(C, ElSize - 1); +FVT = FixedVectorType::get(IRB.getInt1Ty(), FVT->getNumElements()); +return IRB.CreateTrunc(C, FVT); + } + + // `blendv(f, t, c)` is effectively `select(c[top_bit], t, f)`. + void handleBlendvIntrinsic(IntrinsicInst &I) { +Value *C = I.getOperand(2); +Value *T = I.getOperand(1); +Value *F = I.getOperand(0); + +Value *Sc = getShadow(&I, 2); +Value *Oc = MS.TrackOrigins ? getOrigin(C) : nullptr; + +{ + IRBuilder<> IRB(&I); fmayer wrote: Why does it matter that this doesn't outlive `handleSelectLikeInst`? Because that also creates an IRBuilder? How does that work? That creates it from `&I` as well, which means these instructions get inserted before the ones here, right? https://github.com/llvm/llvm-project/pull/94882 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)
@@ -3356,6 +3356,37 @@ struct MemorySanitizerVisitor : public InstVisitor { setOriginForNaryOp(I); } + Value *convertBlendvToSelectMask(IRBuilder<> &IRB, Value *C) { +C = CreateAppToShadowCast(IRB, C); +FixedVectorType *FVT = cast(C->getType()); +unsigned ElSize = FVT->getElementType()->getPrimitiveSizeInBits(); +C = IRB.CreateAShr(C, ElSize - 1); +FVT = FixedVectorType::get(IRB.getInt1Ty(), FVT->getNumElements()); +return IRB.CreateTrunc(C, FVT); + } + + // `blendv(f, t, c)` is effectively `select(c[top_bit], t, f)`. + void handleBlendvIntrinsic(IntrinsicInst &I) { +Value *C = I.getOperand(2); +Value *T = I.getOperand(1); +Value *F = I.getOperand(0); + +Value *Sc = getShadow(&I, 2); +Value *Oc = MS.TrackOrigins ? getOrigin(C) : nullptr; + +{ + IRBuilder<> IRB(&I); vitalybuka wrote: I think it's unimportant. Builder has nothing interesting in destructor. `{}` is rather just to show that we don't need to can about builders conflict. https://github.com/llvm/llvm-project/pull/94882 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)
https://github.com/vitalybuka edited https://github.com/llvm/llvm-project/pull/94882 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)
https://github.com/fmayer approved this pull request. https://github.com/llvm/llvm-project/pull/94882 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [msan] Handle blendv intrinsics (PR #94882)
https://github.com/vitalybuka closed https://github.com/llvm/llvm-project/pull/94882 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] fc671bb - Revert "Bump the DWARF version number to 5 on Darwin. (#95164)"
Author: Florian Mayer Date: 2024-06-12T15:50:03-07:00 New Revision: fc671bbb1ceb94f8aac63bc0e4963e5894bc660e URL: https://github.com/llvm/llvm-project/commit/fc671bbb1ceb94f8aac63bc0e4963e5894bc660e DIFF: https://github.com/llvm/llvm-project/commit/fc671bbb1ceb94f8aac63bc0e4963e5894bc660e.diff LOG: Revert "Bump the DWARF version number to 5 on Darwin. (#95164)" This reverts commit 8f6acd973a38da6dce45faa676cbb51da37f72e5. Added: Modified: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/debug-options.c Removed: diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index ca75a622b061e..ed5737915aa96 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1257,17 +1257,7 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const { if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) || (isTargetIOSBased() && isIPhoneOSVersionLT(9))) return 2; - // Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS 9 - iOS 17. - if ((isTargetMacOSBased() && isMacosxVersionLT(15)) || - (isTargetIOSBased() && isIPhoneOSVersionLT(18)) || - (isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) || - (isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) || - (isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) || - (isTargetMacOSBased() && - TargetVersion.empty()) || // apple-darwin, no version. - (TargetPlatform == llvm::Triple::BridgeOS)) -return 4; - return 5; + return 4; } void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 0a665f7017d63..07f6ca9e3902f 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -68,32 +68,7 @@ // RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// -// RUN: %clang -### -c -fsave-optimization-record %s\ +// RUN: %clang -### -c -fsave-optimization-record %s \ // RUN:-target x86_64-apple-darwin 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -g -fsave-optimization-record %s \ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Drop high discrepancy profiles in matching (PR #95156)
@@ -592,10 +599,15 @@ void preprocessUnreachableBlocks(FlowFunction &Func) { /// Decide if stale profile matching can be applied for a given function. /// Currently we skip inference for (very) large instances and for instances /// having "unexpected" control flow (e.g., having no sink basic blocks). -bool canApplyInference(const FlowFunction &Func) { +bool canApplyInference(const FlowFunction &Func, + const yaml::bolt::BinaryFunctionProfile &YamlBF) { if (Func.Blocks.size() > opts::StaleMatchingMaxFuncSize) return false; + if ((double)Func.MatchedExecCount / YamlBF.ExecCount >= + opts::MatchedProfileThreshold / 100.0) +return false; WenleiHe wrote: > For block-based matching, the threshold should be higher than 5%, perhaps > closer to a half? Yes. Threshold of course need to be tuned based on the heuristic chosen. I just feel that block count based threshold could be a better proxy of how confident we are about the graph match and whether stale profile matching should proceed.. But I don't have very strong opinion. https://github.com/llvm/llvm-project/pull/95156 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
asl wrote: @ahatanak Looks like there are some conflicts that should be resolved https://github.com/llvm/llvm-project/pull/93906 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [Support] Integrate SipHash.cpp into libSupport. (PR #94394)
asl wrote: @kbeyls There are (some) tests in the follow-up commit https://github.com/llvm/llvm-project/pull/93902/files#diff-8df159460fc7a128734566054df883f3192b1b261dc8eac667933b4042e9af5f https://github.com/llvm/llvm-project/pull/94394 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] 8944c8d - Revert "[MLIR][Arith] add fastMathAttr on arith::extf and arith::truncf (#93443)"
Author: Ivy Zhang Date: 2024-06-13T11:12:39+08:00 New Revision: 8944c8df45f8e4da860bf04118106d9a950cbf75 URL: https://github.com/llvm/llvm-project/commit/8944c8df45f8e4da860bf04118106d9a950cbf75 DIFF: https://github.com/llvm/llvm-project/commit/8944c8df45f8e4da860bf04118106d9a950cbf75.diff LOG: Revert "[MLIR][Arith] add fastMathAttr on arith::extf and arith::truncf (#93443)" This reverts commit 6784bf764207d267b781b4f515a2fafdcb345509. Added: Modified: mlir/include/mlir/Dialect/Arith/IR/ArithOps.td mlir/lib/Dialect/Arith/IR/ArithOps.cpp mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp mlir/lib/Dialect/Math/Transforms/LegalizeToF32.cpp mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir mlir/test/Dialect/Arith/canonicalize.mlir mlir/test/Dialect/Arith/emulate-unsupported-floats.mlir Removed: diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td index c4471f9bc5af2..06fbdb7f2c4cb 100644 --- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td +++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td @@ -1199,7 +1199,7 @@ def Arith_ExtSIOp : Arith_IToICastOp<"extsi"> { // ExtFOp //===--===// -def Arith_ExtFOp : Arith_FToFCastOp<"extf", [DeclareOpInterfaceMethods]> { +def Arith_ExtFOp : Arith_FToFCastOp<"extf"> { let summary = "cast from floating-point to wider floating-point"; let description = [{ Cast a floating-point value to a larger floating-point-typed value. @@ -1208,13 +1208,6 @@ def Arith_ExtFOp : Arith_FToFCastOp<"extf", [DeclareOpInterfaceMethods:$fastmath); - let results = (outs FloatLike:$out); - - let assemblyFormat = [{ $in (`fastmath` `` $fastmath^)? - attr-dict `:` type($in) `to` type($out) }]; } //===--===// @@ -1253,11 +1246,8 @@ def Arith_TruncFOp : Arith_Op<"truncf", [Pure, SameOperandsAndResultShape, SameInputOutputTensorDims, DeclareOpInterfaceMethods, - DeclareOpInterfaceMethods, DeclareOpInterfaceMethods]>, Arguments<(ins FloatLike:$in, - DefaultValuedAttr< - Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath, OptionalAttr:$roundingmode)>, Results<(outs FloatLike:$out)> { let summary = "cast from floating-point to narrower floating-point"; @@ -1277,9 +1267,7 @@ def Arith_TruncFOp : let hasFolder = 1; let hasVerifier = 1; - let assemblyFormat = [{ $in ($roundingmode^)? - (`fastmath` `` $fastmath^)? - attr-dict `:` type($in) `to` type($out) }]; + let assemblyFormat = "$in ($roundingmode^)? attr-dict `:` type($in) `to` type($out)"; } //===--===// diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp index 291f6e5424ba5..2f6647a2a27b1 100644 --- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp +++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp @@ -1390,20 +1390,6 @@ LogicalResult arith::ExtSIOp::verify() { /// Fold extension of float constants when there is no information loss due the /// diff erence in fp semantics. OpFoldResult arith::ExtFOp::fold(FoldAdaptor adaptor) { - if (auto truncFOp = getOperand().getDefiningOp()) { -if (truncFOp.getOperand().getType() == getType()) { - arith::FastMathFlags truncFMF = truncFOp.getFastmath(); - bool isTruncContract = - bitEnumContainsAll(truncFMF, arith::FastMathFlags::contract); - arith::FastMathFlags extFMF = getFastmath(); - bool isExtContract = - bitEnumContainsAll(extFMF, arith::FastMathFlags::contract); - if (isTruncContract && isExtContract) { -return truncFOp.getOperand(); - } -} - } - auto resElemType = cast(getElementTypeOrSelf(getType())); const llvm::fltSemantics &targetSemantics = resElemType.getFloatSemantics(); return constFoldCastOp( diff --git a/mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp b/mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp index 8e1cb474feee7..4a50da3513f99 100644 --- a/mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp +++ b/mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp @@ -94,11 +94,8 @@ void EmulateFloatPattern::rewrite(Operation *op, ArrayRef operands, SmallVector newResults(expandedOp->getResults()); for (auto [res, oldType, newType] : llvm::zip_equal( MutableArrayRef{newResults}, op->getResultTypes(), resultTypes)) { -if (oldType != newType) { - auto truncFOp = rewriter.create(loc, oldType, res); - truncFOp.setFastmath(arith::FastMathFlags::contract); - res = truncFOp.getResul
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
https://github.com/ahatanak updated https://github.com/llvm/llvm-project/pull/93906 >From 0e85001f6d53e63beca77a76eaba1875ec84000d Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 24 May 2024 20:23:36 -0700 Subject: [PATCH 1/4] [clang] Implement function pointer signing. Co-Authored-By: John McCall --- clang/include/clang/Basic/CodeGenOptions.h| 4 + .../clang/Basic/DiagnosticDriverKinds.td | 3 + clang/include/clang/Basic/LangOptions.h | 2 + .../include/clang/Basic/PointerAuthOptions.h | 136 ++ .../clang/Frontend/CompilerInvocation.h | 10 ++ clang/lib/CodeGen/CGBuiltin.cpp | 3 +- clang/lib/CodeGen/CGCall.cpp | 3 + clang/lib/CodeGen/CGCall.h| 28 +++- clang/lib/CodeGen/CGExpr.cpp | 17 +-- clang/lib/CodeGen/CGExprConstant.cpp | 19 ++- clang/lib/CodeGen/CGPointerAuth.cpp | 51 +++ clang/lib/CodeGen/CGPointerAuthInfo.h | 96 + clang/lib/CodeGen/CodeGenFunction.cpp | 58 clang/lib/CodeGen/CodeGenFunction.h | 10 ++ clang/lib/CodeGen/CodeGenModule.h | 34 + clang/lib/Frontend/CompilerInvocation.cpp | 36 + clang/lib/Headers/ptrauth.h | 34 + .../CodeGen/ptrauth-function-attributes.c | 13 ++ .../test/CodeGen/ptrauth-function-init-fail.c | 5 + clang/test/CodeGen/ptrauth-function-init.c| 31 .../CodeGen/ptrauth-function-lvalue-cast.c| 23 +++ clang/test/CodeGen/ptrauth-weak_import.c | 10 ++ clang/test/CodeGenCXX/ptrauth.cpp | 24 23 files changed, 633 insertions(+), 17 deletions(-) create mode 100644 clang/lib/CodeGen/CGPointerAuthInfo.h create mode 100644 clang/test/CodeGen/ptrauth-function-attributes.c create mode 100644 clang/test/CodeGen/ptrauth-function-init-fail.c create mode 100644 clang/test/CodeGen/ptrauth-function-init.c create mode 100644 clang/test/CodeGen/ptrauth-function-lvalue-cast.c create mode 100644 clang/test/CodeGen/ptrauth-weak_import.c create mode 100644 clang/test/CodeGenCXX/ptrauth.cpp diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 9469a424045bb..502722a6ec4eb 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -13,6 +13,7 @@ #ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H #define LLVM_CLANG_BASIC_CODEGENOPTIONS_H +#include "clang/Basic/PointerAuthOptions.h" #include "clang/Basic/Sanitizers.h" #include "clang/Basic/XRayInstr.h" #include "llvm/ADT/FloatingPointMode.h" @@ -388,6 +389,9 @@ class CodeGenOptions : public CodeGenOptionsBase { std::vector Reciprocals; + /// Configuration for pointer-signing. + PointerAuthOptions PointerAuth; + /// The preferred width for auto-vectorization transforms. This is intended to /// override default transforms based on the width of the architected vector /// registers. diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 773b234cd68fe..6cbb0c8401c15 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -351,6 +351,9 @@ def err_drv_omp_host_ir_file_not_found : Error< "target regions but cannot be found">; def err_drv_omp_host_target_not_supported : Error< "target '%0' is not a supported OpenMP host target">; +def err_drv_ptrauth_not_supported : Error< + "target '%0' does not support native pointer authentication">; + def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< "'-fopenmp-targets' must be used in conjunction with a '-fopenmp' option " "compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'">; diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 75e88afbd9705..5216822e45b1b 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -346,6 +346,8 @@ class LangOptionsBase { BKey }; + using PointerAuthenticationMode = ::clang::PointerAuthenticationMode; + enum class ThreadModelKind { /// POSIX Threads. POSIX, diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index e5cdcc31ebfb7..32b179e3f9460 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -14,10 +14,146 @@ #ifndef LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H #define LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H +#include "clang/Basic/LLVM.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetOptions.h" +#include +#include +#include +#include + namespace clang { constexpr unsigned PointerAuthKeyNone = -1; +class PointerAuthSchema { +public: + enum class Kind : unsigned { +
[llvm-branch-commits] [clang] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
https://github.com/ahatanak updated https://github.com/llvm/llvm-project/pull/93906 >From 0e85001f6d53e63beca77a76eaba1875ec84000d Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 24 May 2024 20:23:36 -0700 Subject: [PATCH 1/4] [clang] Implement function pointer signing. Co-Authored-By: John McCall --- clang/include/clang/Basic/CodeGenOptions.h| 4 + .../clang/Basic/DiagnosticDriverKinds.td | 3 + clang/include/clang/Basic/LangOptions.h | 2 + .../include/clang/Basic/PointerAuthOptions.h | 136 ++ .../clang/Frontend/CompilerInvocation.h | 10 ++ clang/lib/CodeGen/CGBuiltin.cpp | 3 +- clang/lib/CodeGen/CGCall.cpp | 3 + clang/lib/CodeGen/CGCall.h| 28 +++- clang/lib/CodeGen/CGExpr.cpp | 17 +-- clang/lib/CodeGen/CGExprConstant.cpp | 19 ++- clang/lib/CodeGen/CGPointerAuth.cpp | 51 +++ clang/lib/CodeGen/CGPointerAuthInfo.h | 96 + clang/lib/CodeGen/CodeGenFunction.cpp | 58 clang/lib/CodeGen/CodeGenFunction.h | 10 ++ clang/lib/CodeGen/CodeGenModule.h | 34 + clang/lib/Frontend/CompilerInvocation.cpp | 36 + clang/lib/Headers/ptrauth.h | 34 + .../CodeGen/ptrauth-function-attributes.c | 13 ++ .../test/CodeGen/ptrauth-function-init-fail.c | 5 + clang/test/CodeGen/ptrauth-function-init.c| 31 .../CodeGen/ptrauth-function-lvalue-cast.c| 23 +++ clang/test/CodeGen/ptrauth-weak_import.c | 10 ++ clang/test/CodeGenCXX/ptrauth.cpp | 24 23 files changed, 633 insertions(+), 17 deletions(-) create mode 100644 clang/lib/CodeGen/CGPointerAuthInfo.h create mode 100644 clang/test/CodeGen/ptrauth-function-attributes.c create mode 100644 clang/test/CodeGen/ptrauth-function-init-fail.c create mode 100644 clang/test/CodeGen/ptrauth-function-init.c create mode 100644 clang/test/CodeGen/ptrauth-function-lvalue-cast.c create mode 100644 clang/test/CodeGen/ptrauth-weak_import.c create mode 100644 clang/test/CodeGenCXX/ptrauth.cpp diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 9469a424045bb..502722a6ec4eb 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -13,6 +13,7 @@ #ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H #define LLVM_CLANG_BASIC_CODEGENOPTIONS_H +#include "clang/Basic/PointerAuthOptions.h" #include "clang/Basic/Sanitizers.h" #include "clang/Basic/XRayInstr.h" #include "llvm/ADT/FloatingPointMode.h" @@ -388,6 +389,9 @@ class CodeGenOptions : public CodeGenOptionsBase { std::vector Reciprocals; + /// Configuration for pointer-signing. + PointerAuthOptions PointerAuth; + /// The preferred width for auto-vectorization transforms. This is intended to /// override default transforms based on the width of the architected vector /// registers. diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 773b234cd68fe..6cbb0c8401c15 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -351,6 +351,9 @@ def err_drv_omp_host_ir_file_not_found : Error< "target regions but cannot be found">; def err_drv_omp_host_target_not_supported : Error< "target '%0' is not a supported OpenMP host target">; +def err_drv_ptrauth_not_supported : Error< + "target '%0' does not support native pointer authentication">; + def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< "'-fopenmp-targets' must be used in conjunction with a '-fopenmp' option " "compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'">; diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 75e88afbd9705..5216822e45b1b 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -346,6 +346,8 @@ class LangOptionsBase { BKey }; + using PointerAuthenticationMode = ::clang::PointerAuthenticationMode; + enum class ThreadModelKind { /// POSIX Threads. POSIX, diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index e5cdcc31ebfb7..32b179e3f9460 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -14,10 +14,146 @@ #ifndef LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H #define LLVM_CLANG_BASIC_POINTERAUTHOPTIONS_H +#include "clang/Basic/LLVM.h" +#include "clang/Basic/LangOptions.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetOptions.h" +#include +#include +#include +#include + namespace clang { constexpr unsigned PointerAuthKeyNone = -1; +class PointerAuthSchema { +public: + enum class Kind : unsigned { +
[llvm-branch-commits] [flang] [flang] Lower REDUCE intrinsic for reduction op with args by value (PR #95353)
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/95353 #95297 Updates the runtime entry points to distinguish between reduction operation with arguments passed by value or by reference. Add lowering to support the arguments passed by value. >From defadc4f18b0b4b369a3657a0f6e4c9f79ffd793 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 12 Jun 2024 15:28:31 -0700 Subject: [PATCH] [flang] Update lowering of REDUCE intrinsic for reduction operation with args by value --- .../Optimizer/Builder/Runtime/RTBuilder.h | 22 + .../Optimizer/Builder/Runtime/Reduction.h | 8 +- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 16 +- .../Optimizer/Builder/Runtime/Reduction.cpp | 468 -- flang/test/Lower/Intrinsics/reduce.f90| 235 - 5 files changed, 674 insertions(+), 75 deletions(-) diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h index 809d5b8d569dc..845ba385918d0 100644 --- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h @@ -64,6 +64,18 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *); }; \ } +#define REDUCTION_VALUE_OPERATION_MODEL(T) \ + template <> \ + constexpr TypeBuilderFunc \ + getModel>() { \ +return [](mlir::MLIRContext *context) -> mlir::Type { \ + TypeBuilderFunc f{getModel()}; \ + auto refTy = fir::ReferenceType::get(f(context)); \ + return mlir::FunctionType::get(context, {f(context), f(context)}, \ + refTy); \ +}; \ + } + #define REDUCTION_CHAR_OPERATION_MODEL(T) \ template <> \ constexpr TypeBuilderFunc \ @@ -481,17 +493,27 @@ constexpr TypeBuilderFunc getModel() { } REDUCTION_REF_OPERATION_MODEL(std::int8_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int8_t) REDUCTION_REF_OPERATION_MODEL(std::int16_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int16_t) REDUCTION_REF_OPERATION_MODEL(std::int32_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int32_t) REDUCTION_REF_OPERATION_MODEL(std::int64_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int64_t) REDUCTION_REF_OPERATION_MODEL(Fortran::common::int128_t) +REDUCTION_VALUE_OPERATION_MODEL(Fortran::common::int128_t) REDUCTION_REF_OPERATION_MODEL(float) +REDUCTION_VALUE_OPERATION_MODEL(float) REDUCTION_REF_OPERATION_MODEL(double) +REDUCTION_VALUE_OPERATION_MODEL(double) REDUCTION_REF_OPERATION_MODEL(long double) +REDUCTION_VALUE_OPERATION_MODEL(long double) REDUCTION_REF_OPERATION_MODEL(std::complex) +REDUCTION_VALUE_OPERATION_MODEL(std::complex) REDUCTION_REF_OPERATION_MODEL(std::complex) +REDUCTION_VALUE_OPERATION_MODEL(std::complex) REDUCTION_CHAR_OPERATION_MODEL(char) REDUCTION_CHAR_OPERATION_MODEL(char16_t) diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h index fedf453a6dc8d..2a40cddc0cc2c 100644 --- a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h @@ -229,8 +229,8 @@ void genIParityDim(fir::FirOpBuilder &builder, mlir::Location loc, /// result value. This is used for COMPLEX, CHARACTER and DERIVED TYPES. void genReduce(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value arrayBox, mlir::Value operation, mlir::Value maskBox, - mlir::Value identity, mlir::Value ordered, - mlir::Value resultBox); + mlir::Value identity, mlir::Value ordered, mlir::Value resultBox, + bool argByRef); /// Generate call to `Reduce` intrinsic runtime routine. This is the version /// that does not take a dim argument and return a scalare result. This is used @@ -238,14 +238,14 @@ void genReduce(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value genReduce(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value arrayBox, mlir::Value operation, mlir::Value maskBox, mlir::Value identity, - mlir::Value ordered); + mlir::Value ordered, bool argByRef); /// Generate call to `Reduce` intrinsic runtime routine. This is the version /// that takes arrays of any rank with a dim argument specified.
[llvm-branch-commits] [flang] [flang] Lower REDUCE intrinsic for reduction op with args by value (PR #95353)
llvmbot wrote: @llvm/pr-subscribers-flang-fir-hlfir Author: Valentin Clement (バレンタイン クレメン) (clementval) Changes #95297 Updates the runtime entry points to distinguish between reduction operation with arguments passed by value or by reference. Add lowering to support the arguments passed by value. --- Patch is 62.25 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95353.diff 5 Files Affected: - (modified) flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h (+22) - (modified) flang/include/flang/Optimizer/Builder/Runtime/Reduction.h (+4-4) - (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+12-4) - (modified) flang/lib/Optimizer/Builder/Runtime/Reduction.cpp (+413-55) - (modified) flang/test/Lower/Intrinsics/reduce.f90 (+223-12) ``diff diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h index 809d5b8d569dc..845ba385918d0 100644 --- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h @@ -64,6 +64,18 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *); }; \ } +#define REDUCTION_VALUE_OPERATION_MODEL(T) \ + template <> \ + constexpr TypeBuilderFunc \ + getModel>() { \ +return [](mlir::MLIRContext *context) -> mlir::Type { \ + TypeBuilderFunc f{getModel()}; \ + auto refTy = fir::ReferenceType::get(f(context)); \ + return mlir::FunctionType::get(context, {f(context), f(context)}, \ + refTy); \ +}; \ + } + #define REDUCTION_CHAR_OPERATION_MODEL(T) \ template <> \ constexpr TypeBuilderFunc \ @@ -481,17 +493,27 @@ constexpr TypeBuilderFunc getModel() { } REDUCTION_REF_OPERATION_MODEL(std::int8_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int8_t) REDUCTION_REF_OPERATION_MODEL(std::int16_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int16_t) REDUCTION_REF_OPERATION_MODEL(std::int32_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int32_t) REDUCTION_REF_OPERATION_MODEL(std::int64_t) +REDUCTION_VALUE_OPERATION_MODEL(std::int64_t) REDUCTION_REF_OPERATION_MODEL(Fortran::common::int128_t) +REDUCTION_VALUE_OPERATION_MODEL(Fortran::common::int128_t) REDUCTION_REF_OPERATION_MODEL(float) +REDUCTION_VALUE_OPERATION_MODEL(float) REDUCTION_REF_OPERATION_MODEL(double) +REDUCTION_VALUE_OPERATION_MODEL(double) REDUCTION_REF_OPERATION_MODEL(long double) +REDUCTION_VALUE_OPERATION_MODEL(long double) REDUCTION_REF_OPERATION_MODEL(std::complex) +REDUCTION_VALUE_OPERATION_MODEL(std::complex) REDUCTION_REF_OPERATION_MODEL(std::complex) +REDUCTION_VALUE_OPERATION_MODEL(std::complex) REDUCTION_CHAR_OPERATION_MODEL(char) REDUCTION_CHAR_OPERATION_MODEL(char16_t) diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h index fedf453a6dc8d..2a40cddc0cc2c 100644 --- a/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/Reduction.h @@ -229,8 +229,8 @@ void genIParityDim(fir::FirOpBuilder &builder, mlir::Location loc, /// result value. This is used for COMPLEX, CHARACTER and DERIVED TYPES. void genReduce(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value arrayBox, mlir::Value operation, mlir::Value maskBox, - mlir::Value identity, mlir::Value ordered, - mlir::Value resultBox); + mlir::Value identity, mlir::Value ordered, mlir::Value resultBox, + bool argByRef); /// Generate call to `Reduce` intrinsic runtime routine. This is the version /// that does not take a dim argument and return a scalare result. This is used @@ -238,14 +238,14 @@ void genReduce(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value genReduce(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value arrayBox, mlir::Value operation, mlir::Value maskBox, mlir::Value identity, - mlir::Value ordered); + mlir::Value ordered, bool argByRef); /// Generate call to `Reduce` intrinsic runtime routine. This is the version /// that takes arrays of any rank with a dim argument specified. void genReduceDim(fir::FirOpBuilder &builder,