[llvm-branch-commits] [flang] [flang][OpenMP] lower simple array reductions (PR #84958)
@@ -390,15 +559,35 @@ void ReductionProcessor::addReductionDecl( // initial pass to collect all recuction vars so we can figure out if this // should happen byref + fir::FirOpBuilder &builder = converter.getFirOpBuilder(); for (const Fortran::parser::OmpObject &ompObject : objectList.v) { if (const auto *name{ Fortran::parser::Unwrap(ompObject)}) { if (const Fortran::semantics::Symbol * symbol{name->symbol}) { if (reductionSymbols) reductionSymbols->push_back(symbol); mlir::Value symVal = converter.getSymbolAddress(*symbol); -if (auto declOp = symVal.getDefiningOp()) +auto redType = mlir::cast(symVal.getType()); DavidTruby wrote: Is this cast definitely safe? Will symVal always be a reference type here? https://github.com/llvm/llvm-project/pull/84958 ___ 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] Revise IDE folder structure (PR #89745)
https://github.com/DavidTruby approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/89745 ___ 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] [flang] [mlir][flang][openmp] Rework wsloop reduction operations (PR #80019)
DavidTruby wrote: Note: I have marked this as a draft as I have not yet changed the SCF to OpenMP lowering, meaning that those tests fail. https://github.com/llvm/llvm-project/pull/80019 ___ 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] e5f51fd - [clang][aarch64] Precondition isHomogeneousAggregate on isCXX14Aggregate
Author: David Truby Date: 2021-01-12T19:44:01Z New Revision: e5f51fdd650c6d20c81fedb8e856e9858aa10991 URL: https://github.com/llvm/llvm-project/commit/e5f51fdd650c6d20c81fedb8e856e9858aa10991 DIFF: https://github.com/llvm/llvm-project/commit/e5f51fdd650c6d20c81fedb8e856e9858aa10991.diff LOG: [clang][aarch64] Precondition isHomogeneousAggregate on isCXX14Aggregate MSVC on WoA64 includes isCXX14Aggregate in its definition. This is de-facto specification on that platform, so match msvc's behaviour. Fixes: https://bugs.llvm.org/show_bug.cgi?id=47611 Co-authored-by: Peter Waller Differential Revision: https://reviews.llvm.org/D92751 Added: Modified: clang/lib/CodeGen/CGCXXABI.h clang/lib/CodeGen/MicrosoftCXXABI.cpp clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGenCXX/homogeneous-aggregates.cpp llvm/test/CodeGen/AArch64/arm64-windows-calls.ll Removed: diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h index 171428a3525d..ea839db7528e 100644 --- a/clang/lib/CodeGen/CGCXXABI.h +++ b/clang/lib/CodeGen/CGCXXABI.h @@ -146,6 +146,13 @@ class CGCXXABI { /// 'this' parameter of C++ instance methods. virtual bool isSRetParameterAfterThis() const { return false; } + /// Returns true if the ABI permits the argument to be a homogeneous + /// aggregate. + virtual bool + isPermittedToBeHomogeneousAggregate(const CXXRecordDecl *RD) const { +return true; + }; + /// Find the LLVM type used to represent the given member pointer /// type. virtual llvm::Type * diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index c16c72dc93d5..cb0dc1d5d717 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -771,6 +771,9 @@ class MicrosoftCXXABI : public CGCXXABI { LoadVTablePtr(CodeGenFunction &CGF, Address This, const CXXRecordDecl *RD) override; + virtual bool + isPermittedToBeHomogeneousAggregate(const CXXRecordDecl *RD) const override; + private: typedef std::pair VFTableIdTy; typedef llvm::DenseMap VTablesMapTy; @@ -1070,7 +1073,7 @@ bool MicrosoftCXXABI::hasMostDerivedReturn(GlobalDecl GD) const { return isDeletingDtor(GD); } -static bool isCXX14Aggregate(const CXXRecordDecl *RD) { +static bool isTrivialForAArch64MSVC(const CXXRecordDecl *RD) { // For AArch64, we use the C++14 definition of an aggregate, so we also // check for: // No private or protected non static data members. @@ -1107,7 +1110,7 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo &FI) const { bool isTrivialForABI = RD->isPOD(); bool isAArch64 = CGM.getTarget().getTriple().isAArch64(); if (isAArch64) -isTrivialForABI = RD->canPassInRegisters() && isCXX14Aggregate(RD); +isTrivialForABI = RD->canPassInRegisters() && isTrivialForAArch64MSVC(RD); // MSVC always returns structs indirectly from C++ instance methods. bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod(); @@ -4358,3 +4361,12 @@ MicrosoftCXXABI::LoadVTablePtr(CodeGenFunction &CGF, Address This, performBaseAdjustment(CGF, This, QualType(RD->getTypeForDecl(), 0)); return {CGF.GetVTablePtr(This, CGM.Int8PtrTy, RD), RD}; } + +bool MicrosoftCXXABI::isPermittedToBeHomogeneousAggregate( +const CXXRecordDecl *CXXRD) const { + // MSVC Windows on Arm64 considers a type not HFA if it is not an + // aggregate according to the C++14 spec. This is not consistent with the + // AAPCS64, but is defacto spec on that platform. + return !CGM.getTarget().getTriple().isAArch64() || + isTrivialForAArch64MSVC(CXXRD); +} diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index d36c7344e284..9a11a0720f3c 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -5065,8 +5065,12 @@ bool ABIInfo::isHomogeneousAggregate(QualType Ty, const Type *&Base, Members = 0; -// If this is a C++ record, check the bases first. +// If this is a C++ record, check the properties of the record such as +// bases and ABI specific restrictions if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) { + if (!getCXXABI().isPermittedToBeHomogeneousAggregate(CXXRD)) +return false; + for (const auto &I : CXXRD->bases()) { // Ignore empty records. if (isEmptyRecord(getContext(), I.getType(), true)) diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 2b3af4226407..0fa30b2663bf 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -mfloat-abi hard -triple armv7-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM32 // RUN: %clang_cc1 -mfloat-abi hard -triple aarch64-unknown-lin
[llvm-branch-commits] [clang] 006b649 - [clang][docs] Release notes for C/C++ SVE Operators
Author: David Truby Date: 2022-08-22T13:53:56+01:00 New Revision: 006b649321dc6c72a18d1b73807fc206472e911c URL: https://github.com/llvm/llvm-project/commit/006b649321dc6c72a18d1b73807fc206472e911c DIFF: https://github.com/llvm/llvm-project/commit/006b649321dc6c72a18d1b73807fc206472e911c.diff LOG: [clang][docs] Release notes for C/C++ SVE Operators Added: Modified: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst Removed: diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index de305ce79c247..6e97193888f77 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -532,6 +532,8 @@ number of literals can be specified. For example: vector int vi5 = (vector int)(1, 2, 3, 4); float4 vf = (float4)((float2)(1.0f, 2.0f), (float2)(3.0f, 4.0f)); +.. _Vector Operations: + Vector Operations - diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c4069f9dd190c..906c1925bc823 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -655,6 +655,10 @@ Arm and AArch64 Support in Clang - clang now supports the Cortex-M85 CPU, which can be chosen with `-mcpu=cortex-m85`. By default, this has PACBTI turned on, but it can be disabled with `-mcpu=cortex-m85+nopacbti`. +- clang now supports using C/C++ operators on sizeless SVE vectors such as + `svint32_t`. The set of supported operators is shown in the table Vector + Operations found in the :ref:`Clang Language Extensions ` + document. Floating Point Support in Clang --- ___ 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] ccaad06 - [flang] Fix shared library builds for lib/Lower.
Author: David Truby Date: 2020-07-16T15:52:14+01:00 New Revision: ccaad06b84c0f53f04f3acb97316a8ddef75b12f URL: https://github.com/llvm/llvm-project/commit/ccaad06b84c0f53f04f3acb97316a8ddef75b12f DIFF: https://github.com/llvm/llvm-project/commit/ccaad06b84c0f53f04f3acb97316a8ddef75b12f.diff LOG: [flang] Fix shared library builds for lib/Lower. Summary: This adds missing definitions for functions in the Lower directory that were causing failures in shared library builds. The definitions for these are taken from the fir-dev branch on github. Reviewers: sscalpone, schweitz, jeanPerier, klausler Reviewed By: schweitz Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D83771 Added: flang/lib/Lower/ConvertExpr.cpp Modified: flang/lib/Lower/CMakeLists.txt flang/lib/Optimizer/Dialect/FIROps.cpp Removed: diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt index 3cd71c007a00..975065c9ed7d 100644 --- a/flang/lib/Lower/CMakeLists.txt +++ b/flang/lib/Lower/CMakeLists.txt @@ -7,6 +7,7 @@ add_flang_library(FortranLower Coarray.cpp ComplexExpr.cpp ConvertType.cpp + ConvertExpr.cpp DoLoopHelper.cpp FIRBuilder.cpp IntrinsicCall.cpp diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp new file mode 100644 index ..1bac6884a5f7 --- /dev/null +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -0,0 +1,95 @@ +//===-- ConvertExpr.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "flang/Common/idioms.h" +#include "flang/Lower/IntrinsicCall.h" +#include "flang/Lower/Support/BoxValue.h" + +mlir::Value fir::getBase(const fir::ExtendedValue &ex) { + return std::visit(Fortran::common::visitors{ +[](const fir::UnboxedValue &x) { return x; }, +[](const auto &x) { return x.getAddr(); }, +}, +ex.box); +} + +llvm::raw_ostream &fir::operator<<(llvm::raw_ostream &os, + const fir::CharBoxValue &box) { + os << "boxchar { addr: " << box.getAddr() << ", len: " << box.getLen() + << " }"; + return os; +} + +llvm::raw_ostream &fir::operator<<(llvm::raw_ostream &os, + const fir::ArrayBoxValue &box) { + os << "boxarray { addr: " << box.getAddr(); + if (box.getLBounds().size()) { +os << ", lbounds: ["; +llvm::interleaveComma(box.getLBounds(), os); +os << "]"; + } else { +os << ", lbounds: all-ones"; + } + os << ", shape: ["; + llvm::interleaveComma(box.getExtents(), os); + os << "]}"; + return os; +} + +llvm::raw_ostream &fir::operator<<(llvm::raw_ostream &os, + const fir::CharArrayBoxValue &box) { + os << "boxchararray { addr: " << box.getAddr() << ", len : " << box.getLen(); + if (box.getLBounds().size()) { +os << ", lbounds: ["; +llvm::interleaveComma(box.getLBounds(), os); +os << "]"; + } else { +os << " lbounds: all-ones"; + } + os << ", shape: ["; + llvm::interleaveComma(box.getExtents(), os); + os << "]}"; + return os; +} + +llvm::raw_ostream &fir::operator<<(llvm::raw_ostream &os, + const fir::BoxValue &box) { + os << "box { addr: " << box.getAddr(); + if (box.getLen()) +os << ", size: " << box.getLen(); + if (box.params.size()) { +os << ", type params: ["; +llvm::interleaveComma(box.params, os); +os << "]"; + } + if (box.getLBounds().size()) { +os << ", lbounds: ["; +llvm::interleaveComma(box.getLBounds(), os); +os << "]"; + } + if (box.getExtents().size()) { +os << ", shape: ["; +llvm::interleaveComma(box.getExtents(), os); +os << "]"; + } + os << "}"; + return os; +} + +llvm::raw_ostream &fir::operator<<(llvm::raw_ostream &os, + const fir::ProcBoxValue &box) { + os << "boxproc: { addr: " << box.getAddr() << ", context: " << box.hostContext + << "}"; + return os; +} + +llvm::raw_ostream &fir::operator<<(llvm::raw_ostream &os, + const fir::ExtendedValue &ex) { + std::visit([&](const auto &value) { os << value; }, ex.box); + return os; +} diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp index 30cd365f139b..44310d6e0691 100644 --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -1395,15 +1395,28 @@ mlir::OpFoldResult fir::SubfOp::fold(llvm::ArrayRef opnds) { //===
[llvm-branch-commits] [flang] 15a07e4 - [flang] Add missing link dependencies to FrontendOpenACC.
Author: David Truby Date: 2020-07-16T15:52:15+01:00 New Revision: 15a07e41f01a64f1f4a4ffc3ca89a0f0e5431e54 URL: https://github.com/llvm/llvm-project/commit/15a07e41f01a64f1f4a4ffc3ca89a0f0e5431e54 DIFF: https://github.com/llvm/llvm-project/commit/15a07e41f01a64f1f4a4ffc3ca89a0f0e5431e54.diff LOG: [flang] Add missing link dependencies to FrontendOpenACC. Summary: These link dependencies are required for shared library builds to work correctly. Reviewers: clementval Reviewed By: clementval Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D83938 Added: Modified: flang/lib/Parser/CMakeLists.txt flang/lib/Semantics/CMakeLists.txt Removed: diff --git a/flang/lib/Parser/CMakeLists.txt b/flang/lib/Parser/CMakeLists.txt index e1e77ac6e92d..9ee416803177 100644 --- a/flang/lib/Parser/CMakeLists.txt +++ b/flang/lib/Parser/CMakeLists.txt @@ -30,6 +30,7 @@ add_flang_library(FortranParser LINK_COMPONENTS Support + FrontendOpenACC DEPENDS omp_gen diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt index a869d831109b..2bdc5f958281 100644 --- a/flang/lib/Semantics/CMakeLists.txt +++ b/flang/lib/Semantics/CMakeLists.txt @@ -52,4 +52,5 @@ add_flang_library(FortranSemantics LINK_COMPONENTS Support FrontendOpenMP + FrontendOpenACC ) ___ 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][NFC] Split runtime headers in preparation for cross-compilation. (PR #112188)
https://github.com/DavidTruby approved this pull request. LGTM, but someone else should probably approve as this is quite a large change. I don't think this one is an NFC because of the changes mentioned above by @jeanPerier https://github.com/llvm/llvm-project/pull/112188 ___ 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][NFC] Split runtime headers in preparation for cross-compilation. (PR #112188)
https://github.com/DavidTruby edited https://github.com/llvm/llvm-project/pull/112188 ___ 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] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)
DavidTruby wrote: The issue that @vdonaldson posted about above was present without this patch last week too. It should be fixed on `main` now though so hopefully a rebase will pick it up? https://github.com/llvm/llvm-project/pull/110217 ___ 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] [flang] [lld] [Flang] Rename libFortranRuntime.a to libflang_rt.a (PR #122341)
https://github.com/DavidTruby approved this pull request. LGTM thanks! https://github.com/llvm/llvm-project/pull/122341 ___ 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] release/20.x: [flang] fix AArch64 PCS for struct following pointer (#127802) (PR #128518)
DavidTruby wrote: For context, this fixes an ICE in the specific scenario where you are trying to call a C function from Fortran that has both pointer and struct arguments, on AArch64. It’s quite niche but does cause a hard crash with a completely useless error message. I was hoping we could get it in to 20 just because the fix is very simple and since it only touches this specific scenario it's low risk too. https://github.com/llvm/llvm-project/pull/128518 ___ 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] release/20.x: [flang] fix AArch64 PCS for struct following pointer (#127802) (PR #128518)
https://github.com/DavidTruby updated https://github.com/llvm/llvm-project/pull/128518 >From bbebcafadf448bf5780597e2c2b9813237d2c884 Mon Sep 17 00:00:00 2001 From: David Truby Date: Fri, 21 Feb 2025 18:50:52 + Subject: [PATCH] [flang] fix AArch64 PCS for struct following pointer (#127802) Pointers are already handled as taking up a register in the ABI handling, but the handling for structs was not taking this into account. This patch changes the struct handling to acknowledge that pointer arguments take up an integer register. Fixes #123075 (cherry picked from commit 449f84fea652e31de418c3087d7e3628809241b4) --- flang/lib/Optimizer/CodeGen/Target.cpp | 7 +++ flang/test/Fir/struct-passing-aarch64-byval.fir | 14 ++ 2 files changed, 21 insertions(+) diff --git a/flang/lib/Optimizer/CodeGen/Target.cpp b/flang/lib/Optimizer/CodeGen/Target.cpp index 1bc673bb34e32..2a1eb0bc33f5c 100644 --- a/flang/lib/Optimizer/CodeGen/Target.cpp +++ b/flang/lib/Optimizer/CodeGen/Target.cpp @@ -930,6 +930,13 @@ struct TargetAArch64 : public GenericTarget { .Case([&](auto) { TODO(loc, "passing vector argument to C by value is not supported"); return NRegs{}; +}) +.Default([&](auto ty) { + if (fir::conformsWithPassByRef(ty)) +return NRegs{1, false}; // Pointers take 1 integer register + TODO(loc, "unsupported component type for BIND(C), VALUE derived " +"type argument"); + return NRegs{}; }); } diff --git a/flang/test/Fir/struct-passing-aarch64-byval.fir b/flang/test/Fir/struct-passing-aarch64-byval.fir index 27143459dde2f..087efba393014 100644 --- a/flang/test/Fir/struct-passing-aarch64-byval.fir +++ b/flang/test/Fir/struct-passing-aarch64-byval.fir @@ -71,3 +71,17 @@ func.func private @too_many_hfa(!fir.type, // CHECK-LABEL: func.func private @too_big(!fir.ref}>> {{{.*}}, llvm.byval = !fir.type}>}) func.func private @too_big(!fir.type}>) + +// CHECK-LABEL: func.func private @pointer_type(!fir.ref, !fir.array<1xi64>) +func.func private @pointer_type(!fir.ref, !fir.type) + +// CHECK-LABEL: func.func private @pointer_type_too_many_int(!fir.ref, +// CHECK-SAME: !fir.array<2xi64>, +// CHECK-SAME: !fir.array<2xi64>, +// CHECK-SAME: !fir.array<2xi64>, +// CHECK-SAME: !fir.ref> {{{.*}}, llvm.byval = !fir.type}) +func.func private @pointer_type_too_many_int(!fir.ref, + !fir.type, + !fir.type, + !fir.type, + !fir.type) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits