[llvm-branch-commits] [clang] b045650 - Revert "[clang][dataflow] Model conditional operator correctly. (#89213)"
Author: martinboehme Date: 2024-04-22T09:35:06+02:00 New Revision: b0456501b10a3a83e6e6818a050f3fd691972d79 URL: https://github.com/llvm/llvm-project/commit/b0456501b10a3a83e6e6818a050f3fd691972d79 DIFF: https://github.com/llvm/llvm-project/commit/b0456501b10a3a83e6e6818a050f3fd691972d79.diff LOG: Revert "[clang][dataflow] Model conditional operator correctly. (#89213)" This reverts commit abb958f1610becc0a753ad8f4308a90f85e1338f. Added: Modified: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h clang/include/clang/Analysis/FlowSensitive/Transfer.h clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp clang/lib/Analysis/FlowSensitive/Transfer.cpp clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp clang/unittests/Analysis/FlowSensitive/TestingSupport.h clang/unittests/Analysis/FlowSensitive/TransferTest.cpp Removed: diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h index cdf89c7def2c91..d50dba35f8264c 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -244,21 +244,6 @@ class Environment { Environment::ValueModel &Model, ExprJoinBehavior ExprBehavior); - /// Returns a value that approximates both `Val1` and `Val2`, or null if no - /// such value can be produced. - /// - /// `Env1` and `Env2` can be used to query child values and path condition - /// implications of `Val1` and `Val2` respectively. The joined value will be - /// produced in `JoinedEnv`. - /// - /// Requirements: - /// - /// `Val1` and `Val2` must model values of type `Type`. - static Value *joinValues(QualType Ty, Value *Val1, const Environment &Env1, - Value *Val2, const Environment &Env2, - Environment &JoinedEnv, - Environment::ValueModel &Model); - /// Widens the environment point-wise, using `PrevEnv` as needed to inform the /// approximation. /// diff --git a/clang/include/clang/Analysis/FlowSensitive/Transfer.h b/clang/include/clang/Analysis/FlowSensitive/Transfer.h index 940025e02100f9..ed148250d8eb29 100644 --- a/clang/include/clang/Analysis/FlowSensitive/Transfer.h +++ b/clang/include/clang/Analysis/FlowSensitive/Transfer.h @@ -53,8 +53,7 @@ class StmtToEnvMap { /// Requirements: /// /// `S` must not be `ParenExpr` or `ExprWithCleanups`. -void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env, - Environment::ValueModel &Model); +void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env); } // namespace dataflow } // namespace clang diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp index 3cb656adcbdc0c..05395e07a7a68c 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -237,8 +237,13 @@ joinLocToVal(const llvm::MapVector &LocToVal, continue; assert(It->second != nullptr); -if (Value *JoinedVal = Environment::joinValues( -Loc->getType(), Val, Env1, It->second, Env2, JoinedEnv, Model)) { +if (areEquivalentValues(*Val, *It->second)) { + Result.insert({Loc, Val}); + continue; +} + +if (Value *JoinedVal = joinDistinctValues( +Loc->getType(), *Val, Env1, *It->second, Env2, JoinedEnv, Model)) { Result.insert({Loc, JoinedVal}); } } @@ -770,16 +775,27 @@ Environment Environment::join(const Environment &EnvA, const Environment &EnvB, JoinedEnv.LocForRecordReturnVal = EnvA.LocForRecordReturnVal; JoinedEnv.ThisPointeeLoc = EnvA.ThisPointeeLoc; - if (EnvA.CallStack.empty()) { + if (EnvA.ReturnVal == nullptr || EnvB.ReturnVal == nullptr) { +// `ReturnVal` might not always get set -- for example if we have a return +// statement of the form `return some_other_func()` and we decide not to +// analyze `some_other_func()`. +// In this case, we can't say anything about the joined return value -- we +// don't simply want to propagate the return value that we do have, because +// it might not be the correct one. +// This occurs for example in the test `ContextSensitiveMutualRecursion`. JoinedEnv.ReturnVal = nullptr; + } else if (areEquivalentValues(*EnvA.ReturnVal, *EnvB.ReturnVal)) { +JoinedEnv.ReturnVal = EnvA.ReturnVal; } else { +assert(!EnvA.CallStack.empty()); // FIXME: Make `CallStack` a vector of `FunctionDecl` so we don't need this // cast. auto *Func = dyn_cast(EnvA.CallStack.back()); assert(Func != nullptr); -JoinedEnv.ReturnVal = -joinValues(Fun
[llvm-branch-commits] [llvm] release/18.x: [GlobalISel] Fix fewerElementsVectorPhi to insert after G_PHIs (#87927) (PR #89240)
https://github.com/arsenm milestoned https://github.com/llvm/llvm-project/pull/89240 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [MLIR][OpenMP] Update omp.wsloop translation to LLVM IR (4/5) (PR #89214)
https://github.com/Meinersbur approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/89214 ___ 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] [Frontend][OpenMP] Add functions for checking construct type (PR #87258)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/87258 ___ 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] [Frontend][OpenMP] Add functions for checking construct type (PR #87258)
@@ -37,3 +37,29 @@ TEST(Composition, GetCompoundConstruct) { Directive C6 = getCompoundConstruct({OMPD_parallel_for, OMPD_simd}); ASSERT_EQ(C6, OMPD_parallel_for_simd); } + +TEST(Composition, IsLeafConstruct) { + ASSERT_TRUE(isLeafConstruct(OMPD_loop)); + ASSERT_TRUE(isLeafConstruct(OMPD_teams)); + ASSERT_FALSE(isLeafConstruct(OMPD_for_simd)); skatrak wrote: Nit: Can you add one test case for a combined construct? e.g. `ASSERT_FALSE(isLeafConstruct(OMPD_parallel_for));`. https://github.com/llvm/llvm-project/pull/87258 ___ 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] [Frontend][OpenMP] Add functions for checking construct type (PR #87258)
@@ -37,3 +37,29 @@ TEST(Composition, GetCompoundConstruct) { Directive C6 = getCompoundConstruct({OMPD_parallel_for, OMPD_simd}); ASSERT_EQ(C6, OMPD_parallel_for_simd); } + +TEST(Composition, IsLeafConstruct) { + ASSERT_TRUE(isLeafConstruct(OMPD_loop)); + ASSERT_TRUE(isLeafConstruct(OMPD_teams)); + ASSERT_FALSE(isLeafConstruct(OMPD_for_simd)); + ASSERT_FALSE(isLeafConstruct(OMPD_distribute_simd)); +} + +TEST(Composition, IsCompositeConstruct) { + ASSERT_TRUE(isCompositeConstruct(OMPD_distribute_simd)); + ASSERT_FALSE(isCompositeConstruct(OMPD_for)); + ASSERT_TRUE(isCompositeConstruct(OMPD_for_simd)); + // directive-name-A = "parallel", directive-name-B = "for simd", + // only directive-name-A is loop-associated, so this is not a skatrak wrote: ```suggestion // only directive-name-B is loop-associated, so this is not a ``` https://github.com/llvm/llvm-project/pull/87258 ___ 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] [Frontend][OpenMP] Add functions for checking construct type (PR #87258)
https://github.com/skatrak approved this pull request. LGTM, just small comments. Thanks! https://github.com/llvm/llvm-project/pull/87258 ___ 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] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/89104 ___ 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] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
https://github.com/skatrak commented: Thank you Krzysztof for working on this. I have a suggestion to simplify the implementation quite a bit, but let me know if you have issues with it. https://github.com/llvm/llvm-project/pull/89104 ___ 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] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
@@ -25,6 +25,43 @@ using namespace llvm::omp; #define GEN_DIRECTIVES_IMPL #include "llvm/Frontend/OpenMP/OMP.inc" +static iterator_range::iterator> +getFirstCompositeRange(iterator_range::iterator> Leafs) { skatrak wrote: My understanding is that there can only be at most a single composite construct when decomposing any given compound construct. So there wouldn't be a "first" composite range, but rather one composite range or none. In fact, if there is a composite range, it must also be at the end of the construct. So, something like this: `` can't happen. Decomposing a single compound construct into a list of leaves while keeping composite constructs as a unit should be as simple as forwarding all block-associated leaves until finding a loop-associated leaf and then aggregating (via `getCompoundConstruct()`) everything from there until the end of the leaf list to append one composite or single loop construct. https://github.com/llvm/llvm-project/pull/89104 ___ 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] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
@@ -2071,34 +2092,51 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent( // NOTE: There is no need to update MaxSafeVectorWidthInBits after call to // couldPreventStoreLoadForward, even if it changed MinDepDistBytes, since a // forward dependency will allow vectorization using any width. -if (IsTrueDataDependence && EnableForwardingConflictDetection && -(!HasSameSize || couldPreventStoreLoadForward(Val.abs().getZExtValue(), - TypeByteSize))) { - LLVM_DEBUG(dbgs() << "LAA: Forward but may prevent st->ld forwarding\n"); - return Dependence::ForwardButPreventsForwarding; +if (IsTrueDataDependence && EnableForwardingConflictDetection) { + if (!C) { +// TODO: Relax requirement that there is a common stride to retry with +// non-constant distance dependencies. +FoundNonConstantDistanceDependence |= !!CommonStride; +return Dependence::Unknown; + } + if (!HasSameSize || + couldPreventStoreLoadForward(C->getAPInt().abs().getZExtValue(), + TypeByteSize)) { +LLVM_DEBUG( +dbgs() << "LAA: Forward but may prevent st->ld forwarding\n"); +return Dependence::ForwardButPreventsForwarding; + } } LLVM_DEBUG(dbgs() << "LAA: Dependence is negative\n"); return Dependence::Forward; } - // Write to the same location with the same size. - if (Val == 0) { -if (HasSameSize) - return Dependence::Forward; -LLVM_DEBUG( -dbgs() << "LAA: Zero dependence difference but different type sizes\n"); + if (!C) { +// TODO: Relax requirement that there is a common stride to retry with +// non-constant distance dependencies. +FoundNonConstantDistanceDependence |= !!CommonStride; +LLVM_DEBUG(dbgs() << "LAA: Dependence because of non-constant distance\n"); Meinersbur wrote: This is the bail-out moved here from line 2047. Is this done so return Dependence::Forward with negative distance can be returned also on non-constant distances? `FoundNonConstantDistanceDependence` is not set if there is no common stride, but what does it have to do with the distance between the pointers? Before this patch it would set that flag independent of any stride. https://github.com/llvm/llvm-project/pull/88039 ___ 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] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
@@ -2028,41 +2029,61 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent( if (std::holds_alternative(Res)) return std::get(Res); - const auto &[Dist, Stride, TypeByteSize, AIsWrite, BIsWrite] = + const auto &[Dist, StrideA, StrideB, TypeByteSize, AIsWrite, BIsWrite] = std::get(Res); bool HasSameSize = TypeByteSize > 0; + std::optional CommonStride = + StrideA == StrideB ? std::make_optional(StrideA) : std::nullopt; + if (isa(Dist)) { +// TODO: Relax requirement that there is a common stride to retry with +// non-constant distance dependencies. +FoundNonConstantDistanceDependence |= !!CommonStride; +LLVM_DEBUG(dbgs() << "LAA: Dependence because of uncomputable distance.\n"); +return Dependence::Unknown; + } + ScalarEvolution &SE = *PSE.getSE(); auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout(); // If the distance between the acecsses is larger than their absolute stride // multiplied by the backedge taken count, the accesses are independet, i.e. // they are far enough appart that accesses won't access the same location // across all loop ierations. - if (!isa(Dist) && HasSameSize && + if (HasSameSize && CommonStride && isSafeDependenceDistance(DL, SE, *(PSE.getBackedgeTakenCount()), *Dist, - Stride, TypeByteSize)) + *CommonStride, TypeByteSize)) return Dependence::NoDep; const SCEVConstant *C = dyn_cast(Dist); - if (!C) { -LLVM_DEBUG(dbgs() << "LAA: Dependence because of non-constant distance\n"); -FoundNonConstantDistanceDependence = true; -return Dependence::Unknown; - } - const APInt &Val = C->getAPInt(); - int64_t Distance = Val.getSExtValue(); - - // If the distance between accesses and their strides are known constants, - // check whether the accesses interlace each other. - if (std::abs(Distance) > 0 && Stride > 1 && HasSameSize && - areStridedAccessesIndependent(std::abs(Distance), Stride, TypeByteSize)) { -LLVM_DEBUG(dbgs() << "LAA: Strided accesses are independent\n"); -return Dependence::NoDep; + // Attempt to prove strided accesses independent. + if (C) { +const APInt &Val = C->getAPInt(); +int64_t Distance = Val.getSExtValue(); +// If the distance between accesses and their strides are known constants, +// check whether the accesses interlace each other. +if (std::abs(Distance) > 0 && CommonStride && *CommonStride > 1 && +HasSameSize && +areStridedAccessesIndependent(std::abs(Distance), *CommonStride, + TypeByteSize)) { + LLVM_DEBUG(dbgs() << "LAA: Strided accesses are independent\n"); + return Dependence::NoDep; +} } // Negative distances are not plausible dependencies. - if (Val.isNegative()) { + if (SE.isKnownNonPositive(Dist)) { +if (!SE.isKnownNegative(Dist)) { Meinersbur wrote: [serious] Not knowing something doesn't imply anything. ```suggestion // KnownNonPositive && KnownNonNegative => KnownZero if (SE.isKnownNonNegative(Dist)) { ``` https://github.com/llvm/llvm-project/pull/88039 ___ 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] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
@@ -2028,41 +2029,61 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent( if (std::holds_alternative(Res)) return std::get(Res); - const auto &[Dist, Stride, TypeByteSize, AIsWrite, BIsWrite] = + const auto &[Dist, StrideA, StrideB, TypeByteSize, AIsWrite, BIsWrite] = std::get(Res); bool HasSameSize = TypeByteSize > 0; + std::optional CommonStride = + StrideA == StrideB ? std::make_optional(StrideA) : std::nullopt; + if (isa(Dist)) { +// TODO: Relax requirement that there is a common stride to retry with +// non-constant distance dependencies. +FoundNonConstantDistanceDependence |= !!CommonStride; +LLVM_DEBUG(dbgs() << "LAA: Dependence because of uncomputable distance.\n"); +return Dependence::Unknown; + } + ScalarEvolution &SE = *PSE.getSE(); auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout(); // If the distance between the acecsses is larger than their absolute stride // multiplied by the backedge taken count, the accesses are independet, i.e. // they are far enough appart that accesses won't access the same location // across all loop ierations. - if (!isa(Dist) && HasSameSize && + if (HasSameSize && CommonStride && Meinersbur wrote: `isSafeDependenceDistance` could be easily modified as well to support different sizes, but it's unrelated to this patch. https://github.com/llvm/llvm-project/pull/88039 ___ 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] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/88039 ___ 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] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
https://github.com/fhahn reopened https://github.com/llvm/llvm-project/pull/88039 ___ 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 edited 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] Add new arguments to map_info to help support record type maps (PR #82851)
@@ -1452,10 +1454,14 @@ def MapInfoOp : OpenMP_Op<"map.info", [AttrSizedOperandSegments]> { - `var_type`: The type of the variable to copy. - `var_ptr_ptr`: Used when the variable copied is a member of a class, structure or derived type and refers to the originating struct. -- `members`: Used to indicate mapped child members for the current MapInfoOp, - represented as other MapInfoOp's, utilised in cases where a parent structure - type and members of the structure type are being mapped at the same time. +- `members`: Used to indicate mapped child members for the current MapInfoOp, + represented as other MapInfoOp's, utilised in cases where a parent structure + type and members of the structure type are being mapped at the same time. For example: map(to: parent, parent->member, parent->member2[:10]) +- `members_index`: Used to indicate the ordering of members within the containing + parent (generally a record type such as a structure, class or derived type), + e.g. struct {int x, float y, double z}, x would be 0, y would be 1, and z + would be 2. This aids the mapping skatrak wrote: Nit: It looks like the last sentence in the description here was cut short as well, or maybe just missing a period. ```suggestion - `members_index`: Used to indicate the ordering of members within the containing parent (generally a record type such as a structure, class or derived type), e.g. struct {int x, float y, double z}, x would be 0, y would be 1, and z would be 2. This aids the mapping ``` 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] Add new arguments to map_info to help support record type maps (PR #82851)
@@ -990,6 +990,77 @@ static void printMapClause(OpAsmPrinter &p, Operation *op, } } +static ParseResult parseMembersIndex(OpAsmParser &parser, + DenseIntElementsAttr &membersIdx) { + SmallVector values; + int64_t value; + int64_t shape[2] = {0, 0}; + unsigned shapeTmp = 0; + auto parseIndices = [&]() -> ParseResult { +if (parser.parseInteger(value)) + return failure(); +shapeTmp++; +values.push_back(APInt(32, value)); +return success(); + }; + + do { +if (failed(parser.parseLSquare())) + return failure(); + +if (parser.parseCommaSeparatedList(parseIndices)) + return failure(); + +if (failed(parser.parseRSquare())) + return failure(); + +// Only set once, if any indices are not the same size +// we error out in the next check as that's unsupported +if (shape[1] == 0) + shape[1] = shapeTmp; + +// Verify that the recently parsed list is equal to the +// first one we parsed, they must be equal lengths to +// keep the rectangular shape DenseIntElementsAttr +// requires +if (shapeTmp != shape[1]) + return failure(); + +shapeTmp = 0; +shape[0]++; + } while (succeeded(parser.parseOptionalComma())); + + if (!values.empty()) { +ShapedType valueType = +VectorType::get(shape, IntegerType::get(parser.getContext(), 32)); +membersIdx = DenseIntElementsAttr::get(valueType, values); + } + + return success(); +} + +static void printMembersIndex(OpAsmPrinter &p, MapInfoOp op, + DenseIntElementsAttr membersIdx) { + assert(membersIdx.getShapedType().getShape().size() <= 2); skatrak wrote: Nit: Maybe store a local reference to `membersIdx.getShapedType().getShape()` and reuse it to reduce the verbosity of the code a bit. 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] Add new arguments to map_info to help support record type maps (PR #82851)
https://github.com/skatrak approved this pull request. This LGTM, I just have some small nits. Thanks Andrew! 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] Add new arguments to map_info to help support record type maps (PR #82851)
@@ -1466,6 +1472,8 @@ def MapInfoOp : OpenMP_Op<"map.info", [AttrSizedOperandSegments]> { - 'map_capture_type': Capture type for the variable e.g. this, byref, byvalue, byvla this can affect how the variable is lowered. - `name`: Holds the name of variable as specified in user clause (including bounds). +- `partial_map`: The record type being mapped will not be mapped in its entirety, skatrak wrote: ```suggestion - `partial_map`: The record type being mapped will not be mapped in its entirety, ``` 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] Add new arguments to map_info to help support record type maps (PR #82851)
@@ -1452,10 +1454,14 @@ def MapInfoOp : OpenMP_Op<"map.info", [AttrSizedOperandSegments]> { - `var_type`: The type of the variable to copy. - `var_ptr_ptr`: Used when the variable copied is a member of a class, structure or derived type and refers to the originating struct. -- `members`: Used to indicate mapped child members for the current MapInfoOp, - represented as other MapInfoOp's, utilised in cases where a parent structure - type and members of the structure type are being mapped at the same time. +- `members`: Used to indicate mapped child members for the current MapInfoOp, + represented as other MapInfoOp's, utilised in cases where a parent structure + type and members of the structure type are being mapped at the same time. skatrak wrote: ```suggestion - `members`: Used to indicate mapped child members for the current MapInfoOp, represented as other MapInfoOp's, utilised in cases where a parent structure type and members of the structure type are being mapped at the same time. ``` 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] Add new arguments to map_info to help support record type maps (PR #82851)
https://github.com/skatrak edited 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] [llvm] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
@@ -25,6 +25,43 @@ using namespace llvm::omp; #define GEN_DIRECTIVES_IMPL #include "llvm/Frontend/OpenMP/OMP.inc" +static iterator_range::iterator> +getFirstCompositeRange(iterator_range::iterator> Leafs) { kparzysz wrote: This is intended to be a general utility to find the first sequence of leaf constructs that together constitute a composite construct. The input leafs aren't assumed to represent a legal construct. It's also used in `isCompositeConstruct` as well, where I break up the given directive into leafs and check if the "first composite range" is equal to the sequence of leafs. https://github.com/llvm/llvm-project/pull/89104 ___ 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] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/89104 >From 4593582b2a480dfffd2dceb4611cc0dec9cd7de5 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 11 Apr 2024 10:33:44 -0500 Subject: [PATCH 1/2] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs This function will break up a construct into constituent leaf and composite constructs, e.g. if OMPD_c_d_e and OMPD_d_e are composite constructs, then OMPD_a_b_c_d_e will be broken up into the list {OMPD_a, OMPD_b, OMPD_c_d_e}. --- llvm/include/llvm/Frontend/OpenMP/OMP.h | 6 ++ llvm/lib/Frontend/OpenMP/OMP.cpp | 88 --- .../Frontend/OpenMPCompositionTest.cpp| 32 +++ 3 files changed, 113 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.h b/llvm/include/llvm/Frontend/OpenMP/OMP.h index ec8ae68f1c2ca0..6f7a39acac1d31 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.h @@ -16,9 +16,15 @@ #include "llvm/Frontend/OpenMP/OMP.h.inc" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" namespace llvm::omp { ArrayRef getLeafConstructs(Directive D); +ArrayRef getLeafConstructsOrSelf(Directive D); + +ArrayRef +getLeafOrCompositeConstructs(Directive D, SmallVectorImpl &Output); + Directive getCompoundConstruct(ArrayRef Parts); bool isLeafConstruct(Directive D); diff --git a/llvm/lib/Frontend/OpenMP/OMP.cpp b/llvm/lib/Frontend/OpenMP/OMP.cpp index 4b9b7037ee4ad5..2ebadf5216a084 100644 --- a/llvm/lib/Frontend/OpenMP/OMP.cpp +++ b/llvm/lib/Frontend/OpenMP/OMP.cpp @@ -25,6 +25,43 @@ using namespace llvm::omp; #define GEN_DIRECTIVES_IMPL #include "llvm/Frontend/OpenMP/OMP.inc" +static iterator_range::iterator> +getFirstCompositeRange(iterator_range::iterator> Leafs) { + // OpenMP Spec 5.2: [17.3, 8-9] + // If directive-name-A and directive-name-B both correspond to loop- + // associated constructs then directive-name is a composite construct + // otherwise directive-name is a combined construct. + // + // In the list of leaf constructs, find the first loop-associated construct, + // this is the beginning of the range. Then, starting from the immediately + // following leaf construct, find the first sequence of adjacent loop- + // -associated constructs. The last of those is the last one of the range. + + auto firstLoopAssociated = + [](iterator_range::iterator> List) { +for (auto It = List.begin(), End = List.end(); It != End; ++It) { + if (getDirectiveAssociation(*It) == Association::Loop) +return It; +} +return List.end(); + }; + + auto Begin = firstLoopAssociated(Leafs); + if (Begin == Leafs.end()) +return llvm::make_range(Leafs.end(), Leafs.end()); + + auto End = + firstLoopAssociated(llvm::make_range(std::next(Begin), Leafs.end())); + if (End == Leafs.end()) +return llvm::make_range(Begin, std::next(Begin)); + + for (; End != Leafs.end(); ++End) { +if (getDirectiveAssociation(*End) != Association::Loop) + break; + } + return llvm::make_range(Begin, End); +} + namespace llvm::omp { ArrayRef getLeafConstructs(Directive D) { auto Idx = static_cast(D); @@ -34,6 +71,40 @@ ArrayRef getLeafConstructs(Directive D) { return ArrayRef(&Row[2], &Row[2] + static_cast(Row[1])); } +ArrayRef getLeafConstructsOrSelf(Directive D) { + if (auto Leafs = getLeafConstructs(D); !Leafs.empty()) +return Leafs; + auto Idx = static_cast(D); + assert(Idx < Directive_enumSize && "Invalid directive"); + const auto *Row = LeafConstructTable[LeafConstructTableOrdering[Idx]]; + // The first entry in the row is the directive itself. + return ArrayRef(&Row[0], &Row[0] + 1); +} + +ArrayRef +getLeafOrCompositeConstructs(Directive D, SmallVectorImpl &Output) { + using ArrayTy = ArrayRef; + using IteratorTy = ArrayTy::iterator; + ArrayRef Leafs = getLeafConstructsOrSelf(D); + + IteratorTy Iter = Leafs.begin(); + do { +auto Range = getFirstCompositeRange(llvm::make_range(Iter, Leafs.end())); +// All directives before the range are leaf constructs. +for (; Iter != Range.begin(); ++Iter) + Output.push_back(*Iter); +if (!Range.empty()) { + Directive Comp = + getCompoundConstruct(ArrayTy(Range.begin(), Range.end())); + assert(Comp != OMPD_unknown); + Output.push_back(Comp); +} +Iter = Range.end(); + } while (Iter != Leafs.end()); + + return Output; +} + Directive getCompoundConstruct(ArrayRef Parts) { if (Parts.empty()) return OMPD_unknown; @@ -88,20 +159,11 @@ Directive getCompoundConstruct(ArrayRef Parts) { bool isLeafConstruct(Directive D) { return getLeafConstructs(D).empty(); } bool isCompositeConstruct(Directive D) { - // OpenMP Spec 5.2: [17.3, 8-9] - // If directive-name-A and directive-name-B both correspond to loop- - // associated constructs then directive-name is a composite construct - llvm::ArrayRef Leafs{ge
[llvm-branch-commits] [llvm] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/89104 >From 4593582b2a480dfffd2dceb4611cc0dec9cd7de5 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 11 Apr 2024 10:33:44 -0500 Subject: [PATCH 1/3] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs This function will break up a construct into constituent leaf and composite constructs, e.g. if OMPD_c_d_e and OMPD_d_e are composite constructs, then OMPD_a_b_c_d_e will be broken up into the list {OMPD_a, OMPD_b, OMPD_c_d_e}. --- llvm/include/llvm/Frontend/OpenMP/OMP.h | 6 ++ llvm/lib/Frontend/OpenMP/OMP.cpp | 88 --- .../Frontend/OpenMPCompositionTest.cpp| 32 +++ 3 files changed, 113 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.h b/llvm/include/llvm/Frontend/OpenMP/OMP.h index ec8ae68f1c2ca0..6f7a39acac1d31 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.h @@ -16,9 +16,15 @@ #include "llvm/Frontend/OpenMP/OMP.h.inc" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" namespace llvm::omp { ArrayRef getLeafConstructs(Directive D); +ArrayRef getLeafConstructsOrSelf(Directive D); + +ArrayRef +getLeafOrCompositeConstructs(Directive D, SmallVectorImpl &Output); + Directive getCompoundConstruct(ArrayRef Parts); bool isLeafConstruct(Directive D); diff --git a/llvm/lib/Frontend/OpenMP/OMP.cpp b/llvm/lib/Frontend/OpenMP/OMP.cpp index 4b9b7037ee4ad5..2ebadf5216a084 100644 --- a/llvm/lib/Frontend/OpenMP/OMP.cpp +++ b/llvm/lib/Frontend/OpenMP/OMP.cpp @@ -25,6 +25,43 @@ using namespace llvm::omp; #define GEN_DIRECTIVES_IMPL #include "llvm/Frontend/OpenMP/OMP.inc" +static iterator_range::iterator> +getFirstCompositeRange(iterator_range::iterator> Leafs) { + // OpenMP Spec 5.2: [17.3, 8-9] + // If directive-name-A and directive-name-B both correspond to loop- + // associated constructs then directive-name is a composite construct + // otherwise directive-name is a combined construct. + // + // In the list of leaf constructs, find the first loop-associated construct, + // this is the beginning of the range. Then, starting from the immediately + // following leaf construct, find the first sequence of adjacent loop- + // -associated constructs. The last of those is the last one of the range. + + auto firstLoopAssociated = + [](iterator_range::iterator> List) { +for (auto It = List.begin(), End = List.end(); It != End; ++It) { + if (getDirectiveAssociation(*It) == Association::Loop) +return It; +} +return List.end(); + }; + + auto Begin = firstLoopAssociated(Leafs); + if (Begin == Leafs.end()) +return llvm::make_range(Leafs.end(), Leafs.end()); + + auto End = + firstLoopAssociated(llvm::make_range(std::next(Begin), Leafs.end())); + if (End == Leafs.end()) +return llvm::make_range(Begin, std::next(Begin)); + + for (; End != Leafs.end(); ++End) { +if (getDirectiveAssociation(*End) != Association::Loop) + break; + } + return llvm::make_range(Begin, End); +} + namespace llvm::omp { ArrayRef getLeafConstructs(Directive D) { auto Idx = static_cast(D); @@ -34,6 +71,40 @@ ArrayRef getLeafConstructs(Directive D) { return ArrayRef(&Row[2], &Row[2] + static_cast(Row[1])); } +ArrayRef getLeafConstructsOrSelf(Directive D) { + if (auto Leafs = getLeafConstructs(D); !Leafs.empty()) +return Leafs; + auto Idx = static_cast(D); + assert(Idx < Directive_enumSize && "Invalid directive"); + const auto *Row = LeafConstructTable[LeafConstructTableOrdering[Idx]]; + // The first entry in the row is the directive itself. + return ArrayRef(&Row[0], &Row[0] + 1); +} + +ArrayRef +getLeafOrCompositeConstructs(Directive D, SmallVectorImpl &Output) { + using ArrayTy = ArrayRef; + using IteratorTy = ArrayTy::iterator; + ArrayRef Leafs = getLeafConstructsOrSelf(D); + + IteratorTy Iter = Leafs.begin(); + do { +auto Range = getFirstCompositeRange(llvm::make_range(Iter, Leafs.end())); +// All directives before the range are leaf constructs. +for (; Iter != Range.begin(); ++Iter) + Output.push_back(*Iter); +if (!Range.empty()) { + Directive Comp = + getCompoundConstruct(ArrayTy(Range.begin(), Range.end())); + assert(Comp != OMPD_unknown); + Output.push_back(Comp); +} +Iter = Range.end(); + } while (Iter != Leafs.end()); + + return Output; +} + Directive getCompoundConstruct(ArrayRef Parts) { if (Parts.empty()) return OMPD_unknown; @@ -88,20 +159,11 @@ Directive getCompoundConstruct(ArrayRef Parts) { bool isLeafConstruct(Directive D) { return getLeafConstructs(D).empty(); } bool isCompositeConstruct(Directive D) { - // OpenMP Spec 5.2: [17.3, 8-9] - // If directive-name-A and directive-name-B both correspond to loop- - // associated constructs then directive-name is a composite construct - llvm::ArrayRef Leafs{ge
[llvm-branch-commits] [llvm] [LLVM][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
kparzysz wrote: Push review updates for another PR here by mistake... https://github.com/llvm/llvm-project/pull/89104 ___ 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] [Frontend][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)
https://github.com/kparzysz edited https://github.com/llvm/llvm-project/pull/89104 ___ 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][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -55,6 +55,20 @@ MDNode *getBranchWeightMDNode(const Instruction &I); /// Nullptr otherwise. MDNode *getValidBranchWeightMDNode(const Instruction &I); +/// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* +/// intrinsic +bool hasExpectedProvenance(const Instruction &I); + +/// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* +/// intrinsic +bool hasExpectedProvenance(const MDNode *ProfileData); ilovepi wrote: Fair points ... maybe we should consider that refactoring anyway? I can file a Github issue to track it, and try to set aside some time over the next couple of weeks to look into it. https://github.com/llvm/llvm-project/pull/86609 ___ 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][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -55,6 +55,20 @@ MDNode *getBranchWeightMDNode(const Instruction &I); /// Nullptr otherwise. MDNode *getValidBranchWeightMDNode(const Instruction &I); +/// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* +/// intrinsic +bool hasExpectedProvenance(const Instruction &I); + +/// Check if Branch Weight Metadata has an "expected" field from an llvm.expect* +/// intrinsic +bool hasExpectedProvenance(const MDNode *ProfileData); + +/// Return the offset to the first branch weight data +unsigned getBranchWeightOffset(const Instruction &I); ilovepi wrote: That's a fair point. IIRC I needed this someplace, but maybe I'm mis-remembering and that's a moot point. I'll look at my follow up patches to ensure it isn't required. https://github.com/llvm/llvm-project/pull/86609 ___ 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][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -1210,12 +1210,22 @@ Instruction *Instruction::cloneImpl() const { void Instruction::swapProfMetadata() { MDNode *ProfileData = getBranchWeightMDNode(*this); - if (!ProfileData || ProfileData->getNumOperands() != 3) + if (!isBranchWeightMD(ProfileData)) return; - // The first operand is the name. Fetch them backwards and build a new one. - Metadata *Ops[] = {ProfileData->getOperand(0), ProfileData->getOperand(2), - ProfileData->getOperand(1)}; + SmallVector Ops; + unsigned int FirstIdx = getBranchWeightOffset(ProfileData); + unsigned int SecondIdx = FirstIdx + 1; + // If there are more weights past the second, we can't swap them + if (ProfileData->getNumOperands() > SecondIdx + 1) +return; + Ops.push_back(ProfileData->getOperand(0)); + if (hasExpectedProvenance(ProfileData)) { +Ops.push_back(ProfileData->getOperand(1)); + } ilovepi wrote: That's a good suggestion. I'll update the patch to reflect. https://github.com/llvm/llvm-project/pull/86609 ___ 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] [mlir] [mlir][test] Shard and reorganize the test dialect (PR #89424)
@@ -228,6 +332,7 @@ void TestDialect::initialize() { >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); Mogball wrote: As you noted, this isn't needed. I think this got lost in the merge resolution. I'll delete it. https://github.com/llvm/llvm-project/pull/89424 ___ 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][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
@@ -5196,7 +5198,11 @@ void SwitchInstProfUpdateWrapper::init() { if (!ProfileData) return; - if (ProfileData->getNumOperands() != SI.getNumSuccessors() + 1) { + // FIXME: This check belongs in ProfDataUtils. Its almost equivalent to + // getValidBranchWeightMDNode(), but the need to use llvm_unreachable + // makes them slightly different. + if (ProfileData->getNumOperands() != + SI.getNumSuccessors() + getBranchWeightOffset(ProfileData)) { ilovepi wrote: Another good suggestion. Thank you. https://github.com/llvm/llvm-project/pull/86609 ___ 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][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
ilovepi wrote: @MatzeB Thanks for all the good suggestions. I'm just getting back form EuroLLVM + a vacation, but I'll try to set aside some time this afternoon to update the PR. https://github.com/llvm/llvm-project/pull/86609 ___ 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] [compiler-rt] c10f8e2 - Revert "[compiler-rt][ctx_instr] Add `ctx_profile` component (#89304)"
Author: Mircea Trofin Date: 2024-04-22T09:33:53-07:00 New Revision: c10f8e22ad731488726ecfecb58073127063ca26 URL: https://github.com/llvm/llvm-project/commit/c10f8e22ad731488726ecfecb58073127063ca26 DIFF: https://github.com/llvm/llvm-project/commit/c10f8e22ad731488726ecfecb58073127063ca26.diff LOG: Revert "[compiler-rt][ctx_instr] Add `ctx_profile` component (#89304)" This reverts commit 6ad22c879aab88b6bb0531eeb3a6708a82f88cf6. Added: Modified: compiler-rt/CMakeLists.txt compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake compiler-rt/cmake/config-ix.cmake compiler-rt/lib/CMakeLists.txt Removed: compiler-rt/lib/ctx_profile/CMakeLists.txt compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp compiler-rt/lib/ctx_profile/CtxInstrProfiling.h compiler-rt/lib/ctx_profile/tests/CMakeLists.txt compiler-rt/lib/ctx_profile/tests/CtxInstrProfilingTest.cpp compiler-rt/lib/ctx_profile/tests/driver.cpp diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 6ce451e3cac2e3..8649507ce1c79b 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -50,8 +50,6 @@ option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON) mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER) option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON) mark_as_advanced(COMPILER_RT_BUILD_PROFILE) -option(COMPILER_RT_BUILD_CTX_PROFILE "Build ctx profile runtime" ON) -mark_as_advanced(COMPILER_RT_BUILD_CTX_PROFILE) option(COMPILER_RT_BUILD_MEMPROF "Build memory profiling runtime" ON) mark_as_advanced(COMPILER_RT_BUILD_MEMPROF) option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF) diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake index 2fe06273a814c7..423171532c2028 100644 --- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake +++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake @@ -66,7 +66,6 @@ set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64}) set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} ${PPC64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON} ${RISCV32} ${RISCV64} ${LOONGARCH64}) -set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64}) set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X} ${LOONGARCH64} ${RISCV64}) set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64} diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index ba740af9e1d60f..b281ac64f5d5c7 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -632,9 +632,6 @@ if(APPLE) list_intersect(PROFILE_SUPPORTED_ARCH ALL_PROFILE_SUPPORTED_ARCH SANITIZER_COMMON_SUPPORTED_ARCH) - list_intersect(CTX_PROFILE_SUPPORTED_ARCH -ALL_CTX_PROFILE_SUPPORTED_ARCH -SANITIZER_COMMON_SUPPORTED_ARCH) list_intersect(TSAN_SUPPORTED_ARCH ALL_TSAN_SUPPORTED_ARCH SANITIZER_COMMON_SUPPORTED_ARCH) @@ -681,7 +678,6 @@ else() filter_available_targets(HWASAN_SUPPORTED_ARCH ${ALL_HWASAN_SUPPORTED_ARCH}) filter_available_targets(MEMPROF_SUPPORTED_ARCH ${ALL_MEMPROF_SUPPORTED_ARCH}) filter_available_targets(PROFILE_SUPPORTED_ARCH ${ALL_PROFILE_SUPPORTED_ARCH}) - filter_available_targets(CTX_PROFILE_SUPPORTED_ARCH ${ALL_CTX_PROFILE_SUPPORTED_ARCH}) filter_available_targets(TSAN_SUPPORTED_ARCH ${ALL_TSAN_SUPPORTED_ARCH}) filter_available_targets(UBSAN_SUPPORTED_ARCH ${ALL_UBSAN_SUPPORTED_ARCH}) filter_available_targets(SAFESTACK_SUPPORTED_ARCH @@ -807,13 +803,6 @@ else() set(COMPILER_RT_HAS_PROFILE FALSE) endif() -if (COMPILER_RT_HAS_SANITIZER_COMMON AND CTX_PROFILE_SUPPORTED_ARCH AND -OS_NAME MATCHES "Linux") - set(COMPILER_RT_HAS_CTX_PROFILE TRUE) -else() - set(COMPILER_RT_HAS_CTX_PROFILE FALSE) -endif() - if (COMPILER_RT_HAS_SANITIZER_COMMON AND TSAN_SUPPORTED_ARCH) if (OS_NAME MATCHES "Linux|Darwin|FreeBSD|NetBSD") set(COMPILER_RT_HAS_TSAN TRUE) diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index f9e96563b88090..43ba9a102c8487 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -51,10 +51,6 @@ if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) compiler_rt_build_runtime(profile) endif() -if(COMPILER_RT_BUILD_CTX_PROFILE AND COMPILER_RT_HAS_CTX_PROFILE) - compiler_rt_build_runtime(ctx_profile) -endif() - if(COMPILER_RT_BUILD_XRAY) compiler_rt_build_runtime(xray) endif() diff --git a/compiler-rt/lib/ctx_profile/CMakeLists.txt b/compiler-rt/lib/ctx_profile/CMakeLists.txt deleted file mode 100644 index 621b7d30b76d41..00 --- a/compiler-rt/lib/ctx_profile/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -add_compiler_rt_component(ctx_profile) - -set(CTX_PROFILE_SOURCES - CtxInstrProfiling.cpp - ) - -set(CTX_PROFILE_H
[llvm-branch-commits] [llvm] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
https://github.com/Mogball created https://github.com/llvm/llvm-project/pull/89628 [mlir][test] Shard the Test Dialect (NFC) This PR uses the new op sharding mechanism in tablegen to shard the test dialect's op definitions. This breaks the definition of ops into multiple source files, speeding up compile time of the test dialect dramatically. This improves developer cycle times when iterating on the test dialect. >From 498ea497b99e1328fc16cbc41ebf37575c1c4a59 Mon Sep 17 00:00:00 2001 From: Mogball Date: Mon, 22 Apr 2024 16:39:58 + Subject: [PATCH] [mlir][test] Shard the Test Dialect (NFC) This PR uses the new op sharding mechanism in tablegen to shard the test dialect's op definitions. This breaks the definition of ops into multiple source files, speeding up compile time of the test dialect dramatically. This improves developer cycle times when iterating on the test dialect. --- mlir/test/lib/Dialect/Test/CMakeLists.txt | 6 +++-- mlir/test/lib/Dialect/Test/TestDialect.cpp| 5 +--- mlir/test/lib/Dialect/Test/TestOps.cpp| 1 - .../mlir/test/BUILD.bazel | 25 +++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index f63e4d330e6ac1..fab89378093326 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRTestEnumDefIncGen) set(LLVM_TARGET_DEFINITIONS TestOps.td) -mlir_tablegen(TestOps.h.inc -gen-op-decls) -mlir_tablegen(TestOps.cpp.inc -gen-op-defs) mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test) mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test) mlir_tablegen(TestPatterns.inc -gen-rewriters) @@ -43,6 +41,8 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls) mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRTestOpsSyntaxIncGen) +add_sharded_ops(TestOps 20) + # Exclude tests from libMLIR.so add_mlir_library(MLIRTestDialect TestAttributes.cpp @@ -56,6 +56,7 @@ add_mlir_library(MLIRTestDialect TestTypes.cpp TestOpsSyntax.cpp TestDialectInterfaces.cpp + ${SHARDED_SRCS} EXCLUDE_FROM_LIBMLIR @@ -66,6 +67,7 @@ add_mlir_library(MLIRTestDialect MLIRTestTypeDefIncGen MLIRTestOpsIncGen MLIRTestOpsSyntaxIncGen + MLIRTestOpsShardGen LINK_LIBS PUBLIC MLIRControlFlowInterfaces diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 77fd7e61bd3a06..bfb9592e638288 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -326,12 +326,9 @@ struct TestOpEffectInterfaceFallback void TestDialect::initialize() { registerAttributes(); registerTypes(); - addOperations< -#define GET_OP_LIST -#include "TestOps.cpp.inc" - >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); registerDynamicOp(getDynamicGenericOp(this)); registerDynamicOp(getDynamicOneOperandTwoResultsOp(this)); registerDynamicOp(getDynamicCustomParserPrinterOp(this)); diff --git a/mlir/test/lib/Dialect/Test/TestOps.cpp b/mlir/test/lib/Dialect/Test/TestOps.cpp index ce7e476be74e65..47d5b1b19121ef 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.cpp +++ b/mlir/test/lib/Dialect/Test/TestOps.cpp @@ -14,5 +14,4 @@ using namespace mlir; using namespace test; -#define GET_OP_CLASSES #include "TestOps.cpp.inc" diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel index dc5f4047c286db..b98f7eb5613af4 100644 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("//llvm:lit_test.bzl", "package_path") -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") +load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library", "gentbl_sharded_ops", "td_library") package( default_visibility = ["//visibility:public"], @@ -151,14 +151,6 @@ gentbl_cc_library( name = "TestOpsIncGen", strip_include_prefix = "lib/Dialect/Test", tbl_outs = [ -( -["-gen-op-decls"], -"lib/Dialect/Test/TestOps.h.inc", -), -( -["-gen-op-defs"], -"lib/Dialect/Test/TestOps.cpp.inc", -), ( [ "-gen-dialect-decls", @@ -370,12 +362,25 @@ cc_library( ], ) +gentbl_sharded_ops( +name = "TestDialectOpSrcs", +hdr_out = "lib/Dialect/Test/TestOps.h.inc", +shard_count = 20, +sharder = "//mlir:mlir-src-sharder", +src_file = "lib/Dialect/Test/TestOps.cpp", +src_out = "lib/Dialect/Test/TestOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +
[llvm-branch-commits] [llvm] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
https://github.com/Mogball updated https://github.com/llvm/llvm-project/pull/89628 >From 478b4e8e9523ab80e65f115274b2f2ae4423faf4 Mon Sep 17 00:00:00 2001 From: Mogball Date: Mon, 22 Apr 2024 16:39:58 + Subject: [PATCH] [mlir][test] Shard the Test Dialect (NFC) This PR uses the new op sharding mechanism in tablegen to shard the test dialect's op definitions. This breaks the definition of ops into multiple source files, speeding up compile time of the test dialect dramatically. This improves developer cycle times when iterating on the test dialect. stack-info: PR: https://github.com/llvm/llvm-project/pull/89628, branch: users/Mogball/stack/1 --- mlir/test/lib/Dialect/Test/CMakeLists.txt | 6 +++-- mlir/test/lib/Dialect/Test/TestDialect.cpp| 5 +--- mlir/test/lib/Dialect/Test/TestOps.cpp| 1 - .../mlir/test/BUILD.bazel | 25 +++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index f63e4d330e6ac1..fab89378093326 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRTestEnumDefIncGen) set(LLVM_TARGET_DEFINITIONS TestOps.td) -mlir_tablegen(TestOps.h.inc -gen-op-decls) -mlir_tablegen(TestOps.cpp.inc -gen-op-defs) mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test) mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test) mlir_tablegen(TestPatterns.inc -gen-rewriters) @@ -43,6 +41,8 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls) mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRTestOpsSyntaxIncGen) +add_sharded_ops(TestOps 20) + # Exclude tests from libMLIR.so add_mlir_library(MLIRTestDialect TestAttributes.cpp @@ -56,6 +56,7 @@ add_mlir_library(MLIRTestDialect TestTypes.cpp TestOpsSyntax.cpp TestDialectInterfaces.cpp + ${SHARDED_SRCS} EXCLUDE_FROM_LIBMLIR @@ -66,6 +67,7 @@ add_mlir_library(MLIRTestDialect MLIRTestTypeDefIncGen MLIRTestOpsIncGen MLIRTestOpsSyntaxIncGen + MLIRTestOpsShardGen LINK_LIBS PUBLIC MLIRControlFlowInterfaces diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 77fd7e61bd3a06..bfb9592e638288 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -326,12 +326,9 @@ struct TestOpEffectInterfaceFallback void TestDialect::initialize() { registerAttributes(); registerTypes(); - addOperations< -#define GET_OP_LIST -#include "TestOps.cpp.inc" - >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); registerDynamicOp(getDynamicGenericOp(this)); registerDynamicOp(getDynamicOneOperandTwoResultsOp(this)); registerDynamicOp(getDynamicCustomParserPrinterOp(this)); diff --git a/mlir/test/lib/Dialect/Test/TestOps.cpp b/mlir/test/lib/Dialect/Test/TestOps.cpp index ce7e476be74e65..47d5b1b19121ef 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.cpp +++ b/mlir/test/lib/Dialect/Test/TestOps.cpp @@ -14,5 +14,4 @@ using namespace mlir; using namespace test; -#define GET_OP_CLASSES #include "TestOps.cpp.inc" diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel index dc5f4047c286db..b98f7eb5613af4 100644 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("//llvm:lit_test.bzl", "package_path") -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") +load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library", "gentbl_sharded_ops", "td_library") package( default_visibility = ["//visibility:public"], @@ -151,14 +151,6 @@ gentbl_cc_library( name = "TestOpsIncGen", strip_include_prefix = "lib/Dialect/Test", tbl_outs = [ -( -["-gen-op-decls"], -"lib/Dialect/Test/TestOps.h.inc", -), -( -["-gen-op-defs"], -"lib/Dialect/Test/TestOps.cpp.inc", -), ( [ "-gen-dialect-decls", @@ -370,12 +362,25 @@ cc_library( ], ) +gentbl_sharded_ops( +name = "TestDialectOpSrcs", +hdr_out = "lib/Dialect/Test/TestOps.h.inc", +shard_count = 20, +sharder = "//mlir:mlir-src-sharder", +src_file = "lib/Dialect/Test/TestOps.cpp", +src_out = "lib/Dialect/Test/TestOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "lib/Dialect/Test/TestOps.td", +test = True, +deps = [":TestOpTdFiles"], +) + cc_library( name = "TestDialect", srcs = glob( ["lib/Dialect/Test/*.cpp"], exclude = ["lib/Dialect/Test/TestTo
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
https://github.com/Mogball edited https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
https://github.com/Mogball edited https://github.com/llvm/llvm-project/pull/89424 ___ 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] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
llvmbot wrote: @llvm/pr-subscribers-mlir Author: Jeff Niu (Mogball) Changes Stacked PRs: * __->__#89628 * #89424 * #89423 --- --- --- ### [mlir][test] Shard the Test Dialect (NFC) This PR uses the new op sharding mechanism in tablegen to shard the test dialect's op definitions. This breaks the definition of ops into multiple source files, speeding up compile time of the test dialect dramatically. This improves developer cycle times when iterating on the test dialect. --- Full diff: https://github.com/llvm/llvm-project/pull/89628.diff 4 Files Affected: - (modified) mlir/test/lib/Dialect/Test/CMakeLists.txt (+4-2) - (modified) mlir/test/lib/Dialect/Test/TestDialect.cpp (+1-4) - (modified) mlir/test/lib/Dialect/Test/TestOps.cpp (-1) - (modified) utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel (+15-10) ``diff diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index f63e4d330e6ac1..fab89378093326 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRTestEnumDefIncGen) set(LLVM_TARGET_DEFINITIONS TestOps.td) -mlir_tablegen(TestOps.h.inc -gen-op-decls) -mlir_tablegen(TestOps.cpp.inc -gen-op-defs) mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test) mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test) mlir_tablegen(TestPatterns.inc -gen-rewriters) @@ -43,6 +41,8 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls) mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRTestOpsSyntaxIncGen) +add_sharded_ops(TestOps 20) + # Exclude tests from libMLIR.so add_mlir_library(MLIRTestDialect TestAttributes.cpp @@ -56,6 +56,7 @@ add_mlir_library(MLIRTestDialect TestTypes.cpp TestOpsSyntax.cpp TestDialectInterfaces.cpp + ${SHARDED_SRCS} EXCLUDE_FROM_LIBMLIR @@ -66,6 +67,7 @@ add_mlir_library(MLIRTestDialect MLIRTestTypeDefIncGen MLIRTestOpsIncGen MLIRTestOpsSyntaxIncGen + MLIRTestOpsShardGen LINK_LIBS PUBLIC MLIRControlFlowInterfaces diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 77fd7e61bd3a06..bfb9592e638288 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -326,12 +326,9 @@ struct TestOpEffectInterfaceFallback void TestDialect::initialize() { registerAttributes(); registerTypes(); - addOperations< -#define GET_OP_LIST -#include "TestOps.cpp.inc" - >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); registerDynamicOp(getDynamicGenericOp(this)); registerDynamicOp(getDynamicOneOperandTwoResultsOp(this)); registerDynamicOp(getDynamicCustomParserPrinterOp(this)); diff --git a/mlir/test/lib/Dialect/Test/TestOps.cpp b/mlir/test/lib/Dialect/Test/TestOps.cpp index ce7e476be74e65..47d5b1b19121ef 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.cpp +++ b/mlir/test/lib/Dialect/Test/TestOps.cpp @@ -14,5 +14,4 @@ using namespace mlir; using namespace test; -#define GET_OP_CLASSES #include "TestOps.cpp.inc" diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel index dc5f4047c286db..b98f7eb5613af4 100644 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("//llvm:lit_test.bzl", "package_path") -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") +load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library", "gentbl_sharded_ops", "td_library") package( default_visibility = ["//visibility:public"], @@ -151,14 +151,6 @@ gentbl_cc_library( name = "TestOpsIncGen", strip_include_prefix = "lib/Dialect/Test", tbl_outs = [ -( -["-gen-op-decls"], -"lib/Dialect/Test/TestOps.h.inc", -), -( -["-gen-op-defs"], -"lib/Dialect/Test/TestOps.cpp.inc", -), ( [ "-gen-dialect-decls", @@ -370,12 +362,25 @@ cc_library( ], ) +gentbl_sharded_ops( +name = "TestDialectOpSrcs", +hdr_out = "lib/Dialect/Test/TestOps.h.inc", +shard_count = 20, +sharder = "//mlir:mlir-src-sharder", +src_file = "lib/Dialect/Test/TestOps.cpp", +src_out = "lib/Dialect/Test/TestOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "lib/Dialect/Test/TestOps.td", +test = True, +deps = [":TestOpTdFiles"], +) + cc_library( name = "TestDialect", srcs = glob( ["lib/Dialect/Test/*.cpp"], exclude = ["lib/Dialect/Test/TestToLLVMIRTranslation.cpp"], -), +) + [":TestDialectOpSrcs"], hdrs = glob(["lib/Dialect/Te
[llvm-branch-commits] [llvm] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
https://github.com/Mogball updated https://github.com/llvm/llvm-project/pull/89628 >From 478b4e8e9523ab80e65f115274b2f2ae4423faf4 Mon Sep 17 00:00:00 2001 From: Mogball Date: Mon, 22 Apr 2024 16:39:58 + Subject: [PATCH] [mlir][test] Shard the Test Dialect (NFC) This PR uses the new op sharding mechanism in tablegen to shard the test dialect's op definitions. This breaks the definition of ops into multiple source files, speeding up compile time of the test dialect dramatically. This improves developer cycle times when iterating on the test dialect. stack-info: PR: https://github.com/llvm/llvm-project/pull/89628, branch: users/Mogball/stack/1 --- mlir/test/lib/Dialect/Test/CMakeLists.txt | 6 +++-- mlir/test/lib/Dialect/Test/TestDialect.cpp| 5 +--- mlir/test/lib/Dialect/Test/TestOps.cpp| 1 - .../mlir/test/BUILD.bazel | 25 +++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index f63e4d330e6ac1..fab89378093326 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRTestEnumDefIncGen) set(LLVM_TARGET_DEFINITIONS TestOps.td) -mlir_tablegen(TestOps.h.inc -gen-op-decls) -mlir_tablegen(TestOps.cpp.inc -gen-op-defs) mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test) mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test) mlir_tablegen(TestPatterns.inc -gen-rewriters) @@ -43,6 +41,8 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls) mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRTestOpsSyntaxIncGen) +add_sharded_ops(TestOps 20) + # Exclude tests from libMLIR.so add_mlir_library(MLIRTestDialect TestAttributes.cpp @@ -56,6 +56,7 @@ add_mlir_library(MLIRTestDialect TestTypes.cpp TestOpsSyntax.cpp TestDialectInterfaces.cpp + ${SHARDED_SRCS} EXCLUDE_FROM_LIBMLIR @@ -66,6 +67,7 @@ add_mlir_library(MLIRTestDialect MLIRTestTypeDefIncGen MLIRTestOpsIncGen MLIRTestOpsSyntaxIncGen + MLIRTestOpsShardGen LINK_LIBS PUBLIC MLIRControlFlowInterfaces diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 77fd7e61bd3a06..bfb9592e638288 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -326,12 +326,9 @@ struct TestOpEffectInterfaceFallback void TestDialect::initialize() { registerAttributes(); registerTypes(); - addOperations< -#define GET_OP_LIST -#include "TestOps.cpp.inc" - >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); registerDynamicOp(getDynamicGenericOp(this)); registerDynamicOp(getDynamicOneOperandTwoResultsOp(this)); registerDynamicOp(getDynamicCustomParserPrinterOp(this)); diff --git a/mlir/test/lib/Dialect/Test/TestOps.cpp b/mlir/test/lib/Dialect/Test/TestOps.cpp index ce7e476be74e65..47d5b1b19121ef 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.cpp +++ b/mlir/test/lib/Dialect/Test/TestOps.cpp @@ -14,5 +14,4 @@ using namespace mlir; using namespace test; -#define GET_OP_CLASSES #include "TestOps.cpp.inc" diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel index dc5f4047c286db..b98f7eb5613af4 100644 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("//llvm:lit_test.bzl", "package_path") -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") +load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library", "gentbl_sharded_ops", "td_library") package( default_visibility = ["//visibility:public"], @@ -151,14 +151,6 @@ gentbl_cc_library( name = "TestOpsIncGen", strip_include_prefix = "lib/Dialect/Test", tbl_outs = [ -( -["-gen-op-decls"], -"lib/Dialect/Test/TestOps.h.inc", -), -( -["-gen-op-defs"], -"lib/Dialect/Test/TestOps.cpp.inc", -), ( [ "-gen-dialect-decls", @@ -370,12 +362,25 @@ cc_library( ], ) +gentbl_sharded_ops( +name = "TestDialectOpSrcs", +hdr_out = "lib/Dialect/Test/TestOps.h.inc", +shard_count = 20, +sharder = "//mlir:mlir-src-sharder", +src_file = "lib/Dialect/Test/TestOps.cpp", +src_out = "lib/Dialect/Test/TestOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "lib/Dialect/Test/TestOps.td", +test = True, +deps = [":TestOpTdFiles"], +) + cc_library( name = "TestDialect", srcs = glob( ["lib/Dialect/Test/*.cpp"], exclude = ["lib/Dialect/Test/TestTo
[llvm-branch-commits] [llvm] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
https://github.com/Mogball updated https://github.com/llvm/llvm-project/pull/89628 >From 478b4e8e9523ab80e65f115274b2f2ae4423faf4 Mon Sep 17 00:00:00 2001 From: Mogball Date: Mon, 22 Apr 2024 16:39:58 + Subject: [PATCH] [mlir][test] Shard the Test Dialect (NFC) This PR uses the new op sharding mechanism in tablegen to shard the test dialect's op definitions. This breaks the definition of ops into multiple source files, speeding up compile time of the test dialect dramatically. This improves developer cycle times when iterating on the test dialect. stack-info: PR: https://github.com/llvm/llvm-project/pull/89628, branch: users/Mogball/stack/1 --- mlir/test/lib/Dialect/Test/CMakeLists.txt | 6 +++-- mlir/test/lib/Dialect/Test/TestDialect.cpp| 5 +--- mlir/test/lib/Dialect/Test/TestOps.cpp| 1 - .../mlir/test/BUILD.bazel | 25 +++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index f63e4d330e6ac1..fab89378093326 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRTestEnumDefIncGen) set(LLVM_TARGET_DEFINITIONS TestOps.td) -mlir_tablegen(TestOps.h.inc -gen-op-decls) -mlir_tablegen(TestOps.cpp.inc -gen-op-defs) mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test) mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test) mlir_tablegen(TestPatterns.inc -gen-rewriters) @@ -43,6 +41,8 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls) mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRTestOpsSyntaxIncGen) +add_sharded_ops(TestOps 20) + # Exclude tests from libMLIR.so add_mlir_library(MLIRTestDialect TestAttributes.cpp @@ -56,6 +56,7 @@ add_mlir_library(MLIRTestDialect TestTypes.cpp TestOpsSyntax.cpp TestDialectInterfaces.cpp + ${SHARDED_SRCS} EXCLUDE_FROM_LIBMLIR @@ -66,6 +67,7 @@ add_mlir_library(MLIRTestDialect MLIRTestTypeDefIncGen MLIRTestOpsIncGen MLIRTestOpsSyntaxIncGen + MLIRTestOpsShardGen LINK_LIBS PUBLIC MLIRControlFlowInterfaces diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 77fd7e61bd3a06..bfb9592e638288 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -326,12 +326,9 @@ struct TestOpEffectInterfaceFallback void TestDialect::initialize() { registerAttributes(); registerTypes(); - addOperations< -#define GET_OP_LIST -#include "TestOps.cpp.inc" - >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); registerDynamicOp(getDynamicGenericOp(this)); registerDynamicOp(getDynamicOneOperandTwoResultsOp(this)); registerDynamicOp(getDynamicCustomParserPrinterOp(this)); diff --git a/mlir/test/lib/Dialect/Test/TestOps.cpp b/mlir/test/lib/Dialect/Test/TestOps.cpp index ce7e476be74e65..47d5b1b19121ef 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.cpp +++ b/mlir/test/lib/Dialect/Test/TestOps.cpp @@ -14,5 +14,4 @@ using namespace mlir; using namespace test; -#define GET_OP_CLASSES #include "TestOps.cpp.inc" diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel index dc5f4047c286db..b98f7eb5613af4 100644 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -4,7 +4,7 @@ load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("//llvm:lit_test.bzl", "package_path") -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") +load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library", "gentbl_sharded_ops", "td_library") package( default_visibility = ["//visibility:public"], @@ -151,14 +151,6 @@ gentbl_cc_library( name = "TestOpsIncGen", strip_include_prefix = "lib/Dialect/Test", tbl_outs = [ -( -["-gen-op-decls"], -"lib/Dialect/Test/TestOps.h.inc", -), -( -["-gen-op-defs"], -"lib/Dialect/Test/TestOps.cpp.inc", -), ( [ "-gen-dialect-decls", @@ -370,12 +362,25 @@ cc_library( ], ) +gentbl_sharded_ops( +name = "TestDialectOpSrcs", +hdr_out = "lib/Dialect/Test/TestOps.h.inc", +shard_count = 20, +sharder = "//mlir:mlir-src-sharder", +src_file = "lib/Dialect/Test/TestOps.cpp", +src_out = "lib/Dialect/Test/TestOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "lib/Dialect/Test/TestOps.td", +test = True, +deps = [":TestOpTdFiles"], +) + cc_library( name = "TestDialect", srcs = glob( ["lib/Dialect/Test/*.cpp"], exclude = ["lib/Dialect/Test/TestTo
[llvm-branch-commits] [AsmPrinter][CallGraphSection] Emit call graph section (PR #87576)
https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/87576 ___ 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] [AsmPrinter][CallGraphSection] Emit call graph section (PR #87576)
https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/87576 ___ 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/Prabhuk updated https://github.com/llvm/llvm-project/pull/87573 >From a8a5848885e12c771f12cfa33b4dbc6a0272e925 Mon Sep 17 00:00:00 2001 From: Prabhuk Date: Mon, 22 Apr 2024 11:34:04 -0700 Subject: [PATCH] Update clang/lib/CodeGen/CodeGenModule.cpp Cleaner if checks. Co-authored-by: Matt Arsenault --- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e19bbee996f582..ff1586d2fa8abe 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2711,7 +2711,7 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, void CodeGenModule::CreateFunctionTypeMetadataForIcall(const QualType &QT, llvm::CallBase *CB) { // Only if needed for call graph section and only for indirect calls. - if (!(CodeGenOpts.CallGraphSection && CB && CB->isIndirectCall())) + if (!CodeGenOpts.CallGraphSection || !CB || !CB->isIndirectCall()) return; auto *MD = CreateMetadataIdentifierGeneralized(QT); ___ 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/Prabhuk updated https://github.com/llvm/llvm-project/pull/87573 >From a8a5848885e12c771f12cfa33b4dbc6a0272e925 Mon Sep 17 00:00:00 2001 From: Prabhuk Date: Mon, 22 Apr 2024 11:34:04 -0700 Subject: [PATCH 1/2] Update clang/lib/CodeGen/CodeGenModule.cpp Cleaner if checks. Co-authored-by: Matt Arsenault --- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e19bbee996f582..ff1586d2fa8abe 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2711,7 +2711,7 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, void CodeGenModule::CreateFunctionTypeMetadataForIcall(const QualType &QT, llvm::CallBase *CB) { // Only if needed for call graph section and only for indirect calls. - if (!(CodeGenOpts.CallGraphSection && CB && CB->isIndirectCall())) + if (!CodeGenOpts.CallGraphSection || !CB || !CB->isIndirectCall()) return; auto *MD = CreateMetadataIdentifierGeneralized(QT); >From 019b2ca5e1c263183ed114e0b967b4e77b4a17a8 Mon Sep 17 00:00:00 2001 From: Prabhuk Date: Mon, 22 Apr 2024 11:34:31 -0700 Subject: [PATCH 2/2] Update clang/lib/CodeGen/CodeGenModule.cpp Update the comments as suggested. Co-authored-by: Matt Arsenault --- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index ff1586d2fa8abe..5635a87d2358a7 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2680,9 +2680,9 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, bool EmittedMDIdGeneralized = false; if (CodeGenOpts.CallGraphSection && (!F->hasLocalLinkage() || - F->getFunction().hasAddressTaken(nullptr, /* IgnoreCallbackUses */ true, -/* IgnoreAssumeLikeCalls */ true, -/* IgnoreLLVMUsed */ false))) { + F->getFunction().hasAddressTaken(nullptr, /*IgnoreCallbackUses=*/ true, +/*IgnoreAssumeLikeCalls=*/ true, +/*IgnoreLLVMUsed=*/ false))) { F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType())); EmittedMDIdGeneralized = true; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
joker-eph wrote: LG, but please make sure to remove all spurious headers from the commit description (seems like it should start at "This PR massively ...") https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add [[nodiscard]] to (PR #89181)
https://github.com/philnik777 closed https://github.com/llvm/llvm-project/pull/89181 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
Mogball wrote: > LG, but please make sure to remove all spurious headers from the commit > description (seems like it should start at "This PR massively ...") Yep. The tool removes it before landing the commit https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][ods] Add documentation on how to use sharded op definitions (NFC) (PR #89664)
https://github.com/Mogball created https://github.com/llvm/llvm-project/pull/89664 [mlir][ods] Add documentation on how to use sharded op definitions (NFC) This adds explanations and instructions on how to set up a dialect for sharded op definitions to the MLIR documentation. >From 8991d4f35210cdf5f08a57552058b5606c2f1e57 Mon Sep 17 00:00:00 2001 From: Mogball Date: Mon, 22 Apr 2024 20:40:10 + Subject: [PATCH] [mlir][ods] Add documentation on how to use sharded op definitions (NFC) This adds explanations and instructions on how to set up a dialect for sharded op definitions to the MLIR documentation. --- mlir/docs/DefiningDialects/Operations.md | 94 1 file changed, 94 insertions(+) diff --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md index 729393d5362673..79a0cc55f13840 100644 --- a/mlir/docs/DefiningDialects/Operations.md +++ b/mlir/docs/DefiningDialects/Operations.md @@ -1114,6 +1114,100 @@ void process(AddOp op, ArrayRef newOperands) { } ``` + Sharded Operation Definitions + +Large dialects with many operations may struggle with C++ compile time of +generated op definitions, due to large compilation units. `mlir-tblgen` +provides the ability to shard op definitions by splitting them up evenly +by passing `-op-shard-count` to `-gen-op-defs` and `-gen-op-decls`. The tool +will generate a single include file for the definitions broken up by +`GET_OP_DEFS_${N}` where `${N}` is the shard number. A shard can be compiled in +a single compilation unit by adding a file like this to your dialect library: + +```c++ +#include "mlir/IR/Operation.h" +// Add any other required includes. + +// Utilities shared by generated op definitions: custom directive parsers, +// printers, etc. +#include "OpUtils.h" + +#define GET_OP_DEFS_0 +#include "MyDialectOps.cpp.inc" +``` + +Note: this requires restructing shared utility functions within the dialect +library so they can be shared by multiple compilation units. I.e. instead of +defining `static` methods in the same source file, you should declare them in a +shared header and define them in their own source file. + +The op registration hooks are also sharded, because the template instantiation +can take a very long time to compile. Operations should be registered in your +dialect like: + +```c++ +void MyDialect::initialize() { + registerMyDialectOperations(this); +} +``` + +CMake and Bazel functions are included to make sharding dialects easier. +Assuming you have organized your operation utility functions into their own +header, define a file that looks like the one above, but without the `#define`: + +```c++ +// MyDialectOps.cpp +#include "mlir/IR/Operation.h" + +#include "OpUtils.h" + +#include "MyDialectOps.cpp.inc" +``` + +In CMake, remove the manual `mlir_tablegen` invocations and replace them with: + +```cmake +set(LLVM_TARGET_DEFINITIONS MyDialectOps.td) +add_sharded_ops(MyDialectOps 8) # shard the op definitions by 8 + +add_mlir_library(MyDialect + MyDialect.cpp + MyDialectOpDefs.cpp + ${SHARDED_SRCS} + + DEPENDS + MLIRTestOpsShardGen +) +``` + +This will automatically duplicate the `MyDialectOps.cpp` source file and add the +`#define` up the number of shards indicated. + +It is recommended that any out-of-line op member functions (like verifiers) be +defined in a separate source file. In this example, it is called +`MyDialectOpDefs.cpp`. + +In Bazel, remove the `-gen-op-defs` and `-gen-op-decls` invocations, and add + +```bazel +gentbl_sharded_ops( +name = "MyDialectOpSrcs", +hdr_out = "MyDialectOps.h.inc", +shard_count = 8, +sharder = "//mlir:mlir-src-sharder", +src_file = "MyDialectOps.cpp", +src_out = "MyDialectOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "MyDialectOps.td", +deps = [":MyDialectOpsTdFiles"], +) + +cc_library( +name = "MyDialect", +srcs = glob(["MyDialect/*.cpp"]) + [":MyDialectOpSrcs"] +) +``` + ## Constraints Constraint is a core concept in table-driven operation definition: operation ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][ods] Add documentation on how to use sharded op definitions (NFC) (PR #89664)
https://github.com/Mogball updated https://github.com/llvm/llvm-project/pull/89664 >From f8c449c81fb62dc063eaf9be3dc0cc81407afd1d Mon Sep 17 00:00:00 2001 From: Mogball Date: Mon, 22 Apr 2024 20:40:10 + Subject: [PATCH] [mlir][ods] Add documentation on how to use sharded op definitions (NFC) This adds explanations and instructions on how to set up a dialect for sharded op definitions to the MLIR documentation. stack-info: PR: https://github.com/llvm/llvm-project/pull/89664, branch: users/Mogball/stack/3 --- mlir/docs/DefiningDialects/Operations.md | 94 1 file changed, 94 insertions(+) diff --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md index 729393d5362673..79a0cc55f13840 100644 --- a/mlir/docs/DefiningDialects/Operations.md +++ b/mlir/docs/DefiningDialects/Operations.md @@ -1114,6 +1114,100 @@ void process(AddOp op, ArrayRef newOperands) { } ``` + Sharded Operation Definitions + +Large dialects with many operations may struggle with C++ compile time of +generated op definitions, due to large compilation units. `mlir-tblgen` +provides the ability to shard op definitions by splitting them up evenly +by passing `-op-shard-count` to `-gen-op-defs` and `-gen-op-decls`. The tool +will generate a single include file for the definitions broken up by +`GET_OP_DEFS_${N}` where `${N}` is the shard number. A shard can be compiled in +a single compilation unit by adding a file like this to your dialect library: + +```c++ +#include "mlir/IR/Operation.h" +// Add any other required includes. + +// Utilities shared by generated op definitions: custom directive parsers, +// printers, etc. +#include "OpUtils.h" + +#define GET_OP_DEFS_0 +#include "MyDialectOps.cpp.inc" +``` + +Note: this requires restructing shared utility functions within the dialect +library so they can be shared by multiple compilation units. I.e. instead of +defining `static` methods in the same source file, you should declare them in a +shared header and define them in their own source file. + +The op registration hooks are also sharded, because the template instantiation +can take a very long time to compile. Operations should be registered in your +dialect like: + +```c++ +void MyDialect::initialize() { + registerMyDialectOperations(this); +} +``` + +CMake and Bazel functions are included to make sharding dialects easier. +Assuming you have organized your operation utility functions into their own +header, define a file that looks like the one above, but without the `#define`: + +```c++ +// MyDialectOps.cpp +#include "mlir/IR/Operation.h" + +#include "OpUtils.h" + +#include "MyDialectOps.cpp.inc" +``` + +In CMake, remove the manual `mlir_tablegen` invocations and replace them with: + +```cmake +set(LLVM_TARGET_DEFINITIONS MyDialectOps.td) +add_sharded_ops(MyDialectOps 8) # shard the op definitions by 8 + +add_mlir_library(MyDialect + MyDialect.cpp + MyDialectOpDefs.cpp + ${SHARDED_SRCS} + + DEPENDS + MLIRTestOpsShardGen +) +``` + +This will automatically duplicate the `MyDialectOps.cpp` source file and add the +`#define` up the number of shards indicated. + +It is recommended that any out-of-line op member functions (like verifiers) be +defined in a separate source file. In this example, it is called +`MyDialectOpDefs.cpp`. + +In Bazel, remove the `-gen-op-defs` and `-gen-op-decls` invocations, and add + +```bazel +gentbl_sharded_ops( +name = "MyDialectOpSrcs", +hdr_out = "MyDialectOps.h.inc", +shard_count = 8, +sharder = "//mlir:mlir-src-sharder", +src_file = "MyDialectOps.cpp", +src_out = "MyDialectOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "MyDialectOps.td", +deps = [":MyDialectOpsTdFiles"], +) + +cc_library( +name = "MyDialect", +srcs = glob(["MyDialect/*.cpp"]) + [":MyDialectOpSrcs"] +) +``` + ## Constraints Constraint is a core concept in table-driven operation definition: operation ___ 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] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
https://github.com/Mogball edited https://github.com/llvm/llvm-project/pull/89628 ___ 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] [mlir] [mlir][ods] Allow sharding of op definitions (PR #89423)
https://github.com/Mogball edited https://github.com/llvm/llvm-project/pull/89423 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][ods] Add documentation on how to use sharded op definitions (NFC) (PR #89664)
llvmbot wrote: @llvm/pr-subscribers-mlir Author: Jeff Niu (Mogball) Changes Stacked PRs: * __->__#89664 * #89628 * #89423 * #89424 --- --- --- ### [mlir][ods] Add documentation on how to use sharded op definitions (NFC) This adds explanations and instructions on how to set up a dialect for sharded op definitions to the MLIR documentation. --- Full diff: https://github.com/llvm/llvm-project/pull/89664.diff 1 Files Affected: - (modified) mlir/docs/DefiningDialects/Operations.md (+94) ``diff diff --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md index 729393d5362673..79a0cc55f13840 100644 --- a/mlir/docs/DefiningDialects/Operations.md +++ b/mlir/docs/DefiningDialects/Operations.md @@ -1114,6 +1114,100 @@ void process(AddOp op, ArrayRef newOperands) { } ``` + Sharded Operation Definitions + +Large dialects with many operations may struggle with C++ compile time of +generated op definitions, due to large compilation units. `mlir-tblgen` +provides the ability to shard op definitions by splitting them up evenly +by passing `-op-shard-count` to `-gen-op-defs` and `-gen-op-decls`. The tool +will generate a single include file for the definitions broken up by +`GET_OP_DEFS_${N}` where `${N}` is the shard number. A shard can be compiled in +a single compilation unit by adding a file like this to your dialect library: + +```c++ +#include "mlir/IR/Operation.h" +// Add any other required includes. + +// Utilities shared by generated op definitions: custom directive parsers, +// printers, etc. +#include "OpUtils.h" + +#define GET_OP_DEFS_0 +#include "MyDialectOps.cpp.inc" +``` + +Note: this requires restructing shared utility functions within the dialect +library so they can be shared by multiple compilation units. I.e. instead of +defining `static` methods in the same source file, you should declare them in a +shared header and define them in their own source file. + +The op registration hooks are also sharded, because the template instantiation +can take a very long time to compile. Operations should be registered in your +dialect like: + +```c++ +void MyDialect::initialize() { + registerMyDialectOperations(this); +} +``` + +CMake and Bazel functions are included to make sharding dialects easier. +Assuming you have organized your operation utility functions into their own +header, define a file that looks like the one above, but without the `#define`: + +```c++ +// MyDialectOps.cpp +#include "mlir/IR/Operation.h" + +#include "OpUtils.h" + +#include "MyDialectOps.cpp.inc" +``` + +In CMake, remove the manual `mlir_tablegen` invocations and replace them with: + +```cmake +set(LLVM_TARGET_DEFINITIONS MyDialectOps.td) +add_sharded_ops(MyDialectOps 8) # shard the op definitions by 8 + +add_mlir_library(MyDialect + MyDialect.cpp + MyDialectOpDefs.cpp + ${SHARDED_SRCS} + + DEPENDS + MLIRTestOpsShardGen +) +``` + +This will automatically duplicate the `MyDialectOps.cpp` source file and add the +`#define` up the number of shards indicated. + +It is recommended that any out-of-line op member functions (like verifiers) be +defined in a separate source file. In this example, it is called +`MyDialectOpDefs.cpp`. + +In Bazel, remove the `-gen-op-defs` and `-gen-op-decls` invocations, and add + +```bazel +gentbl_sharded_ops( +name = "MyDialectOpSrcs", +hdr_out = "MyDialectOps.h.inc", +shard_count = 8, +sharder = "//mlir:mlir-src-sharder", +src_file = "MyDialectOps.cpp", +src_out = "MyDialectOps.cpp.inc", +tblgen = "//mlir:mlir-tblgen", +td_file = "MyDialectOps.td", +deps = [":MyDialectOpsTdFiles"], +) + +cc_library( +name = "MyDialect", +srcs = glob(["MyDialect/*.cpp"]) + [":MyDialectOpSrcs"] +) +``` + ## Constraints Constraint is a core concept in table-driven operation definition: operation `` https://github.com/llvm/llvm-project/pull/89664 ___ 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] [mlir] [mlir][ods] Allow sharding of op definitions (PR #89423)
Mogball wrote: > Before I forget: we should add documentation for this, including the how to > structure the dialect to support it. Added in https://github.com/llvm/llvm-project/pull/89664 https://github.com/llvm/llvm-project/pull/89423 ___ 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] [mlir] [mlir][test] Shard the Test Dialect (NFC) (PR #89628)
https://github.com/Mogball edited https://github.com/llvm/llvm-project/pull/89628 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][ods] Add documentation on how to use sharded op definitions (NFC) (PR #89664)
https://github.com/Mogball edited https://github.com/llvm/llvm-project/pull/89664 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [compiler-rt] [llvm] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)
fhahn wrote: Added compiler-rt tests for various strict-aliasing violations from the bug tracker I found. https://github.com/llvm/llvm-project/pull/76261 ___ 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] [GSYM][DWARF] Include end_sequence debug_line rows when looking up addr ranges (PR #89703)
https://github.com/avillega created https://github.com/llvm/llvm-project/pull/89703 Work around for https://github.com/llvm/llvm-project/issues/46494. Before this change end_sequence rows in debug_line were not included in `DWARFDebugLine::LineTable::lookupAddressRangeImpl`, this was problematic for users of this API that needed to handle edge cases like icf optimization. ___ 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] [GSYM][DWARF] Include end_sequence debug_line rows when looking up addr ranges (PR #89703)
llvmbot wrote: @llvm/pr-subscribers-debuginfo Author: Andres Villegas (avillega) Changes Work around for https://github.com/llvm/llvm-project/issues/46494. Before this change end_sequence rows in debug_line were not included in `DWARFDebugLine::LineTable::lookupAddressRangeImpl`, this was problematic for users of this API that needed to handle edge cases like icf optimization. --- Patch is 23.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89703.diff 3 Files Affected: - (modified) llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (+3-2) - (modified) llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp (+15-14) - (added) llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-icf.yaml (+563) ``diff diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 572628f45fc23a..622e7a33508284 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -1386,9 +1386,10 @@ bool DWARFDebugLine::LineTable::lookupAddressRangeImpl( FirstRowIndex = findRowInSeq(CurSeq, Address); // Figure out the last row in the range. +// end_sequence tags can be at EndAddr uint32_t LastRowIndex = -findRowInSeq(CurSeq, {EndAddr - 1, Address.SectionIndex}); -if (LastRowIndex == UnknownRowIndex) +findRowInSeq(CurSeq, {EndAddr, Address.SectionIndex}); +if (LastRowIndex == UnknownRowIndex || !Rows[LastRowIndex].EndSequence) LastRowIndex = CurSeq.LastRowIndex - 1; assert(FirstRowIndex != UnknownRowIndex); diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp index ff6b560d11726b..947a9ce72d87cf 100644 --- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp +++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp @@ -354,6 +354,17 @@ static void convertFunctionLineTable(OutputAggregator &Out, CUInfo &CUI, for (uint32_t RowIndex : RowVector) { // Take file number and line/column from the row. const DWARFDebugLine::Row &Row = CUI.LineTable->Rows[RowIndex]; + +// TODO(avillega): With this conditional, functions folded by `icf` +// optimizations will only include 1 of all the folded functions. There is +// not a clear path forward to have the information of all folded functions +// in gsym. +if (Row.EndSequence) { + // End sequence markers are included for the last address + // in a function or the last contiguos address in a sequence. + break; +} + std::optional OptFileIdx = CUI.DWARFToGSYMFileIndex(Gsym, Row.File); if (!OptFileIdx) { @@ -411,7 +422,7 @@ static void convertFunctionLineTable(OutputAggregator &Out, CUInfo &CUI, else Out.Report("Non-monotonically increasing addresses", [&](raw_ostream &OS) { - OS << "error: line table has addresses that do not " + OS << "warning: line table has addresses that do not " << "monotonically increase:\n"; for (uint32_t RowIndex2 : RowVector) CUI.LineTable->Rows[RowIndex2].dump(OS); @@ -424,19 +435,9 @@ static void convertFunctionLineTable(OutputAggregator &Out, CUInfo &CUI, auto LastLE = FI.OptLineTable->last(); if (LastLE && LastLE->File == FileIdx && LastLE->Line == Row.Line) continue; -// Only push a row if it isn't an end sequence. End sequence markers are -// included for the last address in a function or the last contiguous -// address in a sequence. -if (Row.EndSequence) { - // End sequence means that the next line entry could have a lower address - // that the previous entries. So we clear the previous row so we don't - // trigger the line table error about address that do not monotonically - // increase. - PrevRow = DWARFDebugLine::Row(); -} else { - FI.OptLineTable->push(LE); - PrevRow = Row; -} + +FI.OptLineTable->push(LE); +PrevRow = Row; } // If not line table rows were added, clear the line table so we don't encode // on in the GSYM file. diff --git a/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-icf.yaml b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-icf.yaml new file mode 100644 index 00..144e5ba66058a3 --- /dev/null +++ b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-icf.yaml @@ -0,0 +1,563 @@ +## Test loading an ELF file with DWARF with icf (identical code folding) +## optimizations. +## First we make the ELF file from yaml, +## then we convert the ELF file to GSYM, then we do lookups on the newly +## created GSYM, and finally we dump the entire GSYM. +## +## The elf file corresponds to this c program: +## int f() { +## return 1; +## } +## +## int g() { +## return 1; +## } +## +## int main() { +## f(); +## g(); +## return 0; +## } + +# RUN: yaml2obj %s -o %t +# RUN: llvm-gsymutil --convert %t --out-file=%t.g
[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a regression in ContinuationIndenter (#88414) (PR #89412)
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/89412 ___ 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] release/18.x: [clang-format] Fix a regression in annotating TrailingReturnArrow (#86624) (PR #89415)
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/89415 ___ 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] [polly] release/18.x: [clang-format] Revert breaking stream operators to prev… (PR #89492)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/89492 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits