[llvm-branch-commits] [llvm] release/18.x: [FunctionAttrs] Fix incorrect nonnull inference for non-inbounds GEP (#91180) (PR #91286)
https://github.com/dtcxzyw approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/91286 ___ 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] release/18.x: [FunctionAttrs] Fix incorrect nonnull inference for non-inbounds GEP (#91180) (PR #91286)
https://github.com/fhahn approved this pull request. Should be safe to back port, LGTM, thanks! https://github.com/llvm/llvm-project/pull/91286 ___ 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] Don't pass clauses to op-generating functions anymore (PR #90108)
https://github.com/skatrak approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/90108 ___ 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] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)
https://github.com/skatrak approved this pull request. Thank you Andrew for addressing my concerns, LGTM https://github.com/llvm/llvm-project/pull/82851 ___ 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] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
https://github.com/skatrak deleted https://github.com/llvm/llvm-project/pull/82852 ___ 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] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
@@ -2122,6 +2124,66 @@ void collectMapDataFromMapOperands(MapInfoData &mapData, } } +static int getMapDataMemberIdx(MapInfoData &mapData, + mlir::omp::MapInfoOp memberOp) { + auto *res = llvm::find(mapData.MapClause, memberOp); + assert(res != mapData.MapClause.end() && + "MapInfoOp for member not found in MapData, cannot return index"); + return std::distance(mapData.MapClause.begin(), res); +} + +static mlir::omp::MapInfoOp +getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) { + mlir::DenseIntElementsAttr indexAttr = mapInfo.getMembersIndexAttr(); + + // Only 1 member has been mapped, we can return it. + if (indexAttr.size() == 1) +if (auto mapOp = mlir::dyn_cast( +mapInfo.getMembers()[0].getDefiningOp())) + return mapOp; + + llvm::ArrayRef shape = indexAttr.getShapedType().getShape(); + std::vector indices(shape[0]); + std::iota(indices.begin(), indices.end(), 0); + + llvm::sort( + indices.begin(), indices.end(), [&](const size_t a, const size_t b) { +for (int i = 0; + i < shape[1]; + ++i) { + int aIndex = indexAttr.getValues()[a * shape[1] + i]; + int bIndex = indexAttr.getValues()[b * shape[1] + i]; skatrak wrote: Nit: Extract `indexAttr.getValues()` out of the lambda. ```suggestion int aIndex = indexAttrValues[a * shape[1] + i]; int bIndex = indexAttrValues[b * shape[1] + i]; ``` https://github.com/llvm/llvm-project/pull/82852 ___ 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] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/82852 ___ 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] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
https://github.com/skatrak approved this pull request. Thank you Andrew for working on my suggestions. LGTM, I just have some minimal nits, but there's no need for another review from me before merging this PR. https://github.com/llvm/llvm-project/pull/82852 ___ 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] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
@@ -2122,6 +2124,66 @@ void collectMapDataFromMapOperands(MapInfoData &mapData, } } +static int getMapDataMemberIdx(MapInfoData &mapData, + mlir::omp::MapInfoOp memberOp) { + auto *res = llvm::find(mapData.MapClause, memberOp); + assert(res != mapData.MapClause.end() && + "MapInfoOp for member not found in MapData, cannot return index"); + return std::distance(mapData.MapClause.begin(), res); +} + +static mlir::omp::MapInfoOp +getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) { + mlir::DenseIntElementsAttr indexAttr = mapInfo.getMembersIndexAttr(); + + // Only 1 member has been mapped, we can return it. + if (indexAttr.size() == 1) +if (auto mapOp = mlir::dyn_cast( +mapInfo.getMembers()[0].getDefiningOp())) + return mapOp; + + llvm::ArrayRef shape = indexAttr.getShapedType().getShape(); + std::vector indices(shape[0]); skatrak wrote: Nit: Wouldn't `SmallVector` be preferred in this case? ```suggestion llvm::SmallVector indices(shape[0]); ``` https://github.com/llvm/llvm-project/pull/82852 ___ 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] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
@@ -0,0 +1,63 @@ +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s + +// This test checks the offload sizes, map types and base pointers and pointers +// provided to the OpenMP kernel argument structure are correct when lowering +// to LLVM-IR from MLIR when performing explicit member mapping of a recrod type +// (C++/C class/structure, Fortran derived type) where only members of the record +// type are mapped. + +module attributes {omp.is_target_device = false} { +llvm.func @_QQmain() { +%0 = llvm.mlir.constant(10 : index) : i64 +%1 = llvm.mlir.constant(4 : index) : i64 +%2 = llvm.mlir.constant(1 : index) : i64 +%3 = llvm.mlir.constant(1 : i64) : i64 +%4 = llvm.alloca %3 x !llvm.struct<(f32, array<10 x i32>, i32)> : (i64) -> !llvm.ptr +%5 = llvm.mlir.constant(2 : i32) : i32 +%6 = llvm.getelementptr %4[0, 2] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(f32, array<10 x i32>, i32)> +%7 = omp.map.info var_ptr(%6 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr +%8 = llvm.mlir.constant(1 : i32) : i32 +%9 = llvm.getelementptr %4[0, 1] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(f32, array<10 x i32>, i32)> +%10 = omp.map.bounds lower_bound(%2 : i64) upper_bound(%1 : i64) extent(%0 : i64) stride(%2 : i64) start_idx(%2 : i64) +%11 = omp.map.info var_ptr(%9 : !llvm.ptr, !llvm.array<10 x i32>) map_clauses(tofrom) capture(ByRef) bounds(%10) -> !llvm.ptr +%12 = omp.map.info var_ptr(%4 : !llvm.ptr, !llvm.struct<(f32, array<10 x i32>, i32)>) map_clauses(tofrom) capture(ByRef) members(%7, %11 : [2], [1] : !llvm.ptr, !llvm.ptr) -> !llvm.ptr {partial_map = true} +omp.target map_entries(%7 -> %arg0, %11 -> %arg1, %12 -> %arg2 : !llvm.ptr, !llvm.ptr, !llvm.ptr) { +^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr): + omp.terminator +} +llvm.return + } +} + +// CHECK: @.offload_sizes = private unnamed_addr constant [3 x i64] [i64 0, i64 4, i64 16] +// CHECK: @.offload_maptypes = private unnamed_addr constant [3 x i64] [i64 32, i64 281474976710659, i64 281474976710659] + +// CHECK: define void @_QQmain() +// CHECK: %[[ALLOCA:.*]] = alloca { float, [10 x i32], i32 }, i64 1, align 8 +// CHECK: %[[MEMBER_ACCESS_1:.*]] = getelementptr { float, [10 x i32], i32 }, ptr %[[ALLOCA]], i32 0, i32 2 +// CHECK: %[[MEMBER_ACCESS_2:.*]] = getelementptr { float, [10 x i32], i32 }, ptr %[[ALLOCA]], i32 0, i32 1 + +// CHECK: %[[LAST_MEMBER:.*]] = getelementptr inbounds [10 x i32], ptr %[[MEMBER_ACCESS_2]], i64 0, i64 1 +// CHECK: %[[FIRST_MEMBER:.*]] = getelementptr i32, ptr %[[MEMBER_ACCESS_1]], i64 1 +// CHECK: %[[FIRST_MEMBER_OFF:.*]] = ptrtoint ptr %[[FIRST_MEMBER]] to i64 +// CHECK: %[[SECOND_MEMBER_OFF:.*]] = ptrtoint ptr %[[LAST_MEMBER]] to i64 +// CHECK: %[[MEMBER_DIFF:.*]] = sub i64 %[[FIRST_MEMBER_OFF]], %[[SECOND_MEMBER_OFF]] +// CHECK: %[[OFFLOAD_SIZE:.*]] = sdiv exact i64 %[[MEMBER_DIFF]], ptrtoint (ptr getelementptr (i8, ptr null, i32 1) to i64) + +// CHECK: %[[BASE_PTR_ARR:.*]] = getelementptr inbounds [3 x ptr], ptr %.offload_baseptrs, i32 0, i32 0 +// CHECK: store ptr %[[ALLOCA]], ptr %[[BASE_PTR_ARR]], align 8 +// CHECK: %[[PTR_ARR:.*]] = getelementptr inbounds [3 x ptr], ptr %.offload_ptrs, i32 0, i32 0 +// CHECK: store ptr %[[LAST_MEMBER]], ptr %[[PTR_ARR]], align 8 +// CHECK: %[[SIZE_ARR:.*]] = getelementptr inbounds [3 x i64], ptr %.offload_sizes, i32 0, i32 0 +// CHECK: store i64 %[[OFFLOAD_SIZE]], ptr %[[SIZE_ARR]], align 8 + +// CHECK: %[[BASE_PTR_ARR_2:.*]] = getelementptr inbounds [3 x ptr], ptr %.offload_baseptrs, i32 0, i32 1 +// CHECK: store ptr %[[ALLOCA]], ptr %[[BASE_PTR_ARR_2]], align 8 +// CHECK: %[[PTR_ARR_2:.*]] = getelementptr inbounds [3 x ptr], ptr %.offload_ptrs, i32 0, i32 1 +// CHECK: store ptr %[[MEMBER_ACCESS_1]], ptr %[[PTR_ARR_2]], align 8 + +// CHECK: %[[BASE_PTR_ARR_3:.*]] = getelementptr inbounds [3 x ptr], ptr %.offload_baseptrs, i32 0, i32 2 +// CHECK: store ptr %[[ALLOCA]], ptr %[[BASE_PTR_ARR_3]], align 8 +// CHECK: %[[PTR_ARR_3:.*]] = getelementptr inbounds [3 x ptr], ptr %.offload_ptrs, i32 0, i32 2 +// CHECK: store ptr %[[LAST_MEMBER]], ptr %[[PTR_ARR_3]], align 8 + skatrak wrote: Still there! 😉 https://github.com/llvm/llvm-project/pull/82852 ___ 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] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/90961 >From 5b70158f8eff30125c0bf0d675bab62497ac620f Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 3 May 2024 13:54:06 +0200 Subject: [PATCH 1/2] [clang] CTAD alias: refine the transformation for the require-clause expr. In the clang AST, constraint nodes are deliberately not instantiated unless they are actively being evaluated. Consequently, occurrences of template parameters in the require-clause expression have a subtle "depth" difference compared to normal occurrences in place contexts, such as function parameters. When transforming the require-clause, we must take this distinction into account. The existing implementation overlooks this consideration. This patch is to rewrite the implementation of the require-clause transformation to address this issue. --- clang/lib/Sema/SemaTemplate.cpp | 147 +-- clang/test/AST/ast-dump-ctad-alias.cpp | 40 + clang/test/SemaCXX/cxx20-ctad-type-alias.cpp | 68 + 3 files changed, 242 insertions(+), 13 deletions(-) create mode 100644 clang/test/AST/ast-dump-ctad-alias.cpp diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 7f49acc36769e..1de0cfac8f1f7 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2744,31 +2744,151 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *NTTP = dyn_cast(TemplateParam)) +return NTTP->getDepth(); + llvm_unreachable("Unhandled template parameter types"); +} + NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC, NamedDecl *TemplateParam, MultiLevelTemplateArgumentList &Args, - unsigned NewIndex) { + unsigned NewIndex, unsigned NewDepth) { if (auto *TTP = dyn_cast(TemplateParam)) -return transformTemplateTypeParam(SemaRef, DC, TTP, Args, TTP->getDepth(), +return transformTemplateTypeParam(SemaRef, DC, TTP, Args, NewDepth, NewIndex); if (auto *TTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, - TTP->getDepth()); + NewDepth); if (auto *NTTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, - NTTP->getDepth()); + NewDepth); llvm_unreachable("Unhandled template parameter types"); } -Expr *transformRequireClause(Sema &SemaRef, FunctionTemplateDecl *FTD, - llvm::ArrayRef TransformedArgs) { - Expr *RC = FTD->getTemplateParameters()->getRequiresClause(); +// Transform the require-clause of F if any. +// The return result is expected to be the require-clause for the synthesized +// alias deduction guide. +Expr *transformRequireClause( +Sema &SemaRef, FunctionTemplateDecl *F, +TypeAliasTemplateDecl *AliasTemplate, +ArrayRef DeduceResults) { + Expr *RC = F->getTemplateParameters()->getRequiresClause(); if (!RC) return nullptr; + + auto &Context = SemaRef.Context; + LocalInstantiationScope Scope(SemaRef); + + // In the clang AST, constraint nodes are deliberately not instantiated unless + // they are actively being evaluated. Consequently, occurrences of template + // parameters in the require-clause expression have a subtle "depth" + // difference compared to normal occurrences in places, such as function + // parameters. When transforming the require-clause, we must take this + // distinction into account: + // + // 1) In the transformed require-clause, occurrences of template parameters + // must use the "uninstantiated" depth; + // 2) When substituting on the require-clause expr of the underlying + // deduction guide, we must use the entire set of template argument lists; + // + // It's important to note that we're performing this transformation on an + // *instantiated* AliasTemplate. + + // For 1), if the alias template is nested within a class template, we + // calcualte the 'uninstantiated' depth by adding the substitution level back. + unsigned AdjustDepth = 0; + if (auto *PrimaryTemplate = AliasTemplate->getInstantiatedFromMemberTemplate()) +AdjustDepth = PrimaryTemplate->getTemplateDepth(); + + // We rebuild all template parameters with the uninstantiated depth, and + // build template arguments refer to them. + SmallVector AdjustedAliasTemplateArgs; + + for (auto *TP : *AliasTemplate->getTemplateParameters()) { +// Rebuild an
[llvm-branch-commits] [clang] [clang] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { hokein wrote: Renamed to `getTemplateParameterDepth` per your suggestion. https://github.com/llvm/llvm-project/pull/90961 ___ 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] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *NTTP = dyn_cast(TemplateParam)) +return NTTP->getDepth(); + llvm_unreachable("Unhandled template parameter types"); +} + NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC, NamedDecl *TemplateParam, MultiLevelTemplateArgumentList &Args, - unsigned NewIndex) { + unsigned NewIndex, unsigned NewDepth) { if (auto *TTP = dyn_cast(TemplateParam)) -return transformTemplateTypeParam(SemaRef, DC, TTP, Args, TTP->getDepth(), +return transformTemplateTypeParam(SemaRef, DC, TTP, Args, NewDepth, NewIndex); if (auto *TTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, - TTP->getDepth()); + NewDepth); if (auto *NTTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, - NTTP->getDepth()); + NewDepth); llvm_unreachable("Unhandled template parameter types"); } -Expr *transformRequireClause(Sema &SemaRef, FunctionTemplateDecl *FTD, - llvm::ArrayRef TransformedArgs) { - Expr *RC = FTD->getTemplateParameters()->getRequiresClause(); +// Transform the require-clause of F if any. +// The return result is expected to be the require-clause for the synthesized +// alias deduction guide. +Expr *transformRequireClause( hokein wrote: We're in an anonymous namespace. https://github.com/llvm/llvm-project/pull/90961 ___ 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] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { hokein wrote: Done. https://github.com/llvm/llvm-project/pull/90961 ___ 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] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { hokein wrote: Yeah, we're in an anonymous namespace. https://github.com/llvm/llvm-project/pull/90961 ___ 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] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *NTTP = dyn_cast(TemplateParam)) +return NTTP->getDepth(); + llvm_unreachable("Unhandled template parameter types"); +} + NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC, NamedDecl *TemplateParam, MultiLevelTemplateArgumentList &Args, - unsigned NewIndex) { + unsigned NewIndex, unsigned NewDepth) { if (auto *TTP = dyn_cast(TemplateParam)) -return transformTemplateTypeParam(SemaRef, DC, TTP, Args, TTP->getDepth(), +return transformTemplateTypeParam(SemaRef, DC, TTP, Args, NewDepth, NewIndex); if (auto *TTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, - TTP->getDepth()); + NewDepth); if (auto *NTTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, - NTTP->getDepth()); + NewDepth); llvm_unreachable("Unhandled template parameter types"); } -Expr *transformRequireClause(Sema &SemaRef, FunctionTemplateDecl *FTD, - llvm::ArrayRef TransformedArgs) { - Expr *RC = FTD->getTemplateParameters()->getRequiresClause(); +// Transform the require-clause of F if any. +// The return result is expected to be the require-clause for the synthesized +// alias deduction guide. +Expr *transformRequireClause( +Sema &SemaRef, FunctionTemplateDecl *F, +TypeAliasTemplateDecl *AliasTemplate, +ArrayRef DeduceResults) { + Expr *RC = F->getTemplateParameters()->getRequiresClause(); if (!RC) return nullptr; + + auto &Context = SemaRef.Context; + LocalInstantiationScope Scope(SemaRef); + + // In the clang AST, constraint nodes are not instantiated at all unless they + // are being evaluated. This means that occurrences of template parameters + // in the require-clause expr have subtle differences compared to occurrences + // in other places, such as function parameters. When transforming the + // require-clause, we must respect these differences, particularly regarding + // the 'depth' information: + // 1) In the transformed require-clause, occurrences of template parameters + // must use the "uninstantiated" depth; + // 2) When substituting on the require-clause expr of the underlying + // deduction guide, we must use the entire set of template argument lists. + // + // It's important to note that we're performing this transformation on an + // *instantiated* AliasTemplate. + + // For 1), if the alias template is nested within a class template, we + // calcualte the 'uninstantiated' depth by adding the substitution level back. + unsigned AdjustDepth = 0; + if (auto *PrimaryTemplate = AliasTemplate->getInstantiatedFromMemberTemplate()) +AdjustDepth = PrimaryTemplate->getTemplateDepth(); + + // We rebuild all template parameters with the uninstantiated depth, and + // build template arguments refer to them. + SmallVector AdjustedAliasTemplateArgs; + + for (auto *TP : *AliasTemplate->getTemplateParameters()) { +// Rebuild any internal references to earlier parameters and reindex +// as we go. +MultiLevelTemplateArgumentList Args; +Args.setKind(TemplateSubstitutionKind::Rewrite); +Args.addOuterTemplateArguments(AdjustedAliasTemplateArgs); +NamedDecl *NewParam = transformTemplateParameter( +SemaRef, AliasTemplate->getDeclContext(), TP, Args, +/*NewIndex=*/AdjustedAliasTemplateArgs.size(), +getTemplateDepth(TP) + AdjustDepth); + +auto NewTemplateArgument = Context.getCanonicalTemplateArgument( hokein wrote: Probably not needed, and I think avoiding the use of canonical types can lead to a more optimal AST, see #79798. We've already used this pattern in the `ConvertConstructorToDeductionGuideTransform`, and the current implementation here simply follows it. However, addressing this issue is not the primary focus of this PR. It might be more appropriate to address it in a separate patch. https://github.com/llvm/llvm-project/pull/90961 ___ 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] CTAD alias: fix the transformation for the require-clause expr (PR #90961)
@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +unsigned getTemplateDepth(NamedDecl *TemplateParam) { + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *TTP = dyn_cast(TemplateParam)) +return TTP->getDepth(); + if (auto *NTTP = dyn_cast(TemplateParam)) +return NTTP->getDepth(); + llvm_unreachable("Unhandled template parameter types"); +} + NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC, NamedDecl *TemplateParam, MultiLevelTemplateArgumentList &Args, - unsigned NewIndex) { + unsigned NewIndex, unsigned NewDepth) { if (auto *TTP = dyn_cast(TemplateParam)) -return transformTemplateTypeParam(SemaRef, DC, TTP, Args, TTP->getDepth(), +return transformTemplateTypeParam(SemaRef, DC, TTP, Args, NewDepth, NewIndex); if (auto *TTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, - TTP->getDepth()); + NewDepth); if (auto *NTTP = dyn_cast(TemplateParam)) return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, - NTTP->getDepth()); + NewDepth); llvm_unreachable("Unhandled template parameter types"); } -Expr *transformRequireClause(Sema &SemaRef, FunctionTemplateDecl *FTD, - llvm::ArrayRef TransformedArgs) { - Expr *RC = FTD->getTemplateParameters()->getRequiresClause(); +// Transform the require-clause of F if any. +// The return result is expected to be the require-clause for the synthesized +// alias deduction guide. +Expr *transformRequireClause( +Sema &SemaRef, FunctionTemplateDecl *F, +TypeAliasTemplateDecl *AliasTemplate, +ArrayRef DeduceResults) { + Expr *RC = F->getTemplateParameters()->getRequiresClause(); if (!RC) return nullptr; + + auto &Context = SemaRef.Context; + LocalInstantiationScope Scope(SemaRef); + + // In the clang AST, constraint nodes are not instantiated at all unless they + // are being evaluated. This means that occurrences of template parameters + // in the require-clause expr have subtle differences compared to occurrences + // in other places, such as function parameters. When transforming the + // require-clause, we must respect these differences, particularly regarding + // the 'depth' information: + // 1) In the transformed require-clause, occurrences of template parameters + // must use the "uninstantiated" depth; + // 2) When substituting on the require-clause expr of the underlying + // deduction guide, we must use the entire set of template argument lists. + // + // It's important to note that we're performing this transformation on an + // *instantiated* AliasTemplate. + + // For 1), if the alias template is nested within a class template, we + // calcualte the 'uninstantiated' depth by adding the substitution level back. + unsigned AdjustDepth = 0; + if (auto *PrimaryTemplate = AliasTemplate->getInstantiatedFromMemberTemplate()) hokein wrote: I've noticed that there are several places (e.g.,[1](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplate.cpp#L2374), [2](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/DeclCXX.cpp#L1943), [3](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/Decl.cpp#L4149)) where we use a while-loop to retrieve the primary template. However, I'm not entirely clear on the rationale behind it. It appears that using `getInstantiatedFromMemberTemplate()` consistently provides the correct result for all cases I came up with. Interestingly, removing the while-loop from all occurrences [1], [2], [3] doesn't trigger any test failures on `check-clang`. https://github.com/llvm/llvm-project/pull/90961 ___ 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][MLIR] Initial derived type member map support (PR #82853)
@@ -115,8 +115,7 @@ class ClauseProcessor { bool processMap( mlir::Location currentLocation, Fortran::lower::StatementContext &stmtCtx, mlir::omp::MapClauseOps &result, - llvm::SmallVectorImpl *mapSyms = - nullptr, + llvm::SmallVectorImpl *mapSyms, skatrak wrote: I agree it doesn't look great, but in my opinion it's better to do this than to force the caller to pass an output list even when it won't use it because it's needed internally. Maybe we'll be able to improve things later as we keep developing this. https://github.com/llvm/llvm-project/pull/82853 ___ 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][MLIR] Initial derived type member map support (PR #82853)
@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms( symbolAndClause.emplace_back(clause, *object.id()); } +int getComponentPlacementInParent( +const Fortran::semantics::Symbol *componentSym) { + const auto *derived = + componentSym->owner() + .derivedTypeSpec() + ->typeSymbol() + .detailsIf(); + assert(derived && + "expected derived type details when processing component symbol"); + int placement = 0; + for (auto t : derived->componentNames()) { +if (t == componentSym->name()) + return placement; +placement++; + } + return -1; +} + +std::optional +getCompObjOrNull(std::optional object, + Fortran::semantics::SemanticsContext &semaCtx) { + if (!object) +return std::nullopt; + + auto ref = evaluate::ExtractDataRef(*object.value().ref()); + if (!ref) +return std::nullopt; + + if (std::get_if(&ref->u)) +return object; + + auto baseObj = getBaseObject(object.value(), semaCtx); + if (!baseObj) +return std::nullopt; + + return getCompObjOrNull(baseObj.value(), semaCtx); +} + +llvm::SmallVector skatrak wrote: Yeah, I haven't seen that done often either. The comment was mainly to avoid hardcoding some default `SmallVector` size in the public interface of the function (in this case, the default one for `int`), so passing a reference works for me too. https://github.com/llvm/llvm-project/pull/82853 ___ 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] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)
https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/91345 Allow non-constants in the `sizes` clause such as ``` #pragma omp tile sizes(a) for (int i = 0; i < n; ++i) ``` This is permitted since tile was introduced in [OpenMP 5.1](https://www.openmp.org/spec-html/5.1/openmpsu53.html#x78-860002.11.9). It is possible to sneak-in negative numbers at runtime as in ``` int a = -1; #pragma omp tile sizes(a) ``` Even though it is not well-formed, it should still result in every loop iteration to be executed exactly once, an invariant of the tile construct that we should ensure. `ParseOpenMPExprListClause` is extracted-out to be reused by the `permutation` clause if the `interchange` construct. Some care was put in to ensure correct behavior in template contexts. This patch also adds end-to-end tests. This is to avoid errors like the off-by-one error I caused with the initial implementation of the unroll construct. >From a2aa6950ce3880b8e669025d95ac9e72245e26a7 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 16:42:41 +0200 Subject: [PATCH] Allow non-constant tile sizes --- clang/include/clang/Parse/Parser.h| 17 ++ clang/lib/Parse/ParseOpenMP.cpp | 65 -- clang/lib/Sema/SemaOpenMP.cpp | 113 +++-- clang/test/OpenMP/tile_ast_print.cpp | 17 ++ clang/test/OpenMP/tile_codegen.cpp| 216 -- clang/test/OpenMP/tile_messages.cpp | 50 +++- openmp/runtime/test/transform/tile/intfor.c | 187 +++ .../test/transform/tile/negtile_intfor.c | 44 .../tile/parallel-wsloop-collapse-intfor.cpp | 100 9 files changed, 737 insertions(+), 72 deletions(-) create mode 100644 openmp/runtime/test/transform/tile/intfor.c create mode 100644 openmp/runtime/test/transform/tile/negtile_intfor.c create mode 100644 openmp/runtime/test/transform/tile/parallel-wsloop-collapse-intfor.cpp diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index daefd4f28f011a..1b500c11457f4d 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3553,6 +3553,23 @@ class Parser : public CodeCompletionHandler { OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, bool ParseOnly); + /// Parses a clause consisting of a list of expressions. + /// + /// \param Kind The clause to parse. + /// \param ClauseNameLoc [out] The location of the clause name. + /// \param OpenLoc [out] The location of '('. + /// \param CloseLoc [out] The location of ')'. + /// \param Exprs [out] The parsed expressions. + /// \param ReqIntConst If true, each expression must be an integer constant. + /// + /// \return Whether the clause was parsed successfully. + bool ParseOpenMPExprListClause(OpenMPClauseKind Kind, + SourceLocation &ClauseNameLoc, + SourceLocation &OpenLoc, + SourceLocation &CloseLoc, + SmallVectorImpl &Exprs, + bool ReqIntConst = false); + /// Parses and creates OpenMP 5.0 iterators expression: /// = 'iterator' '(' { [ ] identifier = /// }+ ')' diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 18ba1185ee8de7..b8b32f9546c4fb 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -3107,34 +3107,14 @@ bool Parser::ParseOpenMPSimpleVarList( } OMPClause *Parser::ParseOpenMPSizesClause() { - SourceLocation ClauseNameLoc = ConsumeToken(); + SourceLocation ClauseNameLoc, OpenLoc, CloseLoc; SmallVector ValExprs; - - BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end); - if (T.consumeOpen()) { -Diag(Tok, diag::err_expected) << tok::l_paren; + if (ParseOpenMPExprListClause(OMPC_sizes, ClauseNameLoc, OpenLoc, CloseLoc, +ValExprs)) return nullptr; - } - - while (true) { -ExprResult Val = ParseConstantExpression(); -if (!Val.isUsable()) { - T.skipToEnd(); - return nullptr; -} - -ValExprs.push_back(Val.get()); - -if (Tok.is(tok::r_paren) || Tok.is(tok::annot_pragma_openmp_end)) - break; - -ExpectAndConsume(tok::comma); - } - - T.consumeClose(); - return Actions.OpenMP().ActOnOpenMPSizesClause( - ValExprs, ClauseNameLoc, T.getOpenLocation(), T.getCloseLocation()); + return Actions.OpenMP().ActOnOpenMPSizesClause(ValExprs, ClauseNameLoc, + OpenLoc, CloseLoc); } OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { @@ -4991,3 +4971,38 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, OMPVarListLocTy Locs(Loc, LOpen, Data.RLoc); return Action
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/82853 ___ 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][MLIR] Initial derived type member map support (PR #82853)
https://github.com/skatrak approved this pull request. Thank you Andrew, you've addressed all my concerns so this LGTM. https://github.com/llvm/llvm-project/pull/82853 ___ 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][MLIR] Initial derived type member map support (PR #82853)
@@ -97,7 +269,7 @@ getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject) { if (auto *arrayEle = Fortran::parser::Unwrap( designator)) { - sym = GetFirstName(arrayEle->base).symbol; + sym = GetLastName(arrayEle->base).symbol; skatrak wrote: Thank you for the explanation, it does make a lot of sense to me (and hopefully to whoever comes by and reads the comment later). https://github.com/llvm/llvm-project/pull/82853 ___ 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][MLIR] Initial derived type member map support (PR #82853)
@@ -116,6 +119,216 @@ void gatherFuncAndVarSyms( symbolAndClause.emplace_back(clause, *object.id()); } +mlir::omp::MapInfoOp +createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc, +mlir::Value baseAddr, mlir::Value varPtrPtr, std::string name, +llvm::ArrayRef bounds, +llvm::ArrayRef members, +mlir::DenseIntElementsAttr membersIndex, uint64_t mapType, +mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy, +bool partialMap) { + if (auto boxTy = baseAddr.getType().dyn_cast()) { +baseAddr = builder.create(loc, baseAddr); +retTy = baseAddr.getType(); + } + + mlir::TypeAttr varType = mlir::TypeAttr::get( + llvm::cast(retTy).getElementType()); + + mlir::omp::MapInfoOp op = builder.create( + loc, retTy, baseAddr, varType, varPtrPtr, members, membersIndex, bounds, + builder.getIntegerAttr(builder.getIntegerType(64, false), mapType), + builder.getAttr(mapCaptureType), + builder.getStringAttr(name), builder.getBoolAttr(partialMap)); + + return op; +} + +static int +getComponentPlacementInParent(const Fortran::semantics::Symbol *componentSym) { + const auto *derived = + componentSym->owner() + .derivedTypeSpec() + ->typeSymbol() + .detailsIf(); + assert(derived && + "expected derived type details when processing component symbol"); + for (auto [placement, name] : llvm::enumerate(derived->componentNames())) +if (name == componentSym->name()) + return placement; + return -1; +} + +static std::optional +getComponentObject(std::optional object, + Fortran::semantics::SemanticsContext &semaCtx) { + if (!object) +return std::nullopt; + + auto ref = evaluate::ExtractDataRef(*object.value().ref()); + if (!ref) +return std::nullopt; + + if (std::holds_alternative(ref->u)) +return object; + + auto baseObj = getBaseObject(object.value(), semaCtx); + if (!baseObj) +return std::nullopt; + + return getComponentObject(baseObj.value(), semaCtx); +} + +static void +generateMemberPlacementIndices(const Object &object, + llvm::SmallVectorImpl &indices, + Fortran::semantics::SemanticsContext &semaCtx) { + auto compObj = getComponentObject(object, semaCtx); + while (compObj) { +indices.push_back(getComponentPlacementInParent(compObj->id())); +compObj = +getComponentObject(getBaseObject(compObj.value(), semaCtx), semaCtx); + } + + indices = llvm::SmallVector{llvm::reverse(indices)}; +} + +void addChildIndexAndMapToParent( +const omp::Object &object, +std::map> &parentMemberIndices, +mlir::omp::MapInfoOp &mapOp, +Fortran::semantics::SemanticsContext &semaCtx) { + std::optional dataRef = + ExtractDataRef(object.designator); + assert(dataRef.has_value() && + "DataRef could not be extracted during mapping of derived type " + "cannot proceed"); + const Fortran::semantics::Symbol *parentSym = &dataRef->GetFirstSymbol(); + assert(parentSym && "Could not find parent symbol during lower of " + "a component member in OpenMP map clause"); + llvm::SmallVector indices; + generateMemberPlacementIndices(object, indices, semaCtx); + parentMemberIndices[parentSym].push_back({indices, mapOp}); +} + +static void calculateShapeAndFillIndices( +llvm::SmallVectorImpl &shape, +llvm::SmallVectorImpl &memberPlacementData) { + shape.push_back(memberPlacementData.size()); + size_t largestIndicesSize = + std::max_element(memberPlacementData.begin(), memberPlacementData.end(), + [](auto a, auto b) { + return a.memberPlacementIndices.size() < +b.memberPlacementIndices.size(); + }) + ->memberPlacementIndices.size(); + shape.push_back(largestIndicesSize); + + // DenseElementsAttr expects a rectangular shape for the data, so all + // index lists have to be of the same length, this emplaces -1 as filler skatrak wrote: ```suggestion // index lists have to be of the same length, this emplaces -1 as filler. ``` https://github.com/llvm/llvm-project/pull/82853 ___ 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][MLIR] Initial derived type member map support (PR #82853)
@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms( symbolAndClause.emplace_back(clause, *object.id()); } +int getComponentPlacementInParent( +const Fortran::semantics::Symbol *componentSym) { + const auto *derived = + componentSym->owner() + .derivedTypeSpec() + ->typeSymbol() + .detailsIf(); + assert(derived && + "expected derived type details when processing component symbol"); + int placement = 0; + for (auto t : derived->componentNames()) { +if (t == componentSym->name()) + return placement; +placement++; + } + return -1; +} + +std::optional +getCompObjOrNull(std::optional object, + Fortran::semantics::SemanticsContext &semaCtx) { + if (!object) +return std::nullopt; + + auto ref = evaluate::ExtractDataRef(*object.value().ref()); + if (!ref) +return std::nullopt; + + if (std::get_if(&ref->u)) +return object; + + auto baseObj = getBaseObject(object.value(), semaCtx); + if (!baseObj) +return std::nullopt; + + return getCompObjOrNull(baseObj.value(), semaCtx); +} + +llvm::SmallVector +generateMemberPlacementIndices(const Object &object, + Fortran::semantics::SemanticsContext &semaCtx) { + std::list indices; + auto compObj = getCompObjOrNull(object, semaCtx); + while (compObj) { +indices.push_front(getComponentPlacementInParent(compObj->id())); +compObj = +getCompObjOrNull(getBaseObject(compObj.value(), semaCtx), semaCtx); + } + + return llvm::SmallVector{std::begin(indices), std::end(indices)}; +} + +static void calculateShapeAndFillIndices( +llvm::SmallVectorImpl &shape, +llvm::SmallVector &memberPlacementData) { skatrak wrote: You're right, elements in `llvm::ArrayRef` are read-only. Sorry about that, I hope I didn't make you waste too much time trying this! https://github.com/llvm/llvm-project/pull/82853 ___ 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][MLIR] Initial derived type member map support (PR #82853)
@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms( symbolAndClause.emplace_back(clause, *object.id()); } +int getComponentPlacementInParent( +const Fortran::semantics::Symbol *componentSym) { + const auto *derived = + componentSym->owner() + .derivedTypeSpec() + ->typeSymbol() + .detailsIf(); + assert(derived && + "expected derived type details when processing component symbol"); + int placement = 0; + for (auto t : derived->componentNames()) { +if (t == componentSym->name()) + return placement; +placement++; + } + return -1; +} + +std::optional +getCompObjOrNull(std::optional object, + Fortran::semantics::SemanticsContext &semaCtx) { + if (!object) +return std::nullopt; + + auto ref = evaluate::ExtractDataRef(*object.value().ref()); + if (!ref) +return std::nullopt; + + if (std::get_if(&ref->u)) +return object; + + auto baseObj = getBaseObject(object.value(), semaCtx); + if (!baseObj) +return std::nullopt; + + return getCompObjOrNull(baseObj.value(), semaCtx); +} + +llvm::SmallVector +generateMemberPlacementIndices(const Object &object, + Fortran::semantics::SemanticsContext &semaCtx) { + std::list indices; + auto compObj = getCompObjOrNull(object, semaCtx); + while (compObj) { +indices.push_front(getComponentPlacementInParent(compObj->id())); +compObj = +getCompObjOrNull(getBaseObject(compObj.value(), semaCtx), semaCtx); + } + + return llvm::SmallVector{std::begin(indices), std::end(indices)}; +} + +static void calculateShapeAndFillIndices( +llvm::SmallVectorImpl &shape, +llvm::SmallVector &memberPlacementData) { + shape.push_back(memberPlacementData.size()); + size_t largestIndicesSize = + std::max_element(memberPlacementData.begin(), memberPlacementData.end(), + [](auto a, auto b) { + return a.memberPlacementIndices.size() < +b.memberPlacementIndices.size(); + }) + ->memberPlacementIndices.size(); + shape.push_back(largestIndicesSize); + + // DenseElementsAttr expects a rectangular shape for the data, so all + // index lists have to be of the same length, this implaces -1 as filler + // values + for (auto &v : memberPlacementData) +if (v.memberPlacementIndices.size() < largestIndicesSize) { + auto *prevEnd = v.memberPlacementIndices.end(); + v.memberPlacementIndices.resize(largestIndicesSize); + std::fill(prevEnd, v.memberPlacementIndices.end(), -1); +} +} + +mlir::DenseIntElementsAttr createDenseElementsAttrFromIndices( +llvm::SmallVector &memberPlacementData, +fir::FirOpBuilder &builder) { + llvm::SmallVector shape; + calculateShapeAndFillIndices(shape, memberPlacementData); + + llvm::SmallVector indicesFlattened = std::accumulate( + memberPlacementData.begin(), memberPlacementData.end(), + llvm::SmallVector(), + [](llvm::SmallVector &x, OmpMapMemberIndicesData &y) { +x.insert(x.end(), y.memberPlacementIndices.begin(), + y.memberPlacementIndices.end()); +return x; + }); + + return mlir::DenseIntElementsAttr::get( + mlir::VectorType::get(llvm::ArrayRef(shape), +mlir::IntegerType::get(builder.getContext(), 32)), + llvm::ArrayRef(indicesFlattened)); +} + +void insertChildMapInfoIntoParent( +Fortran::lower::AbstractConverter &converter, +std::map> &parentMemberIndices, +llvm::SmallVectorImpl &mapOperands, +llvm::SmallVectorImpl *mapSymTypes, +llvm::SmallVectorImpl *mapSymLocs, +llvm::SmallVectorImpl *mapSymbols) { + for (auto indices : parentMemberIndices) { +bool parentExists = false; +size_t parentIdx; +for (parentIdx = 0; parentIdx < mapSymbols->size(); ++parentIdx) + if ((*mapSymbols)[parentIdx] == indices.first) { +parentExists = true; +break; + } + +if (parentExists) { + auto mapOp = mlir::dyn_cast( skatrak wrote: That's a good point. If you have a more informative message for this case, I'm fine with you putting that in a separate assert. https://github.com/llvm/llvm-project/pull/82853 ___ 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] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)
https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/91345 >From a2aa6950ce3880b8e669025d95ac9e72245e26a7 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 7 May 2024 16:42:41 +0200 Subject: [PATCH 1/2] Allow non-constant tile sizes --- clang/include/clang/Parse/Parser.h| 17 ++ clang/lib/Parse/ParseOpenMP.cpp | 65 -- clang/lib/Sema/SemaOpenMP.cpp | 113 +++-- clang/test/OpenMP/tile_ast_print.cpp | 17 ++ clang/test/OpenMP/tile_codegen.cpp| 216 -- clang/test/OpenMP/tile_messages.cpp | 50 +++- openmp/runtime/test/transform/tile/intfor.c | 187 +++ .../test/transform/tile/negtile_intfor.c | 44 .../tile/parallel-wsloop-collapse-intfor.cpp | 100 9 files changed, 737 insertions(+), 72 deletions(-) create mode 100644 openmp/runtime/test/transform/tile/intfor.c create mode 100644 openmp/runtime/test/transform/tile/negtile_intfor.c create mode 100644 openmp/runtime/test/transform/tile/parallel-wsloop-collapse-intfor.cpp diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index daefd4f28f011..1b500c11457f4 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3553,6 +3553,23 @@ class Parser : public CodeCompletionHandler { OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, bool ParseOnly); + /// Parses a clause consisting of a list of expressions. + /// + /// \param Kind The clause to parse. + /// \param ClauseNameLoc [out] The location of the clause name. + /// \param OpenLoc [out] The location of '('. + /// \param CloseLoc [out] The location of ')'. + /// \param Exprs [out] The parsed expressions. + /// \param ReqIntConst If true, each expression must be an integer constant. + /// + /// \return Whether the clause was parsed successfully. + bool ParseOpenMPExprListClause(OpenMPClauseKind Kind, + SourceLocation &ClauseNameLoc, + SourceLocation &OpenLoc, + SourceLocation &CloseLoc, + SmallVectorImpl &Exprs, + bool ReqIntConst = false); + /// Parses and creates OpenMP 5.0 iterators expression: /// = 'iterator' '(' { [ ] identifier = /// }+ ')' diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 18ba1185ee8de..b8b32f9546c4f 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -3107,34 +3107,14 @@ bool Parser::ParseOpenMPSimpleVarList( } OMPClause *Parser::ParseOpenMPSizesClause() { - SourceLocation ClauseNameLoc = ConsumeToken(); + SourceLocation ClauseNameLoc, OpenLoc, CloseLoc; SmallVector ValExprs; - - BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end); - if (T.consumeOpen()) { -Diag(Tok, diag::err_expected) << tok::l_paren; + if (ParseOpenMPExprListClause(OMPC_sizes, ClauseNameLoc, OpenLoc, CloseLoc, +ValExprs)) return nullptr; - } - - while (true) { -ExprResult Val = ParseConstantExpression(); -if (!Val.isUsable()) { - T.skipToEnd(); - return nullptr; -} - -ValExprs.push_back(Val.get()); - -if (Tok.is(tok::r_paren) || Tok.is(tok::annot_pragma_openmp_end)) - break; - -ExpectAndConsume(tok::comma); - } - - T.consumeClose(); - return Actions.OpenMP().ActOnOpenMPSizesClause( - ValExprs, ClauseNameLoc, T.getOpenLocation(), T.getCloseLocation()); + return Actions.OpenMP().ActOnOpenMPSizesClause(ValExprs, ClauseNameLoc, + OpenLoc, CloseLoc); } OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { @@ -4991,3 +4971,38 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, OMPVarListLocTy Locs(Loc, LOpen, Data.RLoc); return Actions.OpenMP().ActOnOpenMPVarListClause(Kind, Vars, Locs, Data); } + +bool Parser::ParseOpenMPExprListClause(OpenMPClauseKind Kind, + SourceLocation &ClauseNameLoc, + SourceLocation &OpenLoc, + SourceLocation &CloseLoc, + SmallVectorImpl &Exprs, + bool ReqIntConst) { + assert(getOpenMPClauseName(Kind) == PP.getSpelling(Tok) && + "Expected parsing to start at clause name"); + ClauseNameLoc = ConsumeToken(); + + // Parse inside of '(' and ')'. + BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end); + if (T.consumeOpen()) { +Diag(Tok, diag::err_expected) << tok::l_paren; +return true; + } + + // Parse the list with interleaved comma
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
agozillon wrote: Thank you all very much for the reviews across the PR stack! I believe I have enough acceptance for the PR stack to land now, with at least two reviewers per PR. So I will seek to land this PR stack in the next few days (on Thursday) I'll perform the final adjustments requested, rebase and test prior to landing. However, if anyone has any concerns or further review comments for any segments, please mention them now and I can hold off the PR until they are addressed if necessary :-) https://github.com/llvm/llvm-project/pull/82853 ___ 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] [llvm] release/18.x [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (#90702) (PR #91349)
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/91349 This addresses an issue where the explicit alignment of 2 (for C++ ABI reasons) was being propagated to the back end and causing under-aligned functions (in special sections). This is an alternate approach suggested by @efriedma-quic in PR #90415. Fixes #90358 (cherry picked from commit ddecadabebdd4b301bd65534b58009e57ac1bbe5) >From 40b02c07af93f321e2d8f4d7ff506c8f52257b69 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Sun, 5 May 2024 19:05:15 -0700 Subject: [PATCH] [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (#90702) This addresses an issue where the explicit alignment of 2 (for C++ ABI reasons) was being propagated to the back end and causing under-aligned functions (in special sections). This is an alternate approach suggested by @efriedma-quic in PR #90415. Fixes #90358 (cherry picked from commit ddecadabebdd4b301bd65534b58009e57ac1bbe5) --- clang/lib/Basic/Targets/AArch64.cpp | 12 clang/test/CodeGen/aarch64-type-sizes.c | 2 +- clang/test/CodeGen/coff-aarch64-type-sizes.c | 2 +- clang/test/CodeGen/target-data.c | 6 ++-- clang/test/CodeGenCXX/member-alignment.cpp| 6 ++-- ...ibute_parallel_for_num_threads_codegen.cpp | 20 ++--- ..._parallel_for_simd_num_threads_codegen.cpp | 30 +-- llvm/lib/IR/AutoUpgrade.cpp | 8 + .../Target/AArch64/AArch64TargetMachine.cpp | 8 ++--- .../Bitcode/DataLayoutUpgradeTest.cpp | 9 -- 10 files changed, 57 insertions(+), 46 deletions(-) diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index f5a5d689fa095..82b1df1a02179 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -1442,11 +1442,11 @@ AArch64leTargetInfo::AArch64leTargetInfo(const llvm::Triple &Triple, void AArch64leTargetInfo::setDataLayout() { if (getTriple().isOSBinFormatMachO()) { if(getTriple().isArch32Bit()) - resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128", "_"); + resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128-Fn32", "_"); else - resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128", "_"); + resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128-Fn32", "_"); } else -resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"); + resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"); } void AArch64leTargetInfo::getTargetDefines(const LangOptions &Opts, @@ -1469,7 +1469,7 @@ void AArch64beTargetInfo::getTargetDefines(const LangOptions &Opts, void AArch64beTargetInfo::setDataLayout() { assert(!getTriple().isOSBinFormatMachO()); - resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"); + resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"); } WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple, @@ -1492,8 +1492,8 @@ WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple, void WindowsARM64TargetInfo::setDataLayout() { resetDataLayout(Triple.isOSBinFormatMachO() - ? "e-m:o-i64:64-i128:128-n32:64-S128" - : "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128", + ? "e-m:o-i64:64-i128:128-n32:64-S128-Fn32" + : "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32", Triple.isOSBinFormatMachO() ? "_" : ""); } diff --git a/clang/test/CodeGen/aarch64-type-sizes.c b/clang/test/CodeGen/aarch64-type-sizes.c index 7a2508c6e1587..a40423c1f8deb 100644 --- a/clang/test/CodeGen/aarch64-type-sizes.c +++ b/clang/test/CodeGen/aarch64-type-sizes.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | FileCheck %s // char by definition has size 1 -// CHECK: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +// CHECK: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" int check_short(void) { return sizeof(short); diff --git a/clang/test/CodeGen/coff-aarch64-type-sizes.c b/clang/test/CodeGen/coff-aarch64-type-sizes.c index f8286618fc8f7..9cb0ddbaef3f6 100644 --- a/clang/test/CodeGen/coff-aarch64-type-sizes.c +++ b/clang/test/CodeGen/coff-aarch64-type-sizes.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -w -o - %s | FileCheck %s -// CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128" +// CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" // CHECK: target triple = "aarch64-unknown-windows-msvc" int check_short(void) { diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c index acff367d50eb9..53049fde75426 100644 --- a/clang/test/CodeGen/target-data.c +++ b/clang/test/CodeGen/target-d
[llvm-branch-commits] [clang] [llvm] release/18.x [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (#90702) (PR #91349)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-aarch64 Author: AtariDreams (AtariDreams) Changes This addresses an issue where the explicit alignment of 2 (for C++ ABI reasons) was being propagated to the back end and causing under-aligned functions (in special sections). This is an alternate approach suggested by @efriedma-quic in PR #90415. Fixes #90358 (cherry picked from commit ddecadabebdd4b301bd65534b58009e57ac1bbe5) --- Patch is 21.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/91349.diff 10 Files Affected: - (modified) clang/lib/Basic/Targets/AArch64.cpp (+6-6) - (modified) clang/test/CodeGen/aarch64-type-sizes.c (+1-1) - (modified) clang/test/CodeGen/coff-aarch64-type-sizes.c (+1-1) - (modified) clang/test/CodeGen/target-data.c (+3-3) - (modified) clang/test/CodeGenCXX/member-alignment.cpp (+3-3) - (modified) clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp (+10-10) - (modified) clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp (+15-15) - (modified) llvm/lib/IR/AutoUpgrade.cpp (+8) - (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+4-4) - (modified) llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp (+6-3) ``diff diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index f5a5d689fa095..82b1df1a02179 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -1442,11 +1442,11 @@ AArch64leTargetInfo::AArch64leTargetInfo(const llvm::Triple &Triple, void AArch64leTargetInfo::setDataLayout() { if (getTriple().isOSBinFormatMachO()) { if(getTriple().isArch32Bit()) - resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128", "_"); + resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128-Fn32", "_"); else - resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128", "_"); + resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128-Fn32", "_"); } else -resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"); + resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"); } void AArch64leTargetInfo::getTargetDefines(const LangOptions &Opts, @@ -1469,7 +1469,7 @@ void AArch64beTargetInfo::getTargetDefines(const LangOptions &Opts, void AArch64beTargetInfo::setDataLayout() { assert(!getTriple().isOSBinFormatMachO()); - resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"); + resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"); } WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple, @@ -1492,8 +1492,8 @@ WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple, void WindowsARM64TargetInfo::setDataLayout() { resetDataLayout(Triple.isOSBinFormatMachO() - ? "e-m:o-i64:64-i128:128-n32:64-S128" - : "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128", + ? "e-m:o-i64:64-i128:128-n32:64-S128-Fn32" + : "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32", Triple.isOSBinFormatMachO() ? "_" : ""); } diff --git a/clang/test/CodeGen/aarch64-type-sizes.c b/clang/test/CodeGen/aarch64-type-sizes.c index 7a2508c6e1587..a40423c1f8deb 100644 --- a/clang/test/CodeGen/aarch64-type-sizes.c +++ b/clang/test/CodeGen/aarch64-type-sizes.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | FileCheck %s // char by definition has size 1 -// CHECK: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +// CHECK: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" int check_short(void) { return sizeof(short); diff --git a/clang/test/CodeGen/coff-aarch64-type-sizes.c b/clang/test/CodeGen/coff-aarch64-type-sizes.c index f8286618fc8f7..9cb0ddbaef3f6 100644 --- a/clang/test/CodeGen/coff-aarch64-type-sizes.c +++ b/clang/test/CodeGen/coff-aarch64-type-sizes.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -w -o - %s | FileCheck %s -// CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128" +// CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" // CHECK: target triple = "aarch64-unknown-windows-msvc" int check_short(void) { diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c index acff367d50eb9..53049fde75426 100644 --- a/clang/test/CodeGen/target-data.c +++ b/clang/test/CodeGen/target-data.c @@ -185,15 +185,15 @@ // RUN: %clang_cc1 -triple arm64-unknown -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=AARCH64 -// AARCH64: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +// AARCH64: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" // RUN: %clang_cc1 -triple ar
[llvm-branch-commits] [llvm] [Inline][Cloning] Drop incompatible attributes from `NewFunc` (PR #91350)
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/91350 Performing `instSimplify` while cloning is unsafe due to incomplete remapping (as reported in #87534). Ideally, `instSimplify` ought to reason on the updated newly-cloned function, after returns have been rewritten and callee entry basic block / call-site have been fixed up. This is in contrast to `CloneAndPruneIntoFromInst` behaviour, which is inherently expected to clone basic blocks, with pruning on top of – if any –, and not actually fixing up returns / CFG, which should be up to the Inliner. We may solve this by letting `instSimplify` work on the newly-cloned function, while maintaining old function attributes, so as to avoid inconsistencies between the yet-to-be-solved return type, and new function ret type attributes. (cherry picked from commit 1bb929833b18db4a26a4d145d7270597cb5d48ce) >From 8d591584cbecb9a2c4a2b9e1ace24e13974ad7f5 Mon Sep 17 00:00:00 2001 From: Antonio Frighetto Date: Mon, 29 Apr 2024 17:53:29 +0200 Subject: [PATCH] [Inline][Cloning] Drop incompatible attributes from `NewFunc` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Performing `instSimplify` while cloning is unsafe due to incomplete remapping (as reported in #87534). Ideally, `instSimplify` ought to reason on the updated newly-cloned function, after returns have been rewritten and callee entry basic block / call-site have been fixed up. This is in contrast to `CloneAndPruneIntoFromInst` behaviour, which is inherently expected to clone basic blocks, with pruning on top of – if any –, and not actually fixing up returns / CFG, which should be up to the Inliner. We may solve this by letting `instSimplify` work on the newly-cloned function, while maintaining old function attributes, so as to avoid inconsistencies between the yet-to-be-solved return type, and new function ret type attributes. (cherry picked from commit 1bb929833b18db4a26a4d145d7270597cb5d48ce) --- llvm/lib/Transforms/Utils/CloneFunction.cpp | 21 .../Inline/inline-drop-attributes.ll | 32 +++ 2 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 llvm/test/Transforms/Inline/inline-drop-attributes.ll diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index c0f64fa58..a6821c9df8a92 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -17,6 +17,7 @@ #include "llvm/Analysis/DomTreeUpdater.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/IR/AttributeMask.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DebugInfo.h" @@ -823,13 +824,16 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, } } - // Make a second pass over the PHINodes now that all of them have been - // remapped into the new function, simplifying the PHINode and performing any - // recursive simplifications exposed. This will transparently update the - // WeakTrackingVH in the VMap. Notably, we rely on that so that if we coalesce - // two PHINodes, the iteration over the old PHIs remains valid, and the - // mapping will just map us to the new node (which may not even be a PHI - // node). + // Drop all incompatible return attributes that cannot be applied to NewFunc + // during cloning, so as to allow instruction simplification to reason on the + // old state of the function. The original attributes are restored later. + AttributeMask IncompatibleAttrs = + AttributeFuncs::typeIncompatible(OldFunc->getReturnType()); + AttributeList Attrs = NewFunc->getAttributes(); + NewFunc->removeRetAttrs(IncompatibleAttrs); + + // As phi-nodes have been now remapped, allow incremental simplification of + // newly-cloned instructions. const DataLayout &DL = NewFunc->getParent()->getDataLayout(); SmallSetVector Worklist; for (unsigned Idx = 0, Size = PHIToResolve.size(); Idx != Size; ++Idx) @@ -871,6 +875,9 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, VMap[OrigV] = I; } + // Restore attributes. + NewFunc->setAttributes(Attrs); + // Remap debug intrinsic operands now that all values have been mapped. // Doing this now (late) preserves use-before-defs in debug intrinsics. If // we didn't do this, ValueAsMetadata(use-before-def) operands would be diff --git a/llvm/test/Transforms/Inline/inline-drop-attributes.ll b/llvm/test/Transforms/Inline/inline-drop-attributes.ll new file mode 100644 index 0..9a451f4b8699a --- /dev/null +++ b/llvm/test/Transforms/Inline/inline-drop-attributes.ll @@ -0,0 +1,32 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -passes=inline -S | FileCheck %s +; RUN: opt < %s -passes='cgscc(inline)'
[llvm-branch-commits] [llvm] [Inline][Cloning] Drop incompatible attributes from `NewFunc` (PR #91350)
llvmbot wrote: @llvm/pr-subscribers-llvm-transforms Author: AtariDreams (AtariDreams) Changes Performing `instSimplify` while cloning is unsafe due to incomplete remapping (as reported in #87534). Ideally, `instSimplify` ought to reason on the updated newly-cloned function, after returns have been rewritten and callee entry basic block / call-site have been fixed up. This is in contrast to `CloneAndPruneIntoFromInst` behaviour, which is inherently expected to clone basic blocks, with pruning on top of – if any –, and not actually fixing up returns / CFG, which should be up to the Inliner. We may solve this by letting `instSimplify` work on the newly-cloned function, while maintaining old function attributes, so as to avoid inconsistencies between the yet-to-be-solved return type, and new function ret type attributes. (cherry picked from commit 1bb929833b18db4a26a4d145d7270597cb5d48ce) --- Full diff: https://github.com/llvm/llvm-project/pull/91350.diff 2 Files Affected: - (modified) llvm/lib/Transforms/Utils/CloneFunction.cpp (+14-7) - (added) llvm/test/Transforms/Inline/inline-drop-attributes.ll (+32) ``diff diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index c0f64fa587..a6821c9df8a926 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -17,6 +17,7 @@ #include "llvm/Analysis/DomTreeUpdater.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/IR/AttributeMask.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DebugInfo.h" @@ -823,13 +824,16 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, } } - // Make a second pass over the PHINodes now that all of them have been - // remapped into the new function, simplifying the PHINode and performing any - // recursive simplifications exposed. This will transparently update the - // WeakTrackingVH in the VMap. Notably, we rely on that so that if we coalesce - // two PHINodes, the iteration over the old PHIs remains valid, and the - // mapping will just map us to the new node (which may not even be a PHI - // node). + // Drop all incompatible return attributes that cannot be applied to NewFunc + // during cloning, so as to allow instruction simplification to reason on the + // old state of the function. The original attributes are restored later. + AttributeMask IncompatibleAttrs = + AttributeFuncs::typeIncompatible(OldFunc->getReturnType()); + AttributeList Attrs = NewFunc->getAttributes(); + NewFunc->removeRetAttrs(IncompatibleAttrs); + + // As phi-nodes have been now remapped, allow incremental simplification of + // newly-cloned instructions. const DataLayout &DL = NewFunc->getParent()->getDataLayout(); SmallSetVector Worklist; for (unsigned Idx = 0, Size = PHIToResolve.size(); Idx != Size; ++Idx) @@ -871,6 +875,9 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, VMap[OrigV] = I; } + // Restore attributes. + NewFunc->setAttributes(Attrs); + // Remap debug intrinsic operands now that all values have been mapped. // Doing this now (late) preserves use-before-defs in debug intrinsics. If // we didn't do this, ValueAsMetadata(use-before-def) operands would be diff --git a/llvm/test/Transforms/Inline/inline-drop-attributes.ll b/llvm/test/Transforms/Inline/inline-drop-attributes.ll new file mode 100644 index 00..9a451f4b8699a7 --- /dev/null +++ b/llvm/test/Transforms/Inline/inline-drop-attributes.ll @@ -0,0 +1,32 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -passes=inline -S | FileCheck %s +; RUN: opt < %s -passes='cgscc(inline)' -S | FileCheck %s + +define void @callee() { +; CHECK-LABEL: define void @callee() { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[VAL_PTR:%.*]] = load ptr, ptr null, align 8 +; CHECK-NEXT:[[CMP:%.*]] = icmp eq ptr [[VAL_PTR]], null +; CHECK-NEXT:[[VAL:%.*]] = load i64, ptr null, align 8 +; CHECK-NEXT:[[SEL:%.*]] = select i1 [[CMP]], i64 undef, i64 [[VAL]] +; CHECK-NEXT:ret void +; +entry: + %val_ptr = load ptr, ptr null, align 8 + %cmp = icmp eq ptr %val_ptr, null + %val = load i64, ptr null, align 8 + %sel = select i1 %cmp, i64 undef, i64 %val + ret void +} + +define noundef i1 @caller() { +; CHECK-LABEL: define noundef i1 @caller() { +; CHECK-NEXT:[[VAL_PTR_I:%.*]] = load ptr, ptr null, align 8 +; CHECK-NEXT:[[CMP_I:%.*]] = icmp eq ptr [[VAL_PTR_I]], null +; CHECK-NEXT:[[VAL_I:%.*]] = load i64, ptr null, align 8 +; CHECK-NEXT:[[SEL_I:%.*]] = select i1 [[CMP_I]], i64 undef, i64 [[VAL_I]] +; CHECK-NEXT:ret i1 false +; + call void @callee() + ret i1 false +} `` https://github.com/llvm/llvm-project/pull/91350 ___
[llvm-branch-commits] [llvm] release/18.x: [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) (PR #91161)
https://github.com/RKSimon approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/91161 ___ 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] release/18.x: [AArc64][GlobalISel] Fix legalizer assert for G_INSERT_VECTOR_ELT (PR #90827)
aemerson wrote: @nikic do you know the procedure here? https://github.com/llvm/llvm-project/pull/90827 ___ 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][CallGraphSection] Add type id metadata to indirect call and targets (PR #87573)
@@ -5693,6 +5699,36 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, AllocAlignAttrEmitter AllocAlignAttrEmitter(*this, TargetDecl, CallArgs); Attrs = AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute(Attrs); + if (CGM.getCodeGenOpts().CallGraphSection) { +// Create operand bundle only for indirect calls, not for all +if (callOrInvoke && *callOrInvoke && (*callOrInvoke)->isIndirectCall()) { arsenm wrote: This double null check, for what I assume is an std::optional is really ugly, but I don't actually see where it's defined. Should either just not bother with the optional or without the second check? https://github.com/llvm/llvm-project/pull/87573 ___ 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][CallGraphSection] Add type id metadata to indirect call and targets (PR #87573)
https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/87573 ___ 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] Revise IDE folder structure (PR #89743)
https://github.com/AaronBallman commented: With this patch, I get errors when loading a visual studio solution generated with these change, and all of clang's libraries are placed at the top level. The error is a dialog box saying "The solution already contains an item named 'clang'." Another thing (that is existing behavior) worth noting is that at some point, we lost the ability to browse directly to files in Visual Studio. Instead of going to `Clang Libraries->clangDriver->Source Files->ToolChain.cpp`, you have to go to `Object Libraries->obj.clangDriver->Source Files->ToolChain.cpp` which is pretty strange. Your patch doesn't change this, but if we're correcting folder structure behavior, we should probably address that at the same time if we can. https://github.com/llvm/llvm-project/pull/89743 ___ 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] release/18.x: Prepend all library intrinsics with `#` when building for Arm64EC (PR #88016)
tstellar wrote: Hi @dpaoliello I'm seeing some "Illegal Instruction" errors when running the bolt tests on aarch64. Do you think there is any chance this commit could be the cause? It's the only one between 18.1.3 and 18.1.4 that touches the aarch64 code gen. Here is the full log: https://kojipkgs.fedoraproject.org//work/tasks/3490/117353490/build.log https://github.com/llvm/llvm-project/pull/88016 ___ 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] release/18.x: Prepend all library intrinsics with `#` when building for Arm64EC (PR #88016)
dpaoliello wrote: > Hi @dpaoliello I'm seeing some "Illegal Instruction" errors when running the > bolt tests on aarch64. Do you think there is any chance this commit could be > the cause? It's the only one between 18.1.3 and 18.1.4 that touches the > aarch64 code gen. Here is the full log: > > https://kojipkgs.fedoraproject.org//work/tasks/3490/117353490/build.log @tstellar I wouldn't think so: the code path being changed here is guarded by a check for the Arm64EC subtarget on Windows, so it should never be triggered when building for AArch64 Linux. Additionally, if somehow this code was triggered, it should only result in different names for intrinsics (leading to unresolved symbols) rather than any change to which instruction is emitted. https://github.com/llvm/llvm-project/pull/88016 ___ 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] 5d04944 - Revert "SystemZ: Fold copy of vector immediate to gr128 (#90706)"
Author: Vitaly Buka Date: 2024-05-04T22:13:31-07:00 New Revision: 5d0494479769c5bb5d6f72822f7673be9b77d49f URL: https://github.com/llvm/llvm-project/commit/5d0494479769c5bb5d6f72822f7673be9b77d49f DIFF: https://github.com/llvm/llvm-project/commit/5d0494479769c5bb5d6f72822f7673be9b77d49f.diff LOG: Revert "SystemZ: Fold copy of vector immediate to gr128 (#90706)" This reverts commit 49c5f4d56a89278fcc426cabbeeec33e0915980e. Added: Modified: llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp llvm/lib/Target/SystemZ/SystemZInstrInfo.h Removed: llvm/test/CodeGen/SystemZ/fold-copy-vector-immediate.mir diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp index 0d1aab89c5de89..c18d4e7aa73e11 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -640,51 +640,6 @@ bool SystemZInstrInfo::foldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, Register Reg, MachineRegisterInfo *MRI) const { unsigned DefOpc = DefMI.getOpcode(); - - if (DefOpc == SystemZ::VGBM) { -int64_t ImmVal = DefMI.getOperand(1).getImm(); -if (ImmVal != 0) // TODO: Handle other values - return false; - -// Fold gr128 = COPY (vr128 VGBM imm) -// -// %tmp:gr64 = LGHI 0 -// to gr128 = REG_SEQUENCE %tmp, %tmp -assert(DefMI.getOperand(0).getReg() == Reg); - -if (!UseMI.isCopy()) - return false; - -Register CopyDstReg = UseMI.getOperand(0).getReg(); -if (CopyDstReg.isVirtual() && -MRI->getRegClass(CopyDstReg) == &SystemZ::GR128BitRegClass && -MRI->hasOneNonDBGUse(Reg)) { - // TODO: Handle physical registers - // TODO: Handle gr64 uses with subregister indexes - // TODO: Should this multi-use cases? - Register TmpReg = MRI->createVirtualRegister(&SystemZ::GR64BitRegClass); - MachineBasicBlock &MBB = *UseMI.getParent(); - - // FIXME: probably should be DefMI's DebugLoc but this matches - // loadImmediate's guessing - const DebugLoc &DL = UseMI.getDebugLoc(); - - loadImmediate(MBB, UseMI.getIterator(), TmpReg, ImmVal); - - BuildMI(MBB, UseMI.getIterator(), DL, get(SystemZ::REG_SEQUENCE), - CopyDstReg) - .addReg(TmpReg) - .addImm(SystemZ::subreg_h64) - .addReg(TmpReg) - .addImm(SystemZ::subreg_l64); - - UseMI.eraseFromParent(); - return true; -} - -return false; - } - if (DefOpc != SystemZ::LHIMux && DefOpc != SystemZ::LHI && DefOpc != SystemZ::LGHI) return false; @@ -2282,16 +2237,3 @@ areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, return false; } - -bool SystemZInstrInfo::getConstValDefinedInReg(const MachineInstr &MI, - const Register Reg, - int64_t &ImmVal) const { - - if (MI.getOpcode() == SystemZ::VGBM && Reg == MI.getOperand(0).getReg()) { -ImmVal = MI.getOperand(1).getImm(); -// TODO: Handle non-0 values -return ImmVal == 0; - } - - return false; -} diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.h b/llvm/lib/Target/SystemZ/SystemZInstrInfo.h index 61338b0816155a..aa10fb56496231 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.h +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.h @@ -383,9 +383,6 @@ class SystemZInstrInfo : public SystemZGenInstrInfo { bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override; - - bool getConstValDefinedInReg(const MachineInstr &MI, const Register Reg, - int64_t &ImmVal) const override; }; } // end namespace llvm diff --git a/llvm/test/CodeGen/SystemZ/fold-copy-vector-immediate.mir b/llvm/test/CodeGen/SystemZ/fold-copy-vector-immediate.mir deleted file mode 100644 index 2aee0cb521c4c8..00 --- a/llvm/test/CodeGen/SystemZ/fold-copy-vector-immediate.mir +++ /dev/null @@ -1,182 +0,0 @@ -# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4 -# RUN: llc -mtriple=s390x-linux-gnu -mcpu=z13 -run-pass=peephole-opt -o - %s | FileCheck %s - -name:fold_vgbm_0_copyvr128_to_gr128_virtreg -tracksRegLiveness: true -body: | - bb.0: - liveins: $r2d -; CHECK-LABEL: name: fold_vgbm_0_copyvr128_to_gr128_virtreg -; CHECK: liveins: $r2d -; CHECK-NEXT: {{ $}} -; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64bit = COPY $r2d -; CHECK-NEXT: [[COPY1:%[0-9]+]]:addr64bit = COPY [[COPY]] -; CHECK-NEXT: [[VGBM:%[0-9]+]]:vr128bit = VGBM 0 -; CHECK-NEXT: [[LGHI:%[0-9]+]]:gr64bit = LGHI 0 -; CHECK-NEXT: [[REG_SEQUENCE:%[0-9]+]]:gr128bit = REG_SEQUENCE [[LGHI]], %subreg.subreg_h64, [[LGHI]], %subre
[llvm-branch-commits] [clang] 8468a10 - Revert "Revert "[OpenMP][TR12] change property of map-type modifier." (#90885)"
Author: jyu2-git Date: 2024-05-03T11:09:11-07:00 New Revision: 8468a10bf34e4c432b181d40c370043ad21b5801 URL: https://github.com/llvm/llvm-project/commit/8468a10bf34e4c432b181d40c370043ad21b5801 DIFF: https://github.com/llvm/llvm-project/commit/8468a10bf34e4c432b181d40c370043ad21b5801.diff LOG: Revert "Revert "[OpenMP][TR12] change property of map-type modifier." (#90885)" This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd. Added: Modified: clang/include/clang/Basic/DiagnosticParseKinds.td clang/lib/Parse/ParseOpenMP.cpp clang/test/OpenMP/target_ast_print.cpp clang/test/OpenMP/target_map_messages.cpp Removed: diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index fdffb35ea0d955..44bc4e0e130de8 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1438,6 +1438,9 @@ def err_omp_decl_in_declare_simd_variant : Error< def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 %select{sink:|source:}1' must be with '%select{omp_cur_iteration - 1|omp_cur_iteration}1'">; def err_omp_unknown_map_type : Error< "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">; +def err_omp_more_one_map_type : Error<"map type is already specified">; +def note_previous_map_type_specified_here +: Note<"map type '%0' is previous specified here">; def err_omp_unknown_map_type_modifier : Error< "incorrect map type modifier, expected one of: 'always', 'close', 'mapper'" "%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">; @@ -1445,6 +1448,8 @@ def err_omp_map_type_missing : Error< "missing map type">; def err_omp_map_type_modifier_missing : Error< "missing map type modifier">; +def err_omp_map_modifier_specification_list : Error< + "empty modifier-specification-list is not allowed">; def err_omp_declare_simd_inbranch_notinbranch : Error< "unexpected '%0' clause, '%1' is specified already">; def err_omp_expected_clause_argument diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 18ba1185ee8de7..b1cff11af590a5 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -4228,13 +4228,20 @@ bool Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data) { return T.consumeClose(); } +static OpenMPMapClauseKind isMapType(Parser &P); + /// Parse map-type-modifiers in map clause. -/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) +/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] [map-type] : ] list) /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) | /// present +/// where, map-type ::= alloc | delete | from | release | to | tofrom bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) { + bool HasMapType = false; + SourceLocation PreMapLoc = Tok.getLocation(); + StringRef PreMapName = ""; while (getCurToken().isNot(tok::colon)) { OpenMPMapModifierKind TypeModifier = isMapModifier(*this); +OpenMPMapClauseKind MapKind = isMapType(*this); if (TypeModifier == OMPC_MAP_MODIFIER_always || TypeModifier == OMPC_MAP_MODIFIER_close || TypeModifier == OMPC_MAP_MODIFIER_present || @@ -4257,6 +4264,19 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) { Diag(Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma) << "map type modifier"; +} else if (getLangOpts().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) { + if (!HasMapType) { +HasMapType = true; +Data.ExtraModifier = MapKind; +MapKind = OMPC_MAP_unknown; +PreMapLoc = Tok.getLocation(); +PreMapName = Tok.getIdentifierInfo()->getName(); + } else { +Diag(Tok, diag::err_omp_more_one_map_type); +Diag(PreMapLoc, diag::note_previous_map_type_specified_here) +<< PreMapName; + } + ConsumeToken(); } else { // For the case of unknown map-type-modifier or a map-type. // Map-type is followed by a colon; the function returns when it @@ -4267,8 +4287,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) { continue; } // Potential map-type token as it is followed by a colon. - if (PP.LookAhead(0).is(tok::colon)) -return false; + if (PP.LookAhead(0).is(tok::colon)) { +if (getLangOpts().OpenMP >= 60) { + break; +} else { + return false; +} + } + Diag(Tok, diag::err_omp_unknown_map_type_modifier) << (getLangOpts().OpenMP >= 51 ? (getLangOpts().OpenMP >= 52 ? 2 : 1) : 0) @@ -4278,6 +4304,14 @@ bool Parser::parseMapTypeModifiers(
[llvm-branch-commits] [CallSiteInfo][CallGraphSection] Extract and propagate indirect call type ids (PR #87575)
@@ -488,6 +490,35 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { /// Callee type id. ConstantInt *TypeId = nullptr; + +CallSiteInfo() {} + +/// Extracts the numeric type id from the CallBase's type operand bundle, +/// and sets TypeId. This is used as type id for the indirect call in the +/// call graph section. +CallSiteInfo(const CallBase &CB) { + // Call graph section needs numeric type id only for indirect calls. + if (!CB.isIndirectCall()) +return; + + auto Opt = CB.getOperandBundle(LLVMContext::OB_type); + if (!Opt.has_value()) +return; + + // Get generalized type id string + auto OB = Opt.value(); + assert(OB.Inputs.size() == 1 && "invalid input size"); + auto *OBVal = OB.Inputs.front().get(); + auto *TypeIdMD = cast(OBVal)->getMetadata(); + auto *TypeIdStr = cast(TypeIdMD); + assert(TypeIdStr->getString().endswith(".generalized") && + "invalid type identifier"); + + // Compute numeric type id from generalized type id string + uint64_t TypeIdVal = llvm::MD5Hash(TypeIdStr->getString()); + IntegerType *Int64Ty = Type::getInt64Ty(CB.getContext()); + TypeId = llvm::ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false); arsenm wrote: Don't need any of the llvm::s https://github.com/llvm/llvm-project/pull/87575 ___ 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] [CallSiteInfo][CallGraphSection] Extract and propagate indirect call type ids (PR #87575)
@@ -488,6 +490,35 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { /// Callee type id. ConstantInt *TypeId = nullptr; + +CallSiteInfo() {} arsenm wrote: ```suggestion CallSiteInfo() = default; ``` https://github.com/llvm/llvm-project/pull/87575 ___ 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] [CallSiteInfo][CallGraphSection] Extract and propagate indirect call type ids (PR #87575)
@@ -488,6 +490,35 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { /// Callee type id. ConstantInt *TypeId = nullptr; + +CallSiteInfo() {} + +/// Extracts the numeric type id from the CallBase's type operand bundle, +/// and sets TypeId. This is used as type id for the indirect call in the +/// call graph section. +CallSiteInfo(const CallBase &CB) { + // Call graph section needs numeric type id only for indirect calls. + if (!CB.isIndirectCall()) +return; + + auto Opt = CB.getOperandBundle(LLVMContext::OB_type); + if (!Opt.has_value()) +return; + + // Get generalized type id string + auto OB = Opt.value(); arsenm wrote: Just use *Opt? https://github.com/llvm/llvm-project/pull/87575 ___ 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] [CallSiteInfo][CallGraphSection] Extract and propagate indirect call type ids (PR #87575)
@@ -488,6 +490,35 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { /// Callee type id. ConstantInt *TypeId = nullptr; + +CallSiteInfo() {} + +/// Extracts the numeric type id from the CallBase's type operand bundle, +/// and sets TypeId. This is used as type id for the indirect call in the +/// call graph section. +CallSiteInfo(const CallBase &CB) { + // Call graph section needs numeric type id only for indirect calls. + if (!CB.isIndirectCall()) +return; + + auto Opt = CB.getOperandBundle(LLVMContext::OB_type); + if (!Opt.has_value()) +return; arsenm wrote: Too much auto https://github.com/llvm/llvm-project/pull/87575 ___ 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] [CallSiteInfo][CallGraphSection] Extract and propagate indirect call type ids (PR #87575)
@@ -7922,6 +7923,10 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, *DAG.getContext()); RetCCInfo.AnalyzeCallResult(Ins, RetCC); + // Set type id for call site info. + if (MF.getTarget().Options.EmitCallGraphSection && CB && CB->isIndirectCall()) +CSInfo = MachineFunction::CallSiteInfo(*CB); arsenm wrote: What's the expected behavior for libcalls? Should we still be able to emit something without an IR call site? https://github.com/llvm/llvm-project/pull/87575 ___ 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] [ThinLTO] Generate import status in per-module combined summary (PR #88024)
https://github.com/minglotus-6 updated https://github.com/llvm/llvm-project/pull/88024 >From cfb63d775d43a28b560d938346f1dd4b2dddc765 Mon Sep 17 00:00:00 2001 From: mingmingl Date: Thu, 4 Apr 2024 11:54:17 -0700 Subject: [PATCH 1/9] function import changes --- llvm/include/llvm/IR/ModuleSummaryIndex.h | 24 .../llvm/Transforms/IPO/FunctionImport.h | 18 ++- llvm/lib/LTO/LTO.cpp | 13 +- llvm/lib/LTO/LTOBackend.cpp | 5 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 9 +- llvm/lib/Transforms/IPO/FunctionImport.cpp| 130 -- llvm/tools/llvm-link/llvm-link.cpp| 2 +- 7 files changed, 146 insertions(+), 55 deletions(-) diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h index 286b51bda0e2..259fe56ce5f6 100644 --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -296,6 +296,30 @@ template <> struct DenseMapInfo { static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.getRef(); } }; +struct SummaryImportInfo { + enum class ImportType : uint8_t { +NotImported = 0, +Declaration = 1, +Definition = 2, + }; + unsigned Type : 3; + SummaryImportInfo() : Type(static_cast(ImportType::NotImported)) {} + SummaryImportInfo(ImportType Type) : Type(static_cast(Type)) {} + + // FIXME: delete the first two set* helper function. + void updateType(ImportType InputType) { +Type = std::max(Type, static_cast(InputType)); + } + + bool isDefinition() const { +return static_cast(Type) == ImportType::Definition; + } + + bool isDeclaration() const { +return static_cast(Type) == ImportType::Declaration; + } +}; + /// Summary of memprof callsite metadata. struct CallsiteInfo { // Actual callee function. diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h index c4d19e8641ec..9adc0c31eed4 100644 --- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h +++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h @@ -33,7 +33,14 @@ class FunctionImporter { public: /// Set of functions to import from a source module. Each entry is a set /// containing all the GUIDs of all functions to import for a source module. - using FunctionsToImportTy = std::unordered_set; + using FunctionsToImportTy = DenseMap; + + // FIXME: Remove this. + enum ImportStatus { +NotImported, +ImportDeclaration, +ImportDefinition, + }; /// The different reasons selectCallee will chose not to import a /// candidate. @@ -99,8 +106,10 @@ class FunctionImporter { /// index's module path string table). using ImportMapTy = DenseMap; - /// The set contains an entry for every global value the module exports. - using ExportSetTy = DenseSet; + /// The map contains an entry for every global value the module exports, the + /// key being the value info, and the value is the summary-based import info. + /// FIXME: Does this set need to be a map? + using ExportSetTy = DenseMap; /// A function of this type is used to load modules referenced by the index. using ModuleLoaderTy = @@ -211,7 +220,8 @@ void gatherImportedSummariesForModule( StringRef ModulePath, const DenseMap &ModuleToDefinedGVSummaries, const FunctionImporter::ImportMapTy &ImportList, -std::map &ModuleToSummariesForIndex); +std::map &ModuleToSummariesForIndex, +ModuleToGVSummaryPtrSet &ModuleToDecSummaries); /// Emit into \p OutputFilename the files module \p ModulePath will import from. std::error_code EmitImportsFiles( diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 53060df7f503..ace533fe28c9 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -159,7 +159,7 @@ void llvm::computeLTOCacheKey( std::vector ExportsGUID; ExportsGUID.reserve(ExportList.size()); for (const auto &VI : ExportList) { -auto GUID = VI.getGUID(); +auto GUID = VI.first.getGUID(); ExportsGUID.push_back(GUID); } @@ -205,7 +205,7 @@ void llvm::computeLTOCacheKey( AddUint64(Entry.getFunctions().size()); for (auto &Fn : Entry.getFunctions()) - AddUint64(Fn); + AddUint64(Fn.first); } // Include the hash for the resolved ODR. @@ -277,7 +277,7 @@ void llvm::computeLTOCacheKey( for (const ImportModule &ImpM : ImportModulesVector) for (auto &ImpF : ImpM.getFunctions()) { GlobalValueSummary *S = - Index.findSummaryInModule(ImpF, ImpM.getIdentifier()); + Index.findSummaryInModule(ImpF.first, ImpM.getIdentifier()); AddUsedThings(S); // If this is an alias, we also care about any types/etc. that the aliasee // may reference. @@ -1389,15 +1389,18 @@ class lto::ThinBackendProc { llvm::StringRef ModulePath, const std::string &NewModulePath) { std::map ModuleToSummariesForIndex; +ModuleToGVSummaryP
[llvm-branch-commits] [llvm] release/18.x: [AArc64][GlobalISel] Fix legalizer assert for G_INSERT_VECTOR_ELT (PR #90827)
nikic wrote: @aemerson It looks like llvmbot does not enable the "Maintainers are allowed to edit this pull request" option, so it's not possible to edit this pull request. Need to submit a new one. https://github.com/llvm/llvm-project/pull/90827 ___ 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] [Inline][Cloning] Drop incompatible attributes from `NewFunc` (PR #91350)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/91350 ___ 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] [Inline][Cloning] Drop incompatible attributes from `NewFunc` (PR #91350)
nikic wrote: This backport makes no sense. It takes only one out of two related commits. And taking both would be too high risk for a late backport anyway. https://github.com/llvm/llvm-project/pull/91350 ___ 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] Ignore returns in DataAggregator (PR #90807)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/90807 >From acf58ceb37d2aa917e8d84d243faadc58f5f3a7d Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Mon, 6 May 2024 13:35:04 -0700 Subject: [PATCH 1/2] Simplify IsReturn check Created using spr 1.3.4 --- bolt/lib/Profile/DataAggregator.cpp | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index e4a7324c38175..d02e4499014ed 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -778,13 +778,13 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count, if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr)) { Addr -= Func->getAddress(); if (IsFrom) { -if (Func->hasInstructions()) { - if (MCInst *Inst = Func->getInstructionAtOffset(Addr)) -IsReturn = BC->MIB->isReturn(*Inst); -} else if (std::optional Inst = -Func->disassembleInstructionAtOffset(Addr)) { - IsReturn = BC->MIB->isReturn(*Inst); -} +auto checkReturn = [&](auto MaybeInst) { + IsReturn = MaybeInst && BC->MIB->isReturn(*MaybeInst); +}; +if (Func->hasInstructions()) + checkReturn(Func->getInstructionAtOffset(Addr)); +else + checkReturn(Func->disassembleInstructionAtOffset(Addr)); } if (BAT) >From 22052e461e5671f376fe2dcb733446b0a63e956d Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 7 May 2024 18:30:48 -0700 Subject: [PATCH 2/2] drop const from disassembleInstructionAtOffset Created using spr 1.3.4 --- bolt/include/bolt/Core/BinaryFunction.h | 3 +-- bolt/lib/Core/BinaryFunction.cpp| 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h index b21312f92c485..3c641581e247a 100644 --- a/bolt/include/bolt/Core/BinaryFunction.h +++ b/bolt/include/bolt/Core/BinaryFunction.h @@ -930,8 +930,7 @@ class BinaryFunction { return const_cast(this)->getInstructionAtOffset(Offset); } - const std::optional - disassembleInstructionAtOffset(uint64_t Offset) const; + std::optional disassembleInstructionAtOffset(uint64_t Offset) const; /// Return offset for the first instruction. If there is data at the /// beginning of a function then offset of the first instruction could diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp index 5f3c0cb1ad754..fb81fc3f2ba7b 100644 --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -1167,7 +1167,7 @@ void BinaryFunction::handleAArch64IndirectCall(MCInst &Instruction, } } -const std::optional +std::optional BinaryFunction::disassembleInstructionAtOffset(uint64_t Offset) const { assert(CurrentState == State::Empty); assert(Offset < MaxSize && "invalid offset"); ___ 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] [Inline][Cloning] Drop incompatible attributes from `NewFunc` (PR #91350)
nikic wrote: @AtariDreams I will ask you, again, to not request backports for changes you do not understand. If you are not the patch author and you do not personally require the backport, do not request it. https://github.com/llvm/llvm-project/pull/91350 ___ 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] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/91419 See the LangRef: > All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values. It is incorrect to replace freezes with the simplified value. Proof: https://alive2.llvm.org/ce/z/3Dn9Cd https://alive2.llvm.org/ce/z/Qyh5h6 Fixes https://github.com/llvm/llvm-project/issues/91178 (cherry picked from commit d085b42cbbefe79a41113abcd2b1e1f2a203acef) >From 1c2eb18d52976fef89972e89c52d2ec5ed7e4868 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Wed, 8 May 2024 10:04:09 +0800 Subject: [PATCH] [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the LangRef: > All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values. It is incorrect to replace freezes with the simplified value. Proof: https://alive2.llvm.org/ce/z/3Dn9Cd https://alive2.llvm.org/ce/z/Qyh5h6 Fixes https://github.com/llvm/llvm-project/issues/91178 (cherry picked from commit d085b42cbbefe79a41113abcd2b1e1f2a203acef) --- llvm/lib/Analysis/InstructionSimplify.cpp | 4 + llvm/test/Transforms/InstCombine/icmp.ll | 15 llvm/test/Transforms/InstCombine/select.ll | 88 ++ llvm/test/Transforms/PGOProfile/chr.ll | 7 +- 4 files changed, 111 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 72b6dfa181e86..8dcffe45c644b 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4322,6 +4322,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, if (match(I, m_Intrinsic())) return nullptr; + // Don't simplify freeze. + if (isa(I)) +return nullptr; + // Replace Op with RepOp in instruction operands. SmallVector NewOps; bool AnyReplaced = false; diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 10ab1fe118348..9ac35745742bb 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -5183,3 +5183,18 @@ entry: %cmp = icmp eq i8 %add2, %add1 ret i1 %cmp } + +define i1 @icmp_freeze_sext(i16 %x, i16 %y) { +; CHECK-LABEL: @icmp_freeze_sext( +; CHECK-NEXT:[[CMP1:%.*]] = icmp uge i16 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT:[[CMP1_FR:%.*]] = freeze i1 [[CMP1]] +; CHECK-NEXT:[[TMP1:%.*]] = icmp eq i16 [[Y]], 0 +; CHECK-NEXT:[[CMP2:%.*]] = or i1 [[TMP1]], [[CMP1_FR]] +; CHECK-NEXT:ret i1 [[CMP2]] +; + %cmp1 = icmp uge i16 %x, %y + %ext = sext i1 %cmp1 to i16 + %ext.fr = freeze i16 %ext + %cmp2 = icmp uge i16 %ext.fr, %y + ret i1 %cmp2 +} diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll index 888e7d28f78af..111ac62986d4d 100644 --- a/llvm/test/Transforms/InstCombine/select.ll +++ b/llvm/test/Transforms/InstCombine/select.ll @@ -3708,3 +3708,91 @@ define i32 @src_select_xxory_eq0_xorxy_y(i32 %x, i32 %y) { %cond = select i1 %xor0, i32 %xor, i32 %y ret i32 %cond } + +define i32 @sequence_select_with_same_cond_false(i1 %c1, i1 %c2){ +; CHECK-LABEL: @sequence_select_with_same_cond_false( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], i32 23, i32 45 +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], i32 666, i32 [[S1]] +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], i32 789, i32 [[S2]] +; CHECK-NEXT:ret i32 [[S3]] +; + %s1 = select i1 %c1, i32 23, i32 45 + %s2 = select i1 %c2, i32 666, i32 %s1 + %s3 = select i1 %c1, i32 789, i32 %s2 + ret i32 %s3 +} + +define i32 @sequence_select_with_same_cond_true(i1 %c1, i1 %c2){ +; CHECK-LABEL: @sequence_select_with_same_cond_true( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], i32 45, i32 23 +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], i32 [[S1]], i32 666 +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], i32 [[S2]], i32 789 +; CHECK-NEXT:ret i32 [[S3]] +; + %s1 = select i1 %c1, i32 45, i32 23 + %s2 = select i1 %c2, i32 %s1, i32 666 + %s3 = select i1 %c1, i32 %s2, i32 789 + ret i32 %s3 +} + +define double @sequence_select_with_same_cond_double(double %a, i1 %c1, i1 %c2, double %r1, double %r2){ +; CHECK-LABEL: @sequence_select_with_same_cond_double( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], double 1.00e+00, double 0.00e+00 +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], double [[S1]], double 2.00e+00 +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], double [[S2]], double 3.00e+00 +; CHECK-NEXT:ret double [[S3]] +; + %s1 = select i1 %c1, double 1.0, double 0.0 + %s2 = select i1 %c2, double %s1, double 2.0 + %s3 = select i1 %c
[llvm-branch-commits] [llvm] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
llvmbot wrote: @llvm/pr-subscribers-llvm-analysis Author: AtariDreams (AtariDreams) Changes See the LangRef: > All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values. It is incorrect to replace freezes with the simplified value. Proof: https://alive2.llvm.org/ce/z/3Dn9Cd https://alive2.llvm.org/ce/z/Qyh5h6 Fixes https://github.com/llvm/llvm-project/issues/91178 (cherry picked from commit d085b42cbbefe79a41113abcd2b1e1f2a203acef) --- Full diff: https://github.com/llvm/llvm-project/pull/91419.diff 4 Files Affected: - (modified) llvm/lib/Analysis/InstructionSimplify.cpp (+4) - (modified) llvm/test/Transforms/InstCombine/icmp.ll (+15) - (modified) llvm/test/Transforms/InstCombine/select.ll (+88) - (modified) llvm/test/Transforms/PGOProfile/chr.ll (+4-3) ``diff diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 72b6dfa181e86..8dcffe45c644b 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4322,6 +4322,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, if (match(I, m_Intrinsic())) return nullptr; + // Don't simplify freeze. + if (isa(I)) +return nullptr; + // Replace Op with RepOp in instruction operands. SmallVector NewOps; bool AnyReplaced = false; diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 10ab1fe118348..9ac35745742bb 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -5183,3 +5183,18 @@ entry: %cmp = icmp eq i8 %add2, %add1 ret i1 %cmp } + +define i1 @icmp_freeze_sext(i16 %x, i16 %y) { +; CHECK-LABEL: @icmp_freeze_sext( +; CHECK-NEXT:[[CMP1:%.*]] = icmp uge i16 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT:[[CMP1_FR:%.*]] = freeze i1 [[CMP1]] +; CHECK-NEXT:[[TMP1:%.*]] = icmp eq i16 [[Y]], 0 +; CHECK-NEXT:[[CMP2:%.*]] = or i1 [[TMP1]], [[CMP1_FR]] +; CHECK-NEXT:ret i1 [[CMP2]] +; + %cmp1 = icmp uge i16 %x, %y + %ext = sext i1 %cmp1 to i16 + %ext.fr = freeze i16 %ext + %cmp2 = icmp uge i16 %ext.fr, %y + ret i1 %cmp2 +} diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll index 888e7d28f78af..111ac62986d4d 100644 --- a/llvm/test/Transforms/InstCombine/select.ll +++ b/llvm/test/Transforms/InstCombine/select.ll @@ -3708,3 +3708,91 @@ define i32 @src_select_xxory_eq0_xorxy_y(i32 %x, i32 %y) { %cond = select i1 %xor0, i32 %xor, i32 %y ret i32 %cond } + +define i32 @sequence_select_with_same_cond_false(i1 %c1, i1 %c2){ +; CHECK-LABEL: @sequence_select_with_same_cond_false( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], i32 23, i32 45 +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], i32 666, i32 [[S1]] +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], i32 789, i32 [[S2]] +; CHECK-NEXT:ret i32 [[S3]] +; + %s1 = select i1 %c1, i32 23, i32 45 + %s2 = select i1 %c2, i32 666, i32 %s1 + %s3 = select i1 %c1, i32 789, i32 %s2 + ret i32 %s3 +} + +define i32 @sequence_select_with_same_cond_true(i1 %c1, i1 %c2){ +; CHECK-LABEL: @sequence_select_with_same_cond_true( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], i32 45, i32 23 +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], i32 [[S1]], i32 666 +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], i32 [[S2]], i32 789 +; CHECK-NEXT:ret i32 [[S3]] +; + %s1 = select i1 %c1, i32 45, i32 23 + %s2 = select i1 %c2, i32 %s1, i32 666 + %s3 = select i1 %c1, i32 %s2, i32 789 + ret i32 %s3 +} + +define double @sequence_select_with_same_cond_double(double %a, i1 %c1, i1 %c2, double %r1, double %r2){ +; CHECK-LABEL: @sequence_select_with_same_cond_double( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], double 1.00e+00, double 0.00e+00 +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], double [[S1]], double 2.00e+00 +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], double [[S2]], double 3.00e+00 +; CHECK-NEXT:ret double [[S3]] +; + %s1 = select i1 %c1, double 1.0, double 0.0 + %s2 = select i1 %c2, double %s1, double 2.0 + %s3 = select i1 %c1, double %s2, double 3.0 + ret double %s3 +} + +declare void @use32(i32) + +define i32 @sequence_select_with_same_cond_extra_use(i1 %c1, i1 %c2){ +; CHECK-LABEL: @sequence_select_with_same_cond_extra_use( +; CHECK-NEXT:[[S1:%.*]] = select i1 [[C1:%.*]], i32 23, i32 45 +; CHECK-NEXT:call void @use32(i32 [[S1]]) +; CHECK-NEXT:[[S2:%.*]] = select i1 [[C2:%.*]], i32 666, i32 [[S1]] +; CHECK-NEXT:[[S3:%.*]] = select i1 [[C1]], i32 789, i32 [[S2]] +; CHECK-NEXT:ret i32 [[S3]] +; + %s1 = select i1 %c1, i32 23, i32 45 + call void @use32(i32 %s1) + %s2 = select i1 %c2, i32 666, i32 %s1 + %s3 = select i1 %c1, i32 789, i32 %s2 + ret i32 %s3 +} + +define i8 @test_replace_freeze_mu
[llvm-branch-commits] [llvm] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/91419 ___ 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] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
https://github.com/dtcxzyw requested changes to this pull request. https://github.com/llvm/llvm-project/pull/91419 ___ 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] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
@@ -3708,3 +3708,91 @@ define i32 @src_select_xxory_eq0_xorxy_y(i32 %x, i32 %y) { %cond = select i1 %xor0, i32 %xor, i32 %y ret i32 %cond } + +define i32 @sequence_select_with_same_cond_false(i1 %c1, i1 %c2){ dtcxzyw wrote: These tests don't belong to the original patch. https://github.com/llvm/llvm-project/pull/91419 ___ 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] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/91419 >From 87ae76d90b11ed674b96a6049b53bd02d002f69b Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Wed, 8 May 2024 10:04:09 +0800 Subject: [PATCH] [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the LangRef: > All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values. It is incorrect to replace freezes with the simplified value. Proof: https://alive2.llvm.org/ce/z/3Dn9Cd https://alive2.llvm.org/ce/z/Qyh5h6 Fixes https://github.com/llvm/llvm-project/issues/91178 (cherry picked from commit d085b42cbbefe79a41113abcd2b1e1f2a203acef) Revert "[InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215)" This reverts commit 1c2eb18d52976fef89972e89c52d2ec5ed7e4868. [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) See the LangRef: > All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values. It is incorrect to replace freezes with the simplified value. Proof: https://alive2.llvm.org/ce/z/3Dn9Cd https://alive2.llvm.org/ce/z/Qyh5h6 Fixes https://github.com/llvm/llvm-project/issues/91178 (cherry picked from commit d085b42cbbefe79a41113abcd2b1e1f2a203acef) --- llvm/lib/Analysis/InstructionSimplify.cpp | 4 +++ llvm/test/Transforms/InstCombine/icmp.ll | 15 ++ llvm/test/Transforms/InstCombine/select.ll | 32 ++ llvm/test/Transforms/PGOProfile/chr.ll | 7 +++-- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 72b6dfa181e86..8dcffe45c644b 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4322,6 +4322,10 @@ static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, if (match(I, m_Intrinsic())) return nullptr; + // Don't simplify freeze. + if (isa(I)) +return nullptr; + // Replace Op with RepOp in instruction operands. SmallVector NewOps; bool AnyReplaced = false; diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 10ab1fe118348..9ac35745742bb 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -5183,3 +5183,18 @@ entry: %cmp = icmp eq i8 %add2, %add1 ret i1 %cmp } + +define i1 @icmp_freeze_sext(i16 %x, i16 %y) { +; CHECK-LABEL: @icmp_freeze_sext( +; CHECK-NEXT:[[CMP1:%.*]] = icmp uge i16 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT:[[CMP1_FR:%.*]] = freeze i1 [[CMP1]] +; CHECK-NEXT:[[TMP1:%.*]] = icmp eq i16 [[Y]], 0 +; CHECK-NEXT:[[CMP2:%.*]] = or i1 [[TMP1]], [[CMP1_FR]] +; CHECK-NEXT:ret i1 [[CMP2]] +; + %cmp1 = icmp uge i16 %x, %y + %ext = sext i1 %cmp1 to i16 + %ext.fr = freeze i16 %ext + %cmp2 = icmp uge i16 %ext.fr, %y + ret i1 %cmp2 +} diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll index 888e7d28f78af..1909f9b0daf82 100644 --- a/llvm/test/Transforms/InstCombine/select.ll +++ b/llvm/test/Transforms/InstCombine/select.ll @@ -3708,3 +3708,35 @@ define i32 @src_select_xxory_eq0_xorxy_y(i32 %x, i32 %y) { %cond = select i1 %xor0, i32 %xor, i32 %y ret i32 %cond } + +define i8 @test_replace_freeze_multiuse(i1 %x, i8 %y) { +; CHECK-LABEL: @test_replace_freeze_multiuse( +; CHECK-NEXT:[[EXT:%.*]] = zext i1 [[X:%.*]] to i8 +; CHECK-NEXT:[[SHL:%.*]] = shl nuw i8 [[EXT]], [[Y:%.*]] +; CHECK-NEXT:[[SHL_FR:%.*]] = freeze i8 [[SHL]] +; CHECK-NEXT:[[SEL:%.*]] = select i1 [[X]], i8 0, i8 [[SHL_FR]] +; CHECK-NEXT:[[ADD:%.*]] = add i8 [[SHL_FR]], [[SEL]] +; CHECK-NEXT:ret i8 [[ADD]] +; + %ext = zext i1 %x to i8 + %shl = shl nuw i8 %ext, %y + %shl.fr = freeze i8 %shl + %sel = select i1 %x, i8 0, i8 %shl.fr + %add = add i8 %shl.fr, %sel + ret i8 %add +} + +define i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) { +; CHECK-LABEL: @test_replace_freeze_oneuse( +; CHECK-NEXT:[[EXT:%.*]] = zext i1 [[X:%.*]] to i8 +; CHECK-NEXT:[[SHL:%.*]] = shl nuw i8 [[EXT]], [[Y:%.*]] +; CHECK-NEXT:[[SHL_FR:%.*]] = freeze i8 [[SHL]] +; CHECK-NEXT:[[SEL:%.*]] = select i1 [[X]], i8 0, i8 [[SHL_FR]] +; CHECK-NEXT:ret i8 [[SEL]] +; + %ext = zext i1 %x to i8 + %shl = shl nuw i8 %ext, %y + %shl.fr = freeze i8 %shl + %sel = select i1 %x, i8 0, i8 %shl.fr + ret i8 %sel +} diff --git a/llvm/test/Transforms/PGOProfile/chr.ll b/llvm/test/Transforms/PGOProfile/chr.ll index 0551a171091ca..38e8f8536a19c 100644 --- a/llvm/test/Transforms/PGOProfile/chr.ll +++ b/llvm/test/Transforms/PGOProfile/chr.ll @@ -12
[llvm-branch-commits] [llvm] release/18.x: [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) (PR #91425)
https://github.com/phoebewang milestoned https://github.com/llvm/llvm-project/pull/91425 ___ 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] release/18.x: [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) (PR #91425)
https://github.com/phoebewang created https://github.com/llvm/llvm-project/pull/91425 None >From 5f3651376c051c1fb7b29741778a4616811a1157 Mon Sep 17 00:00:00 2001 From: Phoebe Wang Date: Mon, 6 May 2024 10:59:44 +0800 Subject: [PATCH 1/2] [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) AVX doesn't provide 16-bit BROADCAST instruction. Fixes #91005 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 2 +- llvm/test/CodeGen/X86/pr91005.ll| 39 + 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/X86/pr91005.ll diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 71fc6b5047eaa..2752f8a92447c 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -7295,7 +7295,7 @@ static SDValue lowerBuildVectorAsBroadcast(BuildVectorSDNode *BVOp, // With pattern matching, the VBROADCAST node may become a VMOVDDUP. if (ScalarSize == 32 || (ScalarSize == 64 && (IsGE256 || Subtarget.hasVLX())) || -CVT == MVT::f16 || +(CVT == MVT::f16 && Subtarget.hasAVX2()) || (OptForSize && (ScalarSize == 64 || Subtarget.hasAVX2( { const Constant *C = nullptr; if (ConstantSDNode *CI = dyn_cast(Ld)) diff --git a/llvm/test/CodeGen/X86/pr91005.ll b/llvm/test/CodeGen/X86/pr91005.ll new file mode 100644 index 0..97fd1ce456882 --- /dev/null +++ b/llvm/test/CodeGen/X86/pr91005.ll @@ -0,0 +1,39 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 +; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s + +define void @PR91005(ptr %0) minsize { +; CHECK-LABEL: PR91005: +; CHECK: # %bb.0: +; CHECK-NEXT:xorl %eax, %eax +; CHECK-NEXT:testb %al, %al +; CHECK-NEXT:je .LBB0_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT:vbroadcastss {{.*#+}} xmm0 = [31744,31744,31744,31744] +; CHECK-NEXT:vpcmpeqw %xmm0, %xmm0, %xmm0 +; CHECK-NEXT:vpinsrw $0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1 +; CHECK-NEXT:vpand %xmm1, %xmm0, %xmm0 +; CHECK-NEXT:vcvtph2ps %xmm0, %xmm0 +; CHECK-NEXT:vpxor %xmm1, %xmm1, %xmm1 +; CHECK-NEXT:vmulss %xmm1, %xmm0, %xmm0 +; CHECK-NEXT:vcvtps2ph $4, %xmm0, %xmm0 +; CHECK-NEXT:vmovd %xmm0, %eax +; CHECK-NEXT:movw %ax, (%rdi) +; CHECK-NEXT: .LBB0_2: # %common.ret +; CHECK-NEXT:retq + %2 = bitcast <2 x half> poison to <2 x i16> + %3 = icmp eq <2 x i16> %2, + br i1 poison, label %4, label %common.ret + +common.ret: ; preds = %4, %1 + ret void + +4:; preds = %1 + %5 = select <2 x i1> %3, <2 x half> , <2 x half> zeroinitializer + %6 = fmul <2 x half> %5, zeroinitializer + %7 = fsub <2 x half> %6, zeroinitializer + %8 = extractelement <2 x half> %7, i64 0 + store half %8, ptr %0, align 2 + br label %common.ret +} + +declare <2 x half> @llvm.fabs.v2f16(<2 x half>) >From 2f7c021c62c949d904510917220004b2be86e127 Mon Sep 17 00:00:00 2001 From: Phoebe Wang Date: Wed, 8 May 2024 10:59:31 +0800 Subject: [PATCH 2/2] Fix difference with LLVM 18 release --- llvm/test/CodeGen/X86/pr91005.ll | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/test/CodeGen/X86/pr91005.ll b/llvm/test/CodeGen/X86/pr91005.ll index 97fd1ce456882..16b78bf1e7e17 100644 --- a/llvm/test/CodeGen/X86/pr91005.ll +++ b/llvm/test/CodeGen/X86/pr91005.ll @@ -8,12 +8,13 @@ define void @PR91005(ptr %0) minsize { ; CHECK-NEXT:testb %al, %al ; CHECK-NEXT:je .LBB0_2 ; CHECK-NEXT: # %bb.1: -; CHECK-NEXT:vbroadcastss {{.*#+}} xmm0 = [31744,31744,31744,31744] -; CHECK-NEXT:vpcmpeqw %xmm0, %xmm0, %xmm0 -; CHECK-NEXT:vpinsrw $0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1 -; CHECK-NEXT:vpand %xmm1, %xmm0, %xmm0 +; CHECK-NEXT:vpcmpeqw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 +; CHECK-NEXT:vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 +; CHECK-NEXT:vpextrw $0, %xmm0, %eax +; CHECK-NEXT:movzwl %ax, %eax +; CHECK-NEXT:vmovd %eax, %xmm0 ; CHECK-NEXT:vcvtph2ps %xmm0, %xmm0 -; CHECK-NEXT:vpxor %xmm1, %xmm1, %xmm1 +; CHECK-NEXT:vxorps %xmm1, %xmm1, %xmm1 ; CHECK-NEXT:vmulss %xmm1, %xmm0, %xmm0 ; CHECK-NEXT:vcvtps2ph $4, %xmm0, %xmm0 ; CHECK-NEXT:vmovd %xmm0, %eax ___ 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] release/18.x: [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) (PR #91425)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Phoebe Wang (phoebewang) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/91425.diff 2 Files Affected: - (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1-1) - (added) llvm/test/CodeGen/X86/pr91005.ll (+40) ``diff diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 71fc6b5047eaa..2752f8a92447c 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -7295,7 +7295,7 @@ static SDValue lowerBuildVectorAsBroadcast(BuildVectorSDNode *BVOp, // With pattern matching, the VBROADCAST node may become a VMOVDDUP. if (ScalarSize == 32 || (ScalarSize == 64 && (IsGE256 || Subtarget.hasVLX())) || -CVT == MVT::f16 || +(CVT == MVT::f16 && Subtarget.hasAVX2()) || (OptForSize && (ScalarSize == 64 || Subtarget.hasAVX2( { const Constant *C = nullptr; if (ConstantSDNode *CI = dyn_cast(Ld)) diff --git a/llvm/test/CodeGen/X86/pr91005.ll b/llvm/test/CodeGen/X86/pr91005.ll new file mode 100644 index 0..16b78bf1e7e17 --- /dev/null +++ b/llvm/test/CodeGen/X86/pr91005.ll @@ -0,0 +1,40 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 +; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s + +define void @PR91005(ptr %0) minsize { +; CHECK-LABEL: PR91005: +; CHECK: # %bb.0: +; CHECK-NEXT:xorl %eax, %eax +; CHECK-NEXT:testb %al, %al +; CHECK-NEXT:je .LBB0_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT:vpcmpeqw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 +; CHECK-NEXT:vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 +; CHECK-NEXT:vpextrw $0, %xmm0, %eax +; CHECK-NEXT:movzwl %ax, %eax +; CHECK-NEXT:vmovd %eax, %xmm0 +; CHECK-NEXT:vcvtph2ps %xmm0, %xmm0 +; CHECK-NEXT:vxorps %xmm1, %xmm1, %xmm1 +; CHECK-NEXT:vmulss %xmm1, %xmm0, %xmm0 +; CHECK-NEXT:vcvtps2ph $4, %xmm0, %xmm0 +; CHECK-NEXT:vmovd %xmm0, %eax +; CHECK-NEXT:movw %ax, (%rdi) +; CHECK-NEXT: .LBB0_2: # %common.ret +; CHECK-NEXT:retq + %2 = bitcast <2 x half> poison to <2 x i16> + %3 = icmp eq <2 x i16> %2, + br i1 poison, label %4, label %common.ret + +common.ret: ; preds = %4, %1 + ret void + +4:; preds = %1 + %5 = select <2 x i1> %3, <2 x half> , <2 x half> zeroinitializer + %6 = fmul <2 x half> %5, zeroinitializer + %7 = fsub <2 x half> %6, zeroinitializer + %8 = extractelement <2 x half> %7, i64 0 + store half %8, ptr %0, align 2 + br label %common.ret +} + +declare <2 x half> @llvm.fabs.v2f16(<2 x half>) `` https://github.com/llvm/llvm-project/pull/91425 ___ 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] release/18.x: [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) (PR #91161)
https://github.com/phoebewang closed https://github.com/llvm/llvm-project/pull/91161 ___ 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] release/18.x: [X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125) (PR #91161)
phoebewang wrote: The test failures are caused by LLVM 18 branch difference, created #91425 instead. https://github.com/llvm/llvm-project/pull/91161 ___ 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] [llvm] release/18.x [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (#90702) (PR #91349)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/91349 ___ 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] [llvm] release/18.x [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (#90702) (PR #91349)
nikic wrote: We cannot change DataLayout in a released version. https://github.com/llvm/llvm-project/pull/91349 ___ 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] release/18.x: [InstSimplify] Do not simplify freeze in `simplifyWithOpReplaced` (#91215) (PR #91419)
https://github.com/nikic milestoned https://github.com/llvm/llvm-project/pull/91419 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits