[llvm-branch-commits] [llvm] release/18.x: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/82470 Backport bf471c915d14035a24ec027fb2bb0373cefdabe1 Requested by: @uweigand >From ca0cf5f87c810595ae969670c3209a77adf1099b Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 16 Feb 2024 12:11:04 +0100 Subject: [PATCH] [docs][llvm-objcopy] Add missing formats (#81981) Bring list of supported formats in docs back in sync with the code. (cherry picked from commit bf471c915d14035a24ec027fb2bb0373cefdabe1) --- llvm/docs/CommandGuide/llvm-objcopy.rst | 4 1 file changed, 4 insertions(+) diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst b/llvm/docs/CommandGuide/llvm-objcopy.rst index 6e13cd94b92fda..01a96f2f4f770e 100644 --- a/llvm/docs/CommandGuide/llvm-objcopy.rst +++ b/llvm/docs/CommandGuide/llvm-objcopy.rst @@ -538,6 +538,10 @@ options. For GNU :program:`objcopy` compatibility, the values are all bfdnames. - `elf64-tradlittlemips` - `elf32-sparc` - `elf32-sparcel` +- `elf32-hexagon` +- `elf32-loongarch` +- `elf64-loongarch` +- `elf64-s390` Additionally, all targets except `binary` and `ihex` can have `-freebsd` as a suffix. ___ 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: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/82470 ___ 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: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)
llvmbot wrote: @jh7370 What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/82470 ___ 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: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)
llvmbot wrote: @llvm/pr-subscribers-llvm-binary-utilities Author: None (llvmbot) Changes Backport bf471c915d14035a24ec027fb2bb0373cefdabe1 Requested by: @uweigand --- Full diff: https://github.com/llvm/llvm-project/pull/82470.diff 1 Files Affected: - (modified) llvm/docs/CommandGuide/llvm-objcopy.rst (+4) ``diff diff --git a/llvm/docs/CommandGuide/llvm-objcopy.rst b/llvm/docs/CommandGuide/llvm-objcopy.rst index 6e13cd94b92fda..01a96f2f4f770e 100644 --- a/llvm/docs/CommandGuide/llvm-objcopy.rst +++ b/llvm/docs/CommandGuide/llvm-objcopy.rst @@ -538,6 +538,10 @@ options. For GNU :program:`objcopy` compatibility, the values are all bfdnames. - `elf64-tradlittlemips` - `elf32-sparc` - `elf32-sparcel` +- `elf32-hexagon` +- `elf32-loongarch` +- `elf64-loongarch` +- `elf64-s390` Additionally, all targets except `binary` and `ihex` can have `-freebsd` as a suffix. `` https://github.com/llvm/llvm-project/pull/82470 ___ 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: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)
uweigand wrote: > > Also, as noted in the original PR, the corresponding doc change needs > > picking too. > > I'll add a cherry-pick for the doc PR if and when this PR is approved. https://github.com/llvm/llvm-project/pull/82470 https://github.com/llvm/llvm-project/pull/82324 ___ 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] [RISCV] Support select optimization (PR #80124)
wangpc-pp wrote: Gentle ping. https://github.com/llvm/llvm-project/pull/80124 ___ 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: [docs][llvm-objcopy] Add missing formats (#81981) (PR #82470)
https://github.com/jh7370 approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/82470 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/82474 The dialect conversion rolls back in-place op modifications upon failure. Rolling back modifications of attributes is already supported, but there was no support for properties until now. >From 7be59f67152a684a572c45109e8288304cc4833a Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 21 Feb 2024 08:41:44 + Subject: [PATCH] [mlir][Transforms] Support rolling back properties in dialect conversion The dialect conversion rolls back inplace op modifications upon failure. Rolling back modifications of op properties was not supported before this commit. --- .../Transforms/Utils/DialectConversion.cpp| 28 ++- mlir/test/Transforms/test-legalizer.mlir | 12 mlir/test/lib/Dialect/Test/TestPatterns.cpp | 18 +++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 673bd0383809cb..495e9d8df19d0a 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + int size = op->getPropertiesStorageSize(); + propertiesStorage = operator new(size); + memcpy(propertiesStorage, prop.as(), size); +} + } static bool classof(const IRRewrite *rewrite) { return rewrite->getKind() == Kind::ModifyOperation; } + ~ModifyOperationRewrite() override { +assert(!propertiesStorage && + "rewrite was neither committed nor rolled back"); + } + + void commit() override { +if (propertiesStorage) { + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} + } + /// Discard the transaction state and reset the state of the original /// operation. void rollback() override { @@ -1016,6 +1035,12 @@ class ModifyOperationRewrite : public OperationRewrite { op->setOperands(operands); for (const auto &it : llvm::enumerate(successors)) op->setSuccessor(it.value(), it.index()); +if (propertiesStorage) { + OpaqueProperties prop(propertiesStorage); + op->copyProperties(prop); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} } private: @@ -1023,6 +1048,7 @@ class ModifyOperationRewrite : public OperationRewrite { DictionaryAttr attrs; SmallVector operands; SmallVector successors; + void *propertiesStorage = nullptr; }; } // namespace diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir index 84fcc18ab7d370..62d776cd7573ee 100644 --- a/mlir/test/Transforms/test-legalizer.mlir +++ b/mlir/test/Transforms/test-legalizer.mlir @@ -334,3 +334,15 @@ func.func @test_move_op_before_rollback() { }) : () -> () "test.return"() : () -> () } + +// - + +// CHECK-LABEL: func @test_properties_rollback() +func.func @test_properties_rollback() { + // CHECK: test.with_properties <{a = 32 : i64, + // expected-remark @below{{op 'test.with_properties' is not legalizable}} + test.with_properties + <{a = 32 : i64, array = array, b = "foo"}> + {modify_inplace} + "test.return"() : () -> () +} diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 1c02232b8adbb1..57e846294f8b9f 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -806,6 +806,21 @@ struct TestUndoBlockErase : public ConversionPattern { } }; +/// A pattern that modifies a property in-place, but keeps the op illegal. +struct TestUndoPropertiesModification : public ConversionPattern { + TestUndoPropertiesModification(MLIRContext *ctx) + : ConversionPattern("test.with_properties", /*benefit=*/1, ctx) {} + LogicalResult + matchAndRewrite(Operation *op, ArrayRef operands, + ConversionPatternRewriter &rewriter) const final { +if (!op->hasAttr("modify_inplace")) + return failure(); +rewriter.modifyOpInPlace( +op, [&]() { cast(op).getProperties().setA(42); }); +return success(); + } +}; + //===--===// // Type-Conversion Rewrite Testing @@ -1085,7 +1100,8 @@ struct TestLegalizePatternDriver TestChangeProducerTypeF32ToInvalid, TestUpdateConsumerType, TestNonRootReplacement, TestBoundedRecursiveRewrit
[llvm-branch-commits] [mlir] [mlir][Transforms] Support rolling back properties in dialect conversion (PR #82474)
llvmbot wrote: @llvm/pr-subscribers-mlir-core Author: Matthias Springer (matthias-springer) Changes The dialect conversion rolls back in-place op modifications upon failure. Rolling back modifications of attributes is already supported, but there was no support for properties until now. --- Full diff: https://github.com/llvm/llvm-project/pull/82474.diff 3 Files Affected: - (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+27-1) - (modified) mlir/test/Transforms/test-legalizer.mlir (+12) - (modified) mlir/test/lib/Dialect/Test/TestPatterns.cpp (+17-1) ``diff diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 673bd0383809cb..495e9d8df19d0a 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + int size = op->getPropertiesStorageSize(); + propertiesStorage = operator new(size); + memcpy(propertiesStorage, prop.as(), size); +} + } static bool classof(const IRRewrite *rewrite) { return rewrite->getKind() == Kind::ModifyOperation; } + ~ModifyOperationRewrite() override { +assert(!propertiesStorage && + "rewrite was neither committed nor rolled back"); + } + + void commit() override { +if (propertiesStorage) { + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} + } + /// Discard the transaction state and reset the state of the original /// operation. void rollback() override { @@ -1016,6 +1035,12 @@ class ModifyOperationRewrite : public OperationRewrite { op->setOperands(operands); for (const auto &it : llvm::enumerate(successors)) op->setSuccessor(it.value(), it.index()); +if (propertiesStorage) { + OpaqueProperties prop(propertiesStorage); + op->copyProperties(prop); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} } private: @@ -1023,6 +1048,7 @@ class ModifyOperationRewrite : public OperationRewrite { DictionaryAttr attrs; SmallVector operands; SmallVector successors; + void *propertiesStorage = nullptr; }; } // namespace diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir index 84fcc18ab7d370..62d776cd7573ee 100644 --- a/mlir/test/Transforms/test-legalizer.mlir +++ b/mlir/test/Transforms/test-legalizer.mlir @@ -334,3 +334,15 @@ func.func @test_move_op_before_rollback() { }) : () -> () "test.return"() : () -> () } + +// - + +// CHECK-LABEL: func @test_properties_rollback() +func.func @test_properties_rollback() { + // CHECK: test.with_properties <{a = 32 : i64, + // expected-remark @below{{op 'test.with_properties' is not legalizable}} + test.with_properties + <{a = 32 : i64, array = array, b = "foo"}> + {modify_inplace} + "test.return"() : () -> () +} diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 1c02232b8adbb1..57e846294f8b9f 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -806,6 +806,21 @@ struct TestUndoBlockErase : public ConversionPattern { } }; +/// A pattern that modifies a property in-place, but keeps the op illegal. +struct TestUndoPropertiesModification : public ConversionPattern { + TestUndoPropertiesModification(MLIRContext *ctx) + : ConversionPattern("test.with_properties", /*benefit=*/1, ctx) {} + LogicalResult + matchAndRewrite(Operation *op, ArrayRef operands, + ConversionPatternRewriter &rewriter) const final { +if (!op->hasAttr("modify_inplace")) + return failure(); +rewriter.modifyOpInPlace( +op, [&]() { cast(op).getProperties().setA(42); }); +return success(); + } +}; + //===--===// // Type-Conversion Rewrite Testing @@ -1085,7 +1100,8 @@ struct TestLegalizePatternDriver TestChangeProducerTypeF32ToInvalid, TestUpdateConsumerType, TestNonRootReplacement, TestBoundedRecursiveRewrite, TestNestedOpCreationUndoRewrite, TestReplaceEraseOp, - TestCreateUnregisteredOp, TestUndoMoveOpBefore>(&getContext()); + TestCreateUnregisteredOp, TestUndoMoveOpBefore, + TestUndoPropertiesModification>(&getContext()); patterns.add(&getContext(), converter);
[llvm-branch-commits] [llvm] [RISCV] Support select optimization (PR #80124)
https://github.com/dtcxzyw requested changes to this pull request. https://github.com/llvm/llvm-project/pull/80124 ___ 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] [RISCV] Support select optimization (PR #80124)
@@ -451,6 +456,9 @@ void RISCVPassConfig::addIRPasses() { } TargetPassConfig::addIRPasses(); + + if (getOptLevel() == CodeGenOptLevel::Aggressive && EnableSelectOpt) dtcxzyw wrote: > Failed Tests (1): LLVM :: CodeGen/RISCV/O3-pipeline.ll Please update the test. https://github.com/llvm/llvm-project/pull/80124 ___ 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] [RISCV] Support select optimization (PR #80124)
https://github.com/dtcxzyw edited https://github.com/llvm/llvm-project/pull/80124 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
@@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + int size = op->getPropertiesStorageSize(); + propertiesStorage = operator new(size); + memcpy(propertiesStorage, prop.as(), size); joker-eph wrote: That does not seem correct C++ to me: you can't assume that a property can be copied as a "POD" (I don't remember the new terminology). Properties can be arbitrary C++ objects (think std::string for example). https://github.com/llvm/llvm-project/pull/82474 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/82474 >From 33f2ae9da319110ca8d2581ec6d66d2db83201cb Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 21 Feb 2024 08:41:44 + Subject: [PATCH] [mlir][Transforms] Support rolling back properties in dialect conversion The dialect conversion rolls back inplace op modifications upon failure. Rolling back modifications of op properties was not supported before this commit. --- .../Transforms/Utils/DialectConversion.cpp| 28 ++- mlir/test/Transforms/test-legalizer.mlir | 12 mlir/test/lib/Dialect/Test/TestPatterns.cpp | 18 +++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 673bd0383809cb..5be3e6b90b5d08 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + propertiesStorage = operator new(op->getPropertiesStorageSize()); + OpaqueProperties propCopy(propertiesStorage); + op->getName().copyOpProperties(propCopy, prop); +} + } static bool classof(const IRRewrite *rewrite) { return rewrite->getKind() == Kind::ModifyOperation; } + ~ModifyOperationRewrite() override { +assert(!propertiesStorage && + "rewrite was neither committed nor rolled back"); + } + + void commit() override { +if (propertiesStorage) { + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} + } + /// Discard the transaction state and reset the state of the original /// operation. void rollback() override { @@ -1016,6 +1035,12 @@ class ModifyOperationRewrite : public OperationRewrite { op->setOperands(operands); for (const auto &it : llvm::enumerate(successors)) op->setSuccessor(it.value(), it.index()); +if (propertiesStorage) { + OpaqueProperties prop(propertiesStorage); + op->copyProperties(prop); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} } private: @@ -1023,6 +1048,7 @@ class ModifyOperationRewrite : public OperationRewrite { DictionaryAttr attrs; SmallVector operands; SmallVector successors; + void *propertiesStorage = nullptr; }; } // namespace diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir index 84fcc18ab7d370..62d776cd7573ee 100644 --- a/mlir/test/Transforms/test-legalizer.mlir +++ b/mlir/test/Transforms/test-legalizer.mlir @@ -334,3 +334,15 @@ func.func @test_move_op_before_rollback() { }) : () -> () "test.return"() : () -> () } + +// - + +// CHECK-LABEL: func @test_properties_rollback() +func.func @test_properties_rollback() { + // CHECK: test.with_properties <{a = 32 : i64, + // expected-remark @below{{op 'test.with_properties' is not legalizable}} + test.with_properties + <{a = 32 : i64, array = array, b = "foo"}> + {modify_inplace} + "test.return"() : () -> () +} diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 1c02232b8adbb1..57e846294f8b9f 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -806,6 +806,21 @@ struct TestUndoBlockErase : public ConversionPattern { } }; +/// A pattern that modifies a property in-place, but keeps the op illegal. +struct TestUndoPropertiesModification : public ConversionPattern { + TestUndoPropertiesModification(MLIRContext *ctx) + : ConversionPattern("test.with_properties", /*benefit=*/1, ctx) {} + LogicalResult + matchAndRewrite(Operation *op, ArrayRef operands, + ConversionPatternRewriter &rewriter) const final { +if (!op->hasAttr("modify_inplace")) + return failure(); +rewriter.modifyOpInPlace( +op, [&]() { cast(op).getProperties().setA(42); }); +return success(); + } +}; + //===--===// // Type-Conversion Rewrite Testing @@ -1085,7 +1100,8 @@ struct TestLegalizePatternDriver TestChangeProducerTypeF32ToInvalid, TestUpdateConsumerType, TestNonRootReplacement, TestBoundedRecursiveRewrite, TestNestedOpCreationUndoRewrite, TestReplaceEraseOp, - TestCreateUnregisteredOp, TestUndoMoveOpBefore>(&getContext()); +
[llvm-branch-commits] [mlir] [mlir][Transforms] Support rolling back properties in dialect conversion (PR #82474)
@@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + int size = op->getPropertiesStorageSize(); + propertiesStorage = operator new(size); + memcpy(propertiesStorage, prop.as(), size); matthias-springer wrote: Changed to `copyOpProperties`. https://github.com/llvm/llvm-project/pull/82474 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
@@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + propertiesStorage = operator new(op->getPropertiesStorageSize()); + OpaqueProperties propCopy(propertiesStorage); + op->getName().copyOpProperties(propCopy, prop); +} + } static bool classof(const IRRewrite *rewrite) { return rewrite->getKind() == Kind::ModifyOperation; } + ~ModifyOperationRewrite() override { +assert(!propertiesStorage && + "rewrite was neither committed nor rolled back"); + } + + void commit() override { +if (propertiesStorage) { + operator delete(propertiesStorage); joker-eph wrote: This needs to call the property destructor https://github.com/llvm/llvm-project/pull/82474 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
@@ -1016,13 +1035,20 @@ class ModifyOperationRewrite : public OperationRewrite { op->setOperands(operands); for (const auto &it : llvm::enumerate(successors)) op->setSuccessor(it.value(), it.index()); +if (propertiesStorage) { + OpaqueProperties prop(propertiesStorage); + op->copyProperties(prop); + operator delete(propertiesStorage); joker-eph wrote: (Same) https://github.com/llvm/llvm-project/pull/82474 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
@@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + propertiesStorage = operator new(op->getPropertiesStorageSize()); + OpaqueProperties propCopy(propertiesStorage); + op->getName().copyOpProperties(propCopy, prop); joker-eph wrote: The constructor is never called I believe https://github.com/llvm/llvm-project/pull/82474 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/82474 ___ 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/joker-eph approved this pull request. 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] Support rolling back properties in dialect conversion (PR #82474)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/82474 >From f7a0cc4dd214b9f2b234ea5a61eaecdb19b6b3c4 Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 21 Feb 2024 09:37:48 + Subject: [PATCH] [mlir][Transforms] Support rolling back properties in dialect conversion The dialect conversion rolls back inplace op modifications upon failure. Rolling back modifications of op properties was not supported before this commit. --- .../Transforms/Utils/DialectConversion.cpp| 31 ++- mlir/test/Transforms/test-legalizer.mlir | 12 +++ mlir/test/lib/Dialect/Test/TestPatterns.cpp | 18 ++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 673bd0383809cb..37ecc694455e54 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1002,12 +1002,33 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + propertiesStorage = operator new(op->getPropertiesStorageSize()); + OpaqueProperties propCopy(propertiesStorage); + op->getName().initOpProperties(propCopy, /*init=*/prop); +} + } static bool classof(const IRRewrite *rewrite) { return rewrite->getKind() == Kind::ModifyOperation; } + ~ModifyOperationRewrite() override { +assert(!propertiesStorage && + "rewrite was neither committed nor rolled back"); + } + + void commit() override { +if (propertiesStorage) { + OpaqueProperties prop(propertiesStorage); + op->getName().destroyOpProperties(prop); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} + } + /// Discard the transaction state and reset the state of the original /// operation. void rollback() override { @@ -1016,6 +1037,13 @@ class ModifyOperationRewrite : public OperationRewrite { op->setOperands(operands); for (const auto &it : llvm::enumerate(successors)) op->setSuccessor(it.value(), it.index()); +if (propertiesStorage) { + OpaqueProperties prop(propertiesStorage); + op->copyProperties(prop); + op->getName().destroyOpProperties(prop); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} } private: @@ -1023,6 +1051,7 @@ class ModifyOperationRewrite : public OperationRewrite { DictionaryAttr attrs; SmallVector operands; SmallVector successors; + void *propertiesStorage = nullptr; }; } // namespace diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir index 84fcc18ab7d370..62d776cd7573ee 100644 --- a/mlir/test/Transforms/test-legalizer.mlir +++ b/mlir/test/Transforms/test-legalizer.mlir @@ -334,3 +334,15 @@ func.func @test_move_op_before_rollback() { }) : () -> () "test.return"() : () -> () } + +// - + +// CHECK-LABEL: func @test_properties_rollback() +func.func @test_properties_rollback() { + // CHECK: test.with_properties <{a = 32 : i64, + // expected-remark @below{{op 'test.with_properties' is not legalizable}} + test.with_properties + <{a = 32 : i64, array = array, b = "foo"}> + {modify_inplace} + "test.return"() : () -> () +} diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 1c02232b8adbb1..57e846294f8b9f 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -806,6 +806,21 @@ struct TestUndoBlockErase : public ConversionPattern { } }; +/// A pattern that modifies a property in-place, but keeps the op illegal. +struct TestUndoPropertiesModification : public ConversionPattern { + TestUndoPropertiesModification(MLIRContext *ctx) + : ConversionPattern("test.with_properties", /*benefit=*/1, ctx) {} + LogicalResult + matchAndRewrite(Operation *op, ArrayRef operands, + ConversionPatternRewriter &rewriter) const final { +if (!op->hasAttr("modify_inplace")) + return failure(); +rewriter.modifyOpInPlace( +op, [&]() { cast(op).getProperties().setA(42); }); +return success(); + } +}; + //===--===// // Type-Conversion Rewrite Testing @@ -1085,7 +1100,8 @@ struct TestLegalizePatternDriver TestChangeProducerTypeF32ToInvalid, TestUpdateConsumerType, TestNonRootReplacement, TestBoundedRecursiveRewrite,
[llvm-branch-commits] [mlir] [mlir][Transforms] Support rolling back properties in dialect conversion (PR #82474)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/82474 >From 1795b6dcfdc0b6447c5209000332432de49109cc Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 21 Feb 2024 09:37:48 + Subject: [PATCH] [mlir][Transforms] Support rolling back properties in dialect conversion The dialect conversion rolls back inplace op modifications upon failure. Rolling back modifications of op properties was not supported before this commit. --- .../Transforms/Utils/DialectConversion.cpp| 31 ++- mlir/test/Transforms/test-legalizer.mlir | 12 +++ mlir/test/lib/Dialect/Test/TestPatterns.cpp | 18 ++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 673bd0383809cb..75094a41012e8d 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1002,12 +1002,33 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + propertiesStorage = operator new(op->getPropertiesStorageSize()); + OpaqueProperties propCopy(propertiesStorage); + op->getName().initOpProperties(propCopy, /*init=*/prop); +} + } static bool classof(const IRRewrite *rewrite) { return rewrite->getKind() == Kind::ModifyOperation; } + ~ModifyOperationRewrite() override { +assert(!propertiesStorage && + "rewrite was neither committed nor rolled back"); + } + + void commit() override { +if (propertiesStorage) { + OpaqueProperties propCopy(propertiesStorage); + op->getName().destroyOpProperties(propCopy); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} + } + /// Discard the transaction state and reset the state of the original /// operation. void rollback() override { @@ -1016,6 +1037,13 @@ class ModifyOperationRewrite : public OperationRewrite { op->setOperands(operands); for (const auto &it : llvm::enumerate(successors)) op->setSuccessor(it.value(), it.index()); +if (propertiesStorage) { + OpaqueProperties propCopy(propertiesStorage); + op->copyProperties(propCopy); + op->getName().destroyOpProperties(propCopy); + operator delete(propertiesStorage); + propertiesStorage = nullptr; +} } private: @@ -1023,6 +1051,7 @@ class ModifyOperationRewrite : public OperationRewrite { DictionaryAttr attrs; SmallVector operands; SmallVector successors; + void *propertiesStorage = nullptr; }; } // namespace diff --git a/mlir/test/Transforms/test-legalizer.mlir b/mlir/test/Transforms/test-legalizer.mlir index 84fcc18ab7d370..62d776cd7573ee 100644 --- a/mlir/test/Transforms/test-legalizer.mlir +++ b/mlir/test/Transforms/test-legalizer.mlir @@ -334,3 +334,15 @@ func.func @test_move_op_before_rollback() { }) : () -> () "test.return"() : () -> () } + +// - + +// CHECK-LABEL: func @test_properties_rollback() +func.func @test_properties_rollback() { + // CHECK: test.with_properties <{a = 32 : i64, + // expected-remark @below{{op 'test.with_properties' is not legalizable}} + test.with_properties + <{a = 32 : i64, array = array, b = "foo"}> + {modify_inplace} + "test.return"() : () -> () +} diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp index 1c02232b8adbb1..57e846294f8b9f 100644 --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -806,6 +806,21 @@ struct TestUndoBlockErase : public ConversionPattern { } }; +/// A pattern that modifies a property in-place, but keeps the op illegal. +struct TestUndoPropertiesModification : public ConversionPattern { + TestUndoPropertiesModification(MLIRContext *ctx) + : ConversionPattern("test.with_properties", /*benefit=*/1, ctx) {} + LogicalResult + matchAndRewrite(Operation *op, ArrayRef operands, + ConversionPatternRewriter &rewriter) const final { +if (!op->hasAttr("modify_inplace")) + return failure(); +rewriter.modifyOpInPlace( +op, [&]() { cast(op).getProperties().setA(42); }); +return success(); + } +}; + //===--===// // Type-Conversion Rewrite Testing @@ -1085,7 +1100,8 @@ struct TestLegalizePatternDriver TestChangeProducerTypeF32ToInvalid, TestUpdateConsumerType, TestNonRootReplacement, TestBoundedR
[llvm-branch-commits] [mlir] [mlir][Transforms] Support rolling back properties in dialect conversion (PR #82474)
@@ -1002,12 +1002,31 @@ class ModifyOperationRewrite : public OperationRewrite { : OperationRewrite(Kind::ModifyOperation, rewriterImpl, op), loc(op->getLoc()), attrs(op->getAttrDictionary()), operands(op->operand_begin(), op->operand_end()), -successors(op->successor_begin(), op->successor_end()) {} +successors(op->successor_begin(), op->successor_end()) { +if (OpaqueProperties prop = op->getPropertiesStorage()) { + // Make a copy of the properties. + propertiesStorage = operator new(op->getPropertiesStorageSize()); + OpaqueProperties propCopy(propertiesStorage); + op->getName().copyOpProperties(propCopy, prop); matthias-springer wrote: Replaced `copyOpProperties` with `initProperties`, this is calling the copy constructor. https://github.com/llvm/llvm-project/pull/82474 ___ 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] Support rolling back properties in dialect conversion (PR #82474)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/82474 ___ 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] [RISCV] Support select optimization (PR #80124)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/80124 >From e3fb1fe7bdd4b7c24f9361c4d14dd1206fc8c067 Mon Sep 17 00:00:00 2001 From: wangpc Date: Sun, 18 Feb 2024 11:12:16 +0800 Subject: [PATCH 1/2] Move after addIRPasses Created using spr 1.3.4 --- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index fdf1c023fff878..7a26e1956424cb 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -450,15 +450,15 @@ void RISCVPassConfig::addIRPasses() { if (EnableLoopDataPrefetch) addPass(createLoopDataPrefetchPass()); -if (EnableSelectOpt && getOptLevel() == CodeGenOptLevel::Aggressive) - addPass(createSelectOptimizePass()); - addPass(createRISCVGatherScatterLoweringPass()); addPass(createInterleavedAccessPass()); addPass(createRISCVCodeGenPreparePass()); } TargetPassConfig::addIRPasses(); + + if (getOptLevel() == CodeGenOptLevel::Aggressive && EnableSelectOpt) +addPass(createSelectOptimizePass()); } bool RISCVPassConfig::addPreISel() { >From 5d5398596dc30c47c67572ec20137fb3f9434940 Mon Sep 17 00:00:00 2001 From: wangpc Date: Wed, 21 Feb 2024 21:21:28 +0800 Subject: [PATCH 2/2] Fix test Created using spr 1.3.4 --- llvm/test/CodeGen/RISCV/O3-pipeline.ll | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll index 62c1af52e6c20e..8b52e3fe7b2f15 100644 --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -34,15 +34,6 @@ ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Data Prefetch -; CHECK-NEXT: Post-Dominator Tree Construction -; CHECK-NEXT: Branch Probability Analysis -; CHECK-NEXT: Block Frequency Analysis -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis -; CHECK-NEXT: Optimization Remark Emitter -; CHECK-NEXT: Optimize selects -; CHECK-NEXT: Dominator Tree Construction -; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: RISC-V gather/scatter lowering ; CHECK-NEXT: Interleaved Access Pass ; CHECK-NEXT: RISC-V CodeGenPrepare @@ -77,6 +68,15 @@ ; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: TLS Variable Hoist +; CHECK-NEXT: Post-Dominator Tree Construction +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis +; CHECK-NEXT: Optimization Remark Emitter +; CHECK-NEXT: Optimize selects +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: CodeGen Prepare ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Exception handling preparation ___ 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/smithp35 commented: Thanks for the update, I'm happy with the changes. I would like to see more options for position independent code in embedded systems. The other related embedded position independent option for microcontrollers that I'm aware of is `-fropi` and `-frwpi` which is already implemented in clang. This is relocation free with just one static data area accessed as an offset from r9. It works quite well for C code, but doesn't support C++ (vtables and RTTI need relocations) and some forms of static initialisation. 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/smithp35 approved this pull request. Forgot to approve 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] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
https://github.com/chapuni edited https://github.com/llvm/llvm-project/pull/82448 ___ 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] Turn block type conversion into `IRRewrite` (PR #81756)
https://github.com/jpienaar approved this pull request. Nice, just small nits. Thanks https://github.com/llvm/llvm-project/pull/81756 ___ 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] Turn block type conversion into `IRRewrite` (PR #81756)
@@ -1173,29 +936,110 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener { } // namespace detail } // namespace mlir +void IRRewrite::eraseOp(Operation *op) { + rewriterImpl.eraseRewriter.eraseOp(op); +} + +void IRRewrite::eraseBlock(Block *block) { + rewriterImpl.eraseRewriter.eraseBlock(block); +} + +void BlockTypeConversionRewrite::commit() { + // Process the remapping for each of the original arguments. + for (unsigned i = 0, e = origBlock->getNumArguments(); i != e; ++i) { +std::optional &info = argInfo[i]; +BlockArgument origArg = origBlock->getArgument(i); + +// Handle the case of a 1->0 value mapping. +if (!info) { + if (Value newArg = + rewriterImpl.mapping.lookupOrNull(origArg, origArg.getType())) +origArg.replaceAllUsesWith(newArg); + continue; +} + +// Otherwise this is a 1->1+ value mapping. +Value castValue = info->castValue; +assert(info->newArgSize >= 1 && castValue && "expected 1->1+ mapping"); + +// If the argument is still used, replace it with the generated cast. +if (!origArg.use_empty()) { + origArg.replaceAllUsesWith( + rewriterImpl.mapping.lookupOrDefault(castValue, origArg.getType())); +} + } + + delete origBlock; + origBlock = nullptr; +} + void BlockTypeConversionRewrite::rollback() { - // Undo the type conversion. - rewriterImpl.argConverter.discardRewrites(block); -} - -/// Detach any operations nested in the given operation from their parent -/// blocks, and erase the given operation. This can be used when the nested -/// operations are scheduled for erasure themselves, so deleting the regions of -/// the given operation together with their content would result in double-free. -/// This happens, for example, when rolling back op creation in the reverse -/// order and if the nested ops were created before the parent op. This function -/// does not need to collect nested ops recursively because it is expected to -/// also be called for each nested op when it is about to be deleted. -static void detachNestedAndErase(Operation *op) { + // Drop all uses of the new block arguments and replace uses of the new block. + for (int i = block->getNumArguments() - 1; i >= 0; --i) +block->getArgument(i).dropAllUses(); + block->replaceAllUsesWith(origBlock); + + // Move the operations back the original block, move the original block back + // into its original location and the delete the new block. + origBlock->getOperations().splice(origBlock->end(), block->getOperations()); + block->getParent()->getBlocks().insert(Region::iterator(block), origBlock); + eraseBlock(block); +} + +LogicalResult BlockTypeConversionRewrite::materializeLiveConversions( +function_ref findLiveUser) { + // Process the remapping for each of the original arguments. + for (unsigned i = 0, e = origBlock->getNumArguments(); i != e; ++i) { jpienaar wrote: llvm::enumerate ? https://github.com/llvm/llvm-project/pull/81756 ___ 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] Turn block type conversion into `IRRewrite` (PR #81756)
@@ -1173,29 +936,110 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener { } // namespace detail } // namespace mlir +void IRRewrite::eraseOp(Operation *op) { + rewriterImpl.eraseRewriter.eraseOp(op); +} + +void IRRewrite::eraseBlock(Block *block) { + rewriterImpl.eraseRewriter.eraseBlock(block); +} + +void BlockTypeConversionRewrite::commit() { + // Process the remapping for each of the original arguments. + for (unsigned i = 0, e = origBlock->getNumArguments(); i != e; ++i) { jpienaar wrote: Would llvm::zip work here to enable a range based loop? https://github.com/llvm/llvm-project/pull/81756 ___ 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] Turn block type conversion into `IRRewrite` (PR #81756)
https://github.com/jpienaar edited https://github.com/llvm/llvm-project/pull/81756 ___ 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] Turn op creation into `IRRewrite` (PR #81759)
https://github.com/jpienaar edited https://github.com/llvm/llvm-project/pull/81759 ___ 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] Turn op creation into `IRRewrite` (PR #81759)
https://github.com/jpienaar approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/81759 ___ 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] Turn op creation into `IRRewrite` (PR #81759)
@@ -299,7 +294,8 @@ class IRRewrite { ReplaceBlockArg, MoveOperation, ModifyOperation, -ReplaceOperation jpienaar wrote: Mmm, come to think of it: would it make sense to have "marker" types here so that you wouldn't need to change below if you add types & also where one adds entries here is self-documented due to markers? https://github.com/llvm/llvm-project/pull/81759 ___ 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] Turn op creation into `IRRewrite` (PR #81759)
@@ -372,7 +368,11 @@ class CreateBlockRewrite : public BlockRewrite { auto &blockOps = block->getOperations(); while (!blockOps.empty()) blockOps.remove(blockOps.begin()); -eraseBlock(block); +if (block->getParent()) { jpienaar wrote: Nit: eliding braces for simple conditionals is style here. https://github.com/llvm/llvm-project/pull/81759 ___ 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] Turn op creation into `IRRewrite` (PR #81759)
@@ -2549,10 +2572,15 @@ LogicalResult OperationConverter::legalizeConvertedArgumentTypes( }); return liveUserIt == val.user_end() ? nullptr : *liveUserIt; }; - for (auto &r : rewriterImpl.rewrites) -if (auto *rewrite = dyn_cast(r.get())) - if (failed(rewrite->materializeLiveConversions(findLiveUser))) + // Note: `rewrites` may be reallocated as the loop is running. + for (int64_t i = 0; i < rewriterImpl.rewrites.size(); ++i) { jpienaar wrote: Range based? (yeah seems I'm focussed on loops this morning :)) https://github.com/llvm/llvm-project/pull/81759 ___ 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] Turn op creation into `IRRewrite` (PR #81759)
@@ -1110,7 +1120,18 @@ void ReplaceOperationRewrite::rollback() { void ReplaceOperationRewrite::cleanup() { eraseOp(op); } +void CreateOperationRewrite::rollback() { + for (Region ®ion : op->getRegions()) { +while (!region.getBlocks().empty()) + region.getBlocks().remove(region.getBlocks().begin()); + } + op->dropAllUses(); + eraseOp(op); +} + void ConversionPatternRewriterImpl::detachNestedAndErase(Operation *op) { + // if (erasedIR.erasedOps.contains(op)) return; jpienaar wrote: rm ? https://github.com/llvm/llvm-project/pull/81759 ___ 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/jpienaar approved this pull request. 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] [clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/82448 >From b5ecfcc22cffdd560dc5b6a050889b6c6deacbdb Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 16 Feb 2024 00:09:41 +0900 Subject: [PATCH 1/2] [MC/DC][Coverage] Loosen the limit of NumConds from 6 --- clang/lib/CodeGen/CodeGenPGO.cpp | 61 +- clang/lib/CodeGen/CoverageMappingGen.cpp | 115 +- clang/lib/CodeGen/MCDCState.h | 18 ++- .../CoverageMapping/branch-constfolded.cpp| 34 +++--- clang/test/CoverageMapping/logical.cpp| 8 +- clang/test/CoverageMapping/mcdc-class.cpp | 4 +- .../CoverageMapping/mcdc-error-conditions.cpp | 86 - .../mcdc-logical-scalar-ids.cpp | 30 ++--- .../mcdc-logical-stmt-ids-all.cpp | 32 ++--- .../CoverageMapping/mcdc-logical-stmt-ids.cpp | 30 ++--- clang/test/Profile/c-mcdc-logicalop-ternary.c | 6 +- .../ProfileData/Coverage/CoverageMapping.cpp | 32 ++--- .../llvm-cov/Inputs/mcdc-const-folding.o | Bin 34504 -> 34528 bytes .../Inputs/mcdc-const-folding.proftext| 36 +++--- llvm/test/tools/llvm-cov/Inputs/mcdc-const.o | Bin 5112 -> 5112 bytes .../tools/llvm-cov/Inputs/mcdc-const.proftext | 6 +- .../test/tools/llvm-cov/Inputs/mcdc-general.o | Bin 6200 -> 6232 bytes .../llvm-cov/Inputs/mcdc-general.proftext | 11 +- llvm/test/tools/llvm-cov/Inputs/mcdc-macro.o | Bin 6424 -> 6480 bytes .../tools/llvm-cov/Inputs/mcdc-macro.proftext | 15 +-- llvm/test/tools/llvm-cov/Inputs/mcdc-maxbs.o | Bin 4632 -> 4112 bytes llvm/test/tools/llvm-cov/mcdc-maxbs.test | 2 +- .../ProfileData/CoverageMappingTest.cpp | 2 +- 23 files changed, 348 insertions(+), 180 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 48c5e68a3b7ba4..b004bf45fa75d7 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -163,8 +163,7 @@ struct MapRegionCounters : public RecursiveASTVisitor { PGOHash Hash; /// The map of statements to counters. llvm::DenseMap &CounterMap; - /// The next bitmap byte index to assign. - unsigned NextMCDCBitmapIdx; + /// The state of MC/DC Coverage in this function. MCDC::State &MCDCState; /// Maximum number of supported MC/DC conditions in a boolean expression. unsigned MCDCMaxCond; @@ -178,7 +177,7 @@ struct MapRegionCounters : public RecursiveASTVisitor { MCDC::State &MCDCState, unsigned MCDCMaxCond, DiagnosticsEngine &Diag) : NextCounter(0), Hash(HashVersion), CounterMap(CounterMap), -NextMCDCBitmapIdx(0), MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond), +MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond), ProfileVersion(ProfileVersion), Diag(Diag) {} // Blocks and lambdas are handled as separate functions, so we need not @@ -306,11 +305,8 @@ struct MapRegionCounters : public RecursiveASTVisitor { return false; } - // Otherwise, allocate the number of bytes required for the bitmap - // based on the number of conditions. Must be at least 1-byte long. - MCDCState.BitmapMap[BinOp] = NextMCDCBitmapIdx; - unsigned SizeInBits = std::max(1L << NumCond, CHAR_BIT); - NextMCDCBitmapIdx += SizeInBits / CHAR_BIT; + // Otherwise, allocate the Decision. + MCDCState.BitmapMap[BinOp].BitmapIdx = 0; } return true; } @@ -983,7 +979,7 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { // for most embedded applications. Setting a maximum value prevents the // bitmap footprint from growing too large without the user's knowledge. In // the future, this value could be adjusted with a command-line option. - unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 6 : 0; + unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 32767 : 0; RegionCounterMap.reset(new llvm::DenseMap); RegionMCDCState.reset(new MCDC::State); @@ -999,7 +995,6 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { Walker.TraverseDecl(const_cast(CD)); assert(Walker.NextCounter > 0 && "no entry counter mapped for decl"); NumRegionCounters = Walker.NextCounter; - RegionMCDCState->BitmapBytes = Walker.NextMCDCBitmapIdx; FunctionHash = Walker.Hash.finalize(); } @@ -1124,9 +1119,11 @@ void CodeGenPGO::emitMCDCParameters(CGBuilderTy &Builder) { // Emit intrinsic representing MCDC bitmap parameters at function entry. // This is used by the instrumentation pass, but it isn't actually lowered to // anything. - llvm::Value *Args[3] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), - Builder.getInt64(FunctionHash), - Builder.getInt32(RegionMCDCState->BitmapBytes)}; + llvm::Value *Args[3] = { + llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), + Buil
[llvm-branch-commits] [llvm] [AArch64] SLP can vectorize frem (PR #82488)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/82488 ___ 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] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/82448 >From b5ecfcc22cffdd560dc5b6a050889b6c6deacbdb Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 16 Feb 2024 00:09:41 +0900 Subject: [PATCH 1/5] [MC/DC][Coverage] Loosen the limit of NumConds from 6 --- clang/lib/CodeGen/CodeGenPGO.cpp | 61 +- clang/lib/CodeGen/CoverageMappingGen.cpp | 115 +- clang/lib/CodeGen/MCDCState.h | 18 ++- .../CoverageMapping/branch-constfolded.cpp| 34 +++--- clang/test/CoverageMapping/logical.cpp| 8 +- clang/test/CoverageMapping/mcdc-class.cpp | 4 +- .../CoverageMapping/mcdc-error-conditions.cpp | 86 - .../mcdc-logical-scalar-ids.cpp | 30 ++--- .../mcdc-logical-stmt-ids-all.cpp | 32 ++--- .../CoverageMapping/mcdc-logical-stmt-ids.cpp | 30 ++--- clang/test/Profile/c-mcdc-logicalop-ternary.c | 6 +- .../ProfileData/Coverage/CoverageMapping.cpp | 32 ++--- .../llvm-cov/Inputs/mcdc-const-folding.o | Bin 34504 -> 34528 bytes .../Inputs/mcdc-const-folding.proftext| 36 +++--- llvm/test/tools/llvm-cov/Inputs/mcdc-const.o | Bin 5112 -> 5112 bytes .../tools/llvm-cov/Inputs/mcdc-const.proftext | 6 +- .../test/tools/llvm-cov/Inputs/mcdc-general.o | Bin 6200 -> 6232 bytes .../llvm-cov/Inputs/mcdc-general.proftext | 11 +- llvm/test/tools/llvm-cov/Inputs/mcdc-macro.o | Bin 6424 -> 6480 bytes .../tools/llvm-cov/Inputs/mcdc-macro.proftext | 15 +-- llvm/test/tools/llvm-cov/Inputs/mcdc-maxbs.o | Bin 4632 -> 4112 bytes llvm/test/tools/llvm-cov/mcdc-maxbs.test | 2 +- .../ProfileData/CoverageMappingTest.cpp | 2 +- 23 files changed, 348 insertions(+), 180 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 48c5e68a3b7ba4..b004bf45fa75d7 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -163,8 +163,7 @@ struct MapRegionCounters : public RecursiveASTVisitor { PGOHash Hash; /// The map of statements to counters. llvm::DenseMap &CounterMap; - /// The next bitmap byte index to assign. - unsigned NextMCDCBitmapIdx; + /// The state of MC/DC Coverage in this function. MCDC::State &MCDCState; /// Maximum number of supported MC/DC conditions in a boolean expression. unsigned MCDCMaxCond; @@ -178,7 +177,7 @@ struct MapRegionCounters : public RecursiveASTVisitor { MCDC::State &MCDCState, unsigned MCDCMaxCond, DiagnosticsEngine &Diag) : NextCounter(0), Hash(HashVersion), CounterMap(CounterMap), -NextMCDCBitmapIdx(0), MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond), +MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond), ProfileVersion(ProfileVersion), Diag(Diag) {} // Blocks and lambdas are handled as separate functions, so we need not @@ -306,11 +305,8 @@ struct MapRegionCounters : public RecursiveASTVisitor { return false; } - // Otherwise, allocate the number of bytes required for the bitmap - // based on the number of conditions. Must be at least 1-byte long. - MCDCState.BitmapMap[BinOp] = NextMCDCBitmapIdx; - unsigned SizeInBits = std::max(1L << NumCond, CHAR_BIT); - NextMCDCBitmapIdx += SizeInBits / CHAR_BIT; + // Otherwise, allocate the Decision. + MCDCState.BitmapMap[BinOp].BitmapIdx = 0; } return true; } @@ -983,7 +979,7 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { // for most embedded applications. Setting a maximum value prevents the // bitmap footprint from growing too large without the user's knowledge. In // the future, this value could be adjusted with a command-line option. - unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 6 : 0; + unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 32767 : 0; RegionCounterMap.reset(new llvm::DenseMap); RegionMCDCState.reset(new MCDC::State); @@ -999,7 +995,6 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) { Walker.TraverseDecl(const_cast(CD)); assert(Walker.NextCounter > 0 && "no entry counter mapped for decl"); NumRegionCounters = Walker.NextCounter; - RegionMCDCState->BitmapBytes = Walker.NextMCDCBitmapIdx; FunctionHash = Walker.Hash.finalize(); } @@ -1124,9 +1119,11 @@ void CodeGenPGO::emitMCDCParameters(CGBuilderTy &Builder) { // Emit intrinsic representing MCDC bitmap parameters at function entry. // This is used by the instrumentation pass, but it isn't actually lowered to // anything. - llvm::Value *Args[3] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), - Builder.getInt64(FunctionHash), - Builder.getInt32(RegionMCDCState->BitmapBytes)}; + llvm::Value *Args[3] = { + llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), + Buil
[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Turn block type conversion into `IRRewrite` (PR #81756)
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/81756 >From 68cb2590ea6295504b64d065326a606c2892a2a1 Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Wed, 21 Feb 2024 16:48:48 + Subject: [PATCH] [mlir][Transforms][NFC] Turn block type convertion into `IRRewrite` This commit is a refactoring of the dialect conversion. The dialect conversion maintains a list of "IR rewrites" that can be commited (upon success) or rolled back (upon failure). Until now, the signature conversion of a block was only a "partial" IR rewrite. Rollbacks were triggered via `BlockTypeConversionRewrite::rollback`, but there was no `BlockTypeConversionRewrite::commit` equivalent. Overview of changes: * Remove `ArgConverter`, an internal helper class that kept track of all block type conversions. There is now a separate `BlockTypeConversionRewrite` for each block type conversion. * No more special handling for block type conversions. They are now normal "IR rewrites", just like "block creation" or "block movement". In particular, trigger "commits" of block type conversion via `BlockTypeConversionRewrite::commit`. * Remove `ArgConverter::notifyOpRemoved`. This function was used to inform the `ArgConverter` that an operation was erased, to prevent a double-free of operations in certain situations. It would be unpractical to add a `notifyOpRemoved` API to `IRRewrite`. Instead, erasing ops/block should go through a new `SingleEraseRewriter` (that is owned by the `ConversionPatternRewriterImpl`) if there is chance of double-free. This rewriter ignores `eraseOp`/`eraseBlock` if the op/block was already freed. BEGIN_PUBLIC No public commit message needed for presubmit. END_PUBLIC --- .../Transforms/Utils/DialectConversion.cpp| 794 -- 1 file changed, 364 insertions(+), 430 deletions(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index afdd31a748c8c4..db41b9f19e7e8d 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -154,12 +154,13 @@ namespace { struct RewriterState { RewriterState(unsigned numCreatedOps, unsigned numUnresolvedMaterializations, unsigned numReplacements, unsigned numArgReplacements, -unsigned numRewrites, unsigned numIgnoredOperations) +unsigned numRewrites, unsigned numIgnoredOperations, +unsigned numErased) : numCreatedOps(numCreatedOps), numUnresolvedMaterializations(numUnresolvedMaterializations), numReplacements(numReplacements), numArgReplacements(numArgReplacements), numRewrites(numRewrites), -numIgnoredOperations(numIgnoredOperations) {} +numIgnoredOperations(numIgnoredOperations), numErased(numErased) {} /// The current number of created operations. unsigned numCreatedOps; @@ -178,6 +179,9 @@ struct RewriterState { /// The current number of ignored operations. unsigned numIgnoredOperations; + + /// The current number of erased operations/blocks. + unsigned numErased; }; //===--===// @@ -292,370 +296,6 @@ static Value buildUnresolvedTargetMaterialization( outputType, outputType, converter, unresolvedMaterializations); } -//===--===// -// ArgConverter -//===--===// -namespace { -/// This class provides a simple interface for converting the types of block -/// arguments. This is done by creating a new block that contains the new legal -/// types and extracting the block that contains the old illegal types to allow -/// for undoing pending rewrites in the case of failure. -struct ArgConverter { - ArgConverter( - PatternRewriter &rewriter, - SmallVectorImpl &unresolvedMaterializations) - : rewriter(rewriter), -unresolvedMaterializations(unresolvedMaterializations) {} - - /// This structure contains the information pertaining to an argument that has - /// been converted. - struct ConvertedArgInfo { -ConvertedArgInfo(unsigned newArgIdx, unsigned newArgSize, - Value castValue = nullptr) -: newArgIdx(newArgIdx), newArgSize(newArgSize), castValue(castValue) {} - -/// The start index of in the new argument list that contains arguments that -/// replace the original. -unsigned newArgIdx; - -/// The number of arguments that replaced the original argument. -unsigned newArgSize; - -/// The cast value that was created to cast from the new arguments to the -/// old. This only used if 'newArgSize' > 1. -Value castValue; - }; - - /// This structure contains information pertaining to a block that has had its - /// signature converted. - struct ConvertedBlockInfo { -
[llvm-branch-commits] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)
@@ -1436,6 +1436,8 @@ static void readConfigs(opt::InputArgList &args) { config->zInterpose = hasZOption(args, "interpose"); config->zKeepTextSectionPrefix = getZFlag( args, "keep-text-section-prefix", "nokeep-text-section-prefix", false); + config->zLrodataAfterBss = + getZFlag(args, "lrodata-after-bss", "nolrodata-after-bss", false); aeubanks wrote: When you say "policy" do you mean that the layout policy is documented somewhere? https://github.com/llvm/llvm-project/pull/81224 ___ 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)
MaskRay wrote: > Thanks for the update, I'm happy with the changes. I would like to see more > options for position independent code in embedded systems. > > The other related embedded position independent option for microcontrollers > that I'm aware of is `-fropi` and `-frwpi` which is already implemented in > clang. This is relocation free with just one static data area accessed as an > offset from r9. It works quite well for C code, but doesn't support C++ > (vtables and RTTI need relocations) and some forms of static initialisation. Thanks for the comment. [ROPI/RWPI](https://lists.llvm.org/pipermail/llvm-dev/2015-December/093022.html) seems similar to -mno-pic-data-is-text-relative. In 2013, -mno-pic-data-is-text-relative, generalized from the ARM [VxWorks RTP](https://gcc.gnu.org/pipermail/gcc-patches/2007-May/217111.html) port, was [added](https://inbox.sourceware.org/gcc-patches/01cedf74$bd1bf710$3753e530$@arm.com/) to assume that text and data segments don't have a fixed displacement. On non-VxWorks-RTP targets, -mno-pic-data-is-text-relative implies [-msingle-pic-base](https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-msingle-pic-base): Treat the register used for PIC addressing as read-only, rather than loading it in the prologue for each function. The runtime system is responsible for initializing this register with an appropriate value before execution begins. r9 is used as the static base (`arm_pic_register) in the position-independent data model to access the data segment. Since r9 is not changed, dynamic linking seems unsupported as a DSO needs a different data segment. 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/MaskRay closed 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] [llvm] [CallPromotionUtils]Implement conditional indirect call promotion with vtable-based comparison (PR #81378)
https://github.com/minglotus-6 edited https://github.com/llvm/llvm-project/pull/81378 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
https://github.com/paschalis-mpeis updated https://github.com/llvm/llvm-project/pull/82488 >From 641aaf7c13d520bef52b092726f8346bfecb1c8d Mon Sep 17 00:00:00 2001 From: Paschalis Mpeis Date: Wed, 21 Feb 2024 11:53:00 + Subject: [PATCH 1/3] SLP cannot vectorize frem calls in AArch64. It needs updated costs when there are available vector library functions given the VF and type. --- .../SLPVectorizer/AArch64/slp-frem.ll | 71 +++ 1 file changed, 71 insertions(+) create mode 100644 llvm/test/Transforms/SLPVectorizer/AArch64/slp-frem.ll diff --git a/llvm/test/Transforms/SLPVectorizer/AArch64/slp-frem.ll b/llvm/test/Transforms/SLPVectorizer/AArch64/slp-frem.ll new file mode 100644 index 00..45f667f5657889 --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/AArch64/slp-frem.ll @@ -0,0 +1,71 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 +; RUN: opt < %s -S -mtriple=aarch64 -vector-library=ArmPL -passes=slp-vectorizer | FileCheck %s + +@a = common global ptr null, align 8 + +define void @frem_v2double() { +; CHECK-LABEL: define void @frem_v2double() { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[A0:%.*]] = load double, ptr @a, align 8 +; CHECK-NEXT:[[A1:%.*]] = load double, ptr getelementptr inbounds (double, ptr @a, i64 1), align 8 +; CHECK-NEXT:[[B0:%.*]] = load double, ptr @a, align 8 +; CHECK-NEXT:[[B1:%.*]] = load double, ptr getelementptr inbounds (double, ptr @a, i64 1), align 8 +; CHECK-NEXT:[[R0:%.*]] = frem double [[A0]], [[B0]] +; CHECK-NEXT:[[R1:%.*]] = frem double [[A1]], [[B1]] +; CHECK-NEXT:store double [[R0]], ptr @a, align 8 +; CHECK-NEXT:store double [[R1]], ptr getelementptr inbounds (double, ptr @a, i64 1), align 8 +; CHECK-NEXT:ret void +; +entry: + %a0 = load double, ptr getelementptr inbounds (double, ptr @a, i64 0), align 8 + %a1 = load double, ptr getelementptr inbounds (double, ptr @a, i64 1), align 8 + %b0 = load double, ptr getelementptr inbounds (double, ptr @a, i64 0), align 8 + %b1 = load double, ptr getelementptr inbounds (double, ptr @a, i64 1), align 8 + %r0 = frem double %a0, %b0 + %r1 = frem double %a1, %b1 + store double %r0, ptr getelementptr inbounds (double, ptr @a, i64 0), align 8 + store double %r1, ptr getelementptr inbounds (double, ptr @a, i64 1), align 8 + ret void +} + +define void @frem_v4float() { +; CHECK-LABEL: define void @frem_v4float() { +; CHECK-NEXT: entry: +; CHECK-NEXT:[[A0:%.*]] = load float, ptr @a, align 8 +; CHECK-NEXT:[[A1:%.*]] = load float, ptr getelementptr inbounds (float, ptr @a, i64 1), align 8 +; CHECK-NEXT:[[A2:%.*]] = load float, ptr getelementptr inbounds (float, ptr @a, i64 2), align 8 +; CHECK-NEXT:[[A3:%.*]] = load float, ptr getelementptr inbounds (float, ptr @a, i64 3), align 8 +; CHECK-NEXT:[[B0:%.*]] = load float, ptr @a, align 8 +; CHECK-NEXT:[[B1:%.*]] = load float, ptr getelementptr inbounds (float, ptr @a, i64 1), align 8 +; CHECK-NEXT:[[B2:%.*]] = load float, ptr getelementptr inbounds (float, ptr @a, i64 2), align 8 +; CHECK-NEXT:[[B3:%.*]] = load float, ptr getelementptr inbounds (float, ptr @a, i64 3), align 8 +; CHECK-NEXT:[[R0:%.*]] = frem float [[A0]], [[B0]] +; CHECK-NEXT:[[R1:%.*]] = frem float [[A1]], [[B1]] +; CHECK-NEXT:[[R2:%.*]] = frem float [[A2]], [[B2]] +; CHECK-NEXT:[[R3:%.*]] = frem float [[A3]], [[B3]] +; CHECK-NEXT:store float [[R0]], ptr @a, align 8 +; CHECK-NEXT:store float [[R1]], ptr getelementptr inbounds (float, ptr @a, i64 1), align 8 +; CHECK-NEXT:store float [[R2]], ptr getelementptr inbounds (float, ptr @a, i64 2), align 8 +; CHECK-NEXT:store float [[R3]], ptr getelementptr inbounds (float, ptr @a, i64 3), align 8 +; CHECK-NEXT:ret void +; +entry: + %a0 = load float, ptr getelementptr inbounds (float, ptr @a, i64 0), align 8 + %a1 = load float, ptr getelementptr inbounds (float, ptr @a, i64 1), align 8 + %a2 = load float, ptr getelementptr inbounds (float, ptr @a, i64 2), align 8 + %a3 = load float, ptr getelementptr inbounds (float, ptr @a, i64 3), align 8 + %b0 = load float, ptr getelementptr inbounds (float, ptr @a, i64 0), align 8 + %b1 = load float, ptr getelementptr inbounds (float, ptr @a, i64 1), align 8 + %b2 = load float, ptr getelementptr inbounds (float, ptr @a, i64 2), align 8 + %b3 = load float, ptr getelementptr inbounds (float, ptr @a, i64 3), align 8 + %r0 = frem float %a0, %b0 + %r1 = frem float %a1, %b1 + %r2 = frem float %a2, %b2 + %r3 = frem float %a3, %b3 + store float %r0, ptr getelementptr inbounds (float, ptr @a, i64 0), align 8 + store float %r1, ptr getelementptr inbounds (float, ptr @a, i64 1), align 8 + store float %r2, ptr getelementptr inbounds (float, ptr @a, i64 2), align 8 + store float %r3, ptr getelementptr inbounds (float, ptr @a, i64 3), align 8 + ret void +} + >From 29ae086478e3d4bae6b6250670f87273359626d7 Mon Sep 17
[llvm-branch-commits] [llvm] [AArch64] SLP can vectorize frem (PR #82488)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
@@ -8362,9 +8362,20 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef VectorizedVals, unsigned OpIdx = isa(VL0) ? 0 : 1; TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0)); TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx)); - return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info, - Op2Info) + - CommonCost; + auto VecCost = TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, + Op1Info, Op2Info); + // Some targets can replace frem with vector library calls. + if (ShuffleOrOp == Instruction::FRem) { +LibFunc Func; +if (TLI->getLibFunc(ShuffleOrOp, ScalarTy, Func) && +TLI->isFunctionVectorizable(TLI->getName(Func), +VecTy->getElementCount())) { paschalis-mpeis wrote: Unfortunately TLI (TargetLibraryInfo) is not available in TTI, and changing TTI->getArithmeticInstrCost's signature would require way too many changes. But I agree that part of this logic is better to move, so I've introduced 'getVecLibCallCost' to ensapculate that functionality. https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
paschalis-mpeis wrote: Addressed reviewers and rebased to parent pr: - #80423 Github is now rendering **only** the changes of this patch. https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
@@ -869,6 +870,18 @@ TargetTransformInfo::getOperandInfo(const Value *V) { return {OpInfo, OpProps}; } +InstructionCost TargetTransformInfo::getVecLibCallCost( +const int OpCode, const TargetLibraryInfo *TLI, VectorType *VecTy, +TTI::TargetCostKind CostKind) { + Type *ScalarTy = VecTy->getScalarType(); + LibFunc Func; + if (TLI->getLibFunc(OpCode, ScalarTy, Func) && + TLI->isFunctionVectorizable(TLI->getName(Func), VecTy->getElementCount())) paulwalker-arm wrote: This seems to be surreptitiously adding another mechanism to check for the presence of a vector math routine. Under what circumstance do you need to check for the cost of something that might not exist? I would expect TLI to be queried directly as part of a transformation and once they've concluded a vector math call exists then they'd simply query the cost of the call. https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
@@ -869,6 +870,18 @@ TargetTransformInfo::getOperandInfo(const Value *V) { return {OpInfo, OpProps}; } +InstructionCost TargetTransformInfo::getVecLibCallCost( +const int OpCode, const TargetLibraryInfo *TLI, VectorType *VecTy, +TTI::TargetCostKind CostKind) { + Type *ScalarTy = VecTy->getScalarType(); + LibFunc Func; + if (TLI->getLibFunc(OpCode, ScalarTy, Func) && + TLI->isFunctionVectorizable(TLI->getName(Func), VecTy->getElementCount())) +return getCallInstrCost(nullptr, VecTy, {ScalarTy, ScalarTy}, CostKind); paulwalker-arm wrote: This is hardwiring two scalar parameters when costing the call? https://github.com/llvm/llvm-project/pull/82488 ___ 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] [AArch64] SLP can vectorize frem (PR #82488)
@@ -8362,9 +8362,20 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef VectorizedVals, unsigned OpIdx = isa(VL0) ? 0 : 1; TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0)); TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx)); - return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info, - Op2Info) + - CommonCost; + auto VecCost = TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, + Op1Info, Op2Info); + // Some targets can replace frem with vector library calls. + if (ShuffleOrOp == Instruction::FRem) { +LibFunc Func; +if (TLI->getLibFunc(ShuffleOrOp, ScalarTy, Func) && +TLI->isFunctionVectorizable(TLI->getName(Func), +VecTy->getElementCount())) { alexey-bataev wrote: Better to teach TTI about TLI rather than do something like this in SLP. SLP should keep its target independent nature, all that target-specific stuff should live in TTI https://github.com/llvm/llvm-project/pull/82488 ___ 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] Backport 0bf4f82 to release/18.x (PR #82571)
https://github.com/whentojump milestoned https://github.com/llvm/llvm-project/pull/82571 ___ 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] Backport 0bf4f82 to release/18.x (PR #82571)
https://github.com/whentojump created https://github.com/llvm/llvm-project/pull/82571 Manually cherry-pick 0bf4f82 and resolve conflicts Closes #82570 >From 37f5e39e1c54ad1c839d80580b9e5303b6e692d3 Mon Sep 17 00:00:00 2001 From: Wentao Zhang <35722712+whentoj...@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:24:31 -0600 Subject: [PATCH] [llvm-cov][CoverageView] minor fix/improvement to HTML and text coverage output (#80952) 1. add the missing condition for MC/DC in hasSubViews() 2. add style for selected line 3. remove name="Ln" attribute in the link within MC/DC views 4. remove color for \n (cherry picked from commit 0bf4f82f661817c79bd538c82c99515837cf1cf8) --- llvm/test/tools/llvm-cov/mcdc-general-none.test | 2 +- llvm/test/tools/llvm-cov/mcdc-general.test | 2 +- llvm/tools/llvm-cov/SourceCoverageView.cpp | 2 +- llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 9 + llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/llvm/test/tools/llvm-cov/mcdc-general-none.test b/llvm/test/tools/llvm-cov/mcdc-general-none.test index bcf8f3cbd05d45e..a373075cc5e37cc 100644 --- a/llvm/test/tools/llvm-cov/mcdc-general-none.test +++ b/llvm/test/tools/llvm-cov/mcdc-general-none.test @@ -52,7 +52,7 @@ // Test html output. // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-general.cpp -format html -o %t.html.dir // RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s -// HTML-COUNT-4: MC/DC Decision Region ( +// HTML-COUNT-4: MC/DC Decision Region ( // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s // HTML-INDEX-LABEL: diff --git a/llvm/test/tools/llvm-cov/mcdc-general.test b/llvm/test/tools/llvm-cov/mcdc-general.test index 588aed09c16a5e3..ded2f3eb1c9a5d3 100644 --- a/llvm/test/tools/llvm-cov/mcdc-general.test +++ b/llvm/test/tools/llvm-cov/mcdc-general.test @@ -118,7 +118,7 @@ // Test html output. // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-general.cpp -format html -o %t.html.dir // RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s -// HTML-COUNT-4: MC/DC Decision Region ( +// HTML-COUNT-4: MC/DC Decision Region ( // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s // HTML-INDEX-LABEL: diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp index 71edd5fec4280a6..5b85d7d86bfb946 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp @@ -139,7 +139,7 @@ bool SourceCoverageView::shouldRenderRegionMarkers( bool SourceCoverageView::hasSubViews() const { return !ExpansionSubViews.empty() || !InstantiationSubViews.empty() || - !BranchSubViews.empty(); + !BranchSubViews.empty() || !MCDCSubViews.empty(); } std::unique_ptr diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp index abc4c49ecae98e3..b93d8cb035306b7 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -246,6 +246,9 @@ tr:hover { tr:last-child { border-bottom: none; } +tr:has(> td >a:target) > td.code > pre { + background-color: #ffa; +} )"; const char *EndHeader = ""; @@ -990,15 +993,13 @@ void SourceCoverageViewHTML::renderMCDCView(raw_ostream &OS, MCDCView &MRV, std::string ColNoStr = Twine(DecisionRegion.ColumnStart).str(); std::string TargetName = "L" + LineNoStr; OS << tag("span", - a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr), -TargetName), + a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)), "line-number") + ") to ("; LineNoStr = utostr(uint64_t(DecisionRegion.LineEnd)); ColNoStr = utostr(uint64_t(DecisionRegion.ColumnEnd)); OS << tag("span", - a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr), -TargetName), + a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)), "line-number") + ")\n\n"; diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp index 73b7ffe16a9637e..580da45ecfc0d83 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp @@ -382,7 +382,8 @@ void SourceCoverageViewText::renderMCDCView(raw_ostream &OS, MCDCView &MRV, colored_ostream(OS, raw_ostream::RED, getOptions().Colors && Record.getPercentCovered() < 100.0, /*Bold=*/false, /*BG=*/true)
[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)
https://github.com/whentojump edited https://github.com/llvm/llvm-project/pull/82571 ___ 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] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506) (PR #82572)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/82572 Backport 2cd59bdc891ab59a1abfe5205feb45791a530a47 11d115d0569b212dfeb7fe6485be48070e068e19 815644b4dd882ade2e5649d4f97c3dd6f7aea200 Requested by: @patrick-rivos >From fc403298006a5d8cac015dd932bc86b15f6f1f1c Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Wed, 21 Feb 2024 18:05:04 +0800 Subject: [PATCH 1/3] [RISCV] Add test case for miscompile in gather -> strided load combine. NFC This shows the issue in #82430, but triggers it via the widening SEW combine rather than a GEP that RISCVGatherScatterLowering doesn't detect. (cherry picked from commit 2cd59bdc891ab59a1abfe5205feb45791a530a47) --- .../RISCV/rvv/fixed-vectors-masked-gather.ll | 47 +++ 1 file changed, 47 insertions(+) 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 890707c6337fad..1724b48dd6be9e 100644 --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll @@ -15086,5 +15086,52 @@ define <32 x i64> @mgather_strided_split(ptr %base) { ret <32 x i64> %x } +; FIXME: This is a miscompile triggered by the mgather -> +; riscv.masked.strided.load combine. In order for it to trigger we need either a +; strided gather that RISCVGatherScatterLowering doesn't pick up, or a new +; strided gather generated by the widening sew combine. +define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) { +; RV32V-LABEL: masked_gather_widen_sew_negative_stride: +; RV32V: # %bb.0: +; RV32V-NEXT:addi a0, a0, -128 +; RV32V-NEXT:li a1, -128 +; RV32V-NEXT:vsetivli zero, 2, e64, m1, ta, ma +; RV32V-NEXT:vlse64.v v8, (a0), a1 +; RV32V-NEXT:ret +; +; RV64V-LABEL: masked_gather_widen_sew_negative_stride: +; RV64V: # %bb.0: +; RV64V-NEXT:addi a0, a0, -128 +; RV64V-NEXT:li a1, -128 +; RV64V-NEXT:vsetivli zero, 2, e64, m1, ta, ma +; RV64V-NEXT:vlse64.v v8, (a0), a1 +; RV64V-NEXT:ret +; +; RV32ZVE32F-LABEL: masked_gather_widen_sew_negative_stride: +; RV32ZVE32F: # %bb.0: +; RV32ZVE32F-NEXT:lui a1, 16392 +; RV32ZVE32F-NEXT:addi a1, a1, 1152 +; RV32ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma +; RV32ZVE32F-NEXT:vmv.s.x v9, a1 +; RV32ZVE32F-NEXT:vluxei8.v v8, (a0), v9 +; RV32ZVE32F-NEXT:ret +; +; RV64ZVE32F-LABEL: masked_gather_widen_sew_negative_stride: +; RV64ZVE32F: # %bb.0: +; RV64ZVE32F-NEXT:addi a1, a0, 128 +; RV64ZVE32F-NEXT:lw a2, 132(a0) +; RV64ZVE32F-NEXT:lw a3, 0(a0) +; RV64ZVE32F-NEXT:lw a0, 4(a0) +; RV64ZVE32F-NEXT:vsetivli zero, 4, e32, m1, ta, ma +; RV64ZVE32F-NEXT:vlse32.v v8, (a1), zero +; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a2 +; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a3 +; RV64ZVE32F-NEXT:vslide1down.vx v8, v8, a0 +; RV64ZVE32F-NEXT:ret + %ptrs = getelementptr i32, ptr %base, <4 x i64> + %x = call <4 x i32> @llvm.masked.gather.v4i32.v32p0(<4 x ptr> %ptrs, i32 8, <4 x i1> shufflevector(<4 x i1> insertelement(<4 x i1> poison, i1 true, i32 0), <4 x i1> poison, <4 x i32> zeroinitializer), <4 x i32> poison) + ret <4 x i32> %x +} + ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: ; RV64: {{.*}} >From 37dc7c037b271c646bc168fa2f8514f79cbbef03 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 22 Feb 2024 11:05:06 +0800 Subject: [PATCH 2/3] [RISCV] Adjust test case to show wrong stride. NFC See https://github.com/llvm/llvm-project/pull/82506#discussion_r1498080785 (cherry picked from commit 11d115d0569b212dfeb7fe6485be48070e068e19) --- .../RISCV/rvv/fixed-vectors-masked-gather.ll | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) 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 1724b48dd6be9e..60eec356773bfa 100644 --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll @@ -15093,24 +15093,24 @@ define <32 x i64> @mgather_strided_split(ptr %base) { define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) { ; RV32V-LABEL: masked_gather_widen_sew_negative_stride: ; RV32V: # %bb.0: -; RV32V-NEXT:addi a0, a0, -128 -; RV32V-NEXT:li a1, -128 +; RV32V-NEXT:addi a0, a0, -120 +; RV32V-NEXT:li a1, 120 ; RV32V-NEXT:vsetivli zero, 2, e64, m1, ta, ma ; RV32V-NEXT:vlse64.v v8, (a0), a1 ; RV32V-NEXT:ret ; ; RV64V-LABEL: masked_gather_widen_sew_negative_stride: ; RV64V: # %bb.0: -; RV64V-NEXT:addi a0, a0, -128 -; RV64V-NEXT:li a1, -128 +; RV64V-NEXT:addi a0, a0, -120 +; RV64V-NEXT:li a1, 120 ; RV64V-NEXT:vsetivli zero, 2, e64, m1, ta, ma ; RV64V-NEXT:vlse64.v v8, (a0), a1 ; RV64V-NEXT:ret ; ; RV32ZVE32F-LABEL: masked_gather_wid
[llvm-branch-commits] [llvm] release/18.x: [RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506) (PR #82572)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/82572 ___ 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] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506) (PR #82572)
llvmbot wrote: @topperc What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/82572 ___ 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] Fix mgather -> riscv.masked.strided.load combine not extending indices (#82506) (PR #82572)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v Author: None (llvmbot) Changes Backport 2cd59bdc891ab59a1abfe5205feb45791a530a47 11d115d0569b212dfeb7fe6485be48070e068e19 815644b4dd882ade2e5649d4f97c3dd6f7aea200 Requested by: @patrick-rivos --- Full diff: https://github.com/llvm/llvm-project/pull/82572.diff 2 Files Affected: - (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+12-8) - (modified) llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll (+43) ``diff diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 80447d03c000b8..a0cec426002b6f 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -3192,7 +3192,8 @@ static std::optional getExactInteger(const APFloat &APF, // Note that this method will also match potentially unappealing index // sequences, like , however it is left to the caller to // determine whether this is worth generating code for. -static std::optional isSimpleVIDSequence(SDValue Op) { +static std::optional isSimpleVIDSequence(SDValue Op, + unsigned EltSizeInBits) { unsigned NumElts = Op.getNumOperands(); assert(Op.getOpcode() == ISD::BUILD_VECTOR && "Unexpected BUILD_VECTOR"); bool IsInteger = Op.getValueType().isInteger(); @@ -3200,7 +3201,7 @@ static std::optional isSimpleVIDSequence(SDValue Op) { std::optional SeqStepDenom; std::optional SeqStepNum, SeqAddend; std::optional> PrevElt; - unsigned EltSizeInBits = Op.getValueType().getScalarSizeInBits(); + assert(EltSizeInBits >= Op.getValueType().getScalarSizeInBits()); for (unsigned Idx = 0; Idx < NumElts; Idx++) { // Assume undef elements match the sequence; we just have to be careful // when interpolating across them. @@ -3213,14 +3214,14 @@ static std::optional isSimpleVIDSequence(SDValue Op) { if (!isa(Op.getOperand(Idx))) return std::nullopt; Val = Op.getConstantOperandVal(Idx) & -maskTrailingOnes(EltSizeInBits); +maskTrailingOnes(Op.getScalarValueSizeInBits()); } else { // The BUILD_VECTOR must be all constants. if (!isa(Op.getOperand(Idx))) return std::nullopt; if (auto ExactInteger = getExactInteger( cast(Op.getOperand(Idx))->getValueAPF(), - EltSizeInBits)) + Op.getScalarValueSizeInBits())) Val = *ExactInteger; else return std::nullopt; @@ -3276,11 +3277,11 @@ static std::optional isSimpleVIDSequence(SDValue Op) { uint64_t Val; if (IsInteger) { Val = Op.getConstantOperandVal(Idx) & -maskTrailingOnes(EltSizeInBits); +maskTrailingOnes(Op.getScalarValueSizeInBits()); } else { Val = *getExactInteger( cast(Op.getOperand(Idx))->getValueAPF(), - EltSizeInBits); + Op.getScalarValueSizeInBits()); } uint64_t ExpectedVal = (int64_t)(Idx * (uint64_t)*SeqStepNum) / *SeqStepDenom; @@ -3550,7 +3551,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG, // Try and match index sequences, which we can lower to the vid instruction // with optional modifications. An all-undef vector is matched by // getSplatValue, above. - if (auto SimpleVID = isSimpleVIDSequence(Op)) { + if (auto SimpleVID = isSimpleVIDSequence(Op, Op.getScalarValueSizeInBits())) { int64_t StepNumerator = SimpleVID->StepNumerator; unsigned StepDenominator = SimpleVID->StepDenominator; int64_t Addend = SimpleVID->Addend; @@ -15562,7 +15563,10 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N, if (Index.getOpcode() == ISD::BUILD_VECTOR && MGN->getExtensionType() == ISD::NON_EXTLOAD && isTypeLegal(VT)) { - if (std::optional SimpleVID = isSimpleVIDSequence(Index); + // The sequence will be XLenVT, not the type of Index. Tell + // isSimpleVIDSequence this so we avoid overflow. + if (std::optional SimpleVID = + isSimpleVIDSequence(Index, Subtarget.getXLen()); SimpleVID && SimpleVID->StepDenominator == 1) { const int64_t StepNumerator = SimpleVID->StepNumerator; const int64_t Addend = SimpleVID->Addend; 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 890707c6337fad..88c299a19fb4e8 100644 --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll @@ -15086,5 +15086,48 @@ define <32 x i64> @mgather_strided_split(ptr %base) { ret <32 x i64> %x } +define <4 x i32> @masked_gather_widen_sew_negative_stride(ptr %base) { +; RV32V-LABEL: masked_gather_widen_sew_negative_stride: +; RV32V: # %bb.0: +; RV32V-NEXT:addi a0, a0, 136 +; RV32V-NEXT:li a1, -136 +; RV32V-NEXT:vsetivli zero, 2,