[llvm-branch-commits] [ARM, MC] Support FDPIC relocations (PR #82187)
https://github.com/jh7370 commented: BinaryFormat/llvm-readobj aspects looks fine to me, but the assembler side of things goes a bit over my head, so you'll need someone else to review that area. https://github.com/llvm/llvm-project/pull/82187 ___ 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] [ARM, MC] Support FDPIC relocations (PR #82187)
https://github.com/jh7370 edited https://github.com/llvm/llvm-project/pull/82187 ___ 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] [ARM, MC] Support FDPIC relocations (PR #82187)
@@ -143,3 +143,10 @@ ELF_RELOC(R_ARM_THM_BF16, 0x88) ELF_RELOC(R_ARM_THM_BF12, 0x89) ELF_RELOC(R_ARM_THM_BF18, 0x8a) ELF_RELOC(R_ARM_IRELATIVE, 0xa0) +ELF_RELOC(R_ARM_GOTFUNCDESC,0xa1) +ELF_RELOC(R_ARM_GOTOFFFUNCDESC, 0xa2) +ELF_RELOC(R_ARM_FUNCDESC, 0xa3) +ELF_RELOC(R_ARM_FUNCDESC_VALUE, 0xa4) +ELF_RELOC(R_ARM_TLS_GD32_FDPIC, 0xa5) +ELF_RELOC(R_ARM_TLS_LDM32_FDPIC,0xa6) +ELF_RELOC(R_ARM_TLS_IE32_FDPIC, 0xa7) jh7370 wrote: I might be looking in the wrong place, but I couldn't see the values for these three relocations defined in the doc you link in the description? https://github.com/llvm/llvm-project/pull/82187 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)
davemgreen wrote: This is a fairly big patch to backport. The ampere1b changes should be safe enough considering as it just adds support for an extra CPU. There is also the change from #78027 added for changing how PAUTH is enabled. @atrosinenko @DavidSpickett do you think that is OK to backport to LLVM 18? https://github.com/llvm/llvm-project/pull/81857 ___ 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][Transforms][NFC][WIP] Turn unresolved materializations into `IRRewrite`s (PR #81761)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/81761 >From 51a7e12b4e0e8ceee8429460592307adfad18a96 Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Mon, 19 Feb 2024 10:29:29 + Subject: [PATCH] [WIP] UnresolvedMaterialization BEGIN_PUBLIC No public commit message needed for presubmit. END_PUBLIC --- .../Transforms/Utils/DialectConversion.cpp| 371 +- 1 file changed, 176 insertions(+), 195 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 5b7ad4e7b8e281..4ef26a739e4ea1 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -152,15 +152,11 @@ namespace { /// This class contains a snapshot of the current conversion rewriter state. /// This is useful when saving and undoing a set of rewrites. struct RewriterState { - RewriterState(unsigned numUnresolvedMaterializations, unsigned numRewrites, -unsigned numIgnoredOperations, unsigned numErased) - : numUnresolvedMaterializations(numUnresolvedMaterializations), -numRewrites(numRewrites), numIgnoredOperations(numIgnoredOperations), + RewriterState(unsigned numRewrites, unsigned numIgnoredOperations, +unsigned numErased) + : numRewrites(numRewrites), numIgnoredOperations(numIgnoredOperations), numErased(numErased) {} - /// The current number of unresolved materializations. - unsigned numUnresolvedMaterializations; - /// The current number of rewrites performed. unsigned numRewrites; @@ -171,109 +167,10 @@ struct RewriterState { unsigned numErased; }; -//===--===// -// UnresolvedMaterialization - -/// This class represents an unresolved materialization, i.e. a materialization -/// that was inserted during conversion that needs to be legalized at the end of -/// the conversion process. -class UnresolvedMaterialization { -public: - /// The type of materialization. - enum Kind { -/// This materialization materializes a conversion for an illegal block -/// argument type, to a legal one. -Argument, - -/// This materialization materializes a conversion from an illegal type to a -/// legal one. -Target - }; - - UnresolvedMaterialization(UnrealizedConversionCastOp op = nullptr, -const TypeConverter *converter = nullptr, -Kind kind = Target, Type origOutputType = nullptr) - : op(op), converterAndKind(converter, kind), -origOutputType(origOutputType) {} - - /// Return the temporary conversion operation inserted for this - /// materialization. - UnrealizedConversionCastOp getOp() const { return op; } - - /// Return the type converter of this materialization (which may be null). - const TypeConverter *getConverter() const { -return converterAndKind.getPointer(); - } - - /// Return the kind of this materialization. - Kind getKind() const { return converterAndKind.getInt(); } - - /// Set the kind of this materialization. - void setKind(Kind kind) { converterAndKind.setInt(kind); } - - /// Return the original illegal output type of the input values. - Type getOrigOutputType() const { return origOutputType; } - -private: - /// The unresolved materialization operation created during conversion. - UnrealizedConversionCastOp op; - - /// The corresponding type converter to use when resolving this - /// materialization, and the kind of this materialization. - llvm::PointerIntPair converterAndKind; - - /// The original output type. This is only used for argument conversions. - Type origOutputType; -}; -} // namespace - -/// Build an unresolved materialization operation given an output type and set -/// of input operands. -static Value buildUnresolvedMaterialization( -UnresolvedMaterialization::Kind kind, Block *insertBlock, -Block::iterator insertPt, Location loc, ValueRange inputs, Type outputType, -Type origOutputType, const TypeConverter *converter, -SmallVectorImpl &unresolvedMaterializations) { - // Avoid materializing an unnecessary cast. - if (inputs.size() == 1 && inputs.front().getType() == outputType) -return inputs.front(); - - // Create an unresolved materialization. We use a new OpBuilder to avoid - // tracking the materialization like we do for other operations. - OpBuilder builder(insertBlock, insertPt); - auto convertOp = - builder.create(loc, outputType, inputs); - unresolvedMaterializations.emplace_back(convertOp, converter, kind, - origOutputType); - return convertOp.getResult(0); -} -static Value buildUnresolvedArgumentMaterialization( -PatternRewriter &rewriter, Location loc, ValueRange inputs, -Type origOutputType, Type outputType, const TypeConverter *converter, -SmallVectorImpl &unresolvedMaterial
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC][WIP] Turn unresolved materializations into `IRRewrite`s (PR #81761)
https://github.com/matthias-springer edited https://github.com/llvm/llvm-project/pull/81761 ___ 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][Transforms][NFC][WIP] Turn unresolved materializations into `IRRewrite`s (PR #81761)
https://github.com/matthias-springer ready_for_review https://github.com/llvm/llvm-project/pull/81761 ___ 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][Transforms][NFC][WIP] Turn unresolved materializations into `IRRewrite`s (PR #81761)
llvmbot wrote: @llvm/pr-subscribers-mlir Author: Matthias Springer (matthias-springer) Changes This commit is a refactoring of the dialect conversion. The dialect conversion maintains a list of "IR rewrites" that can be committed (upon success) or rolled back (upon failure). This commit turns the creation of unresolved materializations (`unrealized_conversion_cast`) into `IRRewrite` objects. After this commit, all steps in `applyRewrites` and `discardRewrites` are calls to `IRRewrite::commit` and `IRRewrite::rollback`. --- Patch is 25.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/81761.diff 1 Files Affected: - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+176-195) ``diff diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 5b7ad4e7b8e281..4ef26a739e4ea1 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -152,15 +152,11 @@ namespace { /// This class contains a snapshot of the current conversion rewriter state. /// This is useful when saving and undoing a set of rewrites. struct RewriterState { - RewriterState(unsigned numUnresolvedMaterializations, unsigned numRewrites, -unsigned numIgnoredOperations, unsigned numErased) - : numUnresolvedMaterializations(numUnresolvedMaterializations), -numRewrites(numRewrites), numIgnoredOperations(numIgnoredOperations), + RewriterState(unsigned numRewrites, unsigned numIgnoredOperations, +unsigned numErased) + : numRewrites(numRewrites), numIgnoredOperations(numIgnoredOperations), numErased(numErased) {} - /// The current number of unresolved materializations. - unsigned numUnresolvedMaterializations; - /// The current number of rewrites performed. unsigned numRewrites; @@ -171,109 +167,10 @@ struct RewriterState { unsigned numErased; }; -//===--===// -// UnresolvedMaterialization - -/// This class represents an unresolved materialization, i.e. a materialization -/// that was inserted during conversion that needs to be legalized at the end of -/// the conversion process. -class UnresolvedMaterialization { -public: - /// The type of materialization. - enum Kind { -/// This materialization materializes a conversion for an illegal block -/// argument type, to a legal one. -Argument, - -/// This materialization materializes a conversion from an illegal type to a -/// legal one. -Target - }; - - UnresolvedMaterialization(UnrealizedConversionCastOp op = nullptr, -const TypeConverter *converter = nullptr, -Kind kind = Target, Type origOutputType = nullptr) - : op(op), converterAndKind(converter, kind), -origOutputType(origOutputType) {} - - /// Return the temporary conversion operation inserted for this - /// materialization. - UnrealizedConversionCastOp getOp() const { return op; } - - /// Return the type converter of this materialization (which may be null). - const TypeConverter *getConverter() const { -return converterAndKind.getPointer(); - } - - /// Return the kind of this materialization. - Kind getKind() const { return converterAndKind.getInt(); } - - /// Set the kind of this materialization. - void setKind(Kind kind) { converterAndKind.setInt(kind); } - - /// Return the original illegal output type of the input values. - Type getOrigOutputType() const { return origOutputType; } - -private: - /// The unresolved materialization operation created during conversion. - UnrealizedConversionCastOp op; - - /// The corresponding type converter to use when resolving this - /// materialization, and the kind of this materialization. - llvm::PointerIntPair converterAndKind; - - /// The original output type. This is only used for argument conversions. - Type origOutputType; -}; -} // namespace - -/// Build an unresolved materialization operation given an output type and set -/// of input operands. -static Value buildUnresolvedMaterialization( -UnresolvedMaterialization::Kind kind, Block *insertBlock, -Block::iterator insertPt, Location loc, ValueRange inputs, Type outputType, -Type origOutputType, const TypeConverter *converter, -SmallVectorImpl &unresolvedMaterializations) { - // Avoid materializing an unnecessary cast. - if (inputs.size() == 1 && inputs.front().getType() == outputType) -return inputs.front(); - - // Create an unresolved materialization. We use a new OpBuilder to avoid - // tracking the materialization like we do for other operations. - OpBuilder builder(insertBlock, insertPt); - auto convertOp = - builder.create(loc, outputType, inputs); - unresolvedMaterializations.emplace_back(convertOp, converter, kind, -
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC][WIP] Turn unresolved materializations into `IRRewrite`s (PR #81761)
llvmbot wrote: @llvm/pr-subscribers-mlir-core Author: Matthias Springer (matthias-springer) Changes This commit is a refactoring of the dialect conversion. The dialect conversion maintains a list of "IR rewrites" that can be committed (upon success) or rolled back (upon failure). This commit turns the creation of unresolved materializations (`unrealized_conversion_cast`) into `IRRewrite` objects. After this commit, all steps in `applyRewrites` and `discardRewrites` are calls to `IRRewrite::commit` and `IRRewrite::rollback`. --- Patch is 25.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/81761.diff 1 Files Affected: - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+176-195) ``diff diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 5b7ad4e7b8e281..4ef26a739e4ea1 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -152,15 +152,11 @@ namespace { /// This class contains a snapshot of the current conversion rewriter state. /// This is useful when saving and undoing a set of rewrites. struct RewriterState { - RewriterState(unsigned numUnresolvedMaterializations, unsigned numRewrites, -unsigned numIgnoredOperations, unsigned numErased) - : numUnresolvedMaterializations(numUnresolvedMaterializations), -numRewrites(numRewrites), numIgnoredOperations(numIgnoredOperations), + RewriterState(unsigned numRewrites, unsigned numIgnoredOperations, +unsigned numErased) + : numRewrites(numRewrites), numIgnoredOperations(numIgnoredOperations), numErased(numErased) {} - /// The current number of unresolved materializations. - unsigned numUnresolvedMaterializations; - /// The current number of rewrites performed. unsigned numRewrites; @@ -171,109 +167,10 @@ struct RewriterState { unsigned numErased; }; -//===--===// -// UnresolvedMaterialization - -/// This class represents an unresolved materialization, i.e. a materialization -/// that was inserted during conversion that needs to be legalized at the end of -/// the conversion process. -class UnresolvedMaterialization { -public: - /// The type of materialization. - enum Kind { -/// This materialization materializes a conversion for an illegal block -/// argument type, to a legal one. -Argument, - -/// This materialization materializes a conversion from an illegal type to a -/// legal one. -Target - }; - - UnresolvedMaterialization(UnrealizedConversionCastOp op = nullptr, -const TypeConverter *converter = nullptr, -Kind kind = Target, Type origOutputType = nullptr) - : op(op), converterAndKind(converter, kind), -origOutputType(origOutputType) {} - - /// Return the temporary conversion operation inserted for this - /// materialization. - UnrealizedConversionCastOp getOp() const { return op; } - - /// Return the type converter of this materialization (which may be null). - const TypeConverter *getConverter() const { -return converterAndKind.getPointer(); - } - - /// Return the kind of this materialization. - Kind getKind() const { return converterAndKind.getInt(); } - - /// Set the kind of this materialization. - void setKind(Kind kind) { converterAndKind.setInt(kind); } - - /// Return the original illegal output type of the input values. - Type getOrigOutputType() const { return origOutputType; } - -private: - /// The unresolved materialization operation created during conversion. - UnrealizedConversionCastOp op; - - /// The corresponding type converter to use when resolving this - /// materialization, and the kind of this materialization. - llvm::PointerIntPair converterAndKind; - - /// The original output type. This is only used for argument conversions. - Type origOutputType; -}; -} // namespace - -/// Build an unresolved materialization operation given an output type and set -/// of input operands. -static Value buildUnresolvedMaterialization( -UnresolvedMaterialization::Kind kind, Block *insertBlock, -Block::iterator insertPt, Location loc, ValueRange inputs, Type outputType, -Type origOutputType, const TypeConverter *converter, -SmallVectorImpl &unresolvedMaterializations) { - // Avoid materializing an unnecessary cast. - if (inputs.size() == 1 && inputs.front().getType() == outputType) -return inputs.front(); - - // Create an unresolved materialization. We use a new OpBuilder to avoid - // tracking the materialization like we do for other operations. - OpBuilder builder(insertBlock, insertPt); - auto convertOp = - builder.create(loc, outputType, inputs); - unresolvedMaterializations.emplace_back(convertOp, converter, kind, -
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Turn unresolved materializations into `IRRewrite`s (PR #81761)
https://github.com/matthias-springer edited https://github.com/llvm/llvm-project/pull/81761 ___ 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][Transforms] Make `ConversionPatternRewriter` constructor private (PR #82244)
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/82244 `ConversionPatternRewriter` objects should not be constructed outside of dialect conversions. Some IR modifications performed through a `ConversionPatternRewriter` are reflected in the IR in a delayed fashion (e.g., only when the dialect conversion is guaranteed to succeed). Using a `ConversionPatternRewriter` outside of the dialect conversion is incorrect API usage and can bring the IR in an inconsistent state. Migration guide: Use `IRRewriter` instead of `ConversionPatternRewriter`. >From 9c3b81074c1d1422af00b59ebb4d95465a1c3ad0 Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Mon, 19 Feb 2024 12:50:30 + Subject: [PATCH] [mlir][Transforms] Make `ConversionPatternRewriter` constructor private `ConversionPatternRewriter` objects should not be constructed outside of dialect conversions. Some IR modifications performed through a `ConversionPatternRewriter` are reflected in the IR in a delayed fashion (e.g., only when the dialect conversion is guaranteed to succeed). Using a `ConversionPatternRewriter` outside of the dialect conversion is incorrect API usage and can bring the IR in an inconsistent state. Migration guide: Use `IRRewriter` instead of `ConversionPatternRewriter`. --- .../mlir/Transforms/DialectConversion.h| 10 +- .../lib/Transforms/Utils/DialectConversion.cpp | 18 +++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 2575be4cdea1ac..5c91a9498b35d4 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -27,6 +27,7 @@ class Block; class ConversionPatternRewriter; class MLIRContext; class Operation; +struct OperationConverter; class Type; class Value; @@ -657,7 +658,6 @@ struct ConversionPatternRewriterImpl; /// hooks. class ConversionPatternRewriter final : public PatternRewriter { public: - explicit ConversionPatternRewriter(MLIRContext *ctx); ~ConversionPatternRewriter() override; /// Apply a signature conversion to the entry block of the given region. This @@ -764,6 +764,14 @@ class ConversionPatternRewriter final : public PatternRewriter { detail::ConversionPatternRewriterImpl &getImpl(); private: + // Allow OperationConverter to construct new rewriters. + friend struct OperationConverter; + + /// Conversion pattern rewriters must not be used outside of dialect + /// conversions. They apply some IR rewrites in a delayed fashion and could + /// bring the IR into an inconsistent state when used standalone. + explicit ConversionPatternRewriter(MLIRContext *ctx); + // Hide unsupported pattern rewriter API. using OpBuilder::setListener; diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 4ef26a739e4ea1..6cf178e149be7f 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -594,9 +594,11 @@ class ReplaceOperationRewrite : public OperationRewrite { void cleanup() override; -private: - friend struct OperationConverter; + const TypeConverter *getConverter() const { return converter; } + + bool hasChangedResults() const { return changedResults; } +private: /// An optional type converter that can be used to materialize conversions /// between the new and old values if necessary. const TypeConverter *converter; @@ -2354,7 +2356,9 @@ enum OpConversionMode { /// applied to the operations on success. Analysis, }; +} // namespace +namespace mlir { // This class converts operations to a given conversion target via a set of // rewrite patterns. The conversion behaves differently depending on the // conversion mode. @@ -2414,7 +2418,7 @@ struct OperationConverter { /// *not* to be legalizable to the target. DenseSet *trackedOps; }; -} // namespace +} // namespace mlir LogicalResult OperationConverter::convert(ConversionPatternRewriter &rewriter, Operation *op) { @@ -2506,7 +2510,7 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) { auto *opReplacement = dyn_cast(rewriterImpl.rewrites[i].get()); -if (!opReplacement || !opReplacement->changedResults) +if (!opReplacement || !opReplacement->hasChangedResults()) continue; Operation *op = opReplacement->getOperation(); for (OpResult result : op->getResults()) { @@ -2530,9 +2534,9 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { // Legalize this result. rewriter.setInsertionPoint(op); - if (failed(legalizeChangedResultType(op, result, newValue, - opReplacement->converter, rewri
[llvm-branch-commits] [mlir] [mlir][Transforms] Make `ConversionPatternRewriter` constructor private (PR #82244)
llvmbot wrote: @llvm/pr-subscribers-mlir Author: Matthias Springer (matthias-springer) Changes `ConversionPatternRewriter` objects should not be constructed outside of dialect conversions. Some IR modifications performed through a `ConversionPatternRewriter` are reflected in the IR in a delayed fashion (e.g., only when the dialect conversion is guaranteed to succeed). Using a `ConversionPatternRewriter` outside of the dialect conversion is incorrect API usage and can bring the IR in an inconsistent state. Migration guide: Use `IRRewriter` instead of `ConversionPatternRewriter`. --- Full diff: https://github.com/llvm/llvm-project/pull/82244.diff 2 Files Affected: - (modified) mlir/include/mlir/Transforms/DialectConversion.h (+9-1) - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+11-7) ``diff diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 2575be4cdea1ac..5c91a9498b35d4 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -27,6 +27,7 @@ class Block; class ConversionPatternRewriter; class MLIRContext; class Operation; +struct OperationConverter; class Type; class Value; @@ -657,7 +658,6 @@ struct ConversionPatternRewriterImpl; /// hooks. class ConversionPatternRewriter final : public PatternRewriter { public: - explicit ConversionPatternRewriter(MLIRContext *ctx); ~ConversionPatternRewriter() override; /// Apply a signature conversion to the entry block of the given region. This @@ -764,6 +764,14 @@ class ConversionPatternRewriter final : public PatternRewriter { detail::ConversionPatternRewriterImpl &getImpl(); private: + // Allow OperationConverter to construct new rewriters. + friend struct OperationConverter; + + /// Conversion pattern rewriters must not be used outside of dialect + /// conversions. They apply some IR rewrites in a delayed fashion and could + /// bring the IR into an inconsistent state when used standalone. + explicit ConversionPatternRewriter(MLIRContext *ctx); + // Hide unsupported pattern rewriter API. using OpBuilder::setListener; diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 4ef26a739e4ea1..6cf178e149be7f 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -594,9 +594,11 @@ class ReplaceOperationRewrite : public OperationRewrite { void cleanup() override; -private: - friend struct OperationConverter; + const TypeConverter *getConverter() const { return converter; } + + bool hasChangedResults() const { return changedResults; } +private: /// An optional type converter that can be used to materialize conversions /// between the new and old values if necessary. const TypeConverter *converter; @@ -2354,7 +2356,9 @@ enum OpConversionMode { /// applied to the operations on success. Analysis, }; +} // namespace +namespace mlir { // This class converts operations to a given conversion target via a set of // rewrite patterns. The conversion behaves differently depending on the // conversion mode. @@ -2414,7 +2418,7 @@ struct OperationConverter { /// *not* to be legalizable to the target. DenseSet *trackedOps; }; -} // namespace +} // namespace mlir LogicalResult OperationConverter::convert(ConversionPatternRewriter &rewriter, Operation *op) { @@ -2506,7 +2510,7 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) { auto *opReplacement = dyn_cast(rewriterImpl.rewrites[i].get()); -if (!opReplacement || !opReplacement->changedResults) +if (!opReplacement || !opReplacement->hasChangedResults()) continue; Operation *op = opReplacement->getOperation(); for (OpResult result : op->getResults()) { @@ -2530,9 +2534,9 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { // Legalize this result. rewriter.setInsertionPoint(op); - if (failed(legalizeChangedResultType(op, result, newValue, - opReplacement->converter, rewriter, - rewriterImpl, *inverseMapping))) + if (failed(legalizeChangedResultType( + op, result, newValue, opReplacement->getConverter(), rewriter, + rewriterImpl, *inverseMapping))) return failure(); } } `` https://github.com/llvm/llvm-project/pull/82244 ___ 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][Transforms] Make `ConversionPatternRewriter` constructor private (PR #82244)
llvmbot wrote: @llvm/pr-subscribers-mlir-core Author: Matthias Springer (matthias-springer) Changes `ConversionPatternRewriter` objects should not be constructed outside of dialect conversions. Some IR modifications performed through a `ConversionPatternRewriter` are reflected in the IR in a delayed fashion (e.g., only when the dialect conversion is guaranteed to succeed). Using a `ConversionPatternRewriter` outside of the dialect conversion is incorrect API usage and can bring the IR in an inconsistent state. Migration guide: Use `IRRewriter` instead of `ConversionPatternRewriter`. --- Full diff: https://github.com/llvm/llvm-project/pull/82244.diff 2 Files Affected: - (modified) mlir/include/mlir/Transforms/DialectConversion.h (+9-1) - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+11-7) ``diff diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 2575be4cdea1ac..5c91a9498b35d4 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -27,6 +27,7 @@ class Block; class ConversionPatternRewriter; class MLIRContext; class Operation; +struct OperationConverter; class Type; class Value; @@ -657,7 +658,6 @@ struct ConversionPatternRewriterImpl; /// hooks. class ConversionPatternRewriter final : public PatternRewriter { public: - explicit ConversionPatternRewriter(MLIRContext *ctx); ~ConversionPatternRewriter() override; /// Apply a signature conversion to the entry block of the given region. This @@ -764,6 +764,14 @@ class ConversionPatternRewriter final : public PatternRewriter { detail::ConversionPatternRewriterImpl &getImpl(); private: + // Allow OperationConverter to construct new rewriters. + friend struct OperationConverter; + + /// Conversion pattern rewriters must not be used outside of dialect + /// conversions. They apply some IR rewrites in a delayed fashion and could + /// bring the IR into an inconsistent state when used standalone. + explicit ConversionPatternRewriter(MLIRContext *ctx); + // Hide unsupported pattern rewriter API. using OpBuilder::setListener; diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 4ef26a739e4ea1..6cf178e149be7f 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -594,9 +594,11 @@ class ReplaceOperationRewrite : public OperationRewrite { void cleanup() override; -private: - friend struct OperationConverter; + const TypeConverter *getConverter() const { return converter; } + + bool hasChangedResults() const { return changedResults; } +private: /// An optional type converter that can be used to materialize conversions /// between the new and old values if necessary. const TypeConverter *converter; @@ -2354,7 +2356,9 @@ enum OpConversionMode { /// applied to the operations on success. Analysis, }; +} // namespace +namespace mlir { // This class converts operations to a given conversion target via a set of // rewrite patterns. The conversion behaves differently depending on the // conversion mode. @@ -2414,7 +2418,7 @@ struct OperationConverter { /// *not* to be legalizable to the target. DenseSet *trackedOps; }; -} // namespace +} // namespace mlir LogicalResult OperationConverter::convert(ConversionPatternRewriter &rewriter, Operation *op) { @@ -2506,7 +2510,7 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) { auto *opReplacement = dyn_cast(rewriterImpl.rewrites[i].get()); -if (!opReplacement || !opReplacement->changedResults) +if (!opReplacement || !opReplacement->hasChangedResults()) continue; Operation *op = opReplacement->getOperation(); for (OpResult result : op->getResults()) { @@ -2530,9 +2534,9 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { // Legalize this result. rewriter.setInsertionPoint(op); - if (failed(legalizeChangedResultType(op, result, newValue, - opReplacement->converter, rewriter, - rewriterImpl, *inverseMapping))) + if (failed(legalizeChangedResultType( + op, result, newValue, opReplacement->getConverter(), rewriter, + rewriterImpl, *inverseMapping))) return failure(); } } `` https://github.com/llvm/llvm-project/pull/82244 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [mlir] [mlir][Transforms] Make `ConversionPatternRewriter` constructor private (PR #82244)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/82244 >From f3fe2f1f9e2b561693bcaa2c8df84ac8cc8a60af Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Mon, 19 Feb 2024 12:50:30 + Subject: [PATCH] [mlir][Transforms] Make `ConversionPatternRewriter` constructor private `ConversionPatternRewriter` objects should not be constructed outside of dialect conversions. Some IR modifications performed through a `ConversionPatternRewriter` are reflected in the IR in a delayed fashion (e.g., only when the dialect conversion is guaranteed to succeed). Using a `ConversionPatternRewriter` outside of the dialect conversion is incorrect API usage and can bring the IR in an inconsistent state. Migration guide: Use `IRRewriter` instead of `ConversionPatternRewriter`. --- flang/lib/Frontend/FrontendActions.cpp | 2 +- .../mlir/Transforms/DialectConversion.h| 10 +- .../lib/Transforms/Utils/DialectConversion.cpp | 18 +++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index 44e80e946ed832..849b3c8e4dc027 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -177,7 +177,7 @@ static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule, return; } - mlir::ConversionPatternRewriter builder(mlirModule.getContext()); + mlir::IRRewriter builder(mlirModule.getContext()); unsigned oclcABIVERsion = codeGenOpts.CodeObjectVersion; auto int32Type = builder.getI32Type(); diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 2575be4cdea1ac..5c91a9498b35d4 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -27,6 +27,7 @@ class Block; class ConversionPatternRewriter; class MLIRContext; class Operation; +struct OperationConverter; class Type; class Value; @@ -657,7 +658,6 @@ struct ConversionPatternRewriterImpl; /// hooks. class ConversionPatternRewriter final : public PatternRewriter { public: - explicit ConversionPatternRewriter(MLIRContext *ctx); ~ConversionPatternRewriter() override; /// Apply a signature conversion to the entry block of the given region. This @@ -764,6 +764,14 @@ class ConversionPatternRewriter final : public PatternRewriter { detail::ConversionPatternRewriterImpl &getImpl(); private: + // Allow OperationConverter to construct new rewriters. + friend struct OperationConverter; + + /// Conversion pattern rewriters must not be used outside of dialect + /// conversions. They apply some IR rewrites in a delayed fashion and could + /// bring the IR into an inconsistent state when used standalone. + explicit ConversionPatternRewriter(MLIRContext *ctx); + // Hide unsupported pattern rewriter API. using OpBuilder::setListener; diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 4ef26a739e4ea1..6cf178e149be7f 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -594,9 +594,11 @@ class ReplaceOperationRewrite : public OperationRewrite { void cleanup() override; -private: - friend struct OperationConverter; + const TypeConverter *getConverter() const { return converter; } + + bool hasChangedResults() const { return changedResults; } +private: /// An optional type converter that can be used to materialize conversions /// between the new and old values if necessary. const TypeConverter *converter; @@ -2354,7 +2356,9 @@ enum OpConversionMode { /// applied to the operations on success. Analysis, }; +} // namespace +namespace mlir { // This class converts operations to a given conversion target via a set of // rewrite patterns. The conversion behaves differently depending on the // conversion mode. @@ -2414,7 +2418,7 @@ struct OperationConverter { /// *not* to be legalizable to the target. DenseSet *trackedOps; }; -} // namespace +} // namespace mlir LogicalResult OperationConverter::convert(ConversionPatternRewriter &rewriter, Operation *op) { @@ -2506,7 +2510,7 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) { auto *opReplacement = dyn_cast(rewriterImpl.rewrites[i].get()); -if (!opReplacement || !opReplacement->changedResults) +if (!opReplacement || !opReplacement->hasChangedResults()) continue; Operation *op = opReplacement->getOperation(); for (OpResult result : op->getResults()) { @@ -2530,9 +2534,9 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) { // Legalize this result. rewriter.setInsertionPoint(op); - if (failed(l
[llvm-branch-commits] [compiler-rt] release/18.x: [AIX] Add a dummy variable in the __llvm_orderfile section (#81968) (PR #82148)
https://github.com/qiongsiwu approved this pull request. LGTM! Thanks! https://github.com/llvm/llvm-project/pull/82148 ___ 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][Transforms] Encapsulate dialect conversion options in `ConversionConfig` (PR #82250)
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/82250 This commit adds a new `ConversionConfig` struct that allows users to customize the dialect conversion. This configuration is similar to `GreedyRewriteConfig` for the greedy pattern rewrite driver. A few existing options are moved to this objects, simplifying the dialect conversion API. >From 819e5f95ed0857e88972501cb10b9931b1e91a1c Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Mon, 19 Feb 2024 14:02:14 + Subject: [PATCH] [mlir][Transforms] Encapsulate dialect conversion options in `ConversionConfig` This commit adds a new `ConversionConfig` struct that allows users to customize the dialect conversion. This configuration is similar to `GreedyRewriteConfig` for the greedy pattern rewrite driver. A few existing options are moved to this objects, simplifying the dialect conversion API. --- .../mlir/Transforms/DialectConversion.h | 75 ++ .../Transforms/Utils/DialectConversion.cpp| 129 +- mlir/test/lib/Dialect/Test/TestPatterns.cpp | 14 +- 3 files changed, 118 insertions(+), 100 deletions(-) diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 5c91a9498b35d4..8da5dcb0be3fd0 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -24,6 +24,7 @@ namespace mlir { // Forward declarations. class Attribute; class Block; +struct ConversionConfig; class ConversionPatternRewriter; class MLIRContext; class Operation; @@ -770,7 +771,8 @@ class ConversionPatternRewriter final : public PatternRewriter { /// Conversion pattern rewriters must not be used outside of dialect /// conversions. They apply some IR rewrites in a delayed fashion and could /// bring the IR into an inconsistent state when used standalone. - explicit ConversionPatternRewriter(MLIRContext *ctx); + explicit ConversionPatternRewriter(MLIRContext *ctx, + const ConversionConfig &config); // Hide unsupported pattern rewriter API. using OpBuilder::setListener; @@ -1070,6 +1072,30 @@ class PDLConversionConfig final { #endif // MLIR_ENABLE_PDL_IN_PATTERNMATCH +//===--===// +// ConversionConfig +//===--===// + +/// Dialect conversion configuration. +struct ConversionConfig { + /// An optional callback used to notify about match failure diagnostics during + /// the conversion. Diagnostics are only reported to this callback may only be + /// available in debug mode. + function_ref notifyCallback = nullptr; + + /// Partial conversion only. All operations that are found not to be + /// legalizable are placed in this set. (Note that if there is an op + /// explicitly marked as illegal, the conversion terminates and the set will + /// not necessarily be complete.) + DenseSet *unlegalizedOps = nullptr; + + /// Analysis conversion only. All operations that are found to be legalizable + /// are placed in this set. Note that no actual rewrites are applied to the + /// IR during an analysis conversion and only pre-existing operations are + /// added to the set. + DenseSet *legalizableOps = nullptr; +}; + //===--===// // Op Conversion Entry Points //===--===// @@ -1083,19 +1109,16 @@ class PDLConversionConfig final { /// Apply a partial conversion on the given operations and all nested /// operations. This method converts as many operations to the target as /// possible, ignoring operations that failed to legalize. This method only -/// returns failure if there ops explicitly marked as illegal. If an -/// `unconvertedOps` set is provided, all operations that are found not to be -/// legalizable to the given `target` are placed within that set. (Note that if -/// there is an op explicitly marked as illegal, the conversion terminates and -/// the `unconvertedOps` set will not necessarily be complete.) +/// returns failure if there ops explicitly marked as illegal. LogicalResult -applyPartialConversion(ArrayRef ops, const ConversionTarget &target, +applyPartialConversion(ArrayRef ops, + const ConversionTarget &target, const FrozenRewritePatternSet &patterns, - DenseSet *unconvertedOps = nullptr); + ConversionConfig config = ConversionConfig()); LogicalResult applyPartialConversion(Operation *op, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, - DenseSet *unconvertedOps = nullptr); + ConversionConfig config = ConversionConfig()); /// Apply a compl
[llvm-branch-commits] [mlir] [mlir][Transforms] Encapsulate dialect conversion options in `ConversionConfig` (PR #82250)
llvmbot wrote: @llvm/pr-subscribers-mlir-core @llvm/pr-subscribers-mlir Author: Matthias Springer (matthias-springer) Changes This commit adds a new `ConversionConfig` struct that allows users to customize the dialect conversion. This configuration is similar to `GreedyRewriteConfig` for the greedy pattern rewrite driver. A few existing options are moved to this objects, simplifying the dialect conversion API. --- Patch is 20.73 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/82250.diff 3 Files Affected: - (modified) mlir/include/mlir/Transforms/DialectConversion.h (+47-28) - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+61-68) - (modified) mlir/test/lib/Dialect/Test/TestPatterns.cpp (+10-4) ``diff diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index 5c91a9498b35d4..8da5dcb0be3fd0 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -24,6 +24,7 @@ namespace mlir { // Forward declarations. class Attribute; class Block; +struct ConversionConfig; class ConversionPatternRewriter; class MLIRContext; class Operation; @@ -770,7 +771,8 @@ class ConversionPatternRewriter final : public PatternRewriter { /// Conversion pattern rewriters must not be used outside of dialect /// conversions. They apply some IR rewrites in a delayed fashion and could /// bring the IR into an inconsistent state when used standalone. - explicit ConversionPatternRewriter(MLIRContext *ctx); + explicit ConversionPatternRewriter(MLIRContext *ctx, + const ConversionConfig &config); // Hide unsupported pattern rewriter API. using OpBuilder::setListener; @@ -1070,6 +1072,30 @@ class PDLConversionConfig final { #endif // MLIR_ENABLE_PDL_IN_PATTERNMATCH +//===--===// +// ConversionConfig +//===--===// + +/// Dialect conversion configuration. +struct ConversionConfig { + /// An optional callback used to notify about match failure diagnostics during + /// the conversion. Diagnostics are only reported to this callback may only be + /// available in debug mode. + function_ref notifyCallback = nullptr; + + /// Partial conversion only. All operations that are found not to be + /// legalizable are placed in this set. (Note that if there is an op + /// explicitly marked as illegal, the conversion terminates and the set will + /// not necessarily be complete.) + DenseSet *unlegalizedOps = nullptr; + + /// Analysis conversion only. All operations that are found to be legalizable + /// are placed in this set. Note that no actual rewrites are applied to the + /// IR during an analysis conversion and only pre-existing operations are + /// added to the set. + DenseSet *legalizableOps = nullptr; +}; + //===--===// // Op Conversion Entry Points //===--===// @@ -1083,19 +1109,16 @@ class PDLConversionConfig final { /// Apply a partial conversion on the given operations and all nested /// operations. This method converts as many operations to the target as /// possible, ignoring operations that failed to legalize. This method only -/// returns failure if there ops explicitly marked as illegal. If an -/// `unconvertedOps` set is provided, all operations that are found not to be -/// legalizable to the given `target` are placed within that set. (Note that if -/// there is an op explicitly marked as illegal, the conversion terminates and -/// the `unconvertedOps` set will not necessarily be complete.) +/// returns failure if there ops explicitly marked as illegal. LogicalResult -applyPartialConversion(ArrayRef ops, const ConversionTarget &target, +applyPartialConversion(ArrayRef ops, + const ConversionTarget &target, const FrozenRewritePatternSet &patterns, - DenseSet *unconvertedOps = nullptr); + ConversionConfig config = ConversionConfig()); LogicalResult applyPartialConversion(Operation *op, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, - DenseSet *unconvertedOps = nullptr); + ConversionConfig config = ConversionConfig()); /// Apply a complete conversion on the given operations, and all nested /// operations. This method returns failure if the conversion of any operation @@ -1103,31 +1126,27 @@ applyPartialConversion(Operation *op, const ConversionTarget &target, /// within 'ops'. LogicalResult applyFullConversion(ArrayRef ops, const ConversionTarget &target, -
[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)
ptomsich wrote: > This is a fairly big patch to backport. The ampere1b changes should be safe > enough considering as it just adds support for an extra CPU. There is also > the change from #78027 added for changing how PAUTH is enabled. We can drop the dependency on #78027, if we modify the ampere1b enablement to explicitly add the PAUTH as part of the change in `llvm/include/llvm/TargetParser/AArch64TargetParser.h`; however this would make the change on the release/18.x branch have the extra PAUTH and not be a straight cherry-pick. Our rationale (so far) has been to include the dependency to make sure that this become a pure cherry-pick. https://github.com/llvm/llvm-project/pull/81857 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Main splitting functionality dev-complete (PR #82003)
@@ -48,6 +49,29 @@ using DeclareTargetCapturePair = // Common helper functions //===--===// +static llvm::ArrayRef getWorksharing() { + static llvm::omp::Directive worksharing[] = { + llvm::omp::Directive::OMPD_do, llvm::omp::Directive::OMPD_for, + llvm::omp::Directive::OMPD_scope, llvm::omp::Directive::OMPD_sections, + llvm::omp::Directive::OMPD_single, llvm::omp::Directive::OMPD_workshare, + }; + return worksharing; +} + +static llvm::ArrayRef getWorksharingLoop() { + static llvm::omp::Directive worksharingLoop[] = { + llvm::omp::Directive::OMPD_do, + llvm::omp::Directive::OMPD_for, + }; + return worksharingLoop; +} + +static uint32_t getOpenMPVersion(const mlir::ModuleOp &mod) { + if (mlir::Attribute verAttr = mod->getAttr("omp.version")) +return llvm::cast(verAttr).getVersion(); + llvm_unreachable("Exoecting OpenMP version attribute in module"); clementval wrote: ```suggestion llvm_unreachable("Expecting OpenMP version attribute in module"); ``` https://github.com/llvm/llvm-project/pull/82003 ___ 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] [ARM, MC] Support FDPIC relocations (PR #82187)
@@ -143,3 +143,10 @@ ELF_RELOC(R_ARM_THM_BF16, 0x88) ELF_RELOC(R_ARM_THM_BF12, 0x89) ELF_RELOC(R_ARM_THM_BF18, 0x8a) ELF_RELOC(R_ARM_IRELATIVE, 0xa0) +ELF_RELOC(R_ARM_GOTFUNCDESC,0xa1) +ELF_RELOC(R_ARM_GOTOFFFUNCDESC, 0xa2) +ELF_RELOC(R_ARM_FUNCDESC, 0xa3) +ELF_RELOC(R_ARM_FUNCDESC_VALUE, 0xa4) +ELF_RELOC(R_ARM_TLS_GD32_FDPIC, 0xa5) +ELF_RELOC(R_ARM_TLS_LDM32_FDPIC,0xa6) +ELF_RELOC(R_ARM_TLS_IE32_FDPIC, 0xa7) MaskRay wrote: Thanks for checking. https://github.com/mickael-guene/fdpic_doc doesn't define these values, but binutils-gdb defines the values (also referenced by projects like https://github.com/cutty/uld-fdpic/blob/master/include/elf.h). I've checked that `llvm-readelf -r` output matches `readelf -r`. https://github.com/llvm/llvm-project/pull/82187 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81622 >From 57c70c53a3898d7fc45fd0a71368ae20fe8a1a85 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 6 Feb 2024 17:06:29 -0600 Subject: [PATCH] [flang][OpenMP] Convert unique clauses in ClauseProcessor Temporarily rename old clause list to `clauses2`, old clause iterator to `ClauseIterator2`. Change `findUniqueClause` to iterate over `omp::Clause` objects, modify all handlers to operate on 'omp::clause::xyz` equivalents. --- flang/lib/Lower/OpenMP.cpp | 242 + 1 file changed, 114 insertions(+), 128 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index ae3619609b80ff..4156887c8ff531 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -1670,7 +1670,8 @@ class ClauseProcessor { ClauseProcessor(Fortran::lower::AbstractConverter &converter, Fortran::semantics::SemanticsContext &semaCtx, const Fortran::parser::OmpClauseList &clauses) - : converter(converter), semaCtx(semaCtx), clauses(clauses) {} + : converter(converter), semaCtx(semaCtx), clauses2(clauses), +clauses(omp::makeList(clauses, semaCtx)) {} // 'Unique' clauses: They can appear at most once in the clause list. bool @@ -1770,7 +1771,8 @@ class ClauseProcessor { llvm::omp::Directive directive) const; private: - using ClauseIterator = std::list::const_iterator; + using ClauseIterator = omp::List::const_iterator; + using ClauseIterator2 = std::list::const_iterator; /// Utility to find a clause within a range in the clause list. template @@ -1783,14 +1785,26 @@ class ClauseProcessor { return end; } + /// Utility to find a clause within a range in the clause list. + template + static ClauseIterator2 findClause2(ClauseIterator2 begin, + ClauseIterator2 end) { +for (ClauseIterator2 it = begin; it != end; ++it) { + if (std::get_if(&it->u)) +return it; +} + +return end; + } + /// Return the first instance of the given clause found in the clause list or /// `nullptr` if not present. If more than one instance is expected, use /// `findRepeatableClause` instead. template const T * findUniqueClause(const Fortran::parser::CharBlock **source = nullptr) const { -ClauseIterator it = findClause(clauses.v.begin(), clauses.v.end()); -if (it != clauses.v.end()) { +ClauseIterator it = findClause(clauses.begin(), clauses.end()); +if (it != clauses.end()) { if (source) *source = &it->source; return &std::get(it->u); @@ -1805,9 +1819,9 @@ class ClauseProcessor { std::function callbackFn) const { bool found = false; -ClauseIterator nextIt, endIt = clauses.v.end(); -for (ClauseIterator it = clauses.v.begin(); it != endIt; it = nextIt) { - nextIt = findClause(it, endIt); +ClauseIterator2 nextIt, endIt = clauses2.v.end(); +for (ClauseIterator2 it = clauses2.v.begin(); it != endIt; it = nextIt) { + nextIt = findClause2(it, endIt); if (nextIt != endIt) { callbackFn(&std::get(nextIt->u), nextIt->source); @@ -1830,7 +1844,8 @@ class ClauseProcessor { Fortran::lower::AbstractConverter &converter; Fortran::semantics::SemanticsContext &semaCtx; - const Fortran::parser::OmpClauseList &clauses; + const Fortran::parser::OmpClauseList &clauses2; + omp::List clauses; }; //===--===// @@ -2295,64 +2310,55 @@ class ReductionProcessor { }; static mlir::omp::ScheduleModifier -translateScheduleModifier(const Fortran::parser::OmpScheduleModifierType &m) { - switch (m.v) { - case Fortran::parser::OmpScheduleModifierType::ModType::Monotonic: +translateScheduleModifier(const omp::clause::Schedule::ModType &m) { + switch (m) { + case omp::clause::Schedule::ModType::Monotonic: return mlir::omp::ScheduleModifier::monotonic; - case Fortran::parser::OmpScheduleModifierType::ModType::Nonmonotonic: + case omp::clause::Schedule::ModType::Nonmonotonic: return mlir::omp::ScheduleModifier::nonmonotonic; - case Fortran::parser::OmpScheduleModifierType::ModType::Simd: + case omp::clause::Schedule::ModType::Simd: return mlir::omp::ScheduleModifier::simd; } return mlir::omp::ScheduleModifier::none; } static mlir::omp::ScheduleModifier -getScheduleModifier(const Fortran::parser::OmpScheduleClause &x) { - const auto &modifier = - std::get>(x.t); +getScheduleModifier(const omp::clause::Schedule &clause) { + using ScheduleModifier = omp::clause::Schedule::ScheduleModifier; + const auto &modifier = std::get>(clause.t); // The input may have the modifier any order, so we look for one that isn't // SIMD. If modifier is not set at all, fall down to the bottom and return // "none". if (modifier) { -
[llvm-branch-commits] [flang] [flang][OpenMP] Convert processTODO and remove unused objects (PR #81627)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81627 >From 1299d5190a3c273d2af4ab8c7f800af7df4e4ef6 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Fri, 9 Feb 2024 15:03:54 -0600 Subject: [PATCH] [flang][OpenMP] Convert processTODO and remove unused objects Remove `ClauseIterator2` and `clauses2` from ClauseProcessor. --- flang/lib/Lower/OpenMP.cpp | 75 ++ 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 4309d69434839f..51ed0fe03dbe38 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -1669,13 +1669,11 @@ void DataSharingProcessor::defaultPrivatize() { /// methods that relate to clauses that can impact the lowering of that /// construct. class ClauseProcessor { - using ClauseTy = Fortran::parser::OmpClause; - public: ClauseProcessor(Fortran::lower::AbstractConverter &converter, Fortran::semantics::SemanticsContext &semaCtx, const Fortran::parser::OmpClauseList &clauses) - : converter(converter), semaCtx(semaCtx), clauses2(clauses), + : converter(converter), semaCtx(semaCtx), clauses(omp::makeList(clauses, semaCtx)) {} // 'Unique' clauses: They can appear at most once in the clause list. @@ -1776,7 +1774,6 @@ class ClauseProcessor { private: using ClauseIterator = omp::List::const_iterator; - using ClauseIterator2 = std::list::const_iterator; /// Utility to find a clause within a range in the clause list. template @@ -1836,7 +1833,6 @@ class ClauseProcessor { Fortran::lower::AbstractConverter &converter; Fortran::semantics::SemanticsContext &semaCtx; - const Fortran::parser::OmpClauseList &clauses2; omp::List clauses; }; @@ -3132,19 +3128,17 @@ bool ClauseProcessor::processMotionClauses( template void ClauseProcessor::processTODO(mlir::Location currentLocation, llvm::omp::Directive directive) const { - auto checkUnhandledClause = [&](const auto *x) { + auto checkUnhandledClause = [&](llvm::omp::Clause id, const auto *x) { if (!x) return; TODO(currentLocation, - "Unhandled clause " + - llvm::StringRef(Fortran::parser::ParseTreeDumper::GetNodeName(*x)) - .upper() + + "Unhandled clause " + llvm::omp::getOpenMPClauseName(id).upper() + " in " + llvm::omp::getOpenMPDirectiveName(directive).upper() + " construct"); }; - for (ClauseIterator2 it = clauses2.v.begin(); it != clauses2.v.end(); ++it) -(checkUnhandledClause(std::get_if(&it->u)), ...); + for (ClauseIterator it = clauses.begin(); it != clauses.end(); ++it) +(checkUnhandledClause(it->id, std::get_if(&it->u)), ...); } //===--===// @@ -3723,8 +3717,8 @@ genSingleOp(Fortran::lower::AbstractConverter &converter, ClauseProcessor cp(converter, semaCtx, beginClauseList); cp.processAllocate(allocatorOperands, allocateOperands); - cp.processTODO( - currentLocation, llvm::omp::Directive::OMPD_single); + cp.processTODO(currentLocation, + llvm::omp::Directive::OMPD_single); ClauseProcessor(converter, semaCtx, endClauseList).processNowait(nowaitAttr); @@ -3757,10 +3751,9 @@ genTaskOp(Fortran::lower::AbstractConverter &converter, cp.processMergeable(mergeableAttr); cp.processPriority(stmtCtx, priorityClauseOperand); cp.processDepend(dependTypeOperands, dependOperands); - cp.processTODO( - currentLocation, llvm::omp::Directive::OMPD_task); + cp.processTODO(currentLocation, +llvm::omp::Directive::OMPD_task); return genOpWithBody( OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval) @@ -3785,7 +3778,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter, llvm::SmallVector allocateOperands, allocatorOperands; ClauseProcessor cp(converter, semaCtx, clauseList); cp.processAllocate(allocatorOperands, allocateOperands); - cp.processTODO( + cp.processTODO( currentLocation, llvm::omp::Directive::OMPD_taskgroup); return genOpWithBody( OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval) @@ -3869,8 +3862,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter, cp.processMap(currentLocation, directive, stmtCtx, mapOperands); } - cp.processTODO(currentLocation, - directive); + cp.processTODO(currentLocation, directive); return firOpBuilder.create(currentLocation, ifClauseOperand, deviceOperand, nullptr, mlir::ValueRange(), @@ -4053,16 +4045,11 @@ genTargetOp(Fortran::lower::AbstractConverter &converter, cp.processNowait(nowaitAttr); cp.processMap(currentLocation, directive, stmt
[llvm-branch-commits] [flang] [flang][Lower] Convert OMP Map and related functions to evaluate::Expr (PR #81626)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81626 >From 87437159da37749ad395d84a3fc1b729bd9e2480 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 8 Feb 2024 08:33:40 -0600 Subject: [PATCH] [flang][Lower] Convert OMP Map and related functions to evaluate::Expr The related functions are `gatherDataOperandAddrAndBounds` and `genBoundsOps`. The former is used in OpenACC as well, and it was updated to pass evaluate::Expr instead of parser objects. The difference in the test case comes from unfolded conversions of index expressions, which are explicitly of type integer(kind=8). Delete now unused `findRepeatableClause2` and `findClause2`. Add `AsGenericExpr` that takes std::optional. It already returns optional Expr. Making it accept an optional Expr as input would reduce the number of necessary checks when handling frequent optional values in evaluator. --- flang/include/flang/Evaluate/tools.h | 8 + flang/lib/Lower/DirectivesCommon.h | 389 --- flang/lib/Lower/OpenACC.cpp | 54 ++-- flang/lib/Lower/OpenMP.cpp | 105 +++- 4 files changed, 311 insertions(+), 245 deletions(-) diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h index e974944e88..d5713cfe420a2e 100644 --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -148,6 +148,14 @@ inline Expr AsGenericExpr(Expr &&x) { return std::move(x); } std::optional> AsGenericExpr(DataRef &&); std::optional> AsGenericExpr(const Symbol &); +// Propagate std::optional from input to output. +template +std::optional> AsGenericExpr(std::optional &&x) { + if (!x) +return std::nullopt; + return AsGenericExpr(std::move(*x)); +} + template common::IfNoLvalue::category>>, A> AsCategoryExpr( A &&x) { diff --git a/flang/lib/Lower/DirectivesCommon.h b/flang/lib/Lower/DirectivesCommon.h index 8d560db34e05bf..2fa90572bc63eb 100644 --- a/flang/lib/Lower/DirectivesCommon.h +++ b/flang/lib/Lower/DirectivesCommon.h @@ -808,6 +808,75 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, return bounds; } +namespace detail { +template // +static T &&AsRvalueRef(T &&t) { + return std::move(t); +} +template // +static T AsRvalueRef(T &t) { + return t; +} +template // +static T AsRvalueRef(const T &t) { + return t; +} + +// Helper class for stripping enclosing parentheses and a conversion that +// preserves type category. This is used for triplet elements, which are +// always of type integer(kind=8). The lower/upper bounds are converted to +// an "index" type, which is 64-bit, so the explicit conversion to kind=8 +// (if present) is not needed. When it's present, though, it causes generated +// names to contain "int(..., kind=8)". +struct PeelConvert { + template + static Fortran::semantics::MaybeExpr visit_with_category( + const Fortran::evaluate::Expr> + &expr) { +return std::visit( +[](auto &&s) { return visit_with_category(s); }, +expr.u); + } + template + static Fortran::semantics::MaybeExpr visit_with_category( + const Fortran::evaluate::Convert, + Category> &expr) { +return AsGenericExpr(AsRvalueRef(expr.left())); + } + template + static Fortran::semantics::MaybeExpr visit_with_category(const T &) { +return std::nullopt; // + } + template + static Fortran::semantics::MaybeExpr visit_with_category(const T &) { +return std::nullopt; // + } + + template + static Fortran::semantics::MaybeExpr + visit(const Fortran::evaluate::Expr> +&expr) { +return std::visit([](auto &&s) { return visit_with_category(s); }, + expr.u); + } + static Fortran::semantics::MaybeExpr + visit(const Fortran::evaluate::Expr &expr) { +return std::visit([](auto &&s) { return visit(s); }, expr.u); + } + template // + static Fortran::semantics::MaybeExpr visit(const T &) { +return std::nullopt; + } +}; + +static Fortran::semantics::SomeExpr +peelOuterConvert(Fortran::semantics::SomeExpr &expr) { + if (auto peeled = PeelConvert::visit(expr)) +return *peeled; + return expr; +} +} // namespace detail + /// Generate bounds operations for an array section when subscripts are /// provided. template @@ -815,7 +884,7 @@ llvm::SmallVector genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, Fortran::lower::AbstractConverter &converter, Fortran::lower::StatementContext &stmtCtx, - const std::list &subscripts, + const std::vector &subscripts, std::stringstream &asFortran, fir::ExtendedValue &dataExv, bool dataExvIsAssumedSize, AddrAndBoundsInfo &info, bool treatIndexAsSection = false) { @@ -828,8 +897,7 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1)
[llvm-branch-commits] [flang] [flang][OpenMP] Convert unique clauses in ClauseProcessor (PR #81622)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81622 >From 57c70c53a3898d7fc45fd0a71368ae20fe8a1a85 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 6 Feb 2024 17:06:29 -0600 Subject: [PATCH] [flang][OpenMP] Convert unique clauses in ClauseProcessor Temporarily rename old clause list to `clauses2`, old clause iterator to `ClauseIterator2`. Change `findUniqueClause` to iterate over `omp::Clause` objects, modify all handlers to operate on 'omp::clause::xyz` equivalents. --- flang/lib/Lower/OpenMP.cpp | 242 + 1 file changed, 114 insertions(+), 128 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index ae3619609b80ff..4156887c8ff531 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -1670,7 +1670,8 @@ class ClauseProcessor { ClauseProcessor(Fortran::lower::AbstractConverter &converter, Fortran::semantics::SemanticsContext &semaCtx, const Fortran::parser::OmpClauseList &clauses) - : converter(converter), semaCtx(semaCtx), clauses(clauses) {} + : converter(converter), semaCtx(semaCtx), clauses2(clauses), +clauses(omp::makeList(clauses, semaCtx)) {} // 'Unique' clauses: They can appear at most once in the clause list. bool @@ -1770,7 +1771,8 @@ class ClauseProcessor { llvm::omp::Directive directive) const; private: - using ClauseIterator = std::list::const_iterator; + using ClauseIterator = omp::List::const_iterator; + using ClauseIterator2 = std::list::const_iterator; /// Utility to find a clause within a range in the clause list. template @@ -1783,14 +1785,26 @@ class ClauseProcessor { return end; } + /// Utility to find a clause within a range in the clause list. + template + static ClauseIterator2 findClause2(ClauseIterator2 begin, + ClauseIterator2 end) { +for (ClauseIterator2 it = begin; it != end; ++it) { + if (std::get_if(&it->u)) +return it; +} + +return end; + } + /// Return the first instance of the given clause found in the clause list or /// `nullptr` if not present. If more than one instance is expected, use /// `findRepeatableClause` instead. template const T * findUniqueClause(const Fortran::parser::CharBlock **source = nullptr) const { -ClauseIterator it = findClause(clauses.v.begin(), clauses.v.end()); -if (it != clauses.v.end()) { +ClauseIterator it = findClause(clauses.begin(), clauses.end()); +if (it != clauses.end()) { if (source) *source = &it->source; return &std::get(it->u); @@ -1805,9 +1819,9 @@ class ClauseProcessor { std::function callbackFn) const { bool found = false; -ClauseIterator nextIt, endIt = clauses.v.end(); -for (ClauseIterator it = clauses.v.begin(); it != endIt; it = nextIt) { - nextIt = findClause(it, endIt); +ClauseIterator2 nextIt, endIt = clauses2.v.end(); +for (ClauseIterator2 it = clauses2.v.begin(); it != endIt; it = nextIt) { + nextIt = findClause2(it, endIt); if (nextIt != endIt) { callbackFn(&std::get(nextIt->u), nextIt->source); @@ -1830,7 +1844,8 @@ class ClauseProcessor { Fortran::lower::AbstractConverter &converter; Fortran::semantics::SemanticsContext &semaCtx; - const Fortran::parser::OmpClauseList &clauses; + const Fortran::parser::OmpClauseList &clauses2; + omp::List clauses; }; //===--===// @@ -2295,64 +2310,55 @@ class ReductionProcessor { }; static mlir::omp::ScheduleModifier -translateScheduleModifier(const Fortran::parser::OmpScheduleModifierType &m) { - switch (m.v) { - case Fortran::parser::OmpScheduleModifierType::ModType::Monotonic: +translateScheduleModifier(const omp::clause::Schedule::ModType &m) { + switch (m) { + case omp::clause::Schedule::ModType::Monotonic: return mlir::omp::ScheduleModifier::monotonic; - case Fortran::parser::OmpScheduleModifierType::ModType::Nonmonotonic: + case omp::clause::Schedule::ModType::Nonmonotonic: return mlir::omp::ScheduleModifier::nonmonotonic; - case Fortran::parser::OmpScheduleModifierType::ModType::Simd: + case omp::clause::Schedule::ModType::Simd: return mlir::omp::ScheduleModifier::simd; } return mlir::omp::ScheduleModifier::none; } static mlir::omp::ScheduleModifier -getScheduleModifier(const Fortran::parser::OmpScheduleClause &x) { - const auto &modifier = - std::get>(x.t); +getScheduleModifier(const omp::clause::Schedule &clause) { + using ScheduleModifier = omp::clause::Schedule::ScheduleModifier; + const auto &modifier = std::get>(clause.t); // The input may have the modifier any order, so we look for one that isn't // SIMD. If modifier is not set at all, fall down to the bottom and return // "none". if (modifier) { -
[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81623 >From 841f10e44e5ec5cfc6b166421f878089a17c623c Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 6 Feb 2024 17:06:29 -0600 Subject: [PATCH] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProcessor Rename `findRepeatableClause` to `findRepeatableClause2`, and make the new `findRepeatableClause` operate on new `omp::Clause` objects. Leave `Map` unchanged, because it will require more changes for it to work. --- flang/include/flang/Evaluate/tools.h | 23 + flang/lib/Lower/OpenMP.cpp | 632 +-- 2 files changed, 328 insertions(+), 327 deletions(-) diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h index d257da1a709642..e974944e88 100644 --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -430,6 +430,29 @@ template std::optional ExtractCoarrayRef(const A &x) { } } +struct ExtractSubstringHelper { + template static std::optional visit(T &&) { +return std::nullopt; + } + + static std::optional visit(const Substring &e) { return e; } + + template + static std::optional visit(const Designator &e) { +return std::visit([](auto &&s) { return visit(s); }, e.u); + } + + template + static std::optional visit(const Expr &e) { +return std::visit([](auto &&s) { return visit(s); }, e.u); + } +}; + +template +std::optional ExtractSubstring(const A &x) { + return ExtractSubstringHelper::visit(x); +} + // If an expression is simply a whole symbol data designator, // extract and return that symbol, else null. template const Symbol *UnwrapWholeSymbolDataRef(const A &x) { diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 4156887c8ff531..caae5c0cef9251 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -72,9 +72,9 @@ getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject) { return sym; } -static void genObjectList(const Fortran::parser::OmpObjectList &objectList, - Fortran::lower::AbstractConverter &converter, - llvm::SmallVectorImpl &operands) { +static void genObjectList2(const Fortran::parser::OmpObjectList &objectList, + Fortran::lower::AbstractConverter &converter, + llvm::SmallVectorImpl &operands) { auto addOperands = [&](Fortran::lower::SymbolRef sym) { const mlir::Value variable = converter.getSymbolAddress(sym); if (variable) { @@ -93,27 +93,6 @@ static void genObjectList(const Fortran::parser::OmpObjectList &objectList, } } -static void gatherFuncAndVarSyms( -const Fortran::parser::OmpObjectList &objList, -mlir::omp::DeclareTargetCaptureClause clause, -llvm::SmallVectorImpl &symbolAndClause) { - for (const Fortran::parser::OmpObject &ompObject : objList.v) { -Fortran::common::visit( -Fortran::common::visitors{ -[&](const Fortran::parser::Designator &designator) { - if (const Fortran::parser::Name *name = - Fortran::semantics::getDesignatorNameIfDataRef( - designator)) { -symbolAndClause.emplace_back(clause, *name->symbol); - } -}, -[&](const Fortran::parser::Name &name) { - symbolAndClause.emplace_back(clause, *name.symbol); -}}, -ompObject.u); - } -} - static Fortran::lower::pft::Evaluation * getCollapsedLoopEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) { // Return the Evaluation of the innermost collapsed loop, or the current one @@ -1258,6 +1237,32 @@ List makeList(const parser::OmpClauseList &clauses, } } // namespace omp +static void genObjectList(const omp::ObjectList &objects, + Fortran::lower::AbstractConverter &converter, + llvm::SmallVectorImpl &operands) { + for (const omp::Object &object : objects) { +const Fortran::semantics::Symbol *sym = object.sym; +assert(sym && "Expected Symbol"); +if (mlir::Value variable = converter.getSymbolAddress(*sym)) { + operands.push_back(variable); +} else { + if (const auto *details = + sym->detailsIf()) { +operands.push_back(converter.getSymbolAddress(details->symbol())); +converter.copySymbolBinding(details->symbol(), *sym); + } +} + } +} + +static void gatherFuncAndVarSyms( +const omp::ObjectList &objects, +mlir::omp::DeclareTargetCaptureClause clause, +llvm::SmallVectorImpl &symbolAndClause) { + for (const omp::Object &object : objects) +symbolAndClause.emplace_back(clause, *object.sym); +} + //===--===// // DataSharingProcessor //===--===// @
[llvm-branch-commits] [flang] [flang][OpenMP] Convert processTODO and remove unused objects (PR #81627)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81627 >From 1299d5190a3c273d2af4ab8c7f800af7df4e4ef6 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Fri, 9 Feb 2024 15:03:54 -0600 Subject: [PATCH] [flang][OpenMP] Convert processTODO and remove unused objects Remove `ClauseIterator2` and `clauses2` from ClauseProcessor. --- flang/lib/Lower/OpenMP.cpp | 75 ++ 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 4309d69434839f..51ed0fe03dbe38 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -1669,13 +1669,11 @@ void DataSharingProcessor::defaultPrivatize() { /// methods that relate to clauses that can impact the lowering of that /// construct. class ClauseProcessor { - using ClauseTy = Fortran::parser::OmpClause; - public: ClauseProcessor(Fortran::lower::AbstractConverter &converter, Fortran::semantics::SemanticsContext &semaCtx, const Fortran::parser::OmpClauseList &clauses) - : converter(converter), semaCtx(semaCtx), clauses2(clauses), + : converter(converter), semaCtx(semaCtx), clauses(omp::makeList(clauses, semaCtx)) {} // 'Unique' clauses: They can appear at most once in the clause list. @@ -1776,7 +1774,6 @@ class ClauseProcessor { private: using ClauseIterator = omp::List::const_iterator; - using ClauseIterator2 = std::list::const_iterator; /// Utility to find a clause within a range in the clause list. template @@ -1836,7 +1833,6 @@ class ClauseProcessor { Fortran::lower::AbstractConverter &converter; Fortran::semantics::SemanticsContext &semaCtx; - const Fortran::parser::OmpClauseList &clauses2; omp::List clauses; }; @@ -3132,19 +3128,17 @@ bool ClauseProcessor::processMotionClauses( template void ClauseProcessor::processTODO(mlir::Location currentLocation, llvm::omp::Directive directive) const { - auto checkUnhandledClause = [&](const auto *x) { + auto checkUnhandledClause = [&](llvm::omp::Clause id, const auto *x) { if (!x) return; TODO(currentLocation, - "Unhandled clause " + - llvm::StringRef(Fortran::parser::ParseTreeDumper::GetNodeName(*x)) - .upper() + + "Unhandled clause " + llvm::omp::getOpenMPClauseName(id).upper() + " in " + llvm::omp::getOpenMPDirectiveName(directive).upper() + " construct"); }; - for (ClauseIterator2 it = clauses2.v.begin(); it != clauses2.v.end(); ++it) -(checkUnhandledClause(std::get_if(&it->u)), ...); + for (ClauseIterator it = clauses.begin(); it != clauses.end(); ++it) +(checkUnhandledClause(it->id, std::get_if(&it->u)), ...); } //===--===// @@ -3723,8 +3717,8 @@ genSingleOp(Fortran::lower::AbstractConverter &converter, ClauseProcessor cp(converter, semaCtx, beginClauseList); cp.processAllocate(allocatorOperands, allocateOperands); - cp.processTODO( - currentLocation, llvm::omp::Directive::OMPD_single); + cp.processTODO(currentLocation, + llvm::omp::Directive::OMPD_single); ClauseProcessor(converter, semaCtx, endClauseList).processNowait(nowaitAttr); @@ -3757,10 +3751,9 @@ genTaskOp(Fortran::lower::AbstractConverter &converter, cp.processMergeable(mergeableAttr); cp.processPriority(stmtCtx, priorityClauseOperand); cp.processDepend(dependTypeOperands, dependOperands); - cp.processTODO( - currentLocation, llvm::omp::Directive::OMPD_task); + cp.processTODO(currentLocation, +llvm::omp::Directive::OMPD_task); return genOpWithBody( OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval) @@ -3785,7 +3778,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter, llvm::SmallVector allocateOperands, allocatorOperands; ClauseProcessor cp(converter, semaCtx, clauseList); cp.processAllocate(allocatorOperands, allocateOperands); - cp.processTODO( + cp.processTODO( currentLocation, llvm::omp::Directive::OMPD_taskgroup); return genOpWithBody( OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval) @@ -3869,8 +3862,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter, cp.processMap(currentLocation, directive, stmtCtx, mapOperands); } - cp.processTODO(currentLocation, - directive); + cp.processTODO(currentLocation, directive); return firOpBuilder.create(currentLocation, ifClauseOperand, deviceOperand, nullptr, mlir::ValueRange(), @@ -4053,16 +4045,11 @@ genTargetOp(Fortran::lower::AbstractConverter &converter, cp.processNowait(nowaitAttr); cp.processMap(currentLocation, directive, stmt
[llvm-branch-commits] [flang] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (PR #81623)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81623 >From 841f10e44e5ec5cfc6b166421f878089a17c623c Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 6 Feb 2024 17:06:29 -0600 Subject: [PATCH] [flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProcessor Rename `findRepeatableClause` to `findRepeatableClause2`, and make the new `findRepeatableClause` operate on new `omp::Clause` objects. Leave `Map` unchanged, because it will require more changes for it to work. --- flang/include/flang/Evaluate/tools.h | 23 + flang/lib/Lower/OpenMP.cpp | 632 +-- 2 files changed, 328 insertions(+), 327 deletions(-) diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h index d257da1a709642..e974944e88 100644 --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -430,6 +430,29 @@ template std::optional ExtractCoarrayRef(const A &x) { } } +struct ExtractSubstringHelper { + template static std::optional visit(T &&) { +return std::nullopt; + } + + static std::optional visit(const Substring &e) { return e; } + + template + static std::optional visit(const Designator &e) { +return std::visit([](auto &&s) { return visit(s); }, e.u); + } + + template + static std::optional visit(const Expr &e) { +return std::visit([](auto &&s) { return visit(s); }, e.u); + } +}; + +template +std::optional ExtractSubstring(const A &x) { + return ExtractSubstringHelper::visit(x); +} + // If an expression is simply a whole symbol data designator, // extract and return that symbol, else null. template const Symbol *UnwrapWholeSymbolDataRef(const A &x) { diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 4156887c8ff531..caae5c0cef9251 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -72,9 +72,9 @@ getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject) { return sym; } -static void genObjectList(const Fortran::parser::OmpObjectList &objectList, - Fortran::lower::AbstractConverter &converter, - llvm::SmallVectorImpl &operands) { +static void genObjectList2(const Fortran::parser::OmpObjectList &objectList, + Fortran::lower::AbstractConverter &converter, + llvm::SmallVectorImpl &operands) { auto addOperands = [&](Fortran::lower::SymbolRef sym) { const mlir::Value variable = converter.getSymbolAddress(sym); if (variable) { @@ -93,27 +93,6 @@ static void genObjectList(const Fortran::parser::OmpObjectList &objectList, } } -static void gatherFuncAndVarSyms( -const Fortran::parser::OmpObjectList &objList, -mlir::omp::DeclareTargetCaptureClause clause, -llvm::SmallVectorImpl &symbolAndClause) { - for (const Fortran::parser::OmpObject &ompObject : objList.v) { -Fortran::common::visit( -Fortran::common::visitors{ -[&](const Fortran::parser::Designator &designator) { - if (const Fortran::parser::Name *name = - Fortran::semantics::getDesignatorNameIfDataRef( - designator)) { -symbolAndClause.emplace_back(clause, *name->symbol); - } -}, -[&](const Fortran::parser::Name &name) { - symbolAndClause.emplace_back(clause, *name.symbol); -}}, -ompObject.u); - } -} - static Fortran::lower::pft::Evaluation * getCollapsedLoopEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) { // Return the Evaluation of the innermost collapsed loop, or the current one @@ -1258,6 +1237,32 @@ List makeList(const parser::OmpClauseList &clauses, } } // namespace omp +static void genObjectList(const omp::ObjectList &objects, + Fortran::lower::AbstractConverter &converter, + llvm::SmallVectorImpl &operands) { + for (const omp::Object &object : objects) { +const Fortran::semantics::Symbol *sym = object.sym; +assert(sym && "Expected Symbol"); +if (mlir::Value variable = converter.getSymbolAddress(*sym)) { + operands.push_back(variable); +} else { + if (const auto *details = + sym->detailsIf()) { +operands.push_back(converter.getSymbolAddress(details->symbol())); +converter.copySymbolBinding(details->symbol(), *sym); + } +} + } +} + +static void gatherFuncAndVarSyms( +const omp::ObjectList &objects, +mlir::omp::DeclareTargetCaptureClause clause, +llvm::SmallVectorImpl &symbolAndClause) { + for (const omp::Object &object : objects) +symbolAndClause.emplace_back(clause, *object.sym); +} + //===--===// // DataSharingProcessor //===--===// @
[llvm-branch-commits] [flang] [flang][Lower] Convert OMP Map and related functions to evaluate::Expr (PR #81626)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/81626 >From 87437159da37749ad395d84a3fc1b729bd9e2480 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 8 Feb 2024 08:33:40 -0600 Subject: [PATCH] [flang][Lower] Convert OMP Map and related functions to evaluate::Expr The related functions are `gatherDataOperandAddrAndBounds` and `genBoundsOps`. The former is used in OpenACC as well, and it was updated to pass evaluate::Expr instead of parser objects. The difference in the test case comes from unfolded conversions of index expressions, which are explicitly of type integer(kind=8). Delete now unused `findRepeatableClause2` and `findClause2`. Add `AsGenericExpr` that takes std::optional. It already returns optional Expr. Making it accept an optional Expr as input would reduce the number of necessary checks when handling frequent optional values in evaluator. --- flang/include/flang/Evaluate/tools.h | 8 + flang/lib/Lower/DirectivesCommon.h | 389 --- flang/lib/Lower/OpenACC.cpp | 54 ++-- flang/lib/Lower/OpenMP.cpp | 105 +++- 4 files changed, 311 insertions(+), 245 deletions(-) diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h index e974944e88..d5713cfe420a2e 100644 --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -148,6 +148,14 @@ inline Expr AsGenericExpr(Expr &&x) { return std::move(x); } std::optional> AsGenericExpr(DataRef &&); std::optional> AsGenericExpr(const Symbol &); +// Propagate std::optional from input to output. +template +std::optional> AsGenericExpr(std::optional &&x) { + if (!x) +return std::nullopt; + return AsGenericExpr(std::move(*x)); +} + template common::IfNoLvalue::category>>, A> AsCategoryExpr( A &&x) { diff --git a/flang/lib/Lower/DirectivesCommon.h b/flang/lib/Lower/DirectivesCommon.h index 8d560db34e05bf..2fa90572bc63eb 100644 --- a/flang/lib/Lower/DirectivesCommon.h +++ b/flang/lib/Lower/DirectivesCommon.h @@ -808,6 +808,75 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, return bounds; } +namespace detail { +template // +static T &&AsRvalueRef(T &&t) { + return std::move(t); +} +template // +static T AsRvalueRef(T &t) { + return t; +} +template // +static T AsRvalueRef(const T &t) { + return t; +} + +// Helper class for stripping enclosing parentheses and a conversion that +// preserves type category. This is used for triplet elements, which are +// always of type integer(kind=8). The lower/upper bounds are converted to +// an "index" type, which is 64-bit, so the explicit conversion to kind=8 +// (if present) is not needed. When it's present, though, it causes generated +// names to contain "int(..., kind=8)". +struct PeelConvert { + template + static Fortran::semantics::MaybeExpr visit_with_category( + const Fortran::evaluate::Expr> + &expr) { +return std::visit( +[](auto &&s) { return visit_with_category(s); }, +expr.u); + } + template + static Fortran::semantics::MaybeExpr visit_with_category( + const Fortran::evaluate::Convert, + Category> &expr) { +return AsGenericExpr(AsRvalueRef(expr.left())); + } + template + static Fortran::semantics::MaybeExpr visit_with_category(const T &) { +return std::nullopt; // + } + template + static Fortran::semantics::MaybeExpr visit_with_category(const T &) { +return std::nullopt; // + } + + template + static Fortran::semantics::MaybeExpr + visit(const Fortran::evaluate::Expr> +&expr) { +return std::visit([](auto &&s) { return visit_with_category(s); }, + expr.u); + } + static Fortran::semantics::MaybeExpr + visit(const Fortran::evaluate::Expr &expr) { +return std::visit([](auto &&s) { return visit(s); }, expr.u); + } + template // + static Fortran::semantics::MaybeExpr visit(const T &) { +return std::nullopt; + } +}; + +static Fortran::semantics::SomeExpr +peelOuterConvert(Fortran::semantics::SomeExpr &expr) { + if (auto peeled = PeelConvert::visit(expr)) +return *peeled; + return expr; +} +} // namespace detail + /// Generate bounds operations for an array section when subscripts are /// provided. template @@ -815,7 +884,7 @@ llvm::SmallVector genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, Fortran::lower::AbstractConverter &converter, Fortran::lower::StatementContext &stmtCtx, - const std::list &subscripts, + const std::vector &subscripts, std::stringstream &asFortran, fir::ExtendedValue &dataExv, bool dataExvIsAssumedSize, AddrAndBoundsInfo &info, bool treatIndexAsSection = false) { @@ -828,8 +897,7 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1)
[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Main splitting functionality dev-complete (PR #82003)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/82003 >From ac2d8fd31c0a2b8f818a73a619496d5263c3ccb8 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Tue, 16 Jan 2024 16:40:47 -0600 Subject: [PATCH 1/2] [flang][OpenMP] Main splitting functionality dev-complete [flang][OpenMP] TableGen support for getting leaf constructs Implement getLeafConstructs(D), which for a composite directive D will return the list of the constituent leaf directives. [flang][OpenMP] Set OpenMP attributes in MLIR module in bbc before lowering Right now attributes like OpenMP version or target attributes for offload are set after lowering in bbc. The flang frontend sets them before lowering, making them available in the lowering process. This change sets them before lowering in bbc as well. getOpenMPVersion --- flang/lib/Lower/OpenMP.cpp| 1044 - flang/tools/bbc/bbc.cpp |2 +- .../llvm/Frontend/Directive/DirectiveBase.td |4 + llvm/include/llvm/Frontend/OpenMP/OMP.td | 60 +- llvm/include/llvm/TableGen/DirectiveEmitter.h |4 + llvm/utils/TableGen/DirectiveEmitter.cpp | 77 ++ 6 files changed, 1174 insertions(+), 17 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index e45ab842b15556..ed6a0063848b18 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -31,6 +31,7 @@ #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "mlir/Dialect/SCF/IR/SCF.h" #include "mlir/Transforms/RegionUtils.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Frontend/OpenMP/OMPConstants.h" #include "llvm/Support/CommandLine.h" @@ -48,6 +49,29 @@ using DeclareTargetCapturePair = // Common helper functions //===--===// +static llvm::ArrayRef getWorksharing() { + static llvm::omp::Directive worksharing[] = { + llvm::omp::Directive::OMPD_do, llvm::omp::Directive::OMPD_for, + llvm::omp::Directive::OMPD_scope, llvm::omp::Directive::OMPD_sections, + llvm::omp::Directive::OMPD_single, llvm::omp::Directive::OMPD_workshare, + }; + return worksharing; +} + +static llvm::ArrayRef getWorksharingLoop() { + static llvm::omp::Directive worksharingLoop[] = { + llvm::omp::Directive::OMPD_do, + llvm::omp::Directive::OMPD_for, + }; + return worksharingLoop; +} + +static uint32_t getOpenMPVersion(const mlir::ModuleOp &mod) { + if (mlir::Attribute verAttr = mod->getAttr("omp.version")) +return llvm::cast(verAttr).getVersion(); + llvm_unreachable("Exoecting OpenMP version attribute in module"); +} + static Fortran::semantics::Symbol * getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject) { Fortran::semantics::Symbol *sym = nullptr; @@ -166,6 +190,15 @@ struct SymDsgExtractor { return t; } + static semantics::Symbol *symbol_addr(const evaluate::SymbolRef &ref) { +// Symbols cannot be created after semantic checks, so all symbol +// pointers that are non-null must point to one of those pre-existing +// objects. Throughout the code, symbols are often pointed to by +// non-const pointers, so there is no harm in casting the constness +// away. +return const_cast(&ref.get()); + } + template // static SymDsg visit(T &&) { // Use this to see missing overloads: @@ -175,19 +208,12 @@ struct SymDsgExtractor { template // static SymDsg visit(const evaluate::Designator &e) { -// Symbols cannot be created after semantic checks, so all symbol -// pointers that are non-null must point to one of those pre-existing -// objects. Throughout the code, symbols are often pointed to by -// non-const pointers, so there is no harm in casting the constness -// away. -return std::make_tuple(const_cast(e.GetLastSymbol()), +return std::make_tuple(symbol_addr(*e.GetLastSymbol()), evaluate::AsGenericExpr(AsRvalueRef(e))); } static SymDsg visit(const evaluate::ProcedureDesignator &e) { -// See comment above regarding const_cast. -return std::make_tuple(const_cast(e.GetSymbol()), - std::nullopt); +return std::make_tuple(symbol_addr(*e.GetSymbol()), std::nullopt); } template // @@ -313,6 +339,42 @@ std::optional maybeApply(F &&func, const std::optional &inp) { return std::move(func(*inp)); } +std::optional +getBaseObject(const Object &object, + Fortran::semantics::SemanticsContext &semaCtx) { + // If it's just the symbol, then there is no base. + if (!object.dsg) +return std::nullopt; + + auto maybeRef = evaluate::ExtractDataRef(*object.dsg); + if (!maybeRef) +return std::nullopt; + + evaluate::DataRef ref = *maybeRef; + + if (std::get_if(&ref.u)) { +return std::nullopt; + } else if (auto *comp = std::get_if(&ref.u)) { +const evaluate::DataRef &base = comp
[llvm-branch-commits] [llvm] release/18.x: [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107) (PR #81568)
https://github.com/asb approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/81568 ___ 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] 7c6d538 - Revert "[llvm] Fix assertion error where we didn't check fixed point types. (…"
Author: Vladimir Vereschaka Date: 2024-02-19T14:32:30-08:00 New Revision: 7c6d53889542967be1323799b152a992bf3b916f URL: https://github.com/llvm/llvm-project/commit/7c6d53889542967be1323799b152a992bf3b916f DIFF: https://github.com/llvm/llvm-project/commit/7c6d53889542967be1323799b152a992bf3b916f.diff LOG: Revert "[llvm] Fix assertion error where we didn't check fixed point types. (…" This reverts commit 1807e02b8c280af10628538d69e9511d3df3ed5f. Added: Modified: llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp Removed: llvm/test/DebugInfo/fixed-point.ll diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp index f00ff1565c665f..eb2d992c7e75e7 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp @@ -224,15 +224,12 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) { Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || Encoding == dwarf::DW_ATE_complex_float || - Encoding == dwarf::DW_ATE_signed_fixed || - Encoding == dwarf::DW_ATE_unsigned_fixed || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == "decltype(nullptr)")) && "Unsupported encoding"); return Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || - Encoding == llvm::dwarf::DW_ATE_unsigned_fixed || Ty->getTag() == dwarf::DW_TAG_unspecified_type; } diff --git a/llvm/test/DebugInfo/fixed-point.ll b/llvm/test/DebugInfo/fixed-point.ll deleted file mode 100644 index 0de984484c0e60..00 --- a/llvm/test/DebugInfo/fixed-point.ll +++ /dev/null @@ -1,31 +0,0 @@ -;; This fixes https://github.com/llvm/llvm-project/issues/81555 -; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s -; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump - -verify | FileCheck %s --check-prefix=VERIFY - -; VERIFY-NOT: error: - -; CHECK: {{.*}}: DW_TAG_base_type -; CHECK-NEXT: DW_AT_name ("var") -; CHECK-NEXT: DW_AT_encoding (DW_ATE_signed_fixed) -define void @func() !dbg !26 { -entry: - %classifier = alloca i32, align 4 - tail call void @llvm.dbg.value(metadata i32 32768, metadata !37, metadata !DIExpression()), !dbg !39 - store i32 32768, ptr %classifier, align 4, !dbg !39 - ret void -} - -declare void @llvm.dbg.value(metadata, metadata, metadata) - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!19} - -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug) -!1 = !DIFile(filename: "a", directory: "") -!6 = !DIBasicType(name: "var", size: 32, encoding: DW_ATE_signed_fixed) -!19 = !{i32 2, !"Debug Info Version", i32 3} -!3 = !DISubroutineType(types: null) -!26 = distinct !DISubprogram(unit: !0, type: !3) -!37 = !DILocalVariable(name: "intercept", arg: 2, scope: !26, file: !1, line: 7, type: !6) -!39 = !DILocation(line: 0, scope: !26) - ___ 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] b27f0b4 - [AIX] Add a dummy variable in the __llvm_orderfile section (#81968)
Author: Wael Yehia Date: 2024-02-18T04:13:07Z New Revision: b27f0b4fae68fea5c2468bc080e31bcecfb7faa7 URL: https://github.com/llvm/llvm-project/commit/b27f0b4fae68fea5c2468bc080e31bcecfb7faa7 DIFF: https://github.com/llvm/llvm-project/commit/b27f0b4fae68fea5c2468bc080e31bcecfb7faa7.diff LOG: [AIX] Add a dummy variable in the __llvm_orderfile section (#81968) to satisfy the __start___llvm_orderfile reference when linking with -bexpfull and -fprofile-generate on AIX. (cherry picked from commit 1555919d27eb2e89379a65f6c7809f679fda) Added: compiler-rt/test/profile/AIX/bexpfull-pgo.c Modified: compiler-rt/lib/profile/InstrProfilingPlatformAIX.c Removed: diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c b/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c index 9f46a98d78ac4e..002bec164d7e85 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c @@ -195,6 +195,8 @@ static const int dummy_name[0] COMPILER_RT_SECTION( COMPILER_RT_SEG INSTR_PROF_NAME_SECT_NAME); static int dummy_vnds[0] COMPILER_RT_SECTION( COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME); +static int dummy_orderfile[0] COMPILER_RT_SECTION( +COMPILER_RT_SEG INSTR_PROF_ORDERFILE_SECT_NAME); // To avoid GC'ing of the dummy variables by the linker, reference them in an // array and reference the array in the runtime registration code @@ -206,7 +208,7 @@ static int dummy_vnds[0] COMPILER_RT_SECTION( COMPILER_RT_VISIBILITY void *__llvm_profile_keep[] = {(void *)&dummy_cnts, (void *)&dummy_bits, (void *)&dummy_data, (void *)&dummy_name, - (void *)&dummy_vnds}; + (void *)&dummy_vnds, (void *)&dummy_orderfile}; #ifdef __GNUC__ #pragma GCC diagnostic pop #endif diff --git a/compiler-rt/test/profile/AIX/bexpfull-pgo.c b/compiler-rt/test/profile/AIX/bexpfull-pgo.c new file mode 100644 index 00..f48242ec6bfeaa --- /dev/null +++ b/compiler-rt/test/profile/AIX/bexpfull-pgo.c @@ -0,0 +1,7 @@ +// RUN: %clang_pgogen %s -bexpall +// RUN: %clang_pgogen %s -bexpfull + +#include +int ar[10]; +int n; +int main() { memcpy(ar, ar + 1, n); }; ___ 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] release/18.x: [AIX] Add a dummy variable in the __llvm_orderfile section (#81968) (PR #82148)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/82148 ___ 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] release/18.x: [OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996) (PR #82146)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/82146 >From ae276000164a41a8fc814bf1d4eccf31347c88f5 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Fri, 16 Feb 2024 15:12:41 -0500 Subject: [PATCH] [OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996) This patch sets the stack size of worker threads to `2 x KMP_DEFAULT_STKSIZE` (2 x 4MB) for AIX if the system stack size is too big. Also defines maximum stack size for 32-bit AIX. (cherry picked from commit 2de269a641e4ffbb7a44e559c4c0a91bb66df823) --- openmp/runtime/src/kmp.h| 4 openmp/runtime/src/kmp_settings.cpp | 5 + 2 files changed, 9 insertions(+) diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index b147063d228263..259c57b5afbca5 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -1181,7 +1181,11 @@ extern void __kmp_init_target_task(); #define KMP_MIN_STKSIZE ((size_t)(32 * 1024)) #endif +#if KMP_OS_AIX && KMP_ARCH_PPC +#define KMP_MAX_STKSIZE 0x1000 /* 256Mb max size on 32-bit AIX */ +#else #define KMP_MAX_STKSIZE (~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1))) +#endif #if KMP_ARCH_X86 #define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024)) diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp index d2157b10b7819a..ec86ee07472c1e 100644 --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -255,8 +255,13 @@ static void __kmp_stg_parse_bool(char const *name, char const *value, // placed here in order to use __kmp_round4k static function void __kmp_check_stksize(size_t *val) { // if system stack size is too big then limit the size for worker threads +#if KMP_OS_AIX + if (*val > KMP_DEFAULT_STKSIZE * 2) // Use 2 times, 16 is too large for AIX. +*val = KMP_DEFAULT_STKSIZE * 2; +#else if (*val > KMP_DEFAULT_STKSIZE * 16) // just a heuristics... *val = KMP_DEFAULT_STKSIZE * 16; +#endif if (*val < __kmp_sys_min_stksize) *val = __kmp_sys_min_stksize; if (*val > KMP_MAX_STKSIZE) ___ 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] ae27600 - [OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996)
Author: Xing Xue Date: 2024-02-19T16:14:44-08:00 New Revision: ae276000164a41a8fc814bf1d4eccf31347c88f5 URL: https://github.com/llvm/llvm-project/commit/ae276000164a41a8fc814bf1d4eccf31347c88f5 DIFF: https://github.com/llvm/llvm-project/commit/ae276000164a41a8fc814bf1d4eccf31347c88f5.diff LOG: [OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996) This patch sets the stack size of worker threads to `2 x KMP_DEFAULT_STKSIZE` (2 x 4MB) for AIX if the system stack size is too big. Also defines maximum stack size for 32-bit AIX. (cherry picked from commit 2de269a641e4ffbb7a44e559c4c0a91bb66df823) Added: Modified: openmp/runtime/src/kmp.h openmp/runtime/src/kmp_settings.cpp Removed: diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index b147063d228263..259c57b5afbca5 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -1181,7 +1181,11 @@ extern void __kmp_init_target_task(); #define KMP_MIN_STKSIZE ((size_t)(32 * 1024)) #endif +#if KMP_OS_AIX && KMP_ARCH_PPC +#define KMP_MAX_STKSIZE 0x1000 /* 256Mb max size on 32-bit AIX */ +#else #define KMP_MAX_STKSIZE (~((size_t)1 << ((sizeof(size_t) * (1 << 3)) - 1))) +#endif #if KMP_ARCH_X86 #define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024)) diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp index d2157b10b7819a..ec86ee07472c1e 100644 --- a/openmp/runtime/src/kmp_settings.cpp +++ b/openmp/runtime/src/kmp_settings.cpp @@ -255,8 +255,13 @@ static void __kmp_stg_parse_bool(char const *name, char const *value, // placed here in order to use __kmp_round4k static function void __kmp_check_stksize(size_t *val) { // if system stack size is too big then limit the size for worker threads +#if KMP_OS_AIX + if (*val > KMP_DEFAULT_STKSIZE * 2) // Use 2 times, 16 is too large for AIX. +*val = KMP_DEFAULT_STKSIZE * 2; +#else if (*val > KMP_DEFAULT_STKSIZE * 16) // just a heuristics... *val = KMP_DEFAULT_STKSIZE * 16; +#endif if (*val < __kmp_sys_min_stksize) *val = __kmp_sys_min_stksize; if (*val > KMP_MAX_STKSIZE) ___ 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] release/18.x: [OpenMP][AIX] Set worker stack size to 2 x KMP_DEFAULT_STKSIZE if system stack size is too big (#81996) (PR #82146)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/82146 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [Support/ELF] Add OpenBSD PT_OPENBSD_SYSCALLS constant. (PR #82143)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/82143 >From c5e1885af0426897affc008fab174348eeca7af7 Mon Sep 17 00:00:00 2001 From: Frederic Cambus Date: Sat, 17 Feb 2024 15:38:05 +0100 Subject: [PATCH] [Support/ELF] Add OpenBSD PT_OPENBSD_SYSCALLS constant. Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h (cherry picked from commit 97eff26d0ca4d187a5efb8534af484dbb68bce30) --- llvm/include/llvm/BinaryFormat/ELF.h | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index 81cdd39afc6bab..f17ba75e3efa6a 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1464,6 +1464,7 @@ enum { PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data. PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations. PT_OPENBSD_NOBTCFI = 0x65a3dbe8, // Do not enforce branch target CFI. + PT_OPENBSD_SYSCALLS = 0x65a3dbe9, // System call sites. PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments. // ARM program header types. ___ 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] c5e1885 - [Support/ELF] Add OpenBSD PT_OPENBSD_SYSCALLS constant.
Author: Frederic Cambus Date: 2024-02-19T16:18:19-08:00 New Revision: c5e1885af0426897affc008fab174348eeca7af7 URL: https://github.com/llvm/llvm-project/commit/c5e1885af0426897affc008fab174348eeca7af7 DIFF: https://github.com/llvm/llvm-project/commit/c5e1885af0426897affc008fab174348eeca7af7.diff LOG: [Support/ELF] Add OpenBSD PT_OPENBSD_SYSCALLS constant. Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h (cherry picked from commit 97eff26d0ca4d187a5efb8534af484dbb68bce30) Added: Modified: llvm/include/llvm/BinaryFormat/ELF.h Removed: diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h index 81cdd39afc6bab..f17ba75e3efa6a 100644 --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -1464,6 +1464,7 @@ enum { PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data. PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations. PT_OPENBSD_NOBTCFI = 0x65a3dbe8, // Do not enforce branch target CFI. + PT_OPENBSD_SYSCALLS = 0x65a3dbe9, // System call sites. PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments. // ARM program header types. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [Support/ELF] Add OpenBSD PT_OPENBSD_SYSCALLS constant. (PR #82143)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/82143 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [ValueTracking] Fix computeKnownFPClass for fpext (#81972) (PR #82117)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/82117 >From b845f0662a287912332c89e56f5900037aa7c70f Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Sat, 17 Feb 2024 23:30:45 +0800 Subject: [PATCH] [ValueTracking] Fix computeKnownFPClass for fpext (#81972) This patch adds the missing `subnormal -> normal` part for `fpext` in `computeKnownFPClass`. Fixes the miscompilation reported by https://github.com/llvm/llvm-project/pull/80941#issuecomment-1947302100. (cherry picked from commit a5865c3c3dbbd17ae12ecc1c297fe1fc2605df52) --- llvm/lib/Analysis/ValueTracking.cpp | 7 +++- .../Transforms/Attributor/nofpclass-fpext.ll | 34 +-- llvm/test/Transforms/InstCombine/pr80941.ll | 32 + 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 llvm/test/Transforms/InstCombine/pr80941.ll diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 5d6c3465a0c364..412115eb649c2f 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -5083,8 +5083,13 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts, Op->getOperand(0)->getType()->getScalarType()->getFltSemantics(); // All subnormal inputs should be in the normal range in the result type. -if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) +if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) { + if (Known.KnownFPClasses & fcPosSubnormal) +Known.KnownFPClasses |= fcPosNormal; + if (Known.KnownFPClasses & fcNegSubnormal) +Known.KnownFPClasses |= fcNegNormal; Known.knownNot(fcSubnormal); +} // Sign bit of a nan isn't guaranteed. if (!Known.isKnownNeverNaN()) diff --git a/llvm/test/Transforms/Attributor/nofpclass-fpext.ll b/llvm/test/Transforms/Attributor/nofpclass-fpext.ll index 0ba114117ceec6..ee36f949529d4f 100644 --- a/llvm/test/Transforms/Attributor/nofpclass-fpext.ll +++ b/llvm/test/Transforms/Attributor/nofpclass-fpext.ll @@ -142,7 +142,7 @@ define double @ret_fpext_f32_to_f64_nosub(float nofpclass(sub) %arg0) { } define double @ret_fpext_f32_to_f64_nonorm(float nofpclass(norm) %arg0) { -; CHECK-LABEL: define nofpclass(sub norm) double @ret_fpext_f32_to_f64_nonorm +; CHECK-LABEL: define nofpclass(sub) double @ret_fpext_f32_to_f64_nonorm ; CHECK-SAME: (float nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { ; CHECK-NEXT:[[EXT:%.*]] = fpext float [[ARG0]] to double ; CHECK-NEXT:ret double [[EXT]] @@ -482,7 +482,37 @@ define double @ret_fpext_bf16_f64_nosub(bfloat nofpclass(sub) %arg0) { } define double @ret_fpext_bf16_f64_nonorm(bfloat nofpclass(norm) %arg0) { -; CHECK-LABEL: define nofpclass(sub norm) double @ret_fpext_bf16_f64_nonorm +; CHECK-LABEL: define nofpclass(sub) double @ret_fpext_bf16_f64_nonorm +; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { +; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double +; CHECK-NEXT:ret double [[EXT]] +; + %ext = fpext bfloat %arg0 to double + ret double %ext +} + +define double @ret_fpext_bf16_f64_nonorm_psub(bfloat nofpclass(norm psub) %arg0) { +; CHECK-LABEL: define nofpclass(sub pnorm) double @ret_fpext_bf16_f64_nonorm_psub +; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { +; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double +; CHECK-NEXT:ret double [[EXT]] +; + %ext = fpext bfloat %arg0 to double + ret double %ext +} + +define double @ret_fpext_bf16_f64_nonorm_nsub(bfloat nofpclass(norm nsub) %arg0) { +; CHECK-LABEL: define nofpclass(sub nnorm) double @ret_fpext_bf16_f64_nonorm_nsub +; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { +; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double +; CHECK-NEXT:ret double [[EXT]] +; + %ext = fpext bfloat %arg0 to double + ret double %ext +} + +define double @ret_fpext_bf16_f64_nonorm_sub(bfloat nofpclass(norm sub) %arg0) { +; CHECK-LABEL: define nofpclass(sub norm) double @ret_fpext_bf16_f64_nonorm_sub ; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { ; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double ; CHECK-NEXT:ret double [[EXT]] diff --git a/llvm/test/Transforms/InstCombine/pr80941.ll b/llvm/test/Transforms/InstCombine/pr80941.ll new file mode 100644 index 00..95242b1d1407bf --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr80941.ll @@ -0,0 +1,32 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -S -passes=instcombine < %s | FileCheck %s + +define float @pr80941(float %arg) { +; CHECK-LABEL: define float @pr80941( +; CHECK-SAME: float [[ARG:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[COND:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[ARG]], i32 144) +; CHECK-NEXT:br i1 [[COND]], label [[IF_THEN:%.*]], label [[IF_EXIT:%.*]] +; CHECK: if.then: +; CHECK
[llvm-branch-commits] [llvm] b845f06 - [ValueTracking] Fix computeKnownFPClass for fpext (#81972)
Author: Yingwei Zheng Date: 2024-02-19T16:36:53-08:00 New Revision: b845f0662a287912332c89e56f5900037aa7c70f URL: https://github.com/llvm/llvm-project/commit/b845f0662a287912332c89e56f5900037aa7c70f DIFF: https://github.com/llvm/llvm-project/commit/b845f0662a287912332c89e56f5900037aa7c70f.diff LOG: [ValueTracking] Fix computeKnownFPClass for fpext (#81972) This patch adds the missing `subnormal -> normal` part for `fpext` in `computeKnownFPClass`. Fixes the miscompilation reported by https://github.com/llvm/llvm-project/pull/80941#issuecomment-1947302100. (cherry picked from commit a5865c3c3dbbd17ae12ecc1c297fe1fc2605df52) Added: llvm/test/Transforms/InstCombine/pr80941.ll Modified: llvm/lib/Analysis/ValueTracking.cpp llvm/test/Transforms/Attributor/nofpclass-fpext.ll Removed: diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 5d6c3465a0c364..412115eb649c2f 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -5083,8 +5083,13 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts, Op->getOperand(0)->getType()->getScalarType()->getFltSemantics(); // All subnormal inputs should be in the normal range in the result type. -if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) +if (APFloat::isRepresentableAsNormalIn(SrcTy, DstTy)) { + if (Known.KnownFPClasses & fcPosSubnormal) +Known.KnownFPClasses |= fcPosNormal; + if (Known.KnownFPClasses & fcNegSubnormal) +Known.KnownFPClasses |= fcNegNormal; Known.knownNot(fcSubnormal); +} // Sign bit of a nan isn't guaranteed. if (!Known.isKnownNeverNaN()) diff --git a/llvm/test/Transforms/Attributor/nofpclass-fpext.ll b/llvm/test/Transforms/Attributor/nofpclass-fpext.ll index 0ba114117ceec6..ee36f949529d4f 100644 --- a/llvm/test/Transforms/Attributor/nofpclass-fpext.ll +++ b/llvm/test/Transforms/Attributor/nofpclass-fpext.ll @@ -142,7 +142,7 @@ define double @ret_fpext_f32_to_f64_nosub(float nofpclass(sub) %arg0) { } define double @ret_fpext_f32_to_f64_nonorm(float nofpclass(norm) %arg0) { -; CHECK-LABEL: define nofpclass(sub norm) double @ret_fpext_f32_to_f64_nonorm +; CHECK-LABEL: define nofpclass(sub) double @ret_fpext_f32_to_f64_nonorm ; CHECK-SAME: (float nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { ; CHECK-NEXT:[[EXT:%.*]] = fpext float [[ARG0]] to double ; CHECK-NEXT:ret double [[EXT]] @@ -482,7 +482,37 @@ define double @ret_fpext_bf16_f64_nosub(bfloat nofpclass(sub) %arg0) { } define double @ret_fpext_bf16_f64_nonorm(bfloat nofpclass(norm) %arg0) { -; CHECK-LABEL: define nofpclass(sub norm) double @ret_fpext_bf16_f64_nonorm +; CHECK-LABEL: define nofpclass(sub) double @ret_fpext_bf16_f64_nonorm +; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { +; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double +; CHECK-NEXT:ret double [[EXT]] +; + %ext = fpext bfloat %arg0 to double + ret double %ext +} + +define double @ret_fpext_bf16_f64_nonorm_psub(bfloat nofpclass(norm psub) %arg0) { +; CHECK-LABEL: define nofpclass(sub pnorm) double @ret_fpext_bf16_f64_nonorm_psub +; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { +; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double +; CHECK-NEXT:ret double [[EXT]] +; + %ext = fpext bfloat %arg0 to double + ret double %ext +} + +define double @ret_fpext_bf16_f64_nonorm_nsub(bfloat nofpclass(norm nsub) %arg0) { +; CHECK-LABEL: define nofpclass(sub nnorm) double @ret_fpext_bf16_f64_nonorm_nsub +; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { +; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double +; CHECK-NEXT:ret double [[EXT]] +; + %ext = fpext bfloat %arg0 to double + ret double %ext +} + +define double @ret_fpext_bf16_f64_nonorm_sub(bfloat nofpclass(norm sub) %arg0) { +; CHECK-LABEL: define nofpclass(sub norm) double @ret_fpext_bf16_f64_nonorm_sub ; CHECK-SAME: (bfloat nofpclass(sub norm) [[ARG0:%.*]]) #[[ATTR0]] { ; CHECK-NEXT:[[EXT:%.*]] = fpext bfloat [[ARG0]] to double ; CHECK-NEXT:ret double [[EXT]] diff --git a/llvm/test/Transforms/InstCombine/pr80941.ll b/llvm/test/Transforms/InstCombine/pr80941.ll new file mode 100644 index 00..95242b1d1407bf --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr80941.ll @@ -0,0 +1,32 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt -S -passes=instcombine < %s | FileCheck %s + +define float @pr80941(float %arg) { +; CHECK-LABEL: define float @pr80941( +; CHECK-SAME: float [[ARG:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[COND:%.*]] = tail call i1 @llvm.is.fpclass.f32(float [[ARG]], i32 144) +; CHECK-NEXT:br i1 [[COND]], label [[IF_THEN:%.*]], label [[IF_EXIT:%.*]] +; CHECK:
[llvm-branch-commits] [llvm] release/18.x: [ValueTracking] Fix computeKnownFPClass for fpext (#81972) (PR #82117)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/82117 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107) (PR #81568)
https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/81568 >From c7b0a6ecd442363620d13e44077ca25a5f59fb59 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Fri, 9 Feb 2024 06:51:11 +0800 Subject: [PATCH] [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107) Otherwise we will crash since target intrinsics don't have their types legalized. Let the mgather get legalized first, then do the combine on the legal type. Fixes #81088 Co-authored-by: Craig Topper (cherry picked from commit 06c89bd59ca2279f76a41e851b7b2df634a6191e) --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 2 +- .../RISCV/rvv/fixed-vectors-masked-gather.ll | 448 ++ 2 files changed, 449 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 37d94be5316eea..80447d03c000b8 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -15561,7 +15561,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N, MGN->getMemOperand(), IndexType, MGN->getExtensionType()); if (Index.getOpcode() == ISD::BUILD_VECTOR && -MGN->getExtensionType() == ISD::NON_EXTLOAD) { +MGN->getExtensionType() == ISD::NON_EXTLOAD && isTypeLegal(VT)) { if (std::optional SimpleVID = isSimpleVIDSequence(Index); SimpleVID && SimpleVID->StepDenominator == 1) { const int64_t StepNumerator = SimpleVID->StepNumerator; diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll index df41ac10f80d36..890707c6337fad 100644 --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll @@ -14638,5 +14638,453 @@ define <8 x i16> @mgather_shuffle_vrgather(ptr %base) { %v = call <8 x i16> @llvm.masked.gather.v8i16.v8p0(<8 x ptr> %ptrs, i32 4, <8 x i1> %allones, <8 x i16> poison) ret <8 x i16> %v } + +; v32i64 is not a legal type, so make sure we don't try to combine the mgather +; to a vlse intrinsic until it is legalized and split. +define <32 x i64> @mgather_strided_split(ptr %base) { +; RV32V-LABEL: mgather_strided_split: +; RV32V: # %bb.0: +; RV32V-NEXT:li a1, 16 +; RV32V-NEXT:vsetivli zero, 16, e64, m8, ta, ma +; RV32V-NEXT:vlse64.v v8, (a0), a1 +; RV32V-NEXT:addi a0, a0, 256 +; RV32V-NEXT:vlse64.v v16, (a0), a1 +; RV32V-NEXT:ret +; +; RV64V-LABEL: mgather_strided_split: +; RV64V: # %bb.0: +; RV64V-NEXT:li a1, 16 +; RV64V-NEXT:vsetivli zero, 16, e64, m8, ta, ma +; RV64V-NEXT:vlse64.v v8, (a0), a1 +; RV64V-NEXT:addi a0, a0, 256 +; RV64V-NEXT:vlse64.v v16, (a0), a1 +; RV64V-NEXT:ret +; +; RV32ZVE32F-LABEL: mgather_strided_split: +; RV32ZVE32F: # %bb.0: +; RV32ZVE32F-NEXT:addi sp, sp, -512 +; RV32ZVE32F-NEXT:.cfi_def_cfa_offset 512 +; RV32ZVE32F-NEXT:sw ra, 508(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s0, 504(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s2, 500(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s3, 496(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s4, 492(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s5, 488(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s6, 484(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s7, 480(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s8, 476(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s9, 472(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s10, 468(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s11, 464(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:.cfi_offset ra, -4 +; RV32ZVE32F-NEXT:.cfi_offset s0, -8 +; RV32ZVE32F-NEXT:.cfi_offset s2, -12 +; RV32ZVE32F-NEXT:.cfi_offset s3, -16 +; RV32ZVE32F-NEXT:.cfi_offset s4, -20 +; RV32ZVE32F-NEXT:.cfi_offset s5, -24 +; RV32ZVE32F-NEXT:.cfi_offset s6, -28 +; RV32ZVE32F-NEXT:.cfi_offset s7, -32 +; RV32ZVE32F-NEXT:.cfi_offset s8, -36 +; RV32ZVE32F-NEXT:.cfi_offset s9, -40 +; RV32ZVE32F-NEXT:.cfi_offset s10, -44 +; RV32ZVE32F-NEXT:.cfi_offset s11, -48 +; RV32ZVE32F-NEXT:addi s0, sp, 512 +; RV32ZVE32F-NEXT:.cfi_def_cfa s0, 0 +; RV32ZVE32F-NEXT:andi sp, sp, -128 +; RV32ZVE32F-NEXT:li a2, 32 +; RV32ZVE32F-NEXT:vsetvli zero, a2, e32, m8, ta, ma +; RV32ZVE32F-NEXT:vid.v v8 +; RV32ZVE32F-NEXT:vsll.vi v8, v8, 4 +; RV32ZVE32F-NEXT:vadd.vx v8, v8, a1 +; RV32ZVE32F-NEXT:vmv.x.s a1, v8 +; RV32ZVE32F-NEXT:lw a3, 0(a1) +; RV32ZVE32F-NEXT:sw a3, 216(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:lw a1, 4(a1) +; RV32ZVE32F-NEXT:sw a1, 208(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:vsetivli zero, 1, e32, m1, ta, ma +; RV32ZVE32F-NEXT:vslidedown.vi v16, v8, 1 +; RV32ZVE32F-NEXT:vmv.x.s a1, v16 +; RV32ZVE32F-NEXT:lw a3, 0(a1) +; RV32ZVE32F-NEXT:sw a
[llvm-branch-commits] [llvm] c7b0a6e - [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107)
Author: Luke Lau Date: 2024-02-19T16:43:22-08:00 New Revision: c7b0a6ecd442363620d13e44077ca25a5f59fb59 URL: https://github.com/llvm/llvm-project/commit/c7b0a6ecd442363620d13e44077ca25a5f59fb59 DIFF: https://github.com/llvm/llvm-project/commit/c7b0a6ecd442363620d13e44077ca25a5f59fb59.diff LOG: [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107) Otherwise we will crash since target intrinsics don't have their types legalized. Let the mgather get legalized first, then do the combine on the legal type. Fixes #81088 Co-authored-by: Craig Topper (cherry picked from commit 06c89bd59ca2279f76a41e851b7b2df634a6191e) Added: Modified: llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll Removed: diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 37d94be5316eea..80447d03c000b8 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -15561,7 +15561,7 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N, MGN->getMemOperand(), IndexType, MGN->getExtensionType()); if (Index.getOpcode() == ISD::BUILD_VECTOR && -MGN->getExtensionType() == ISD::NON_EXTLOAD) { +MGN->getExtensionType() == ISD::NON_EXTLOAD && isTypeLegal(VT)) { if (std::optional SimpleVID = isSimpleVIDSequence(Index); SimpleVID && SimpleVID->StepDenominator == 1) { const int64_t StepNumerator = SimpleVID->StepNumerator; diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll index df41ac10f80d36..890707c6337fad 100644 --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll @@ -14638,5 +14638,453 @@ define <8 x i16> @mgather_shuffle_vrgather(ptr %base) { %v = call <8 x i16> @llvm.masked.gather.v8i16.v8p0(<8 x ptr> %ptrs, i32 4, <8 x i1> %allones, <8 x i16> poison) ret <8 x i16> %v } + +; v32i64 is not a legal type, so make sure we don't try to combine the mgather +; to a vlse intrinsic until it is legalized and split. +define <32 x i64> @mgather_strided_split(ptr %base) { +; RV32V-LABEL: mgather_strided_split: +; RV32V: # %bb.0: +; RV32V-NEXT:li a1, 16 +; RV32V-NEXT:vsetivli zero, 16, e64, m8, ta, ma +; RV32V-NEXT:vlse64.v v8, (a0), a1 +; RV32V-NEXT:addi a0, a0, 256 +; RV32V-NEXT:vlse64.v v16, (a0), a1 +; RV32V-NEXT:ret +; +; RV64V-LABEL: mgather_strided_split: +; RV64V: # %bb.0: +; RV64V-NEXT:li a1, 16 +; RV64V-NEXT:vsetivli zero, 16, e64, m8, ta, ma +; RV64V-NEXT:vlse64.v v8, (a0), a1 +; RV64V-NEXT:addi a0, a0, 256 +; RV64V-NEXT:vlse64.v v16, (a0), a1 +; RV64V-NEXT:ret +; +; RV32ZVE32F-LABEL: mgather_strided_split: +; RV32ZVE32F: # %bb.0: +; RV32ZVE32F-NEXT:addi sp, sp, -512 +; RV32ZVE32F-NEXT:.cfi_def_cfa_offset 512 +; RV32ZVE32F-NEXT:sw ra, 508(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s0, 504(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s2, 500(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s3, 496(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s4, 492(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s5, 488(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s6, 484(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s7, 480(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s8, 476(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s9, 472(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s10, 468(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:sw s11, 464(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:.cfi_offset ra, -4 +; RV32ZVE32F-NEXT:.cfi_offset s0, -8 +; RV32ZVE32F-NEXT:.cfi_offset s2, -12 +; RV32ZVE32F-NEXT:.cfi_offset s3, -16 +; RV32ZVE32F-NEXT:.cfi_offset s4, -20 +; RV32ZVE32F-NEXT:.cfi_offset s5, -24 +; RV32ZVE32F-NEXT:.cfi_offset s6, -28 +; RV32ZVE32F-NEXT:.cfi_offset s7, -32 +; RV32ZVE32F-NEXT:.cfi_offset s8, -36 +; RV32ZVE32F-NEXT:.cfi_offset s9, -40 +; RV32ZVE32F-NEXT:.cfi_offset s10, -44 +; RV32ZVE32F-NEXT:.cfi_offset s11, -48 +; RV32ZVE32F-NEXT:addi s0, sp, 512 +; RV32ZVE32F-NEXT:.cfi_def_cfa s0, 0 +; RV32ZVE32F-NEXT:andi sp, sp, -128 +; RV32ZVE32F-NEXT:li a2, 32 +; RV32ZVE32F-NEXT:vsetvli zero, a2, e32, m8, ta, ma +; RV32ZVE32F-NEXT:vid.v v8 +; RV32ZVE32F-NEXT:vsll.vi v8, v8, 4 +; RV32ZVE32F-NEXT:vadd.vx v8, v8, a1 +; RV32ZVE32F-NEXT:vmv.x.s a1, v8 +; RV32ZVE32F-NEXT:lw a3, 0(a1) +; RV32ZVE32F-NEXT:sw a3, 216(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:lw a1, 4(a1) +; RV32ZVE32F-NEXT:sw a1, 208(sp) # 4-byte Folded Spill +; RV32ZVE32F-NEXT:vsetivli zero, 1, e32, m1, ta, ma +; RV32ZVE32F-NEXT:
[llvm-branch-commits] [llvm] release/18.x: [RISCV] Check type is legal before combining mgather to vlse intrinsic (#81107) (PR #81568)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/81568 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] release/18.x: [AArch64] Backport Ampere1B support (#81297 , #81341, and #81744) (PR #81857)
tstellar wrote: Is this ready to merge? https://github.com/llvm/llvm-project/pull/81857 ___ 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] [lldb] f350b6a - Revert "[lldb] Migrate distutils.version.LooseVersion to packaging (#82066)"
Author: Jonas Devlieghere Date: 2024-02-19T17:45:45-08:00 New Revision: f350b6a9b674f06a9f51048f0de10161813805a2 URL: https://github.com/llvm/llvm-project/commit/f350b6a9b674f06a9f51048f0de10161813805a2 DIFF: https://github.com/llvm/llvm-project/commit/f350b6a9b674f06a9f51048f0de10161813805a2.diff LOG: Revert "[lldb] Migrate distutils.version.LooseVersion to packaging (#82066)" This reverts commit 13dce35876acdd35269f7d64c187c1d831bbf980. Added: Modified: lldb/packages/Python/lldbsuite/test/decorators.py lldb/packages/Python/lldbsuite/test/lldbplatformutil.py lldb/test/API/sanity/TestSettingSkipping.py lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py lldb/test/Shell/helper/build.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b691f82b90652c..a5d7a7a25879df 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1,6 +1,6 @@ # System modules +from distutils.version import LooseVersion from functools import wraps -from pkg_resources import packaging import ctypes import locale import os @@ -65,10 +65,10 @@ def fn_neq(x, y): ">=": fn_geq, "<=": fn_leq, } +expected_str = ".".join([str(x) for x in expected]) +actual_str = ".".join([str(x) for x in actual]) -return op_lookup[comparison]( -packaging.version.parse(actual), packaging.version.parse(expected) -) +return op_lookup[comparison](LooseVersion(actual_str), LooseVersion(expected_str)) def _match_decorator_property(expected, actual): @@ -238,9 +238,7 @@ def fn(actual_debug_info=None): ) ) skip_for_py_version = (py_version is None) or _check_expected_version( -py_version[0], -py_version[1], -"{}.{}".format(sys.version_info.major, sys.version_info.minor), +py_version[0], py_version[1], sys.version_info ) skip_for_macos_version = (macos_version is None) or ( (platform.mac_ver()[0] != "") diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index a118aa61a6287d..bd92d03e0e2212 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -7,8 +7,8 @@ import subprocess import sys import os +from distutils.version import LooseVersion from urllib.parse import urlparse -from pkg_resources import packaging # LLDB modules import lldb @@ -297,30 +297,27 @@ def expectedCompilerVersion(compiler_version): if compiler_version is None: return True operator = str(compiler_version[0]) -version_str = str(compiler_version[1]) +version = compiler_version[1] -if not version_str: +if version is None: return True -test_compiler_version_str = getCompilerVersion() -if test_compiler_version_str == "unknown": +test_compiler_version = getCompilerVersion() +if test_compiler_version == "unknown": # Assume the compiler version is at or near the top of trunk. return operator in [">", ">=", "!", "!=", "not"] -version = packaging.version.parse(version_str) -test_compiler_version = packaging.version.parse(test_compiler_version_str) - if operator == ">": -return test_compiler_version < version +return LooseVersion(test_compiler_version) > LooseVersion(version) if operator == ">=" or operator == "=>": -return test_compiler_version >= version +return LooseVersion(test_compiler_version) >= LooseVersion(version) if operator == "<": -return test_compiler_version < version +return LooseVersion(test_compiler_version) < LooseVersion(version) if operator == "<=" or operator == "=<": -return test_compiler_version <= version +return LooseVersion(test_compiler_version) <= LooseVersion(version) if operator == "!=" or operator == "!" or operator == "not": -return version_str not in test_compiler_version_str -return version_str in test_compiler_version_str +return str(version) not in str(test_compiler_version) +return str(version) in str(test_compiler_version) def expectedCompiler(compilers): diff --git a/lldb/test/API/sanity/TestSettingSkipping.py b/lldb/test/API/sanity/TestSettingSkipping.py index f0d4d266073e03..5f58ec2638456d 100644 --- a/lldb/test/API/sanity/TestSettingSkipping.py +++ b/lldb/test/API/sanity/TestSettingSkipping.py @@ -1,7 +1,8 @@ """ -This is a sanity check that verifies that test can be skipped based on settings. +This is a sanity check that verifies that test can be sklipped based on settings. """ + import lldb from lldbsuite.test.lldbtest import * from lldbsu
[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Mask constant operands in ValueBit tracking (#67653) (PR #82301)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/82301 Backport 292d9e869fc Requested by: @ecnelises >From 64dd69d0c652c3017c918b1b16abbb10cebdae66 Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Tue, 6 Feb 2024 18:37:31 +0800 Subject: [PATCH] [PowerPC] Mask constant operands in ValueBit tracking (#67653) In IR or C code, shift amount larger than value size is undefined behavior. But in practice, backend lowering for shift_parts produces add/sub of shift amounts, thus constant shift amounts might be negative or larger than value size, which depends on ISA definition. PowerPC ISA says, the lowest 7 bits (6 bits for 32-bit instruction) will be taken, and if the highest among them is 1, result will be zero, otherwise the low 6 bits (or 5 on 32-bit) are used as shift amount. This commit emulates the behavior and avoids array overflow in bit permutation's value bits calculator. (cherry picked from commit 292d9e869fcfc2ece694848db4022b0b939847e3) --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 37 -- llvm/test/CodeGen/PowerPC/pr59074.ll| 132 2 files changed, 156 insertions(+), 13 deletions(-) create mode 100644 llvm/test/CodeGen/PowerPC/pr59074.ll diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 26ed74108ec36c..18a4223d481ef0 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -1635,7 +1635,8 @@ class BitPermutationSelector { default: break; case ISD::ROTL: if (isa(V.getOperand(1))) { -unsigned RotAmt = V.getConstantOperandVal(1); +assert(isPowerOf2_32(NumBits) && "rotl bits should be power of 2!"); +unsigned RotAmt = V.getConstantOperandVal(1) & (NumBits - 1); const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second; @@ -1648,15 +1649,20 @@ class BitPermutationSelector { case ISD::SHL: case PPCISD::SHL: if (isa(V.getOperand(1))) { -unsigned ShiftAmt = V.getConstantOperandVal(1); +// sld takes 7 bits, slw takes 6. +unsigned ShiftAmt = V.getConstantOperandVal(1) & ((NumBits << 1) - 1); const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second; -for (unsigned i = ShiftAmt; i < NumBits; ++i) - Bits[i] = LHSBits[i - ShiftAmt]; - -for (unsigned i = 0; i < ShiftAmt; ++i) - Bits[i] = ValueBit(ValueBit::ConstZero); +if (ShiftAmt >= NumBits) { + for (unsigned i = 0; i < NumBits; ++i) +Bits[i] = ValueBit(ValueBit::ConstZero); +} else { + for (unsigned i = ShiftAmt; i < NumBits; ++i) +Bits[i] = LHSBits[i - ShiftAmt]; + for (unsigned i = 0; i < ShiftAmt; ++i) +Bits[i] = ValueBit(ValueBit::ConstZero); +} return std::make_pair(Interesting = true, &Bits); } @@ -1664,15 +1670,20 @@ class BitPermutationSelector { case ISD::SRL: case PPCISD::SRL: if (isa(V.getOperand(1))) { -unsigned ShiftAmt = V.getConstantOperandVal(1); +// srd takes lowest 7 bits, srw takes 6. +unsigned ShiftAmt = V.getConstantOperandVal(1) & ((NumBits << 1) - 1); const auto &LHSBits = *getValueBits(V.getOperand(0), NumBits).second; -for (unsigned i = 0; i < NumBits - ShiftAmt; ++i) - Bits[i] = LHSBits[i + ShiftAmt]; - -for (unsigned i = NumBits - ShiftAmt; i < NumBits; ++i) - Bits[i] = ValueBit(ValueBit::ConstZero); +if (ShiftAmt >= NumBits) { + for (unsigned i = 0; i < NumBits; ++i) +Bits[i] = ValueBit(ValueBit::ConstZero); +} else { + for (unsigned i = 0; i < NumBits - ShiftAmt; ++i) +Bits[i] = LHSBits[i + ShiftAmt]; + for (unsigned i = NumBits - ShiftAmt; i < NumBits; ++i) +Bits[i] = ValueBit(ValueBit::ConstZero); +} return std::make_pair(Interesting = true, &Bits); } diff --git a/llvm/test/CodeGen/PowerPC/pr59074.ll b/llvm/test/CodeGen/PowerPC/pr59074.ll new file mode 100644 index 00..3e328c6ad9f0ba --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/pr59074.ll @@ -0,0 +1,132 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s --check-prefix=LE64 +; RUN: llc -mtriple=powerpcle-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s --check-prefix=LE32 +; RUN: llc -mtriple=powerpc64-ibm-aix -mcpu=pwr7 < %s | FileCheck %s --check-prefix=BE64 +; RUN: llc -mtriple=powerpc-ibm-aix -mcpu=pwr7 < %s | FileCheck %s --check-prefix=BE32 + +; To verify this doesn't crash due to array out of bound. +define void @pr59074(ptr %0) { +; LE64-LABEL: pr59074: +; LE64: # %bb.0: # %entry +; LE64-NEXT:lwz 6, 0(3) +; LE64-NEXT:li 7, 12 +; LE64-NEXT:ld 4, 16(3) +; LE64-NEXT:ld 5, 24(3) +; LE64-
[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Mask constant operands in ValueBit tracking (#67653) (PR #82301)
llvmbot wrote: @bzEq What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/82301 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Mask constant operands in ValueBit tracking (#67653) (PR #82301)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/82301 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [PowerPC] Mask constant operands in ValueBit tracking (#67653) (PR #82301)
https://github.com/bzEq approved this pull request. LG. https://github.com/llvm/llvm-project/pull/82301 ___ 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: [Serialization] Record whether the ODR is skipped (#82302) (PR #82309)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/82309 ___ 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: [Serialization] Record whether the ODR is skipped (#82302) (PR #82309)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/82309 Backport 49775b1 Requested by: @marwing >From 94bfde4bcec2b4c2529f0586d951b5a0d7b3a25b Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Tue, 20 Feb 2024 13:31:28 +0800 Subject: [PATCH] [Serialization] Record whether the ODR is skipped (#82302) Close https://github.com/llvm/llvm-project/issues/80570. In https://github.com/llvm/llvm-project/commit/a0b6747804e46665ecfd00295b60432bfe1775b6, we skipped ODR checks for decls in GMF. Then it should be natural to skip storing the ODR values in BMI. Generally it should be fine as long as the writer and the reader keep consistent. However, the use of preamble in clangd shows the tricky part. For, ``` // test.cpp module; // any one off these is enough to crash clangd // #include // #include // #include // #include // #include // #include // probably many more // only ok with libc++, not the system provided libstdc++ 13.2.1 // these are ok export module test; ``` clangd will store the headers as preamble to speedup the parsing and the preamble reuses the serialization techniques. (Generally we'd call the preamble as PCH. However it is not true strictly. I've tested the PCH wouldn't be problematic.) However, the tricky part is that the preamble is not modules. It literally serialiaze and deserialize things. So before clangd parsing the above test module, clangd will serialize the headers into the preamble. Note that there is no concept like GMF now. So the ODR bits are stored. However, when clangd parse the file actually, the decls from preamble are thought as in GMF literally, then hte ODR bits are skipped. Then mismatch happens. To solve the problem, this patch adds another bit for decls to record whether or not the ODR bits are skipped. (cherry picked from commit 49775b1dc0cdb3a9d18811f67f268e3b3a381669) --- clang/lib/Serialization/ASTReaderDecl.cpp | 10 +- clang/lib/Serialization/ASTWriter.cpp | 6 +- clang/lib/Serialization/ASTWriterDecl.cpp | 15 +- clang/unittests/Serialization/CMakeLists.txt | 1 + .../PreambleInNamedModulesTest.cpp| 132 ++ 5 files changed, 154 insertions(+), 10 deletions(-) create mode 100644 clang/unittests/Serialization/PreambleInNamedModulesTest.cpp diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 1fadd8039462d4..321c11e55c14e3 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -800,11 +800,12 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { BitsUnpacker EnumDeclBits(Record.readInt()); ED->setNumPositiveBits(EnumDeclBits.getNextBits(/*Width=*/8)); ED->setNumNegativeBits(EnumDeclBits.getNextBits(/*Width=*/8)); + bool ShouldSkipCheckingODR = EnumDeclBits.getNextBit(); ED->setScoped(EnumDeclBits.getNextBit()); ED->setScopedUsingClassTag(EnumDeclBits.getNextBit()); ED->setFixed(EnumDeclBits.getNextBit()); - if (!shouldSkipCheckingODR(ED)) { + if (!ShouldSkipCheckingODR) { ED->setHasODRHash(true); ED->ODRHash = Record.readInt(); } @@ -1073,6 +1074,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FD->setCachedLinkage((Linkage)FunctionDeclBits.getNextBits(/*Width=*/3)); FD->setStorageClass((StorageClass)FunctionDeclBits.getNextBits(/*Width=*/3)); + bool ShouldSkipCheckingODR = FunctionDeclBits.getNextBit(); FD->setInlineSpecified(FunctionDeclBits.getNextBit()); FD->setImplicitlyInline(FunctionDeclBits.getNextBit()); FD->setHasSkippedBody(FunctionDeclBits.getNextBit()); @@ -1102,7 +1104,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { if (FD->isExplicitlyDefaulted()) FD->setDefaultLoc(readSourceLocation()); - if (!shouldSkipCheckingODR(FD)) { + if (!ShouldSkipCheckingODR) { FD->ODRHash = Record.readInt(); FD->setHasODRHash(true); } @@ -1973,6 +1975,8 @@ void ASTDeclReader::ReadCXXDefinitionData( BitsUnpacker CXXRecordDeclBits = Record.readInt(); + bool ShouldSkipCheckingODR = CXXRecordDeclBits.getNextBit(); + #define FIELD(Name, Width, Merge) \ if (!CXXRecordDeclBits.canGetNextNBits(Width)) \ CXXRecordDeclBits.updateValue(Record.readInt()); \ @@ -1982,7 +1986,7 @@ void ASTDeclReader::ReadCXXDefinitionData( #undef FIELD // We only perform ODR checks for decls not in GMF. - if (!shouldSkipCheckingODR(D)) { + if (!ShouldSkipCheckingODR) { // Note: the caller has deserialized the IsLambda bit already. Data.ODRHash = Record.readInt(); Data.HasODRHash = true; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 3b79a9238d1af3..73018c1170d8f2 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -6010,6 +6010,9 @@ void ASTRecordWriter::AddCXXDefinitionDat
[llvm-branch-commits] [clang] release/18.x: [Serialization] Record whether the ODR is skipped (#82302) (PR #82309)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (llvmbot) Changes Backport 49775b1 Requested by: @marwing --- Full diff: https://github.com/llvm/llvm-project/pull/82309.diff 5 Files Affected: - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+7-3) - (modified) clang/lib/Serialization/ASTWriter.cpp (+4-2) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+10-5) - (modified) clang/unittests/Serialization/CMakeLists.txt (+1) - (added) clang/unittests/Serialization/PreambleInNamedModulesTest.cpp (+132) ``diff diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 1fadd8039462d4..321c11e55c14e3 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -800,11 +800,12 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { BitsUnpacker EnumDeclBits(Record.readInt()); ED->setNumPositiveBits(EnumDeclBits.getNextBits(/*Width=*/8)); ED->setNumNegativeBits(EnumDeclBits.getNextBits(/*Width=*/8)); + bool ShouldSkipCheckingODR = EnumDeclBits.getNextBit(); ED->setScoped(EnumDeclBits.getNextBit()); ED->setScopedUsingClassTag(EnumDeclBits.getNextBit()); ED->setFixed(EnumDeclBits.getNextBit()); - if (!shouldSkipCheckingODR(ED)) { + if (!ShouldSkipCheckingODR) { ED->setHasODRHash(true); ED->ODRHash = Record.readInt(); } @@ -1073,6 +1074,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { FD->setCachedLinkage((Linkage)FunctionDeclBits.getNextBits(/*Width=*/3)); FD->setStorageClass((StorageClass)FunctionDeclBits.getNextBits(/*Width=*/3)); + bool ShouldSkipCheckingODR = FunctionDeclBits.getNextBit(); FD->setInlineSpecified(FunctionDeclBits.getNextBit()); FD->setImplicitlyInline(FunctionDeclBits.getNextBit()); FD->setHasSkippedBody(FunctionDeclBits.getNextBit()); @@ -1102,7 +1104,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { if (FD->isExplicitlyDefaulted()) FD->setDefaultLoc(readSourceLocation()); - if (!shouldSkipCheckingODR(FD)) { + if (!ShouldSkipCheckingODR) { FD->ODRHash = Record.readInt(); FD->setHasODRHash(true); } @@ -1973,6 +1975,8 @@ void ASTDeclReader::ReadCXXDefinitionData( BitsUnpacker CXXRecordDeclBits = Record.readInt(); + bool ShouldSkipCheckingODR = CXXRecordDeclBits.getNextBit(); + #define FIELD(Name, Width, Merge) \ if (!CXXRecordDeclBits.canGetNextNBits(Width)) \ CXXRecordDeclBits.updateValue(Record.readInt()); \ @@ -1982,7 +1986,7 @@ void ASTDeclReader::ReadCXXDefinitionData( #undef FIELD // We only perform ODR checks for decls not in GMF. - if (!shouldSkipCheckingODR(D)) { + if (!ShouldSkipCheckingODR) { // Note: the caller has deserialized the IsLambda bit already. Data.ODRHash = Record.readInt(); Data.HasODRHash = true; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 3b79a9238d1af3..73018c1170d8f2 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -6010,6 +6010,9 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) { BitsPacker DefinitionBits; + bool ShouldSkipCheckingODR = shouldSkipCheckingODR(D); + DefinitionBits.addBit(ShouldSkipCheckingODR); + #define FIELD(Name, Width, Merge) \ if (!DefinitionBits.canWriteNextNBits(Width)) { \ Record->push_back(DefinitionBits); \ @@ -6023,11 +6026,10 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) { Record->push_back(DefinitionBits); // We only perform ODR checks for decls not in GMF. - if (!shouldSkipCheckingODR(D)) { + if (!ShouldSkipCheckingODR) // getODRHash will compute the ODRHash if it has not been previously // computed. Record->push_back(D->getODRHash()); - } bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType(); diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index f224075643e998..e73800100e3ccf 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -488,13 +488,15 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) { BitsPacker EnumDeclBits; EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8); EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8); + bool ShouldSkipCheckingODR = shouldSkipCheckingODR(D); + EnumDeclBits.addBit(ShouldSkipCheckingODR); EnumDeclBits.addBit(D->isScoped()); EnumDeclBits.addBit(D->isScopedUsingClassTag()); EnumDeclBits.addBit(D->isFixed()); Record.push_back(EnumDeclBits); // We only perform ODR checks for decls not in GMF. - if (!shouldSkipCheckingODR(D)) +
[llvm-branch-commits] [clang] release/18.x: [Serialization] Record whether the ODR is skipped (#82302) (PR #82309)
ChuanqiXu9 wrote: Although we announced that the support for C++20 modules in clangd is broken, there are already a lot of people tried to use clangd with modules in some level. So it should be helpful to backport this to clang18 as well to improve the user experience as much as possible. https://github.com/llvm/llvm-project/pull/82309 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits