[llvm-branch-commits] [mlir] [draft] Dialect Conversion without Rollback (PR #93412)
@@ -1053,3 +1055,241 @@ LogicalResult mlir::applyOpPatternsAndFold( }); return converged; } + +//===--===// +// One-Shot Dialect Conversion Infrastructure +//===--===// + +namespace { +/// A conversion rewriter for the One-Shot Dialect Conversion. This rewriter +/// immediately materializes all IR changes. It derives from +/// `ConversionPatternRewriter` so that the existing conversion patterns can +/// be used with the One-Shot Dialect Conversion. +class OneShotConversionPatternRewriter : public ConversionPatternRewriter { +public: + OneShotConversionPatternRewriter(MLIRContext *ctx) + : ConversionPatternRewriter(ctx) {} + + bool canRecoverFromRewriteFailure() const override { return false; } + + void replaceOp(Operation *op, ValueRange newValues) override; + + void replaceOp(Operation *op, Operation *newOp) override { +replaceOp(op, newOp->getResults()); + } + + void eraseOp(Operation *op) override { PatternRewriter::eraseOp(op); } + + void eraseBlock(Block *block) override { PatternRewriter::eraseBlock(block); } + + void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, + ValueRange argValues = std::nullopt) override { +PatternRewriter::inlineBlockBefore(source, dest, before, argValues); + } + using PatternRewriter::inlineBlockBefore; + + void startOpModification(Operation *op) override { +PatternRewriter::startOpModification(op); + } + + void finalizeOpModification(Operation *op) override { +PatternRewriter::finalizeOpModification(op); + } + + void cancelOpModification(Operation *op) override { +PatternRewriter::cancelOpModification(op); + } + + void setCurrentTypeConverter(const TypeConverter *converter) override { +typeConverter = converter; + } + + const TypeConverter *getCurrentTypeConverter() const override { +return typeConverter; + } + + LogicalResult getAdapterOperands(StringRef valueDiagTag, + std::optional inputLoc, + ValueRange values, + SmallVector &remapped) override; + +private: + /// Build an unrealized_conversion_cast op or look it up in the cache. + Value buildUnrealizedConversionCast(Location loc, Type type, Value value); + + /// The current type converter. + const TypeConverter *typeConverter; + + /// A cache for unrealized_conversion_casts. To ensure that identical casts + /// are not built multiple times. + DenseMap, Value> castCache; +}; + +void OneShotConversionPatternRewriter::replaceOp(Operation *op, + ValueRange newValues) { + assert(op->getNumResults() == newValues.size()); + for (auto [orig, repl] : llvm::zip_equal(op->getResults(), newValues)) { +if (orig.getType() != repl.getType()) { + // Type mismatch: insert unrealized_conversion cast. + replaceAllUsesWith(orig, buildUnrealizedConversionCast( + op->getLoc(), orig.getType(), repl)); +} else { + // Same type: use replacement value directly. + replaceAllUsesWith(orig, repl); +} + } + eraseOp(op); +} + +Value OneShotConversionPatternRewriter::buildUnrealizedConversionCast( +Location loc, Type type, Value value) { + auto it = castCache.find(std::make_pair(value, type)); + if (it != castCache.end()) +return it->second; + + // Insert cast at the beginning of the block (for block arguments) or right + // after the defining op. + OpBuilder::InsertionGuard g(*this); + Block *insertBlock = value.getParentBlock(); + Block::iterator insertPt = insertBlock->begin(); + if (OpResult inputRes = dyn_cast(value)) +insertPt = ++inputRes.getOwner()->getIterator(); + setInsertionPoint(insertBlock, insertPt); + auto castOp = create(loc, type, value); + castCache[std::make_pair(value, type)] = castOp.getOutputs()[0]; + return castOp.getOutputs()[0]; +} + +class ConversionPatternRewriteDriver : public GreedyPatternRewriteDriver { joker-eph wrote: Relying on the greedy driver makes me concerned about the "one shot" aspect. I would really like to see a **simple** implementation, with the minimum amount of bookkeeping (ideally not even a worklist!), and relying on the GreedyPatternRewriteDriver does not really go in this direction right now. https://github.com/llvm/llvm-project/pull/93412 ___ 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] [draft] Dialect Conversion without Rollback (PR #93412)
@@ -1053,3 +1055,241 @@ LogicalResult mlir::applyOpPatternsAndFold( }); return converged; } + +//===--===// +// One-Shot Dialect Conversion Infrastructure +//===--===// + +namespace { +/// A conversion rewriter for the One-Shot Dialect Conversion. This rewriter +/// immediately materializes all IR changes. It derives from +/// `ConversionPatternRewriter` so that the existing conversion patterns can +/// be used with the One-Shot Dialect Conversion. +class OneShotConversionPatternRewriter : public ConversionPatternRewriter { +public: + OneShotConversionPatternRewriter(MLIRContext *ctx) + : ConversionPatternRewriter(ctx) {} + + bool canRecoverFromRewriteFailure() const override { return false; } + + void replaceOp(Operation *op, ValueRange newValues) override; + + void replaceOp(Operation *op, Operation *newOp) override { +replaceOp(op, newOp->getResults()); + } + + void eraseOp(Operation *op) override { PatternRewriter::eraseOp(op); } + + void eraseBlock(Block *block) override { PatternRewriter::eraseBlock(block); } + + void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, + ValueRange argValues = std::nullopt) override { +PatternRewriter::inlineBlockBefore(source, dest, before, argValues); + } + using PatternRewriter::inlineBlockBefore; + + void startOpModification(Operation *op) override { +PatternRewriter::startOpModification(op); + } + + void finalizeOpModification(Operation *op) override { +PatternRewriter::finalizeOpModification(op); + } + + void cancelOpModification(Operation *op) override { +PatternRewriter::cancelOpModification(op); + } + + void setCurrentTypeConverter(const TypeConverter *converter) override { +typeConverter = converter; + } + + const TypeConverter *getCurrentTypeConverter() const override { +return typeConverter; + } + + LogicalResult getAdapterOperands(StringRef valueDiagTag, + std::optional inputLoc, + ValueRange values, + SmallVector &remapped) override; + +private: + /// Build an unrealized_conversion_cast op or look it up in the cache. + Value buildUnrealizedConversionCast(Location loc, Type type, Value value); + + /// The current type converter. + const TypeConverter *typeConverter; + + /// A cache for unrealized_conversion_casts. To ensure that identical casts + /// are not built multiple times. + DenseMap, Value> castCache; +}; + +void OneShotConversionPatternRewriter::replaceOp(Operation *op, + ValueRange newValues) { + assert(op->getNumResults() == newValues.size()); + for (auto [orig, repl] : llvm::zip_equal(op->getResults(), newValues)) { +if (orig.getType() != repl.getType()) { + // Type mismatch: insert unrealized_conversion cast. + replaceAllUsesWith(orig, buildUnrealizedConversionCast( + op->getLoc(), orig.getType(), repl)); +} else { + // Same type: use replacement value directly. + replaceAllUsesWith(orig, repl); +} + } + eraseOp(op); +} + +Value OneShotConversionPatternRewriter::buildUnrealizedConversionCast( +Location loc, Type type, Value value) { + auto it = castCache.find(std::make_pair(value, type)); + if (it != castCache.end()) +return it->second; + + // Insert cast at the beginning of the block (for block arguments) or right + // after the defining op. + OpBuilder::InsertionGuard g(*this); + Block *insertBlock = value.getParentBlock(); + Block::iterator insertPt = insertBlock->begin(); + if (OpResult inputRes = dyn_cast(value)) +insertPt = ++inputRes.getOwner()->getIterator(); + setInsertionPoint(insertBlock, insertPt); + auto castOp = create(loc, type, value); + castCache[std::make_pair(value, type)] = castOp.getOutputs()[0]; + return castOp.getOutputs()[0]; +} + +class ConversionPatternRewriteDriver : public GreedyPatternRewriteDriver { joker-eph wrote: I don't have problem with dialect conversion complexity actually, other than replaceAllUsesWith not doing what it says it does, and the fact that you have to go through the rewriter for these. But you're not changing these aspects are you? > I am reluctant to build something that is not compatible with the large > number of existing conversion patterns. Without rollback you're incompatible anyway, people can't "just adopt it". But otherwise what kind of incompatibility are you worried about here? Greedy is a fixed-point iterative algorithm which has non-trivial cost associated with it. I don't quite get why it is suitable here? https://github.com/llvm/llvm-project/pull/93412 ___ llvm-branch-commits mailing list llvm-branch-commi
[llvm-branch-commits] [mlir] [mlir][Transforms] Support `moveOpBefore`/`After` in dialect conversion (PR #81240)
@@ -970,6 +971,54 @@ class BlockTypeConversionAction : public BlockAction { void rollback() override; }; + +/// An operation rewrite. joker-eph wrote: Can you expand on the role of the class, the context where it's used? The "Action" name for this whole section is not great by the way, since the concept of "Actions" is now core to MLIR tracing... https://github.com/llvm/llvm-project/pull/81240 ___ 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 `moveOpBefore`/`After` in dialect conversion (PR #81240)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/81240 ___ 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] Modularize block actions (PR #81237)
@@ -820,6 +740,238 @@ void ArgConverter::insertConversion(Block *newBlock, conversionInfo.insert({newBlock, std::move(info)}); } +//===--===// +// RewriteAction joker-eph wrote: Mentioned it in the other PR: do we have an alternative to "Action" here? https://github.com/llvm/llvm-project/pull/81237 ___ 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] release/18.x: [mlir] Skip invalid test on big endian platform (s390x) (#80246) (PR #81373)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/81373 ___ 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] Modularize block actions (PR #81237)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/81237 ___ 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 `moveOpBefore`/`After` in dialect conversion (PR #81240)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/81240 ___ 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)
@@ -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/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] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/83702 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From 7935f2b8d298c7c882a472baf982cd29aa87cb26 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 5 Mar 2024 10:38:41 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/lib/Core/ParallelUtilities.cpp | 4 ++-- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- .../clang-doc/tool/ClangDocMain.cpp | 2 +- .../tool/FindAllSymbolsMain.cpp | 2 +- clang/lib/Tooling/AllTUsExecution.cpp | 2 +- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 4 ++-- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 2 +- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/include/mlir/IR/MLIRContext.h| 2 +- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 2 +- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 37 files changed, 65 insertions(+), 66 deletions(-) diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 88d9444a6a2ba7..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index c6dfd3cfdc56de..f2ac5ad4492ee5 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl &Filenames) { // least 4 tasks. ThreadPoolStrategy S = optimal_concurrency( std::max(Filenames.size() / 4, static_cast(1))); - ThreadPool Pool(S); + DefaultThreadPool Pool(S); DenseMap ParsedProfiles( Pool.getMaxConcurrency()); for (const auto &Filename : Filenames) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 22bdb5de22d871..21b581fa6df2e1 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -238,7 +238,7 @@ Example usage for a project using a compile commands database: Error = false; llvm::sys::Mutex IndexMutex; // ExecutorConcurrency is a flag exposed by AllTUsExecution.h - llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); + llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); for (auto &Group : USRToBitcode) { Pool.async([&]() { std::vector> Infos; diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp index b2d0efecc20692..298b02e77cb0aa 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ b/clang-tools-extra/clang-include-fixer/find
[llvm-branch-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
joker-eph wrote: Here is the extracted one: https://github.com/llvm/llvm-project/pull/84056 And the diff here is now clean (stacked on top of #84056 ) How does it look now @dwblaikie ? https://github.com/llvm/llvm-project/pull/83702 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph closed https://github.com/llvm/llvm-project/pull/83702 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph reopened https://github.com/llvm/llvm-project/pull/83702 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
@@ -68,9 +68,9 @@ class PatternApplicator { ///invalidate the match and try another pattern. LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter, - function_ref canApply = {}, - function_ref onFailure = {}, - function_ref onSuccess = {}); + std::function canApply = {}, + std::function onFailure = {}, + std::function onSuccess = {}); joker-eph wrote: Why this change? https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
@@ -562,30 +562,39 @@ bool GreedyPatternRewriteDriver::processWorklist() { // Try to match one of the patterns. The rewriter is automatically // notified of any necessary changes, so there is nothing else to do // here. +std::function canApply = nullptr; +std::function onFailure = nullptr; +std::function onSuccess = nullptr; +bool debugBuild = false; #ifndef NDEBUG -auto canApply = [&](const Pattern &pattern) { - LLVM_DEBUG({ -logger.getOStream() << "\n"; -logger.startLine() << "* Pattern " << pattern.getDebugName() << " : '" - << op->getName() << " -> ("; -llvm::interleaveComma(pattern.getGeneratedOps(), logger.getOStream()); -logger.getOStream() << ")' {\n"; -logger.indent(); - }); - return true; -}; -auto onFailure = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("failure", "pattern failed to match")); -}; -auto onSuccess = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("success", "pattern applied successfully")); - return success(); -}; -#else -function_ref canApply = {}; -function_ref onFailure = {}; -function_ref onSuccess = {}; -#endif +debugBuild = true; joker-eph wrote: Why changing the structure of the code with this variable? https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
@@ -562,30 +562,39 @@ bool GreedyPatternRewriteDriver::processWorklist() { // Try to match one of the patterns. The rewriter is automatically // notified of any necessary changes, so there is nothing else to do // here. +std::function canApply = nullptr; +std::function onFailure = nullptr; +std::function onSuccess = nullptr; +bool debugBuild = false; #ifndef NDEBUG -auto canApply = [&](const Pattern &pattern) { - LLVM_DEBUG({ -logger.getOStream() << "\n"; -logger.startLine() << "* Pattern " << pattern.getDebugName() << " : '" - << op->getName() << " -> ("; -llvm::interleaveComma(pattern.getGeneratedOps(), logger.getOStream()); -logger.getOStream() << ")' {\n"; -logger.indent(); - }); - return true; -}; -auto onFailure = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("failure", "pattern failed to match")); -}; -auto onSuccess = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("success", "pattern applied successfully")); - return success(); -}; -#else -function_ref canApply = {}; -function_ref onFailure = {}; -function_ref onSuccess = {}; -#endif +debugBuild = true; joker-eph wrote: Oh never mind I see! https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
@@ -68,9 +68,9 @@ class PatternApplicator { ///invalidate the match and try another pattern. LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter, - function_ref canApply = {}, - function_ref onFailure = {}, - function_ref onSuccess = {}); + std::function canApply = {}, + std::function onFailure = {}, + std::function onSuccess = {}); joker-eph wrote: That can explain why you changed it at the call-site, but I'm puzzled about this function: it does not capture the callback as far as I can tell. https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
@@ -68,9 +68,9 @@ class PatternApplicator { ///invalidate the match and try another pattern. LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter, - function_ref canApply = {}, - function_ref onFailure = {}, - function_ref onSuccess = {}); + std::function canApply = {}, + std::function onFailure = {}, + std::function onSuccess = {}); joker-eph wrote: > What are you referring to with this function? Where this comment thread is anchored: `matchAndRewrite` > The problem here is really just caused by the fact that the canApply = > assignment is inside of a nested scope. And the lambda object is dead by the > time matcher.matchAndRewrite is called. I.e., the canApply function_ref > points to an already free'd lambda. At least that's my understanding. Yes, but that's a problem for the call-site, I don't quite see where you make the connection to the signature of `matchAndRewrite`? https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
@@ -572,20 +571,33 @@ bool GreedyPatternRewriteDriver::processWorklist() { logger.getOStream() << ")' {\n"; logger.indent(); }); + if (config.listener) +config.listener->notifyPatternBegin(pattern, op); return true; }; -auto onFailure = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("failure", "pattern failed to match")); -}; -auto onSuccess = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("success", "pattern applied successfully")); - return success(); -}; -#else -function_ref canApply = {}; -function_ref onFailure = {}; -function_ref onSuccess = {}; -#endif +function_ref onFailure = +[&](const Pattern &pattern) { + LLVM_DEBUG(logResult("failure", "pattern failed to match")); + if (config.listener) +config.listener->notifyPatternEnd(pattern, failure()); +}; +function_ref onSuccess = +[&](const Pattern &pattern) { + LLVM_DEBUG(logResult("success", "pattern applied successfully")); + if (config.listener) +config.listener->notifyPatternEnd(pattern, success()); + return success(); +}; + +#ifdef NDEBUG +// Optimization: PatternApplicator callbacks are not needed when running in +// optimized mode and without a listener. +if (!config.listener) { + canApply = nullptr; + onFailure = nullptr; + onSuccess = nullptr; +} +#endif // NDEBUG joker-eph wrote: Note: I didn't suggest changing this, what you had here was reasonable! https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR] Add listener notifications for pattern begin/end (PR #84131)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/84131 ___ 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][IR][NFC] Make `replaceAllUsesWith` non-templatized (PR #84722)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/84722 ___ 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 `replaceAllUsesWith` in dialect conversion (PR #84725)
@@ -751,6 +731,44 @@ class UnresolvedMaterializationRewrite : public OperationRewrite { /// The original output type. This is only used for argument conversions. Type origOutputType; }; + +/// A value rewrite. +class ValueRewrite : public IRRewrite { +public: + /// Return the operation that this rewrite operates on. + Value getValue() const { return value; } + + static bool classof(const IRRewrite *rewrite) { +return rewrite->getKind() >= Kind::ReplaceAllUses && + rewrite->getKind() <= Kind::ReplaceAllUses; + } + +protected: + ValueRewrite(Kind kind, ConversionPatternRewriterImpl &rewriterImpl, + Value value) + : IRRewrite(kind, rewriterImpl), value(value) {} + + // The value that this rewrite operates on. + Value value; +}; + +/// Replacing a value. This rewrite is not immediately reflected in the IR. An +/// internal IR mapping is updated, but the actual replacement is delayed until +/// the rewrite is committed. +class ReplaceAllUsesRewrite : public ValueRewrite { +public: + ReplaceAllUsesRewrite(ConversionPatternRewriterImpl &rewriterImpl, +Value value) + : ValueRewrite(Kind::ReplaceAllUses, rewriterImpl, value) {} + + static bool classof(const IRRewrite *rewrite) { +return rewrite->getKind() == Kind::ReplaceAllUses; + } + + void commit(RewriterBase &rewriter) override; + + void rollback() override; +}; joker-eph wrote: The whole flow of Dialect conversion tracking of these changes is too complicated for me to know whether the commit/rollback logic is safe and complete here :( It's likely that only testing will tell, but that's unfortunate! https://github.com/llvm/llvm-project/pull/84725 ___ 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] release/18.x: [mlir][NFC] Apply rule of five to *Pass classes (#80998) (PR #83971)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/83971 ___ 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][LLVM] erase call mappings in forgetMapping() (PR #84955)
joker-eph wrote: We need a test here https://github.com/llvm/llvm-project/pull/84955 ___ 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] release/18.x: [mlir][NFC] Apply rule of five to *Pass classes (#80998) (PR #83971)
joker-eph wrote: Do we have any ABI stability guarantees for LLVM C++ APIs? I would think that a lot of back ports can break the C++ ABI of LLVM in general? (I was assuming we'd care about the LLVM C API, libclang, ...) https://github.com/llvm/llvm-project/pull/83971 ___ 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][LLVM] erase call mappings in forgetMapping() (PR #84955)
@@ -0,0 +1,47 @@ +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s + +// Test that we don't crash when there is a call operation in the combiner + +omp.reduction.declare @add_f32 : f32 +init { +^bb0(%arg: f32): + %0 = llvm.mlir.constant(0.0 : f32) : f32 + omp.yield (%0 : f32) +} +combiner { +^bb1(%arg0: f32, %arg1: f32): +// test this call here: + llvm.call @test_call() : () -> () + %1 = llvm.fadd %arg0, %arg1 : f32 + omp.yield (%1 : f32) +} +atomic { +^bb2(%arg2: !llvm.ptr, %arg3: !llvm.ptr): + %2 = llvm.load %arg3 : !llvm.ptr -> f32 + llvm.atomicrmw fadd %arg2, %2 monotonic : !llvm.ptr, f32 + omp.yield +} + +llvm.func @simple_reduction(%lb : i64, %ub : i64, %step : i64) { + %c1 = llvm.mlir.constant(1 : i32) : i32 + %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr + omp.parallel { +omp.wsloop reduction(@add_f32 %0 -> %prv : !llvm.ptr) +for (%iv) : i64 = (%lb) to (%ub) step (%step) { + %1 = llvm.mlir.constant(2.0 : f32) : f32 + %2 = llvm.load %prv : !llvm.ptr -> f32 + %3 = llvm.fadd %1, %2 : f32 + llvm.store %3, %prv : f32, !llvm.ptr + omp.yield +} +omp.terminator + } + llvm.return +} + +llvm.func @test_call() -> () joker-eph wrote: This seems quite complex to me: is this the minimum test? Why do we need any OpenMp constructs here? https://github.com/llvm/llvm-project/pull/84955 ___ 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][LLVM] erase call mappings in forgetMapping() (PR #84955)
@@ -0,0 +1,47 @@ +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s + +// Test that we don't crash when there is a call operation in the combiner + +omp.reduction.declare @add_f32 : f32 +init { +^bb0(%arg: f32): + %0 = llvm.mlir.constant(0.0 : f32) : f32 + omp.yield (%0 : f32) +} +combiner { +^bb1(%arg0: f32, %arg1: f32): +// test this call here: + llvm.call @test_call() : () -> () + %1 = llvm.fadd %arg0, %arg1 : f32 + omp.yield (%1 : f32) +} +atomic { +^bb2(%arg2: !llvm.ptr, %arg3: !llvm.ptr): + %2 = llvm.load %arg3 : !llvm.ptr -> f32 + llvm.atomicrmw fadd %arg2, %2 monotonic : !llvm.ptr, f32 + omp.yield +} + +llvm.func @simple_reduction(%lb : i64, %ub : i64, %step : i64) { + %c1 = llvm.mlir.constant(1 : i32) : i32 + %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr + omp.parallel { +omp.wsloop reduction(@add_f32 %0 -> %prv : !llvm.ptr) +for (%iv) : i64 = (%lb) to (%ub) step (%step) { + %1 = llvm.mlir.constant(2.0 : f32) : f32 + %2 = llvm.load %prv : !llvm.ptr -> f32 + %3 = llvm.fadd %1, %2 : f32 + llvm.store %3, %prv : f32, !llvm.ptr + omp.yield +} +omp.terminator + } + llvm.return +} + +llvm.func @test_call() -> () joker-eph wrote: The OpenMP translation predates the LLVMTranslationInterface, but it really should evolve to this model: the OpenMP specific component should be better identified and isolated really. Anyway that's not a thing for this PR, thank for clarifying! https://github.com/llvm/llvm-project/pull/84955 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter &printer) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter &os) const override; joker-eph wrote: Nit: you are defining this dialect in the ::mlir::cir namespace, so you can remove the ::mlir:: prefix everywhere here. https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,16 @@ +# This replicates part of the add_mlir_dialect cmake function from MLIR that +# cannot be used here. This happens because it expects to be run inside MLIR +# directory which is not the case for CIR (and also FIR, both have similar +# workarounds). + +# Equivalent to add_mlir_dialect(CIROps cir) +set(LLVM_TARGET_DEFINITIONS CIROps.td) +mlir_tablegen(CIROps.h.inc -gen-op-decls) +mlir_tablegen(CIROps.cpp.inc -gen-op-defs) +mlir_tablegen(CIROpsTypes.h.inc -gen-typedef-decls) +mlir_tablegen(CIROpsTypes.cpp.inc -gen-typedef-defs) +mlir_tablegen(CIROpsDialect.h.inc -gen-dialect-decls) +mlir_tablegen(CIROpsDialect.cpp.inc -gen-dialect-defs) +add_public_tablegen_target(MLIRCIROpsIncGen) +add_dependencies(mlir-headers MLIRCIROpsIncGen) joker-eph wrote: You're not generating the dialect doc? https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS joker-eph wrote: It not "as well", I believe it should be "instead of `MLIR_`" here? Also `IR` is missing, the path mangles into `CLANG_CIR_DIALECT_IR_CIR_OPS_TD` I think? https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; joker-eph wrote: If the comment is on the TableGen code: you don't have a choice here because you're implement the ODS API. These aren't just "data member", they are actually "magic" names used by the tablegen backend. For the C++ code a few lines below, function like `printType()` are override of virtual methods defined in MLIR. https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,16 @@ +# This replicates part of the add_mlir_dialect cmake function from MLIR that +# cannot be used here. This happens because it expects to be run inside MLIR +# directory which is not the case for CIR (and also FIR, both have similar +# workarounds). + +# Equivalent to add_mlir_dialect(CIROps cir) +set(LLVM_TARGET_DEFINITIONS CIROps.td) +mlir_tablegen(CIROps.h.inc -gen-op-decls) +mlir_tablegen(CIROps.cpp.inc -gen-op-defs) +mlir_tablegen(CIROpsTypes.h.inc -gen-typedef-decls) +mlir_tablegen(CIROpsTypes.cpp.inc -gen-typedef-defs) +mlir_tablegen(CIROpsDialect.h.inc -gen-dialect-decls) +mlir_tablegen(CIROpsDialect.cpp.inc -gen-dialect-defs) +add_public_tablegen_target(MLIRCIROpsIncGen) +add_dependencies(mlir-headers MLIRCIROpsIncGen) joker-eph wrote: Also: can these lines be abstracted by just calling the `add_mlir_dialect` macro? https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; joker-eph wrote: Yes, in the early months of MLIR, there was a big discussion on llvm-dev@ about changing the naming convention to start with lower-cases. And it seemed to us that it converged and so on our side we anticipated and updated all the codebase to use the "new" convention. However this didn't carry forward, I don't remember why... (The plan was even documented: https://llvm.org/docs/Proposals/VariableNames.html ) https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; joker-eph wrote: Thread: https://groups.google.com/g/llvm-dev/c/i7TLvzd1OAw/m/cJg8sGnMDAAJ https://github.com/llvm/llvm-project/pull/86080 ___ 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] release/18.x: [ODS][NFC] Cast range.size() to int32_t in accumulation (#85629) (PR #86677)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/86677 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [MLIR][OpenMP] Introduce the LoopWrapperInterface (PR #87232)
@@ -69,6 +69,74 @@ def ReductionClauseInterface : OpInterface<"ReductionClauseInterface"> { ]; } +def LoopWrapperInterface : OpInterface<"LoopWrapperInterface"> { + let description = [{ +OpenMP operations that can wrap a single loop nest. When taking a wrapper +role, these operations must only contain a single region with a single block +in which there's a single operation and a terminator. That nested operation +must be another loop wrapper or an `omp.loop_nest`. + }]; + + let cppNamespace = "::mlir::omp"; + + let methods = [ +InterfaceMethod< + /*description=*/[{ +Tell whether the operation could be taking the role of a loop wrapper. +That is, it has a single region with a single block in which there are +two operations: another wrapper or `omp.loop_nest` operation and a +terminator. + }], + /*retTy=*/"bool", + /*methodName=*/"isWrapper", + (ins ), [{}], [{ +if ($_op->getNumRegions() != 1) + return false; + +::mlir::Region &r = $_op->getRegion(0); joker-eph wrote: It depends if anyone outside of this dialect could also implement this interface? (if not then why is it in the public header directory though?) Another dialect implementing this interface could be in another namespace and see this kind of code injected potentially. https://github.com/llvm/llvm-project/pull/87232 ___ 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][Interfaces] `ValueBoundsOpInterface`: Fix typo (PR #87976)
joker-eph wrote: Can you provide a test that exercises this? Thanks! https://github.com/llvm/llvm-project/pull/87976 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,44 @@ +//===- CIRDialect.td - CIR dialect -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file declares the CIR dialect. +// +//===--===// + +#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT +#define LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +Type parseType(DialectAsmParser &parser) const override; joker-eph wrote: This will be added to generated class which have lower-case starting APIs: consistency within the class seems to prevail to me. You should really expect that all the MLIR code will follow this convention, because it'll be intertwined closely with the MLIR framework. https://github.com/llvm/llvm-project/pull/86080 ___ 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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,44 @@ +//===- CIRDialect.td - CIR dialect -*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file declares the CIR dialect. +// +//===--===// + +#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT +#define LLVM_CLANG_CIR_DIALECT_IR_CIRDIALECT + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +Type parseType(DialectAsmParser &parser) const override; joker-eph wrote: I think I mentioned it elsewhere, but worth keeping in mind: MLIR didn't intend to diverge from LLVM, it started about at the time where there was this plan to adopt a new style for LLVM: https://llvm.org/docs/Proposals/VariableNames.html So we thought we were just adopting the "new coding style" to limit churn, and unfortunately this didn't pan out for the whole codebase (I think lldb and lld are also using this style now) https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [mlir] [mlir][test] Shard and reorganize the test dialect (PR #89424)
@@ -228,6 +332,7 @@ void TestDialect::initialize() { >(); registerOpsSyntax(); addOperations(); + registerTestDialectOperations(this); joker-eph wrote: This the actual "magic" right? You're calling into the generated registration method which dispatch to the shards? What does the: ``` addOperations< #define GET_OP_LIST #include "TestOps.cpp.inc" >(); ``` still do above? https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
joker-eph wrote: LG, but please make sure to remove all spurious headers from the commit description (seems like it should start at "This PR massively ...") https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][test] Reorganize the test dialect (PR #89424)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/89424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir] Revise IDE folder structure (PR #89749)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/89749 ___ 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] Backport into 17.x : [mlir][nfc] Allow ops to have operands/attributes named `context`. (PR #65281)
https://github.com/joker-eph review_requested https://github.com/llvm/llvm-project/pull/65281 ___ 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] Backport into 17.x : [mlir][nfc] Allow ops to have operands/attributes named `context`. (PR #65281)
https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/65281: This is important to back port because it'll help adopting MLIR "properties" which became the default in LLVM 18 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D159185 >From 1810c14ff5f3a0a34b8a4c858f51f15264236eba Mon Sep 17 00:00:00 2001 From: Christian Sigg Date: Wed, 30 Aug 2023 12:23:25 +0200 Subject: [PATCH] [mlir][nfc] Allow ops to have operands/attributes named `context`. This is probably a bad idea, but it's only become a problem with properties and is easy to fix. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D159185 --- mlir/include/mlir/IR/OperationSupport.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index f3a79eb52f8ec00..adae3560570ddca 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -555,7 +555,7 @@ class RegisteredOperationName : public OperationName { StringRef name) final { if constexpr (hasProperties) { auto concreteOp = cast(op); -return ConcreteOp::getInherentAttr(concreteOp.getContext(), +return ConcreteOp::getInherentAttr(concreteOp->getContext(), concreteOp.getProperties(), name); } // If the op does not have support for properties, we dispatch back to the @@ -576,7 +576,7 @@ class RegisteredOperationName : public OperationName { void populateInherentAttrs(Operation *op, NamedAttrList &attrs) final { if constexpr (hasProperties) { auto concreteOp = cast(op); -ConcreteOp::populateInherentAttrs(concreteOp.getContext(), +ConcreteOp::populateInherentAttrs(concreteOp->getContext(), concreteOp.getProperties(), attrs); } } ___ 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] f013914 - [𝘀𝗽𝗿] initial version
Author: Mehdi Amini Date: 2023-11-03T03:07:29-07:00 New Revision: f013914def456db56fe6aeacacafb200cc11fe0e URL: https://github.com/llvm/llvm-project/commit/f013914def456db56fe6aeacacafb200cc11fe0e DIFF: https://github.com/llvm/llvm-project/commit/f013914def456db56fe6aeacacafb200cc11fe0e.diff LOG: [𝘀𝗽𝗿] initial version Created using spr 1.3.4 Added: Modified: llvm/CMakeLists.txt llvm/include/llvm/Config/llvm-config.h.cmake Removed: diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 292efa3316df748..7ff3acd48304de7 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -955,6 +955,8 @@ foreach(t ${LLVM_TARGETS_TO_BUILD}) endif() else() set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n") +string(TOUPPER ${t} T_UPPER) +set(LLVM_HAS_${T_UPPER}_TARGET 1) endif() file(GLOB asmp_file "${td}/*AsmPrinter.cpp") diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 17b2d47fb6c43a3..6605ea60df99e14 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -54,6 +54,81 @@ /* LLVM name for the native target MCA init function, if available */ #cmakedefine LLVM_NATIVE_TARGETMCA LLVMInitialize${LLVM_NATIVE_ARCH}TargetMCA +/* Define if the AArch64 target is built in */ +#cmakedefine01 LLVM_HAS_AARCH64_TARGET + +/* Define if the AMDGPU target is built in */ +#cmakedefine01 LLVM_HAS_AMDGPU_TARGET + +/* Define if the ARC target is built in */ +#cmakedefine01 LLVM_HAS_ARC_TARGET + +/* Define if the ARM target is built in */ +#cmakedefine01 LLVM_HAS_ARM_TARGET + +/* Define if the AVR target is built in */ +#cmakedefine01 LLVM_HAS_AVR_TARGET + +/* Define if the BPF target is built in */ +#cmakedefine01 LLVM_HAS_BPF_TARGET + +/* Define if the CSKY target is built in */ +#cmakedefine01 LLVM_HAS_CSKY_TARGET + +/* Define if the DirectX target is built in */ +#cmakedefine01 LLVM_HAS_DIRECTX_TARGET + +/* Define if the Hexagon target is built in */ +#cmakedefine01 LLVM_HAS_HEXAGON_TARGET + +/* Define if the Lanai target is built in */ +#cmakedefine01 LLVM_HAS_LANAI_TARGET + +/* Define if the LoongArch target is built in */ +#cmakedefine01 LLVM_HAS_LOONGARCH_TARGET + +/* Define if the M68k target is built in */ +#cmakedefine01 LLVM_HAS_M68K_TARGET + +/* Define if the Mips target is built in */ +#cmakedefine01 LLVM_HAS_MIPS_TARGET + +/* Define if the MSP430 target is built in */ +#cmakedefine01 LLVM_HAS_MSP430_TARGET + +/* Define if the NVPTX target is built in */ +#cmakedefine01 LLVM_HAS_NVPTX_TARGET + +/* Define if the PowerPC target is built in */ +#cmakedefine01 LLVM_HAS_POWERPC_TARGET + +/* Define if the RISCV target is built in */ +#cmakedefine01 LLVM_HAS_RISCV_TARGET + +/* Define if the Sparc target is built in */ +#cmakedefine01 LLVM_HAS_SPARC_TARGET + +/* Define if the SPIRV target is built in */ +#cmakedefine01 LLVM_HAS_SPIRV_TARGET + +/* Define if the SystemZ target is built in */ +#cmakedefine01 LLVM_HAS_SYSTEMZ_TARGET + +/* Define if the VE target is built in */ +#cmakedefine01 LLVM_HAS_VE_TARGET + +/* Define if the WebAssembly target is built in */ +#cmakedefine01 LLVM_HAS_WEBASSEMBLY_TARGET + +/* Define if the X86 target is built in */ +#cmakedefine01 LLVM_HAS_X86_TARGET + +/* Define if the XCore target is built in */ +#cmakedefine01 LLVM_HAS_XCORE_TARGET + +/* Define if the Xtensa target is built in */ +#cmakedefine01 LLVM_HAS_XTENSA_TARGET + /* Define if this is Unixish platform */ #cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX} ___ 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] 0267760 - [𝘀𝗽𝗿] initial version
Author: Mehdi Amini Date: 2023-11-03T03:07:34-07:00 New Revision: 0267760d2726671d76bb8d3adfe0b981288b3fb6 URL: https://github.com/llvm/llvm-project/commit/0267760d2726671d76bb8d3adfe0b981288b3fb6 DIFF: https://github.com/llvm/llvm-project/commit/0267760d2726671d76bb8d3adfe0b981288b3fb6.diff LOG: [𝘀𝗽𝗿] initial version Created using spr 1.3.4 Added: Modified: llvm/CMakeLists.txt llvm/include/llvm/Config/llvm-config.h.cmake mlir/include/mlir/Target/LLVM/ModuleToObject.h mlir/include/mlir/Target/LLVM/NVVM/Utils.h mlir/include/mlir/Target/LLVM/ROCDL/Utils.h mlir/lib/Conversion/GPUCommon/CMakeLists.txt mlir/lib/Dialect/GPU/CMakeLists.txt mlir/lib/Target/LLVM/CMakeLists.txt mlir/lib/Target/LLVM/ModuleToObject.cpp mlir/lib/Target/LLVM/NVVM/Target.cpp mlir/lib/Target/LLVM/ROCDL/Target.cpp Removed: diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 292efa3316df748..7ff3acd48304de7 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -955,6 +955,8 @@ foreach(t ${LLVM_TARGETS_TO_BUILD}) endif() else() set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n") +string(TOUPPER ${t} T_UPPER) +set(LLVM_HAS_${T_UPPER}_TARGET 1) endif() file(GLOB asmp_file "${td}/*AsmPrinter.cpp") diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 17b2d47fb6c43a3..6605ea60df99e14 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -54,6 +54,81 @@ /* LLVM name for the native target MCA init function, if available */ #cmakedefine LLVM_NATIVE_TARGETMCA LLVMInitialize${LLVM_NATIVE_ARCH}TargetMCA +/* Define if the AArch64 target is built in */ +#cmakedefine01 LLVM_HAS_AARCH64_TARGET + +/* Define if the AMDGPU target is built in */ +#cmakedefine01 LLVM_HAS_AMDGPU_TARGET + +/* Define if the ARC target is built in */ +#cmakedefine01 LLVM_HAS_ARC_TARGET + +/* Define if the ARM target is built in */ +#cmakedefine01 LLVM_HAS_ARM_TARGET + +/* Define if the AVR target is built in */ +#cmakedefine01 LLVM_HAS_AVR_TARGET + +/* Define if the BPF target is built in */ +#cmakedefine01 LLVM_HAS_BPF_TARGET + +/* Define if the CSKY target is built in */ +#cmakedefine01 LLVM_HAS_CSKY_TARGET + +/* Define if the DirectX target is built in */ +#cmakedefine01 LLVM_HAS_DIRECTX_TARGET + +/* Define if the Hexagon target is built in */ +#cmakedefine01 LLVM_HAS_HEXAGON_TARGET + +/* Define if the Lanai target is built in */ +#cmakedefine01 LLVM_HAS_LANAI_TARGET + +/* Define if the LoongArch target is built in */ +#cmakedefine01 LLVM_HAS_LOONGARCH_TARGET + +/* Define if the M68k target is built in */ +#cmakedefine01 LLVM_HAS_M68K_TARGET + +/* Define if the Mips target is built in */ +#cmakedefine01 LLVM_HAS_MIPS_TARGET + +/* Define if the MSP430 target is built in */ +#cmakedefine01 LLVM_HAS_MSP430_TARGET + +/* Define if the NVPTX target is built in */ +#cmakedefine01 LLVM_HAS_NVPTX_TARGET + +/* Define if the PowerPC target is built in */ +#cmakedefine01 LLVM_HAS_POWERPC_TARGET + +/* Define if the RISCV target is built in */ +#cmakedefine01 LLVM_HAS_RISCV_TARGET + +/* Define if the Sparc target is built in */ +#cmakedefine01 LLVM_HAS_SPARC_TARGET + +/* Define if the SPIRV target is built in */ +#cmakedefine01 LLVM_HAS_SPIRV_TARGET + +/* Define if the SystemZ target is built in */ +#cmakedefine01 LLVM_HAS_SYSTEMZ_TARGET + +/* Define if the VE target is built in */ +#cmakedefine01 LLVM_HAS_VE_TARGET + +/* Define if the WebAssembly target is built in */ +#cmakedefine01 LLVM_HAS_WEBASSEMBLY_TARGET + +/* Define if the X86 target is built in */ +#cmakedefine01 LLVM_HAS_X86_TARGET + +/* Define if the XCore target is built in */ +#cmakedefine01 LLVM_HAS_XCORE_TARGET + +/* Define if the Xtensa target is built in */ +#cmakedefine01 LLVM_HAS_XTENSA_TARGET + /* Define if this is Unixish platform */ #cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX} diff --git a/mlir/include/mlir/Target/LLVM/ModuleToObject.h b/mlir/include/mlir/Target/LLVM/ModuleToObject.h index d17afc1077fb45d..e40d7e9a43dd6b5 100644 --- a/mlir/include/mlir/Target/LLVM/ModuleToObject.h +++ b/mlir/include/mlir/Target/LLVM/ModuleToObject.h @@ -31,7 +31,7 @@ class ModuleToObject { public: ModuleToObject(Operation &module, StringRef triple, StringRef chip, StringRef features = {}, int optLevel = 3); - virtual ~ModuleToObject() = default; + virtual ~ModuleToObject(); /// Returns the operation being serialized. Operation &getOperation(); @@ -42,44 +42,43 @@ class ModuleToObject { protected: // Hooks to be implemented by derived classes. + /// Hook for computing the Datalayout + virtual void setDataLayoutAndTriple(llvm::Module &module); + /// Hook for loading bitcode files, returns std::nullopt on failure. virtual std::optional>> - loadBitcodeFiles(llvm::M
[llvm-branch-commits] [llvm] [mlir] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)
https://github.com/joker-eph created https://github.com/llvm/llvm-project/pull/71165 Some specific implementation of the offload may want more customization, and even avoid using LLVM in-tree to dispatch the ISA translation to a custom solution. This refactoring makes it possible for such implementation to work without even configuring the target backend in LLVM. ___ 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] [clang] [llvm] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/71165 ___ 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] 3289ecf - [𝘀𝗽𝗿] changes introduced through rebase
Author: Mehdi Amini Date: 2023-11-03T03:23:43-07:00 New Revision: 3289ecff8e8f5022cb6a40777392c98f1bcf5780 URL: https://github.com/llvm/llvm-project/commit/3289ecff8e8f5022cb6a40777392c98f1bcf5780 DIFF: https://github.com/llvm/llvm-project/commit/3289ecff8e8f5022cb6a40777392c98f1bcf5780.diff LOG: [𝘀𝗽𝗿] changes introduced through rebase Created using spr 1.3.4 [skip ci] Added: Modified: clang/test/OpenMP/cancel_codegen.cpp clang/test/OpenMP/parallel_codegen.cpp llvm/lib/IR/ConstantFold.cpp mlir/include/mlir/Conversion/Passes.td mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp mlir/test/Conversion/VectorToLLVM/vector-mask-to-llvm.mlir mlir/test/Conversion/VectorToLLVM/vector-reduction-to-llvm.mlir mlir/test/Conversion/VectorToLLVM/vector-scalable-memcpy.mlir mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir Removed: mlir/test/Conversion/VectorToLLVM/typed-pointers.mlir diff --git a/clang/test/OpenMP/cancel_codegen.cpp b/clang/test/OpenMP/cancel_codegen.cpp index 53580e0c2b0293f..03024cf331b2717 100644 --- a/clang/test/OpenMP/cancel_codegen.cpp +++ b/clang/test/OpenMP/cancel_codegen.cpp @@ -1026,25 +1026,25 @@ for (int i = 0; i < argc; ++i) { // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata [[META8:![0-9]+]]) // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata [[META10:![0-9]+]]) // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata [[META12:![0-9]+]]) -// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, !noalias !14 -// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, !noalias !14 +// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, !noalias ![[NOALIAS0:[0-9]+]] +// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, !noalias ![[NOALIAS0]] // CHECK3-NEXT:[[OMP_GLOBAL_THREAD_NUM_I:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB12:[0-9]+]]) // CHECK3-NEXT:[[TMP9:%.*]] = call i32 @__kmpc_cancel(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM_I]], i32 4) // CHECK3-NEXT:[[TMP10:%.*]] = icmp ne i32 [[TMP9]], 0 // CHECK3-NEXT:br i1 [[TMP10]], label [[DOTCANCEL_EXIT_I:%.*]], label [[DOTCANCEL_CONTINUE_I:%.*]] // CHECK3: .cancel.exit.i: -// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14 +// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1:[0-9]+]] // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT:%.*]] // CHECK3: .cancel.continue.i: -// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14 +// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]] // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT]] // CHECK3: .omp_outlined..exit: -// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14 +// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]] // CHECK3-NEXT:ret i32 0 // // diff --git a/clang/test/OpenMP/parallel_codegen.cpp b/clang/test/OpenMP/parallel_codegen.cpp index 5c98761be0808ef..d545b4a9d9fa887 100644 --- a/clang/test/OpenMP/parallel_codegen.cpp +++ b/clang/test/OpenMP/parallel_codegen.cpp @@ -812,7 +812,7 @@ int main (int argc, char **argv) { // // // CHECK3-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par -// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], ptr [[TMP0:%.*]]) #[[ATTR1]] { +// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]] // CHECK3-NEXT: omp.par.entry: // CHECK3-NEXT:[[GEP__RELOADED:%.*]] = getelementptr { ptr, ptr }, ptr [[TMP0]], i32 0, i32 0 // CHECK3-NEXT:
[llvm-branch-commits] [clang] b7e4dc7 - rebase
Author: Mehdi Amini Date: 2023-11-03T03:23:50-07:00 New Revision: b7e4dc73442b986e8effe80afdd7bb409d0a367b URL: https://github.com/llvm/llvm-project/commit/b7e4dc73442b986e8effe80afdd7bb409d0a367b DIFF: https://github.com/llvm/llvm-project/commit/b7e4dc73442b986e8effe80afdd7bb409d0a367b.diff LOG: rebase Created using spr 1.3.4 Added: Modified: clang/test/OpenMP/cancel_codegen.cpp clang/test/OpenMP/parallel_codegen.cpp llvm/lib/IR/ConstantFold.cpp mlir/include/mlir/Conversion/Passes.td mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp mlir/test/Conversion/VectorToLLVM/vector-mask-to-llvm.mlir mlir/test/Conversion/VectorToLLVM/vector-reduction-to-llvm.mlir mlir/test/Conversion/VectorToLLVM/vector-scalable-memcpy.mlir mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir Removed: mlir/test/Conversion/VectorToLLVM/typed-pointers.mlir diff --git a/clang/test/OpenMP/cancel_codegen.cpp b/clang/test/OpenMP/cancel_codegen.cpp index 53580e0c2b0293f..03024cf331b2717 100644 --- a/clang/test/OpenMP/cancel_codegen.cpp +++ b/clang/test/OpenMP/cancel_codegen.cpp @@ -1026,25 +1026,25 @@ for (int i = 0; i < argc; ++i) { // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata [[META8:![0-9]+]]) // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata [[META10:![0-9]+]]) // CHECK3-NEXT:call void @llvm.experimental.noalias.scope.decl(metadata [[META12:![0-9]+]]) -// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, !noalias !14 -// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, !noalias !14 -// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, !noalias !14 +// CHECK3-NEXT:store i32 [[TMP2]], ptr [[DOTGLOBAL_TID__ADDR_I]], align 4, !noalias ![[NOALIAS0:[0-9]+]] +// CHECK3-NEXT:store ptr [[TMP5]], ptr [[DOTPART_ID__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr null, ptr [[DOTPRIVATES__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr null, ptr [[DOTCOPY_FN__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr [[TMP3]], ptr [[DOTTASK_T__ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:store ptr [[TMP7]], ptr [[__CONTEXT_ADDR_I]], align 8, !noalias ![[NOALIAS0]] +// CHECK3-NEXT:[[TMP8:%.*]] = load ptr, ptr [[__CONTEXT_ADDR_I]], align 8, !noalias ![[NOALIAS0]] // CHECK3-NEXT:[[OMP_GLOBAL_THREAD_NUM_I:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB12:[0-9]+]]) // CHECK3-NEXT:[[TMP9:%.*]] = call i32 @__kmpc_cancel(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM_I]], i32 4) // CHECK3-NEXT:[[TMP10:%.*]] = icmp ne i32 [[TMP9]], 0 // CHECK3-NEXT:br i1 [[TMP10]], label [[DOTCANCEL_EXIT_I:%.*]], label [[DOTCANCEL_CONTINUE_I:%.*]] // CHECK3: .cancel.exit.i: -// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14 +// CHECK3-NEXT:store i32 1, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1:[0-9]+]] // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT:%.*]] // CHECK3: .cancel.continue.i: -// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14 +// CHECK3-NEXT:store i32 0, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]] // CHECK3-NEXT:br label [[DOTOMP_OUTLINED__EXIT]] // CHECK3: .omp_outlined..exit: -// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias !14 +// CHECK3-NEXT:[[CLEANUP_DEST_I:%.*]] = load i32, ptr [[CLEANUP_DEST_SLOT_I]], align 4, !noalias ![[NOALIAS1]] // CHECK3-NEXT:ret i32 0 // // diff --git a/clang/test/OpenMP/parallel_codegen.cpp b/clang/test/OpenMP/parallel_codegen.cpp index 5c98761be0808ef..d545b4a9d9fa887 100644 --- a/clang/test/OpenMP/parallel_codegen.cpp +++ b/clang/test/OpenMP/parallel_codegen.cpp @@ -812,7 +812,7 @@ int main (int argc, char **argv) { // // // CHECK3-LABEL: define {{[^@]+}}@_Z5tmainIPPcEiT_..omp_par -// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], ptr [[TMP0:%.*]]) #[[ATTR1]] { +// CHECK3-SAME: (ptr noalias [[TID_ADDR:%.*]], ptr noalias [[ZERO_ADDR:%.*]], ptr [[TMP0:%.*]]) #[[ATTR2:[0-9]+]] // CHECK3-NEXT: omp.par.entry: // CHECK3-NEXT:[[GEP__RELOADED:%.*]] = getelementptr { ptr, ptr }, ptr [[TMP0]], i32 0, i32 0 // CHECK3-NEXT:[[LOADGEP__RELOADED:%.*]] = load ptr, ptr [
[llvm-branch-commits] [clang] [mlir] [llvm] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)
@@ -39,32 +39,32 @@ ModuleToObject::ModuleToObject(Operation &module, StringRef triple, : module(module), triple(triple), chip(chip), features(features), optLevel(optLevel) {} +ModuleToObject::~ModuleToObject() = default; + Operation &ModuleToObject::getOperation() { return module; } -std::unique_ptr ModuleToObject::createTargetMachine() { +std::optional +ModuleToObject::getOrCreateTargetMachine() { std::string error; joker-eph wrote: Thanks! https://github.com/llvm/llvm-project/pull/71165 ___ 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] 183f509 - use cached TM
Author: Mehdi Amini Date: 2023-11-03T13:26:56-07:00 New Revision: 183f5094ff7da09beed46f760a857af449a24245 URL: https://github.com/llvm/llvm-project/commit/183f5094ff7da09beed46f760a857af449a24245 DIFF: https://github.com/llvm/llvm-project/commit/183f5094ff7da09beed46f760a857af449a24245.diff LOG: use cached TM Created using spr 1.3.4 Added: Modified: mlir/lib/Target/LLVM/ModuleToObject.cpp Removed: diff --git a/mlir/lib/Target/LLVM/ModuleToObject.cpp b/mlir/lib/Target/LLVM/ModuleToObject.cpp index 6af3d49ab23bf74..d94c10de8d7c424 100644 --- a/mlir/lib/Target/LLVM/ModuleToObject.cpp +++ b/mlir/lib/Target/LLVM/ModuleToObject.cpp @@ -45,8 +45,10 @@ Operation &ModuleToObject::getOperation() { return module; } std::optional ModuleToObject::getOrCreateTargetMachine() { - std::string error; + if (targetMachine) +return targetMachine.get(); // Load the target. + std::string error; const llvm::Target *target = llvm::TargetRegistry::lookupTarget(triple, error); if (!target) { ___ 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] [clang] [mlir] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/71165 >From 183f5094ff7da09beed46f760a857af449a24245 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 3 Nov 2023 13:26:56 -0700 Subject: [PATCH] use cached TM Created using spr 1.3.4 --- mlir/lib/Target/LLVM/ModuleToObject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Target/LLVM/ModuleToObject.cpp b/mlir/lib/Target/LLVM/ModuleToObject.cpp index 6af3d49ab23bf74..d94c10de8d7c424 100644 --- a/mlir/lib/Target/LLVM/ModuleToObject.cpp +++ b/mlir/lib/Target/LLVM/ModuleToObject.cpp @@ -45,8 +45,10 @@ Operation &ModuleToObject::getOperation() { return module; } std::optional ModuleToObject::getOrCreateTargetMachine() { - std::string error; + if (targetMachine) +return targetMachine.get(); // Load the target. + std::string error; const llvm::Target *target = llvm::TargetRegistry::lookupTarget(triple, error); if (!target) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-tools-extra] [llvm] [flang] [lldb] [mlir] [libcxx] [compiler-rt] [libcxxabi] [lld] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/71165 >From 183f5094ff7da09beed46f760a857af449a24245 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 3 Nov 2023 13:26:56 -0700 Subject: [PATCH] use cached TM Created using spr 1.3.4 --- mlir/lib/Target/LLVM/ModuleToObject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Target/LLVM/ModuleToObject.cpp b/mlir/lib/Target/LLVM/ModuleToObject.cpp index 6af3d49ab23bf74..d94c10de8d7c424 100644 --- a/mlir/lib/Target/LLVM/ModuleToObject.cpp +++ b/mlir/lib/Target/LLVM/ModuleToObject.cpp @@ -45,8 +45,10 @@ Operation &ModuleToObject::getOperation() { return module; } std::optional ModuleToObject::getOrCreateTargetMachine() { - std::string error; + if (targetMachine) +return targetMachine.get(); // Load the target. + std::string error; const llvm::Target *target = llvm::TargetRegistry::lookupTarget(triple, error); if (!target) { ___ 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] 6542aad - [𝘀𝗽𝗿] initial version
Author: Florian Hahn Date: 2023-11-03T13:31:37-07:00 New Revision: 6542aad3fd2f8a158f6c2180b44c875144670dec URL: https://github.com/llvm/llvm-project/commit/6542aad3fd2f8a158f6c2180b44c875144670dec DIFF: https://github.com/llvm/llvm-project/commit/6542aad3fd2f8a158f6c2180b44c875144670dec.diff LOG: [𝘀𝗽𝗿] initial version Created using spr 1.3.4 Added: Modified: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll Removed: diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 4f547886f602534..1c208f72af678f7 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1103,7 +1103,8 @@ void InnerLoopVectorizer::collectPoisonGeneratingRecipes( if (auto *RecWithFlags = dyn_cast(CurRec)) { RecWithFlags->dropPoisonGeneratingFlags(); } else { -Instruction *Instr = CurRec->getUnderlyingInstr(); +Instruction *Instr = dyn_cast_or_null( +CurRec->getVPSingleValue()->getUnderlyingValue()); (void)Instr; assert((!Instr || !Instr->hasPoisonGeneratingFlags()) && "found instruction with poison generating flags not covered by " diff --git a/llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll b/llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll index b440da6dd866081..5694367dd1f9016 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll +++ b/llvm/test/Transforms/LoopVectorize/X86/drop-poison-generating-flags.ll @@ -405,6 +405,89 @@ loop.exit: ret void } +@c = external global [5 x i8] + +; Test case for https://github.com/llvm/llvm-project/issues/70590. +; Note that the then block has UB, but I could not find any other way to +; construct a suitable test case. +define void @pr70590_recipe_without_underlying_instr(i64 %n, ptr noalias %dst) { +; CHECK-LABEL: @pr70590_recipe_without_underlying_instr( +; CHECK: vector.body: +; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH:%.+]] ], [ [[INDEX_NEXT:%.*]], [[PRED_SREM_CONTINUE6:%.*]] ] +; CHECK-NEXT:[[VEC_IND:%.*]] = phi <4 x i64> [ , [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[PRED_SREM_CONTINUE6]] ] +; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[INDEX]], 0 +; CHECK-NEXT:[[TMP1:%.*]] = icmp eq <4 x i64> [[VEC_IND]], +; CHECK-NEXT:[[TMP2:%.*]] = xor <4 x i1> [[TMP1]], +; CHECK-NEXT:[[TMP3:%.*]] = extractelement <4 x i1> [[TMP2]], i32 0 +; CHECK-NEXT:br i1 [[TMP3]], label [[PRED_SREM_IF:%.*]], label [[PRED_SREM_CONTINUE:%.*]] +; CHECK: pred.srem.if: +; CHECK-NEXT:[[TMP4:%.*]] = srem i64 3, 0 +; CHECK-NEXT:br label [[PRED_SREM_CONTINUE]] +; CHECK: pred.srem.continue: +; CHECK-NEXT:[[TMP5:%.*]] = phi i64 [ poison, %vector.body ], [ [[TMP4]], [[PRED_SREM_IF]] ] +; CHECK-NEXT:[[TMP6:%.*]] = extractelement <4 x i1> [[TMP2]], i32 1 +; CHECK-NEXT:br i1 [[TMP6]], label [[PRED_SREM_IF1:%.*]], label [[PRED_SREM_CONTINUE2:%.*]] +; CHECK: pred.srem.if1: +; CHECK-NEXT:[[TMP7:%.*]] = srem i64 3, 0 +; CHECK-NEXT:br label [[PRED_SREM_CONTINUE2]] +; CHECK: pred.srem.continue2: +; CHECK-NEXT:[[TMP8:%.*]] = phi i64 [ poison, [[PRED_SREM_CONTINUE]] ], [ [[TMP7]], [[PRED_SREM_IF1]] ] +; CHECK-NEXT:[[TMP9:%.*]] = extractelement <4 x i1> [[TMP2]], i32 2 +; CHECK-NEXT:br i1 [[TMP9]], label [[PRED_SREM_IF3:%.*]], label [[PRED_SREM_CONTINUE4:%.*]] +; CHECK: pred.srem.if3: +; CHECK-NEXT:[[TMP10:%.*]] = srem i64 3, 0 +; CHECK-NEXT:br label [[PRED_SREM_CONTINUE4]] +; CHECK: pred.srem.continue4: +; CHECK-NEXT:[[TMP11:%.*]] = phi i64 [ poison, [[PRED_SREM_CONTINUE2]] ], [ [[TMP10]], [[PRED_SREM_IF3]] ] +; CHECK-NEXT:[[TMP12:%.*]] = extractelement <4 x i1> [[TMP2]], i32 3 +; CHECK-NEXT:br i1 [[TMP12]], label [[PRED_SREM_IF5:%.*]], label [[PRED_SREM_CONTINUE6]] +; CHECK: pred.srem.if5: +; CHECK-NEXT:[[TMP13:%.*]] = srem i64 3, 0 +; CHECK-NEXT:br label [[PRED_SREM_CONTINUE6]] +; CHECK: pred.srem.continue6: +; CHECK-NEXT:[[TMP14:%.*]] = phi i64 [ poison, [[PRED_SREM_CONTINUE4]] ], [ [[TMP13]], [[PRED_SREM_IF5]] ] +; CHECK-NEXT:[[TMP15:%.*]] = add i64 [[TMP5]], -3 +; CHECK-NEXT:[[TMP16:%.*]] = add i64 [[TMP0]], [[TMP15]] +; CHECK-NEXT:[[TMP17:%.*]] = getelementptr [5 x i8], ptr @c, i64 0, i64 [[TMP16]] +; CHECK-NEXT:[[TMP18:%.*]] = getelementptr i8, ptr [[TMP17]], i32 0 +; CHECK-NEXT:[[WIDE_LOAD:%.*]] = load <4 x i8>, ptr [[TMP18]], align 1 +; CHECK-NEXT:[[PREDPHI:%.*]] = select <4 x i1> [[TMP2]], <4 x i8> [[WIDE_LOAD]], <4 x i8> zeroinitializer +; CHECK-NEXT:[[TMP19:%.*]] = getelementptr i8, ptr %dst, i64 [[TMP0]] +; CHECK-NEXT:[[TMP20:%.*]] = getelementptr i8, ptr [[TMP1
[llvm-branch-commits] [mlir] [mlir] Start moving some builtin type formats to the dialect (PR #80421)
@@ -25,7 +25,8 @@ include "mlir/IR/BuiltinTypeInterfaces.td" // Base class for Builtin dialect types. class Builtin_Type traits = [], string baseCppClass = "::mlir::Type"> -: TypeDef { +: TypeDefhttps://github.com/llvm/llvm-project/pull/80421 ___ 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] Dialect conversion: Cache `UnresolvedMaterializationRewrite` (PR #108359)
@@ -935,8 +909,10 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener { /// to modify/access them is invalid rewriter API usage. SetVector replacedOps; - /// A set of all unresolved materializations. - DenseSet unresolvedMaterializations; + /// A mapping of all unresolved materializations (UnrealizedConversionCastOp) + /// to the corresponding rewrite objects. + DenseMap joker-eph wrote: Can the key be directly `UnrealizedConversionCastOp` ? https://github.com/llvm/llvm-project/pull/108359 ___ 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] Dialect conversion: Cache `UnresolvedMaterializationRewrite` (PR #108359)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/108359 ___ 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] Dialect conversion: Unify materialization of value replacements (PR #108381)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/108381 ___ 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] Dialect conversion: Unify materialization of value replacements (PR #108381)
@@ -558,8 +558,8 @@ func.func @deinterleave(%a: vector<4xf32>) -> (vector<2xf32>, vector<2xf32>) { // CHECK-LABEL: func @deinterleave_scalar // CHECK-SAME: (%[[ARG0:.+]]: vector<2xf32>) -// CHECK: %[[EXTRACT0:.*]] = spirv.CompositeExtract %[[ARG0]][0 : i32] : vector<2xf32> -// CHECK: %[[EXTRACT1:.*]] = spirv.CompositeExtract %[[ARG0]][1 : i32] : vector<2xf32> +// CHECK-DAG: %[[EXTRACT0:.*]] = spirv.CompositeExtract %[[ARG0]][0 : i32] : vector<2xf32> +// CHECK-DAG: %[[EXTRACT1:.*]] = spirv.CompositeExtract %[[ARG0]][1 : i32] : vector<2xf32> joker-eph wrote: Can you just push this separately ahead as its own commit? https://github.com/llvm/llvm-project/pull/108381 ___ 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] [cfe-branch] r287579 - [LTO] Merge r285254 into 3.9.1 (Darwin clang driver always pass -lto_library)
Author: mehdi_amini Date: Mon Nov 21 15:27:58 2016 New Revision: 287579 URL: http://llvm.org/viewvc/llvm-project?rev=287579&view=rev Log: [LTO] Merge r285254 into 3.9.1 (Darwin clang driver always pass -lto_library) See: https://llvm.org/PR30840 Modified: cfe/branches/release_39/lib/Driver/Tools.cpp cfe/branches/release_39/test/Driver/darwin-ld-lto.c Modified: cfe/branches/release_39/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/Tools.cpp?rev=287579&r1=287578&r2=287579&view=diff == --- cfe/branches/release_39/lib/Driver/Tools.cpp (original) +++ cfe/branches/release_39/lib/Driver/Tools.cpp Mon Nov 21 15:27:58 2016 @@ -7637,22 +7637,22 @@ void darwin::Linker::AddLinkArgs(Compila CmdArgs.push_back("-object_path_lto"); CmdArgs.push_back(TmpPath); } + } -// Use -lto_library option to specify the libLTO.dylib path. Try to find -// it in clang installed libraries. If not found, the option is not used -// and 'ld' will use its default mechanism to search for libLTO.dylib. -if (Version[0] >= 133) { - // Search for libLTO in /../lib/libLTO.dylib - StringRef P = llvm::sys::path::parent_path(D.getInstalledDir()); - SmallString<128> LibLTOPath(P); - llvm::sys::path::append(LibLTOPath, "lib"); - llvm::sys::path::append(LibLTOPath, "libLTO.dylib"); - if (llvm::sys::fs::exists(LibLTOPath)) { -CmdArgs.push_back("-lto_library"); -CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); - } else { -D.Diag(diag::warn_drv_lto_libpath); - } + // Use -lto_library option to specify the libLTO.dylib path. Try to find + // it in clang installed libraries. If not found, the option is not used + // and 'ld' will use its default mechanism to search for libLTO.dylib. + if (Version[0] >= 133) { +// Search for libLTO in /../lib/libLTO.dylib +StringRef P = llvm::sys::path::parent_path(D.getInstalledDir()); +SmallString<128> LibLTOPath(P); +llvm::sys::path::append(LibLTOPath, "lib"); +llvm::sys::path::append(LibLTOPath, "libLTO.dylib"); +if (llvm::sys::fs::exists(LibLTOPath)) { + CmdArgs.push_back("-lto_library"); + CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); +} else { + D.Diag(diag::warn_drv_lto_libpath); } } Modified: cfe/branches/release_39/test/Driver/darwin-ld-lto.c URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Driver/darwin-ld-lto.c?rev=287579&r1=287578&r2=287579&view=diff == --- cfe/branches/release_39/test/Driver/darwin-ld-lto.c (original) +++ cfe/branches/release_39/test/Driver/darwin-ld-lto.c Mon Nov 21 15:27:58 2016 @@ -3,22 +3,21 @@ // Check that ld gets "-lto_library" and warnings about libLTO.dylib path. // RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -mlinker-version=133 -flto 2> %t.log -// RUN: cat %t.log -// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s < %t.log +// RUN: -ccc-install-dir %T/bin -mlinker-version=133 2> %t.log +// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log // // LINK_LTOLIB_PATH: {{ld(.exe)?"}} // LINK_LTOLIB_PATH: "-lto_library" // RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -flto 2> %t.log +// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log // RUN: cat %t.log // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s < %t.log // // LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead // RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto -flto 2> %t.log +// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 2> %t.log // RUN: cat %t.log // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s < %t.log // ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cfe-branch] r287580 - Merge r285525 into 3.9.1: Fix clang installed path to handle case where clang is invoked through a symlink
Author: mehdi_amini Date: Mon Nov 21 15:29:59 2016 New Revision: 287580 URL: http://llvm.org/viewvc/llvm-project?rev=287580&view=rev Log: Merge r285525 into 3.9.1: Fix clang installed path to handle case where clang is invoked through a symlink See https://llvm.org/PR30840 Modified: cfe/branches/release_39/lib/Driver/Tools.cpp Modified: cfe/branches/release_39/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/Tools.cpp?rev=287580&r1=287579&r2=287580&view=diff == --- cfe/branches/release_39/lib/Driver/Tools.cpp (original) +++ cfe/branches/release_39/lib/Driver/Tools.cpp Mon Nov 21 15:29:59 2016 @@ -7644,7 +7644,7 @@ void darwin::Linker::AddLinkArgs(Compila // and 'ld' will use its default mechanism to search for libLTO.dylib. if (Version[0] >= 133) { // Search for libLTO in /../lib/libLTO.dylib -StringRef P = llvm::sys::path::parent_path(D.getInstalledDir()); +StringRef P = llvm::sys::path::parent_path(D.Dir); SmallString<128> LibLTOPath(P); llvm::sys::path::append(LibLTOPath, "lib"); llvm::sys::path::append(LibLTOPath, "libLTO.dylib"); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cfe-branch] r287784 - [LTO] Merge r287685 into the 3.9.1 branch, darwin: Unconditionally pass -lto_library, remove -Wliblto warning.
Author: mehdi_amini Date: Wed Nov 23 12:00:06 2016 New Revision: 287784 URL: http://llvm.org/viewvc/llvm-project?rev=287784&view=rev Log: [LTO] Merge r287685 into the 3.9.1 branch, darwin: Unconditionally pass -lto_library, remove -Wliblto warning. See: https://llvm.org/bugs/PR31120 Modified: cfe/branches/release_39/include/clang/Basic/DiagnosticDriverKinds.td cfe/branches/release_39/lib/Driver/Tools.cpp cfe/branches/release_39/test/Driver/darwin-ld-lto.c Modified: cfe/branches/release_39/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/include/clang/Basic/DiagnosticDriverKinds.td?rev=287784&r1=287783&r2=287784&view=diff == --- cfe/branches/release_39/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/branches/release_39/include/clang/Basic/DiagnosticDriverKinds.td Wed Nov 23 12:00:06 2016 @@ -159,8 +159,6 @@ def err_drv_bitcode_unsupported_on_toolc "-fembed-bitcode is not supported on versions of iOS prior to 6.0">; def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup; -def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead">, - InGroup; def warn_drv_optimization_value : Warning<"optimization level '%0' is not supported; using '%1%2' instead">, InGroup; def warn_ignored_gcc_optimization : Warning<"optimization flag '%0' is not supported">, Modified: cfe/branches/release_39/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/Tools.cpp?rev=287784&r1=287783&r2=287784&view=diff == --- cfe/branches/release_39/lib/Driver/Tools.cpp (original) +++ cfe/branches/release_39/lib/Driver/Tools.cpp Wed Nov 23 12:00:06 2016 @@ -7640,20 +7640,20 @@ void darwin::Linker::AddLinkArgs(Compila } // Use -lto_library option to specify the libLTO.dylib path. Try to find - // it in clang installed libraries. If not found, the option is not used - // and 'ld' will use its default mechanism to search for libLTO.dylib. + // it in clang installed libraries. ld64 will only look at this argument + // when it actually uses LTO, so libLTO.dylib only needs to exist at link + // time if ld64 decides that it needs to use LTO. + // Since this is passed unconditionally, ld64 will never look for libLTO.dylib + // next to it. That's ok since ld64 using a libLTO.dylib not matching the + // clang version won't work anyways. if (Version[0] >= 133) { // Search for libLTO in /../lib/libLTO.dylib StringRef P = llvm::sys::path::parent_path(D.Dir); SmallString<128> LibLTOPath(P); llvm::sys::path::append(LibLTOPath, "lib"); llvm::sys::path::append(LibLTOPath, "libLTO.dylib"); -if (llvm::sys::fs::exists(LibLTOPath)) { - CmdArgs.push_back("-lto_library"); - CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); -} else { - D.Diag(diag::warn_drv_lto_libpath); -} +CmdArgs.push_back("-lto_library"); +CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath)); } // Derived from the "link" spec. Modified: cfe/branches/release_39/test/Driver/darwin-ld-lto.c URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Driver/darwin-ld-lto.c?rev=287784&r1=287783&r2=287784&view=diff == --- cfe/branches/release_39/test/Driver/darwin-ld-lto.c (original) +++ cfe/branches/release_39/test/Driver/darwin-ld-lto.c Wed Nov 23 12:00:06 2016 @@ -1,6 +1,6 @@ // REQUIRES: system-darwin -// Check that ld gets "-lto_library" and warnings about libLTO.dylib path. +// Check that ld gets "-lto_library". // RUN: %clang -target x86_64-apple-darwin10 -### %s \ // RUN: -ccc-install-dir %T/bin -mlinker-version=133 2> %t.log @@ -9,16 +9,8 @@ // LINK_LTOLIB_PATH: {{ld(.exe)?"}} // LINK_LTOLIB_PATH: "-lto_library" +// Also pass -lto_library even if the file doesn't exist; if it's needed at +// link time, ld will complain instead. // RUN: %clang -target x86_64-apple-darwin10 -### %s \ // RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log -// RUN: cat %t.log -// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s < %t.log -// -// LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead - -// RUN: %clang -target x86_64-apple-darwin10 -### %s \ -// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 2> %t.log -// RUN: cat %t.log -// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s < %t.log -// -// LINK_LTOLIB_PATH_NOWRN-NOT: warning: libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead +// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log _
[llvm-branch-commits] [llvm-branch] r287805 - Merge r287453 in 3.9.1 : [ThinLTO] Fix crash when importing an opaque type
Author: mehdi_amini Date: Wed Nov 23 14:52:51 2016 New Revision: 287805 URL: http://llvm.org/viewvc/llvm-project?rev=287805&view=rev Log: Merge r287453 in 3.9.1 : [ThinLTO] Fix crash when importing an opaque type See: http://llvm.org/PR31072 Added: llvm/branches/release_39/test/ThinLTO/X86/Inputs/import_opaque_type.ll llvm/branches/release_39/test/ThinLTO/X86/import_opaque_type.ll Modified: llvm/branches/release_39/lib/Linker/IRMover.cpp Modified: llvm/branches/release_39/lib/Linker/IRMover.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Linker/IRMover.cpp?rev=287805&r1=287804&r2=287805&view=diff == --- llvm/branches/release_39/lib/Linker/IRMover.cpp (original) +++ llvm/branches/release_39/lib/Linker/IRMover.cpp Wed Nov 23 14:52:51 2016 @@ -1336,7 +1336,7 @@ bool IRMover::IdentifiedStructTypeSet::h IRMover::IRMover(Module &M) : Composite(M) { TypeFinder StructTypes; - StructTypes.run(M, true); + StructTypes.run(M, /* OnlyNamed */ false); for (StructType *Ty : StructTypes) { if (Ty->isOpaque()) IdentifiedStructTypes.addOpaque(Ty); Added: llvm/branches/release_39/test/ThinLTO/X86/Inputs/import_opaque_type.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/test/ThinLTO/X86/Inputs/import_opaque_type.ll?rev=287805&view=auto == --- llvm/branches/release_39/test/ThinLTO/X86/Inputs/import_opaque_type.ll (added) +++ llvm/branches/release_39/test/ThinLTO/X86/Inputs/import_opaque_type.ll Wed Nov 23 14:52:51 2016 @@ -0,0 +1,15 @@ +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.11.0" + +%0 = type { i8 } + +%a = type { %0 * } + +define void @bar(%a *) { + ret void +} + +define void @baz() { + call void @bar(%a *null) + ret void +} Added: llvm/branches/release_39/test/ThinLTO/X86/import_opaque_type.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/test/ThinLTO/X86/import_opaque_type.ll?rev=287805&view=auto == --- llvm/branches/release_39/test/ThinLTO/X86/import_opaque_type.ll (added) +++ llvm/branches/release_39/test/ThinLTO/X86/import_opaque_type.ll Wed Nov 23 14:52:51 2016 @@ -0,0 +1,27 @@ +; Do setup work for all below tests: generate bitcode and combined index +; RUN: opt -module-summary %s -o %t.bc +; RUN: opt -module-summary %p/Inputs/import_opaque_type.ll -o %t2.bc +; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc + +; Check that we import correctly the imported type to replace the opaque one here +; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s + + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.11.0" + +; CHECK: %0 = type { i8 } +%0 = type opaque + +%a = type { %0 * } + +declare void @baz() +define void @foo(%a *) { + call void @baz() + ret void +} + +define i32 @main() { +call void @foo(%a *null) + ret i32 0 +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cfe-branch] r287815 - Merge r275905 into 3.9 branch: Allow iOS and tvOS version numbers with 2-digit major version numbers.
Author: mehdi_amini Date: Wed Nov 23 15:25:50 2016 New Revision: 287815 URL: http://llvm.org/viewvc/llvm-project?rev=287815&view=rev Log: Merge r275905 into 3.9 branch: Allow iOS and tvOS version numbers with 2-digit major version numbers. See: http://llvm.org/PR30555 Modified: cfe/branches/release_39/lib/Basic/Targets.cpp cfe/branches/release_39/lib/Driver/ToolChains.cpp cfe/branches/release_39/test/Frontend/darwin-version.c Modified: cfe/branches/release_39/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Basic/Targets.cpp?rev=287815&r1=287814&r2=287815&view=diff == --- cfe/branches/release_39/lib/Basic/Targets.cpp (original) +++ cfe/branches/release_39/lib/Basic/Targets.cpp Wed Nov 23 15:25:50 2016 @@ -158,14 +158,25 @@ static void getDarwinDefines(MacroBuilde // Set the appropriate OS version define. if (Triple.isiOS()) { -assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!"); -char Str[6]; -Str[0] = '0' + Maj; -Str[1] = '0' + (Min / 10); -Str[2] = '0' + (Min % 10); -Str[3] = '0' + (Rev / 10); -Str[4] = '0' + (Rev % 10); -Str[5] = '\0'; +assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!"); +char Str[7]; +if (Maj < 10) { + Str[0] = '0' + Maj; + Str[1] = '0' + (Min / 10); + Str[2] = '0' + (Min % 10); + Str[3] = '0' + (Rev / 10); + Str[4] = '0' + (Rev % 10); + Str[5] = '\0'; +} else { + // Handle versions >= 10. + Str[0] = '0' + (Maj / 10); + Str[1] = '0' + (Maj % 10); + Str[2] = '0' + (Min / 10); + Str[3] = '0' + (Min % 10); + Str[4] = '0' + (Rev / 10); + Str[5] = '0' + (Rev % 10); + Str[6] = '\0'; +} if (Triple.isTvOS()) Builder.defineMacro("__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__", Str); else Modified: cfe/branches/release_39/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/ToolChains.cpp?rev=287815&r1=287814&r2=287815&view=diff == --- cfe/branches/release_39/lib/Driver/ToolChains.cpp (original) +++ cfe/branches/release_39/lib/Driver/ToolChains.cpp Wed Nov 23 15:25:50 2016 @@ -688,13 +688,13 @@ void Darwin::AddDeploymentTarget(Derived assert(iOSVersion && "Unknown target platform!"); if (!Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro, HadExtra) || -HadExtra || Major >= 10 || Minor >= 100 || Micro >= 100) +HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100) getDriver().Diag(diag::err_drv_invalid_version_number) << iOSVersion->getAsString(Args); } else if (Platform == TvOS) { if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor, Micro, HadExtra) || HadExtra || -Major >= 10 || Minor >= 100 || Micro >= 100) +Major >= 100 || Minor >= 100 || Micro >= 100) getDriver().Diag(diag::err_drv_invalid_version_number) << TvOSVersion->getAsString(Args); } else if (Platform == WatchOS) { Modified: cfe/branches/release_39/test/Frontend/darwin-version.c URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Frontend/darwin-version.c?rev=287815&r1=287814&r2=287815&view=diff == --- cfe/branches/release_39/test/Frontend/darwin-version.c (original) +++ cfe/branches/release_39/test/Frontend/darwin-version.c Wed Nov 23 15:25:50 2016 @@ -10,6 +10,8 @@ // RUN: %clang_cc1 -triple armv6-apple-ios2.3.1 -dM -E -o %t %s // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20301' | count 1 // RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t +// RUN: %clang_cc1 -triple armv7-apple-ios10.1.2 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '100102' | count 1 // RUN: %clang_cc1 -triple i386-apple-macosx10.4.0 -dM -E -o %t %s // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t @@ -32,6 +34,8 @@ // RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '80300' | count 1 // RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t +// RUN: %clang_cc1 -triple arm64-apple-tvos10.2.3 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '100203' | count 1 // RUN: %clang_cc1 -triple x86_64-apple-tvos8.3 -dM -E -o %t %s // RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '80300' | count 1 ___ llvm-branch-commits mailing list llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r287912 - Merge r283123 into 3.9.1
Author: mehdi_amini Date: Thu Nov 24 22:47:11 2016 New Revision: 287912 URL: http://llvm.org/viewvc/llvm-project?rev=287912&view=rev Log: Merge r283123 into 3.9.1 [RTDyld] Fix a bug in RTDyldMemoryManager::deregisterEHFrames. See: https://llvm.org/bugs/show_bug.cgi?id=31160 Modified: llvm/branches/release_39/include/llvm/ExecutionEngine/RTDyldMemoryManager.h Modified: llvm/branches/release_39/include/llvm/ExecutionEngine/RTDyldMemoryManager.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=287912&r1=287911&r2=287912&view=diff == --- llvm/branches/release_39/include/llvm/ExecutionEngine/RTDyldMemoryManager.h (original) +++ llvm/branches/release_39/include/llvm/ExecutionEngine/RTDyldMemoryManager.h Thu Nov 24 22:47:11 2016 @@ -72,7 +72,7 @@ public: } void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override { -registerEHFramesInProcess(Addr, Size); +deregisterEHFramesInProcess(Addr, Size); } /// This method returns the address of the specified function or variable in ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r292505 - Merge r292420 in 4.0 Release: "[ThinLTO] Add a recursive step in Metadata lazy-loading"
Author: mehdi_amini Date: Thu Jan 19 12:48:31 2017 New Revision: 292505 URL: http://llvm.org/viewvc/llvm-project?rev=292505&view=rev Log: Merge r292420 in 4.0 Release: "[ThinLTO] Add a recursive step in Metadata lazy-loading" Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp?rev=292505&r1=292504&r2=292505&view=diff == --- llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp (original) +++ llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp Thu Jan 19 12:48:31 2017 @@ -768,13 +768,12 @@ void MetadataLoader::MetadataLoaderImpl: unsigned ID, PlaceholderQueue &Placeholders) { assert(ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size()); assert(ID >= MDStringRef.size() && "Unexpected lazy-loading of MDString"); -#ifndef NDEBUG // Lookup first if the metadata hasn't already been loaded. if (auto *MD = MetadataList.lookup(ID)) { auto *N = dyn_cast_or_null(MD); -assert(N && N->isTemporary() && "Lazy loading an already loaded metadata"); +if (!N->isTemporary()) + return; } -#endif SmallVector Record; StringRef Blob; IndexCursor.JumpToBit(GlobalMetadataBitPosIndex[ID - MDStringRef.size()]); @@ -827,8 +826,22 @@ Error MetadataLoader::MetadataLoaderImpl auto getMD = [&](unsigned ID) -> Metadata * { if (ID < MDStringRef.size()) return lazyLoadOneMDString(ID); -if (!IsDistinct) +if (!IsDistinct) { + if (auto *MD = MetadataList.lookup(ID)) +return MD; + // If lazy-loading is enabled, we try recursively to load the operand + // instead of creating a temporary. + if (ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) { +// Create a temporary for the node that is referencing the operand we +// will lazy-load. It is needed before recursing in case there are +// uniquing cycles. +MetadataList.getMetadataFwdRef(NextMetadataNo); +lazyLoadOneMetadata(ID, Placeholders); +return MetadataList.lookup(ID); + } + // Return a temporary. return MetadataList.getMetadataFwdRef(ID); +} if (auto *MD = MetadataList.getMetadataIfResolved(ID)) return MD; return &Placeholders.getPlaceholderOp(ID); Modified: llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll?rev=292505&r1=292504&r2=292505&view=diff == --- llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll (original) +++ llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll Thu Jan 19 12:48:31 2017 @@ -17,7 +17,7 @@ ; RUN: -o /dev/null -disable-ondemand-mds-loading -stats \ ; RUN: 2>&1 | FileCheck %s -check-prefix=NOTLAZY ; NOTLAZY: 58 bitcode-reader - Number of Metadata records loaded -; NOTLAZY: 8 bitcode-reader - Number of MDStrings loaded +; NOTLAZY: 6 bitcode-reader - Number of MDStrings loaded target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" @@ -48,7 +48,7 @@ define void @globalfunc3(i32 %arg) { !3 = !{!"3"} !4 = !{!"4"} !5 = !{!"5"} -!6 = !{!"6"} +!6 = !{!9} !7 = !{!"7"} !8 = !{!"8"} -!9 = !{!"9"} +!9 = !{!6} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r292731 - LLVM 4.0: cherry-pick r292667 [ThinLTO] The "codegen only" path didn't honor the recently added file-based API
Author: mehdi_amini Date: Sat Jan 21 16:08:38 2017 New Revision: 292731 URL: http://llvm.org/viewvc/llvm-project?rev=292731&view=rev Log: LLVM 4.0: cherry-pick r292667 [ThinLTO] The "codegen only" path didn't honor the recently added file-based API Modified: llvm/branches/release_40/ (props changed) llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp Propchange: llvm/branches/release_40/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Jan 21 16:08:38 2017 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280 +/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292667 Modified: llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp?rev=292731&r1=292730&r2=292731&view=diff == --- llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp (original) +++ llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp Sat Jan 21 16:08:38 2017 @@ -829,11 +829,22 @@ static std::string writeGeneratedObject( // Main entry point for the ThinLTO processing void ThinLTOCodeGenerator::run() { + // Prepare the resulting object vector + assert(ProducedBinaries.empty() && "The generator should not be reused"); + if (SavedObjectsDirectoryPath.empty()) +ProducedBinaries.resize(Modules.size()); + else { +sys::fs::create_directories(SavedObjectsDirectoryPath); +bool IsDir; +sys::fs::is_directory(SavedObjectsDirectoryPath, IsDir); +if (!IsDir) + report_fatal_error("Unexistent dir: '" + SavedObjectsDirectoryPath + "'"); +ProducedBinaryFiles.resize(Modules.size()); + } + if (CodeGenOnly) { // Perform only parallel codegen and return. ThreadPool Pool; -assert(ProducedBinaries.empty() && "The generator should not be reused"); -ProducedBinaries.resize(Modules.size()); int count = 0; for (auto &ModuleBuffer : Modules) { Pool.async([&](int count) { @@ -845,7 +856,12 @@ void ThinLTOCodeGenerator::run() { /*IsImporting*/ false); // CodeGen -ProducedBinaries[count] = codegen(*TheModule); +auto OutputBuffer = codegen(*TheModule); +if (SavedObjectsDirectoryPath.empty()) + ProducedBinaries[count] = std::move(OutputBuffer); +else + ProducedBinaryFiles[count] = writeGeneratedObject( + count, "", SavedObjectsDirectoryPath, *OutputBuffer); }, count++); } @@ -866,18 +882,6 @@ void ThinLTOCodeGenerator::run() { WriteIndexToFile(*Index, OS); } - // Prepare the resulting object vector - assert(ProducedBinaries.empty() && "The generator should not be reused"); - if (SavedObjectsDirectoryPath.empty()) -ProducedBinaries.resize(Modules.size()); - else { -sys::fs::create_directories(SavedObjectsDirectoryPath); -bool IsDir; -sys::fs::is_directory(SavedObjectsDirectoryPath, IsDir); -if (!IsDir) - report_fatal_error("Unexistent dir: '" + SavedObjectsDirectoryPath + "'"); -ProducedBinaryFiles.resize(Modules.size()); - } // Prepare the module map. auto ModuleMap = generateModuleMap(Modules); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r292732 - LLVM 4.0: cherry-pick r292711 Add missing dependency to "Module Summary Analysis" pass
Author: mehdi_amini Date: Sat Jan 21 16:09:27 2017 New Revision: 292732 URL: http://llvm.org/viewvc/llvm-project?rev=292732&view=rev Log: LLVM 4.0: cherry-pick r292711 Add missing dependency to "Module Summary Analysis" pass Modified: llvm/branches/release_40/ (props changed) llvm/branches/release_40/lib/Analysis/ModuleSummaryAnalysis.cpp Propchange: llvm/branches/release_40/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Jan 21 16:09:27 2017 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292667 +/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292667,292711 Modified: llvm/branches/release_40/lib/Analysis/ModuleSummaryAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Analysis/ModuleSummaryAnalysis.cpp?rev=292732&r1=292731&r2=292732&view=diff == --- llvm/branches/release_40/lib/Analysis/ModuleSummaryAnalysis.cpp (original) +++ llvm/branches/release_40/lib/Analysis/ModuleSummaryAnalysis.cpp Sat Jan 21 16:09:27 2017 @@ -405,6 +405,7 @@ char ModuleSummaryIndexWrapperPass::ID = INITIALIZE_PASS_BEGIN(ModuleSummaryIndexWrapperPass, "module-summary-analysis", "Module Summary Analysis", false, true) INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass) +INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass) INITIALIZE_PASS_END(ModuleSummaryIndexWrapperPass, "module-summary-analysis", "Module Summary Analysis", false, true) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r292760 - LLVM 4.0: Merge r292641 "[ThinLTO] Fix lazy-loading of MDString instruction attachments"
Author: mehdi_amini Date: Sun Jan 22 13:37:24 2017 New Revision: 292760 URL: http://llvm.org/viewvc/llvm-project?rev=292760&view=rev Log: LLVM 4.0: Merge r292641 "[ThinLTO] Fix lazy-loading of MDString instruction attachments" Modified: llvm/branches/release_40/ (props changed) llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll Propchange: llvm/branches/release_40/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Jan 22 13:37:24 2017 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292667,292711 +/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292641,292667,292711 Modified: llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp?rev=292760&r1=292759&r2=292760&view=diff == --- llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/release_40/lib/Bitcode/Reader/BitcodeReader.cpp Sun Jan 22 13:37:24 2017 @@ -512,7 +512,7 @@ private: } Metadata *getFnMetadataByID(unsigned ID) { -return MDLoader->getMetadataFwdRef(ID); +return MDLoader->getMetadataFwdRefOrLoad(ID); } BasicBlock *getBasicBlock(unsigned ID) const { Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp?rev=292760&r1=292759&r2=292760&view=diff == --- llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp (original) +++ llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp Sun Jan 22 13:37:24 2017 @@ -485,8 +485,21 @@ public: Error parseMetadata(bool ModuleLevel); bool hasFwdRefs() const { return MetadataList.hasFwdRefs(); } - Metadata *getMetadataFwdRef(unsigned Idx) { -return MetadataList.getMetadataFwdRef(Idx); + + Metadata *getMetadataFwdRefOrLoad(unsigned ID) { +if (ID < MDStringRef.size()) + return lazyLoadOneMDString(ID); +if (auto *MD = MetadataList.lookup(ID)) + return MD; +// If lazy-loading is enabled, we try recursively to load the operand +// instead of creating a temporary. +if (ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) { + PlaceholderQueue Placeholders; + lazyLoadOneMetadata(ID, Placeholders); + resolveForwardRefsAndPlaceholders(Placeholders); + return MetadataList.lookup(ID); +} +return MetadataList.getMetadataFwdRef(ID); } MDNode *getMDNodeFwdRefOrNull(unsigned Idx) { @@ -1727,8 +1740,8 @@ bool MetadataLoader::hasFwdRefs() const /// Return the given metadata, creating a replaceable forward reference if /// necessary. -Metadata *MetadataLoader::getMetadataFwdRef(unsigned Idx) { - return Pimpl->getMetadataFwdRef(Idx); +Metadata *MetadataLoader::getMetadataFwdRefOrLoad(unsigned Idx) { + return Pimpl->getMetadataFwdRefOrLoad(Idx); } MDNode *MetadataLoader::getMDNodeFwdRefOrNull(unsigned Idx) { Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h?rev=292760&r1=292759&r2=292760&view=diff == --- llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h (original) +++ llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.h Sun Jan 22 13:37:24 2017 @@ -63,7 +63,7 @@ public: /// Return the given metadata, creating a replaceable forward reference if /// necessary. - Metadata *getMetadataFwdRef(unsigned Idx); + Metadata *getMetadataFwdRefOrLoad(unsigned Idx); MDNode *getMDNodeFwdRefOrNull(unsigned Idx); Modified: llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll?rev=292760&r1=292759&r2=292760&view=diff == --- llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll (original) +++ llvm/branches/release_40/test/ThinLTO/X86/lazyload_metadata.ll Sun Jan 22 13:37:24 2017 @@ -11,19 +11,20 @@ ; RUN: -o /dev/null -stats \ ; RUN: 2>&1 | FileCheck %s -check-prefix=LAZY ; LAZY: 49 bitcode-reader - Number of Metadata records loaded -; LAZY: 1 bitcode-reader - Number of
[llvm-branch-commits] [llvm-branch] r293292 - LLVM 4.0: cherry-pick r293291 - Avoid using unspecified ordering in MetadataLoader::MetadataLoaderImpl::parseOneMetadata.
Author: mehdi_amini Date: Fri Jan 27 10:06:47 2017 New Revision: 293292 URL: http://llvm.org/viewvc/llvm-project?rev=293292&view=rev Log: LLVM 4.0: cherry-pick r293291 - Avoid using unspecified ordering in MetadataLoader::MetadataLoaderImpl::parseOneMetadata. Modified: llvm/branches/release_40/ (props changed) llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp Propchange: llvm/branches/release_40/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jan 27 10:06:47 2017 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,291858-291859,291863,291875,291909,291966,291968,291979,292133,292242,292254-292255,292280,292323,292444,292467,292583,292625,292641,292651,292667,292711,292758,293025 +/llvm/trunk:155241,291858-291859,291863,291875,291909,291966,291968,291979,292133,292242,292254-292255,292280,292323,292444,292467,292583,292625,292641,292651,292667,292711,292758,293025,293291 Modified: llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp?rev=293292&r1=293291&r2=293292&view=diff == --- llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp (original) +++ llvm/branches/release_40/lib/Bitcode/Reader/MetadataLoader.cpp Fri Jan 27 10:06:47 2017 @@ -919,7 +919,8 @@ Error MetadataLoader::MetadataLoaderImpl // If this isn't a LocalAsMetadata record, we're dropping it. This used // to be legal, but there's no upgrade path. auto dropRecord = [&] { - MetadataList.assignValue(MDNode::get(Context, None), NextMetadataNo++); + MetadataList.assignValue(MDNode::get(Context, None), NextMetadataNo); + NextMetadataNo++; }; if (Record.size() != 2) { dropRecord(); @@ -934,7 +935,8 @@ Error MetadataLoader::MetadataLoaderImpl MetadataList.assignValue( LocalAsMetadata::get(ValueList.getValueFwdRef(Record[1], Ty)), -NextMetadataNo++); +NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_OLD_NODE: { @@ -959,7 +961,8 @@ Error MetadataLoader::MetadataLoaderImpl } else Elts.push_back(nullptr); } -MetadataList.assignValue(MDNode::get(Context, Elts), NextMetadataNo++); +MetadataList.assignValue(MDNode::get(Context, Elts), NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_VALUE: { @@ -972,7 +975,8 @@ Error MetadataLoader::MetadataLoaderImpl MetadataList.assignValue( ValueAsMetadata::get(ValueList.getValueFwdRef(Record[1], Ty)), -NextMetadataNo++); +NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_DISTINCT_NODE: @@ -985,7 +989,8 @@ Error MetadataLoader::MetadataLoaderImpl Elts.push_back(getMDOrNull(ID)); MetadataList.assignValue(IsDistinct ? MDNode::getDistinct(Context, Elts) : MDNode::get(Context, Elts), - NextMetadataNo++); + NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_LOCATION: { @@ -999,7 +1004,8 @@ Error MetadataLoader::MetadataLoaderImpl Metadata *InlinedAt = getMDOrNull(Record[4]); MetadataList.assignValue( GET_OR_DISTINCT(DILocation, (Context, Line, Column, Scope, InlinedAt)), -NextMetadataNo++); +NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_GENERIC_DEBUG: { @@ -1019,7 +1025,8 @@ Error MetadataLoader::MetadataLoaderImpl DwarfOps.push_back(getMDOrNull(Record[I])); MetadataList.assignValue( GET_OR_DISTINCT(GenericDINode, (Context, Tag, Header, DwarfOps)), -NextMetadataNo++); +NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_SUBRANGE: { @@ -1030,7 +1037,8 @@ Error MetadataLoader::MetadataLoaderImpl MetadataList.assignValue( GET_OR_DISTINCT(DISubrange, (Context, Record[1], unrotateSign(Record[2]))), -NextMetadataNo++); +NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_ENUMERATOR: { @@ -1041,7 +1049,8 @@ Error MetadataLoader::MetadataLoaderImpl MetadataList.assignValue( GET_OR_DISTINCT(DIEnumerator, (Context, unrotateSign(Record[1]), getMDString(Record[2]))), -NextMetadataNo++); +NextMetadataNo); +NextMetadataNo++; break; } case bitc::METADATA_BASIC_TYPE: { @@ -1053,7 +1062,8 @@ Error MetadataLoader::MetadataLoaderImpl GET_OR_DISTINCT(DIBasicType, (Context, Record[1], getMDString(Record[2]), Record[3], Record[4], Record[5])), -
[llvm-branch-commits] [llvm-branch] r293294 - LLVM 4.0: cherry-pick r293293 - "Fix BasicAA incorrect assumption on GEP"
Author: mehdi_amini Date: Fri Jan 27 10:16:33 2017 New Revision: 293294 URL: http://llvm.org/viewvc/llvm-project?rev=293294&view=rev Log: LLVM 4.0: cherry-pick r293293 - "Fix BasicAA incorrect assumption on GEP" Added: llvm/branches/release_40/test/Analysis/BasicAA/pr31761.ll - copied unchanged from r293293, llvm/trunk/test/Analysis/BasicAA/pr31761.ll Modified: llvm/branches/release_40/ (props changed) llvm/branches/release_40/lib/Analysis/BasicAliasAnalysis.cpp Propchange: llvm/branches/release_40/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jan 27 10:16:33 2017 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,291858-291859,291863,291875,291909,291966,291968,291979,292133,292242,292254-292255,292280,292323,292444,292467,292583,292625,292641,292651,292667,292711,292758,293025,293291 +/llvm/trunk:155241,291858-291859,291863,291875,291909,291966,291968,291979,292133,292242,292254-292255,292280,292323,292444,292467,292583,292625,292641,292651,292667,292711,292758,293025,293291,293293 Modified: llvm/branches/release_40/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Analysis/BasicAliasAnalysis.cpp?rev=293294&r1=293293&r2=293294&view=diff == --- llvm/branches/release_40/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/branches/release_40/lib/Analysis/BasicAliasAnalysis.cpp Fri Jan 27 10:16:33 2017 @@ -1191,14 +1191,14 @@ AliasResult BasicAAResult::aliasGEP(cons return MayAlias; AliasResult R = aliasCheck(UnderlyingV1, MemoryLocation::UnknownSize, - AAMDNodes(), V2, V2Size, V2AAInfo, - nullptr, UnderlyingV2); + AAMDNodes(), V2, MemoryLocation::UnknownSize, + V2AAInfo, nullptr, UnderlyingV2); if (R != MustAlias) // If V2 may alias GEP base pointer, conservatively returns MayAlias. // If V2 is known not to alias GEP base pointer, then the two values - // cannot alias per GEP semantics: "A pointer value formed from a - // getelementptr instruction is associated with the addresses associated - // with the first operand of the getelementptr". + // cannot alias per GEP semantics: "Any memory access must be done through + // a pointer value associated with an address range of the memory access, + // otherwise the behavior is undefined.". return R; // If the max search depth is reached the result is undefined ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r295024 - [ThinLTO] Make a copy of buffer identifier in ThinLTOCodeGenerator
Author: mehdi_amini Date: Mon Feb 13 22:49:31 2017 New Revision: 295024 URL: http://llvm.org/viewvc/llvm-project?rev=295024&view=rev Log: [ThinLTO] Make a copy of buffer identifier in ThinLTOCodeGenerator This is anticipating a crash with ThinLTO and Xcode 8.3. Modified: llvm/branches/release_40/ (props changed) llvm/branches/release_40/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp Propchange: llvm/branches/release_40/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Feb 13 22:49:31 2017 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294102,294203,294267,294318,294348-294349,294357 +/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294102,294203,294267,294318,294348-294349,294357,295018 Modified: llvm/branches/release_40/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h?rev=295024&r1=295023&r2=295024&view=diff == --- llvm/branches/release_40/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h (original) +++ llvm/branches/release_40/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h Mon Feb 13 22:49:31 2017 @@ -31,6 +31,23 @@ class StringRef; class LLVMContext; class TargetMachine; +/// Wrapper around MemoryBufferRef, owning the identifier +class ThinLTOBuffer { + std::string OwnedIdentifier; + StringRef Buffer; + +public: + ThinLTOBuffer(StringRef Buffer, StringRef Identifier) + : OwnedIdentifier(Identifier), Buffer(Buffer) {} + + MemoryBufferRef getMemBuffer() const { +return MemoryBufferRef(Buffer, + {OwnedIdentifier.c_str(), OwnedIdentifier.size()}); + } + StringRef getBuffer() const { return Buffer; } + StringRef getBufferIdentifier() const { return OwnedIdentifier; } +}; + /// Helper to gather options relevant to the target machine creation struct TargetMachineBuilder { Triple TheTriple; @@ -280,7 +297,7 @@ private: /// Vector holding the input buffers containing the bitcode modules to /// process. - std::vector Modules; + std::vector Modules; /// Set of symbols that need to be preserved outside of the set of bitcode /// files. Modified: llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp?rev=295024&r1=295023&r2=295024&view=diff == --- llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp (original) +++ llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp Mon Feb 13 22:49:31 2017 @@ -150,13 +150,13 @@ static void computePrevailingCopies( } static StringMap -generateModuleMap(const std::vector &Modules) { +generateModuleMap(const std::vector &Modules) { StringMap ModuleMap; for (auto &ModuleBuffer : Modules) { assert(ModuleMap.find(ModuleBuffer.getBufferIdentifier()) == ModuleMap.end() && "Expect unique Buffer Identifier"); -ModuleMap[ModuleBuffer.getBufferIdentifier()] = ModuleBuffer; +ModuleMap[ModuleBuffer.getBufferIdentifier()] = ModuleBuffer.getMemBuffer(); } return ModuleMap; } @@ -522,13 +522,13 @@ static void initTMBuilder(TargetMachineB } // end anonymous namespace void ThinLTOCodeGenerator::addModule(StringRef Identifier, StringRef Data) { - MemoryBufferRef Buffer(Data, Identifier); + ThinLTOBuffer Buffer(Data, Identifier); if (Modules.empty()) { // First module added, so initialize the triple and some options LLVMContext Context; StringRef TripleStr; -ErrorOr TripleOrErr = -expectedToErrorOrAndEmitErrors(Context, getBitcodeTargetTriple(Buffer)); +ErrorOr TripleOrErr = expectedToErrorOrAndEmitErrors( +Context, getBitcodeTargetTriple(Buffer.getMemBuffer())); if (TripleOrErr) TripleStr = *TripleOrErr; Triple TheTriple(TripleStr); @@ -538,8 +538,8 @@ void ThinLTOCodeGenerator::addModule(Str else { LLVMContext Context; StringRef Tri
[llvm-branch-commits] [mlir] d8113cd - Add newline to terminate debug message (NFC)
Author: Mehdi Amini Date: 2021-01-14T19:29:18Z New Revision: d8113cda782b56477d71321027c50389f05f5d31 URL: https://github.com/llvm/llvm-project/commit/d8113cda782b56477d71321027c50389f05f5d31 DIFF: https://github.com/llvm/llvm-project/commit/d8113cda782b56477d71321027c50389f05f5d31.diff LOG: Add newline to terminate debug message (NFC) Added: Modified: mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp Removed: diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index 170f882c02d0..c1d286690c48 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -258,7 +258,7 @@ mlir::applyPatternsAndFoldGreedily(MutableArrayRef regions, bool converged = driver.simplify(regions, maxIterations); LLVM_DEBUG(if (!converged) { llvm::dbgs() << "The pattern rewrite doesn't converge after scanning " - << maxIterations << " times"; + << maxIterations << " times\n"; }); return success(converged); } ___ 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] 7dadcd0 - Fix a few GCC compiler warnings (NFC)
Author: Mehdi Amini Date: 2021-01-19T06:00:04Z New Revision: 7dadcd02d6ce0278723c87736f6278610da0ddb2 URL: https://github.com/llvm/llvm-project/commit/7dadcd02d6ce0278723c87736f6278610da0ddb2 DIFF: https://github.com/llvm/llvm-project/commit/7dadcd02d6ce0278723c87736f6278610da0ddb2.diff LOG: Fix a few GCC compiler warnings (NFC) Added: Modified: mlir/lib/CAPI/Dialect/Linalg.cpp mlir/lib/CAPI/Dialect/SCF.cpp mlir/lib/CAPI/Dialect/Shape.cpp mlir/lib/CAPI/Dialect/Standard.cpp mlir/lib/CAPI/Dialect/Tensor.cpp mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp mlir/lib/ExecutionEngine/SparseUtils.cpp mlir/lib/Rewrite/ByteCode.cpp mlir/tools/mlir-tblgen/OpFormatGen.cpp mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp Removed: diff --git a/mlir/lib/CAPI/Dialect/Linalg.cpp b/mlir/lib/CAPI/Dialect/Linalg.cpp index 3e45c41adc72..da6fd4846bd6 100644 --- a/mlir/lib/CAPI/Dialect/Linalg.cpp +++ b/mlir/lib/CAPI/Dialect/Linalg.cpp @@ -11,4 +11,4 @@ #include "mlir/Dialect/Linalg/IR/LinalgOps.h" MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Linalg, linalg, - mlir::linalg::LinalgDialect); + mlir::linalg::LinalgDialect) diff --git a/mlir/lib/CAPI/Dialect/SCF.cpp b/mlir/lib/CAPI/Dialect/SCF.cpp index f81b010b04e2..c1dca6d2118f 100644 --- a/mlir/lib/CAPI/Dialect/SCF.cpp +++ b/mlir/lib/CAPI/Dialect/SCF.cpp @@ -10,4 +10,4 @@ #include "mlir-c/Dialect/SCF.h" #include "mlir/CAPI/Registration.h" -MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SCF, scf, mlir::scf::SCFDialect); +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SCF, scf, mlir::scf::SCFDialect) diff --git a/mlir/lib/CAPI/Dialect/Shape.cpp b/mlir/lib/CAPI/Dialect/Shape.cpp index 22e20ad8eaaa..1f8e83a0c729 100644 --- a/mlir/lib/CAPI/Dialect/Shape.cpp +++ b/mlir/lib/CAPI/Dialect/Shape.cpp @@ -10,4 +10,4 @@ #include "mlir-c/Dialect/Shape.h" #include "mlir/CAPI/Registration.h" -MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Shape, shape, mlir::shape::ShapeDialect); +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Shape, shape, mlir::shape::ShapeDialect) diff --git a/mlir/lib/CAPI/Dialect/Standard.cpp b/mlir/lib/CAPI/Dialect/Standard.cpp index b611cb85f6f6..57083a8a21a3 100644 --- a/mlir/lib/CAPI/Dialect/Standard.cpp +++ b/mlir/lib/CAPI/Dialect/Standard.cpp @@ -10,4 +10,4 @@ #include "mlir/CAPI/Registration.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" -MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Standard, std, mlir::StandardOpsDialect); +MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Standard, std, mlir::StandardOpsDialect) diff --git a/mlir/lib/CAPI/Dialect/Tensor.cpp b/mlir/lib/CAPI/Dialect/Tensor.cpp index 8f336c0bf3c4..266efc26b6f9 100644 --- a/mlir/lib/CAPI/Dialect/Tensor.cpp +++ b/mlir/lib/CAPI/Dialect/Tensor.cpp @@ -11,4 +11,4 @@ #include "mlir/CAPI/Registration.h" MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Tensor, tensor, - mlir::tensor::TensorDialect); + mlir::tensor::TensorDialect) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp index 84c71e84c42e..898b15266072 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Sparsification.cpp @@ -500,6 +500,7 @@ static unsigned buildLattices(Merger &merger, linalg::GenericOp op, case Kind::kAddI: return merger.takeDisj(kind, s0, s1); } + llvm_unreachable("unexpected expression kind"); } /// Maps sparse integer option to actual integral storage type. @@ -512,6 +513,7 @@ static Type genIntType(PatternRewriter &rewriter, linalg::SparseIntType tp) { case linalg::SparseIntType::kI32: return rewriter.getIntegerType(32); } + llvm_unreachable("unexpected SparseIntType"); } /// Local bufferization of all dense and sparse data structures. @@ -735,6 +737,7 @@ static Value genExp(Merger &merger, CodeGen &codegen, PatternRewriter &rewriter, case Kind::kAddI: return rewriter.create(op.getLoc(), v0, v1); } + llvm_unreachable("unexpected expression kind"); } /// Hoists loop invariant tensor loads for which indices have been exhausted. @@ -825,6 +828,7 @@ static bool isVectorFor(CodeGen &codegen, bool isInner, bool isSparse) { case linalg::SparseVectorizationStrategy::kAnyStorageInnerLoop: return isInner; } + llvm_unreachable("unexpected vectorization strategy"); } /// Returns parallelization strategy. Any implicit loop in the Linalg operation @@ -844,6 +848,7 @@ static bool isParallelFor(CodeGen &codegen, bool isOuter, bool isReduction, case linalg::SparseParallelizationStrategy::kAnyStorageAnyLoop: return !isReduction && !isVector; } + llvm_unreachable("unexpected parallelization strategy"); } /// Generates a for-loop on a single index. diff --git a/mlir/lib/ExecutionEngi
[llvm-branch-commits] [mlir] 1bf2b16 - Implement constant folding for DivFOp
Author: Jackson Fellows Date: 2021-01-19T23:08:06Z New Revision: 1bf2b1665b43e1a5090177486c8fa6374a4596a2 URL: https://github.com/llvm/llvm-project/commit/1bf2b1665b43e1a5090177486c8fa6374a4596a2 DIFF: https://github.com/llvm/llvm-project/commit/1bf2b1665b43e1a5090177486c8fa6374a4596a2.diff LOG: Implement constant folding for DivFOp Add a constant folder for DivFOp. Analogous to existing folders for AddFOp, SubFOp, and MulFOp. Matches the behavior of existing LLVM constant folding (https://github.com/llvm/llvm-project/blob/999f5da6b3088fa4c0bb9d05b358d015ca74c71f/llvm/lib/IR/ConstantFold.cpp#L1432). Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D94939 Added: Modified: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td mlir/lib/Dialect/StandardOps/IR/Ops.cpp Removed: diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index 8e3f1f1a7a85..8db6129dbb88 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -1589,6 +1589,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> { def DivFOp : FloatArithmeticOp<"divf"> { let summary = "floating point division operation"; + let hasFolder = 1; } //===--===// diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp index e1be47f54798..1718ab14d5d1 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -1483,6 +1483,15 @@ void DimOp::getCanonicalizationPatterns(OwningRewritePatternList &results, DimOfCastOp>(context); } +// --- +// DivFOp +// --- + +OpFoldResult DivFOp::fold(ArrayRef operands) { + return constFoldBinaryOp( + operands, [](APFloat a, APFloat b) { return a / b; }); +} + // --- // DmaStartOp // --- ___ 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] 8a7ff73 - [mlir] Make MLIRContext::getOrLoadDialect(StringRef, TypeID, ...) public
Author: mfehr Date: 2021-01-21T00:29:58Z New Revision: 8a7ff7301a6ce50f2adf52959c04f37a00c5a631 URL: https://github.com/llvm/llvm-project/commit/8a7ff7301a6ce50f2adf52959c04f37a00c5a631 DIFF: https://github.com/llvm/llvm-project/commit/8a7ff7301a6ce50f2adf52959c04f37a00c5a631.diff LOG: [mlir] Make MLIRContext::getOrLoadDialect(StringRef, TypeID, ...) public Having this function in a public scope is helpful to register dialects that are defined at runtime, and thus that need a runtime-defined TypeID. Also, a similar function in DialectRegistry, insert(TypeID, StringRef, ...), has a public scope. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D95091 Added: Modified: mlir/include/mlir/IR/MLIRContext.h Removed: diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h index e460064a889f..4751f00a36df 100644 --- a/mlir/include/mlir/IR/MLIRContext.h +++ b/mlir/include/mlir/IR/MLIRContext.h @@ -156,17 +156,19 @@ class MLIRContext { void enterMultiThreadedExecution(); void exitMultiThreadedExecution(); -private: - const std::unique_ptr impl; - /// Get a dialect for the provided namespace and TypeID: abort the program if /// a dialect exist for this namespace with diff erent TypeID. If a dialect has /// not been loaded for this namespace/TypeID yet, use the provided ctor to /// create one on the fly and load it. Returns a pointer to the dialect owned /// by the context. + /// The use of this method is in general discouraged in favor of + /// 'getOrLoadDialect()'. Dialect *getOrLoadDialect(StringRef dialectNamespace, TypeID dialectID, function_ref()> ctor); +private: + const std::unique_ptr impl; + MLIRContext(const MLIRContext &) = delete; void operator=(const MLIRContext &) = delete; }; ___ 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] 922b26c - Add Python bindings for the builtin dialect
Author: Mehdi Amini Date: 2021-01-21T22:44:44Z New Revision: 922b26cde4d1c89a5fa90e6a1d6d97d0f8eace6d URL: https://github.com/llvm/llvm-project/commit/922b26cde4d1c89a5fa90e6a1d6d97d0f8eace6d DIFF: https://github.com/llvm/llvm-project/commit/922b26cde4d1c89a5fa90e6a1d6d97d0f8eace6d.diff LOG: Add Python bindings for the builtin dialect This includes some minor customization for FuncOp and ModuleOp. Differential Revision: https://reviews.llvm.org/D95022 Added: mlir/lib/Bindings/Python/BuiltinOps.td mlir/lib/Bindings/Python/mlir/dialects/_builtin.py mlir/test/Bindings/Python/.style.yapf mlir/test/Bindings/Python/dialects/builtin.py Modified: mlir/lib/Bindings/Python/CMakeLists.txt mlir/lib/Bindings/Python/mlir/dialects/__init__.py mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp Removed: diff --git a/mlir/lib/Bindings/Python/BuiltinOps.td b/mlir/lib/Bindings/Python/BuiltinOps.td new file mode 100644 index ..ecbb8227d490 --- /dev/null +++ b/mlir/lib/Bindings/Python/BuiltinOps.td @@ -0,0 +1,15 @@ +//===-- BuiltinOps.td - Entry point for builtin bindings ---*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef PYTHON_BINDINGS_BUILTIN_OPS +#define PYTHON_BINDINGS_BUILTIN_OPS + +include "mlir/Bindings/Python/Attributes.td" +include "mlir/IR/BuiltinOps.td" + +#endif diff --git a/mlir/lib/Bindings/Python/CMakeLists.txt b/mlir/lib/Bindings/Python/CMakeLists.txt index 1749ea2e5472..951aa7883c90 100644 --- a/mlir/lib/Bindings/Python/CMakeLists.txt +++ b/mlir/lib/Bindings/Python/CMakeLists.txt @@ -11,6 +11,7 @@ set(PY_SRC_FILES mlir/ir.py mlir/dialects/__init__.py mlir/dialects/_linalg.py + mlir/dialects/_builtin.py mlir/ir.py mlir/passmanager.py mlir/transforms/__init__.py @@ -36,6 +37,11 @@ endforeach() # Generate dialect-specific bindings. +add_mlir_dialect_python_bindings(MLIRBindingsPythonBuiltinOps + TD_FILE BuiltinOps.td + DIALECT_NAME builtin) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonBuiltinOps) + add_mlir_dialect_python_bindings(MLIRBindingsPythonLinalgOps TD_FILE LinalgOps.td DIALECT_NAME linalg diff --git a/mlir/lib/Bindings/Python/mlir/dialects/__init__.py b/mlir/lib/Bindings/Python/mlir/dialects/__init__.py index 9c003b415438..f5a71bf88700 100644 --- a/mlir/lib/Bindings/Python/mlir/dialects/__init__.py +++ b/mlir/lib/Bindings/Python/mlir/dialects/__init__.py @@ -43,7 +43,7 @@ def class_decorator(parent_opview_cls: type): except AttributeError: # Try to default resolve it. try: -select_mixin = getattr(ext_module, parent_opview_cls.__name__) +mixin_cls = getattr(ext_module, parent_opview_cls.__name__) except AttributeError: pass else: diff --git a/mlir/lib/Bindings/Python/mlir/dialects/_builtin.py b/mlir/lib/Bindings/Python/mlir/dialects/_builtin.py new file mode 100644 index ..8d430d5a50da --- /dev/null +++ b/mlir/lib/Bindings/Python/mlir/dialects/_builtin.py @@ -0,0 +1,93 @@ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +from mlir.ir import * + + +class ModuleOp: + """Specialization for the module op class.""" + + def __init__(self, loc=None, ip=None): +super().__init__( +self._ods_build_default(operands=[], results=[], loc=loc, ip=ip)) +body = self.regions[0].blocks.append() +with InsertionPoint(body): + Operation.create("module_terminator") + + @property + def body(self): +return self.regions[0].blocks[0] + + +class FuncOp: + """Specialization for the func op class.""" + + def __init__(self, + name, + type, + visibility, + body_builder=None, + loc=None, + ip=None): +""" +Create a FuncOp with the provided `name`, `type`, and `visibility`. +- `name` is a string representing the function name. +- `type` is either a FunctionType or a pair of list describing inputs and + results. +- `visibility` is a string matching `public`, `private`, or `nested`. The + empty string implies a private visibility. +- `body_builder` is an optional callback, when provided a new entry block + is created and the callback is invoked with the new op as argument within + an InsertionPoint context already set for the block. The callback is + expected to insert a terminator in the block. +""" +
[llvm-branch-commits] [mlir] 2c8f5bd - [MLIR] Make ComplexType buildable if its element type is buildable
Author: Chris Morin Date: 2020-12-29T23:31:42Z New Revision: 2c8f5bd53945a209cd3cd851c63df3713fa0f9bd URL: https://github.com/llvm/llvm-project/commit/2c8f5bd53945a209cd3cd851c63df3713fa0f9bd DIFF: https://github.com/llvm/llvm-project/commit/2c8f5bd53945a209cd3cd851c63df3713fa0f9bd.diff LOG: [MLIR] Make ComplexType buildable if its element type is buildable If a ComplexType's element type is buildable, then that ComplexType should be buildable. This is accomplished by the introduction of a new ODS class called `SameBuildabilityAs`. This can be used by other types that are conditionally buildable. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D93892 Added: Modified: mlir/include/mlir/IR/OpBase.td mlir/test/mlir-tblgen/types.mlir Removed: diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 857a652f17d9..c65cc22c90f0 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -333,6 +333,13 @@ class BuildableType { code builderCall = builder; } +// A type that's buildable iff the type passed as an argument is buildable. +// This is intended for use by types like container types, which are only +// buildable if the type of their elements is buildable. +class SameBuildabilityAs { + code builderCall = !if(!empty(type.builderCall), "", builder); +} + // Any type at all. def AnyType : Type, "any type">; @@ -479,7 +486,9 @@ class Complex "$_self.cast<::mlir::ComplexType>().getElementType()", type.predicate>]>, "complex type with " # type.description # " elements", - "::mlir::ComplexType"> { + "::mlir::ComplexType">, + SameBuildabilityAs { Type elementType = type; } diff --git a/mlir/test/mlir-tblgen/types.mlir b/mlir/test/mlir-tblgen/types.mlir index 5e4dac33012b..61727d18e68f 100644 --- a/mlir/test/mlir-tblgen/types.mlir +++ b/mlir/test/mlir-tblgen/types.mlir @@ -58,7 +58,7 @@ func @complex_f64_tensor_success() { // - func @complex_f64_failure() { - // expected-error@+1 {{must be complex type with 64-bit float elements}} + // expected-error@+1 {{op inferred type incompatible with return type of operation}} "test.complex_f64"() : () -> (f64) return } ___ 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] 58ce477 - Fix DRR pattern when attributes and operands are interleaved and a dag subtree appears in the rewrite
Author: Mehdi Amini Date: 2020-12-30T00:19:38Z New Revision: 58ce477676c7bd9c6cee0c6d05f2708b4e178ff3 URL: https://github.com/llvm/llvm-project/commit/58ce477676c7bd9c6cee0c6d05f2708b4e178ff3 DIFF: https://github.com/llvm/llvm-project/commit/58ce477676c7bd9c6cee0c6d05f2708b4e178ff3.diff LOG: Fix DRR pattern when attributes and operands are interleaved and a dag subtree appears in the rewrite This fixes an incorrect fatal error in TableGen. This code probably comes from before attributes were allowed to interleave with operands in ODS. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D93915 Added: Modified: mlir/test/mlir-tblgen/rewriter-indexing.td mlir/tools/mlir-tblgen/RewriterGen.cpp Removed: diff --git a/mlir/test/mlir-tblgen/rewriter-indexing.td b/mlir/test/mlir-tblgen/rewriter-indexing.td index ed493d09008b..c21b04f6d0f6 100644 --- a/mlir/test/mlir-tblgen/rewriter-indexing.td +++ b/mlir/test/mlir-tblgen/rewriter-indexing.td @@ -47,3 +47,11 @@ def test1 : Pat<(BOp $attr, (AOp $input)), // CHECK: castedOp0.getODSOperands(1).begin()).getDefiningOp() def test2 : Pat<(COp $attr1, $op1, $attr2, (AOp $op2)), (BOp $attr1, $op2)>; + + +// Check rewriting with a DAG subtree in the result and remapping a location. +// CHECK: struct test3 : public ::mlir::RewritePattern { +// CHECK: rewriter.create((*a.getODSResults(0).begin()).getLoc() +def test3 : Pat<(BOp $attr, (AOp:$a $input)), +(BOp $attr, (AOp $input), (location $a))>; + diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index da189c65ec2a..96488d9cedc0 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -998,7 +998,7 @@ std::string PatternEmitter::handleOpCreation(DagNode tree, int resultIndex, // First go through all the child nodes who are nested DAG constructs to // create ops for them and remember the symbol names for them, so that we can // use the results in the current node. This happens in a recursive manner. - for (int i = 0, e = resultOp.getNumOperands(); i != e; ++i) { + for (int i = 0, e = tree.getNumArgs() - hasLocationDirective; i != e; ++i) { if (auto child = tree.getArgAsNestedDag(i)) childNodeNames[i] = handleResultPattern(child, i, depth + 1); } ___ 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] 7afd5cf - [NFC] Fix -Wrange-loop-analysis warnings.
Author: Dan Zheng Date: 2021-01-05T18:44:17Z New Revision: 7afd5cfbc757b004cba99d234df4e76b06956b2d URL: https://github.com/llvm/llvm-project/commit/7afd5cfbc757b004cba99d234df4e76b06956b2d DIFF: https://github.com/llvm/llvm-project/commit/7afd5cfbc757b004cba99d234df4e76b06956b2d.diff LOG: [NFC] Fix -Wrange-loop-analysis warnings. Remove unnecessary `&` from loop variables. Fix warnings: "loop variable is always a copy because the range does not return a reference". ``` [240/2862] Building CXX object tools/mlir/tools/mlir-tblgen/CMakeFiles/mlir-tblgen.dir/TypeDefGen.cpp.o llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:50:25: warning: loop variable 'typeDef' is always a copy because the range of type 'llvm::iterator_range, (lambda at llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:40:16), mlir::tblgen::TypeDef> >' does not return a reference [-Wrange-loop-analysis] for (const TypeDef &typeDef : defs) ^ llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:50:10: note: use non-reference type 'mlir::tblgen::TypeDef' for (const TypeDef &typeDef : defs) ^~~~ llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:64:23: warning: loop variable 'typeDef' is always a copy because the range of type 'llvm::iterator_range, (lambda at llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:40:16), mlir::tblgen::TypeDef> >' does not return a reference [-Wrange-loop-analysis] for (const TypeDef &typeDef : defs) ^ llvm-project/mlir/tools/mlir-tblgen/TypeDefGen.cpp:64:8: note: use non-reference type 'mlir::tblgen::TypeDef' for (const TypeDef &typeDef : defs) ^~~~ 2 warnings generated. [1934/2862] Building CXX object tools...Files/toyc-ch4.dir/mlir/MLIRGen.cpp.o llvm-project/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp:139:22: warning: loop variable 'name_value' is always a copy because the range of type 'detail::zippy > > &, MutableArrayRef >' does not return a reference [-Wrange-loop-analysis] for (const auto &name_value : ^ llvm-project/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp:139:10: note: use non-reference type 'std::__1::tuple > &, mlir::BlockArgument &>' for (const auto &name_value : ^~~~ 1 warning generated. [1940/2862] Building CXX object tools...Files/toyc-ch5.dir/mlir/MLIRGen.cpp.o llvm-project/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp:139:22: warning: loop variable 'name_value' is always a copy because the range of type 'detail::zippy > > &, MutableArrayRef >' does not return a reference [-Wrange-loop-analysis] for (const auto &name_value : ^ llvm-project/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp:139:10: note: use non-reference type 'std::__1::tuple > &, mlir::BlockArgument &>' for (const auto &name_value : ^~~~ 1 warning generated. ``` Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D94003 Added: Modified: mlir/examples/toy/Ch2/mlir/MLIRGen.cpp mlir/examples/toy/Ch3/mlir/MLIRGen.cpp mlir/examples/toy/Ch4/mlir/MLIRGen.cpp mlir/examples/toy/Ch5/mlir/MLIRGen.cpp mlir/examples/toy/Ch6/mlir/MLIRGen.cpp mlir/examples/toy/Ch7/mlir/Dialect.cpp mlir/examples/toy/Ch7/mlir/MLIRGen.cpp mlir/tools/mlir-tblgen/TypeDefGen.cpp Removed: diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 282a1bc76815..8b9f9dbdf190 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -136,10 +136,10 @@ class MLIRGenImpl { auto protoArgs = funcAST.getProto()->getArgs(); // Declare all the function arguments in the symbol table. -for (const auto &name_value : +for (const auto nameValue : llvm::zip(protoArgs, entryBlock.getArguments())) { - if (failed(declare(std::get<0>(name_value)->getName(), - std::get<1>(name_value + if (failed(declare(std::get<0>(nameValue)->getName(), + std::get<1>(nameValue return nullptr; } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 282a1bc76815..8b9f9dbdf190 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -136,10 +136,10 @@ class MLIRGenImpl { auto protoArgs = funcAST.getProto()->getArgs(); // Declare all the function arguments in the symbol table. -for (const auto &name_value : +for (const auto nameValue : llvm::zip(protoArgs, entryBlock.getArguments())) { - if (failed(declare(std::get<0>(name_value)->getName(), - std::get<1>(name_value + if (failed(declare(std::get<0>(nameValue)->getName(), + std::get<1>(nameValue retur
[llvm-branch-commits] [mlir] 86d68e2 - [mlir] Gen removeAttr methods with tablegen
Author: Felipe de Azevedo Piovezan Date: 2021-01-05T18:48:09Z New Revision: 86d68e288585964546d6382ecf71dcce10d018b7 URL: https://github.com/llvm/llvm-project/commit/86d68e288585964546d6382ecf71dcce10d018b7 DIFF: https://github.com/llvm/llvm-project/commit/86d68e288585964546d6382ecf71dcce10d018b7.diff LOG: [mlir] Gen removeAttr methods with tablegen If an operation defines an optional attribute (OptionalAttr or UnitAttr), transformations may wish to remove these attributes while maintaining invariants established by the operation. Currently, the only way to do this is by calling `Operation::removeAttr("attrName")`, which requires developers to know the exact name of the attribute used by table-gen. Furthermore, if the attribute name changes, this won't be detected at compile time. Instead, `removeAttr` would return an empty attribute and no errors would be raised, unless the caller checks for the returned value. This patch adds table gen support for generating `removeAttr` methods for OptionalAttributes defined by operations. Implementation choice: to preserve camelCase for the method's name, the first character of an attribute called `myAttr` is changed to upper case in order to preserve the coding style, so the final method would be called `removeMyAttr`. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D93903 Added: Modified: mlir/test/mlir-tblgen/op-attribute.td mlir/test/mlir-tblgen/op-decl.td mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp Removed: diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index 833f90dd28a2..b4c193c30c51 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -77,6 +77,12 @@ def AOp : NS_Op<"a_op", []> { // DEF: void AOp::cAttrAttr(some-attr-kind attr) { // DEF-NEXT: (*this)->setAttr("cAttr", attr); +// Test remove methods +// --- + +// DEF: Attribute AOp::removeCAttrAttr() { +// DEF-NEXT: return (*this)->removeAttr("cAttr"); + // Test build methods // --- @@ -265,6 +271,9 @@ def UnitAttrOp : NS_Op<"unit_attr_op", []> { // DEF: bool UnitAttrOp::attr() { // DEF: return {{.*}} != nullptr +// DEF: Attribute UnitAttrOp::removeAttrAttr() { +// DEF-NEXT: (*this)->removeAttr("attr"); + // DEF: build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr attr) diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td index 13daca67c475..d4d1a8b012c6 100644 --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -81,6 +81,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> { // CHECK: uint32_t attr1(); // CHECK: ::mlir::FloatAttr attr2Attr() // CHECK: ::llvm::Optional< ::llvm::APFloat > attr2(); +// CHECK: Attribute removeAttr2Attr(); // CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value val); // CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, int integer = 0); // CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::mlir::TypeRange s, ::mlir::Value a, ::mlir::ValueRange b, ::mlir::IntegerAttr attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount) diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 995b4cd05cd5..468fd7848d82 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -328,6 +328,9 @@ class OpEmitter { // Generates setter for the attributes. void genAttrSetters(); + // Generates removers for optional attributes. + void genOptionalAttrRemovers(); + // Generates getters for named operands. void genNamedOperandGetters(); @@ -600,6 +603,7 @@ OpEmitter::OpEmitter(const Operator &op, genNamedSuccessorGetters(); genAttrGetters(); genAttrSetters(); + genOptionalAttrRemovers(); genBuilder(); genParser(); genPrinter(); @@ -777,6 +781,28 @@ void OpEmitter::genAttrSetters() { } } +void OpEmitter::genOptionalAttrRemovers() { + // Generate methods for removing optional attributes, instead of having to + // use the string interface. Enables better compile time verification. + auto emitRemoveAttr = [&](StringRef name) { +auto upperInitial = name.take_front().upper(); +auto suffix = name.drop_front(); +auto *method = opClass.addMethodAndPrune( +"Attribute", ("remove" + upperInitial + suffix + "Attr").str()); +if (!method) + return; +auto &body = method->body(); +body << " return (*this)->removeAttr(\"" << name << "\");"; + }; + + for (const auto &namedAttr : op.getAttributes()) { +const auto &name = namedAttr.name; +const auto &attr = namedAttr.at
[llvm-branch-commits] [mlir] 4ae7952 - [mlir] Fix MathJax rendering in Affine doc
Author: lewuathe Date: 2021-01-06T02:11:36Z New Revision: 4ae7952e2b3566d373c55c8e9740051ca37ed738 URL: https://github.com/llvm/llvm-project/commit/4ae7952e2b3566d373c55c8e9740051ca37ed738 DIFF: https://github.com/llvm/llvm-project/commit/4ae7952e2b3566d373c55c8e9740051ca37ed738.diff LOG: [mlir] Fix MathJax rendering in Affine doc MathJax is not properly imported in Affine doc. It causes the invalid rendering of math formulas in the Affine doc page. https://mlir.llvm.org/docs/Dialects/Affine/#affine-expressions Importing MathJax code from CDN resolved the rendering issue as follows. {F14942131} Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D94004 Added: Modified: mlir/docs/Dialects/Affine.md Removed: diff --git a/mlir/docs/Dialects/Affine.md b/mlir/docs/Dialects/Affine.md index cedbb0106c30..1ce535a0c9b7 100644 --- a/mlir/docs/Dialects/Affine.md +++ b/mlir/docs/Dialects/Affine.md @@ -124,19 +124,19 @@ one-dimensional affine expressions, with the entire list enclosed in parentheses. **Context:** An affine function, informally, is a linear function plus a -constant. More formally, a function f defined on a vector $$\vec{v} \in -\mathbb{Z}^n$$ is a multidimensional affine function of $$\vec{v}$$ if -$$f(\vec{v})$$ can be expressed in the form $$M \vec{v} + \vec{c}$$ where $$M$$ -is a constant matrix from $$\mathbb{Z}^{m \times n}$$ and $$\vec{c}$$ is a -constant vector from $$\mathbb{Z}$$. $$m$$ is the dimensionality of such an +constant. More formally, a function f defined on a vector $\vec{v} \in +\mathbb{Z}^n$ is a multidimensional affine function of $\vec{v}$ if +$f(\vec{v})$ can be expressed in the form $M \vec{v} + \vec{c}$ where $M$ +is a constant matrix from $\mathbb{Z}^{m \times n}$ and $\vec{c}$ is a +constant vector from $\mathbb{Z}$. $m$ is the dimensionality of such an affine function. MLIR further extends the definition of an affine function to allow 'floordiv', 'ceildiv', and 'mod' with respect to positive integer constants. Such extensions to affine functions have often been referred to as quasi-affine functions by the polyhedral compiler community. MLIR uses the term 'affine map' to refer to these multidimensional quasi-affine functions. As -examples, $$(i+j+1, j)$$, $$(i \mod 2, j+i)$$, $$(j, i/4, i \mod 4)$$, $$(2i+1, -j)$$ are two-dimensional affine functions of $$(i, j)$$, but $$(i \cdot j, -i^2)$$, $$(i \mod j, i/j)$$ are not affine functions of $$(i, j)$$. +examples, $(i+j+1, j)$, $(i \mod 2, j+i)$, $(j, i/4, i \mod 4)$, $(2i+1, +j)$ are two-dimensional affine functions of $(i, j)$, but $(i \cdot j, +i^2)$, $(i \mod j, i/j)$ are not affine functions of $(i, j)$. ### Affine Maps ___ 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] 41e31ea - Fix GCC5 build, require explicit this->... in this call inside a lambda (NFC)
Author: Mehdi Amini Date: 2021-01-07T17:44:42Z New Revision: 41e31eac14c239970a220f81de5fdd3b231b5184 URL: https://github.com/llvm/llvm-project/commit/41e31eac14c239970a220f81de5fdd3b231b5184 DIFF: https://github.com/llvm/llvm-project/commit/41e31eac14c239970a220f81de5fdd3b231b5184.diff LOG: Fix GCC5 build, require explicit this->... in this call inside a lambda (NFC) Error was: mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp:2247:36: error: cannot call member function 'mlir::LLVM::FastmathFlags mlir::LLVM::FMFAttr::getFlags() const' without object return bitEnumContains(getFlags(), flag); ^ Added: Modified: mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp Removed: diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index b7f7789ee44b..cc57b1803f26 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2244,7 +2244,7 @@ static constexpr const FastmathFlags FastmathFlagsList[] = { void FMFAttr::print(DialectAsmPrinter &printer) const { printer << "fastmath<"; auto flags = llvm::make_filter_range(FastmathFlagsList, [&](auto flag) { -return bitEnumContains(getFlags(), flag); +return bitEnumContains(this->getFlags(), flag); }); llvm::interleaveComma(flags, printer, [&](auto flag) { printer << stringifyEnum(flag); }); ___ 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] 467e916 - Fix gcc5 build failure (NFC)
Author: Mehdi Amini Date: 2021-01-07T20:11:57Z New Revision: 467e916d3032bc068995aa1b6b16655eb573e750 URL: https://github.com/llvm/llvm-project/commit/467e916d3032bc068995aa1b6b16655eb573e750 DIFF: https://github.com/llvm/llvm-project/commit/467e916d3032bc068995aa1b6b16655eb573e750.diff LOG: Fix gcc5 build failure (NFC) The loop index was shadowing the container name. It seems that we can just not use a for-range loop here since there is an induction variable anyway. Differential Revision: https://reviews.llvm.org/D94254 Added: Modified: llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp Removed: diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp index 12b9688c2ee0..3b6e263ee6d8 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp @@ -330,11 +330,11 @@ void AMDGPUCallLowering::processSplitArgs( // FIXME: This is mostly nasty pre-processing before handleAssignments. Most // of this should be performed by handleAssignments. - int SplitIdx = 0; - for (const ArgInfo &SplitArg : SplitArg) { + for (int SplitIdx = 0, e = SplitArg.size(); SplitIdx != e; ++SplitIdx) { +const ArgInfo &CurSplitArg = SplitArg[SplitIdx]; Register Reg = OrigArg.Regs[SplitIdx]; -EVT VT = EVT::getEVT(SplitArg.Ty); -LLT LLTy = getLLTForType(*SplitArg.Ty, DL); +EVT VT = EVT::getEVT(CurSplitArg.Ty); +LLT LLTy = getLLTForType(*CurSplitArg.Ty, DL); unsigned NumParts = TLI.getNumRegistersForCallingConv(Ctx, CallConv, VT); MVT RegVT = TLI.getRegisterTypeForCallingConv(Ctx, CallConv, VT); @@ -342,9 +342,8 @@ void AMDGPUCallLowering::processSplitArgs( if (NumParts == 1) { // No splitting to do, but we want to replace the original type (e.g. [1 x // double] -> double). - SplitArgs.emplace_back(Reg, SplitArg.Ty, OrigArg.Flags, OrigArg.IsFixed); - - ++SplitIdx; + SplitArgs.emplace_back(Reg, CurSplitArg.Ty, OrigArg.Flags, + OrigArg.IsFixed); continue; } @@ -362,8 +361,6 @@ void AMDGPUCallLowering::processSplitArgs( } PerformArgSplit(SplitRegs, Reg, LLTy, PartLLT, SplitIdx); - -++SplitIdx; } } ___ 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] [debuginfo-tests] 476db17 - Fix include path for check-gdb-mlir-support to include the MLIR binary dir
Author: Mehdi Amini Date: 2021-01-07T21:29:09Z New Revision: 476db17dcb64ef3ec6e247f4b1c673b57f61a367 URL: https://github.com/llvm/llvm-project/commit/476db17dcb64ef3ec6e247f4b1c673b57f61a367 DIFF: https://github.com/llvm/llvm-project/commit/476db17dcb64ef3ec6e247f4b1c673b57f61a367.diff LOG: Fix include path for check-gdb-mlir-support to include the MLIR binary dir This fixes a build failure: fatal error: 'mlir/IR/BuiltinTypes.h.inc' file not found Added: Modified: debuginfo-tests/CMakeLists.txt Removed: diff --git a/debuginfo-tests/CMakeLists.txt b/debuginfo-tests/CMakeLists.txt index 4b6af5212fc8..0abbe4604a79 100644 --- a/debuginfo-tests/CMakeLists.txt +++ b/debuginfo-tests/CMakeLists.txt @@ -26,7 +26,9 @@ if ("mlir" IN_LIST LLVM_ENABLE_PROJECTS) add_llvm_executable(check-gdb-mlir-support llvm-prettyprinters/gdb/mlir-support.cpp ) - target_include_directories(check-gdb-mlir-support PRIVATE ${LLVM_EXTERNAL_MLIR_SOURCE_DIR}/include) + target_include_directories(check-gdb-mlir-support PRIVATE + ${LLVM_EXTERNAL_MLIR_SOURCE_DIR}/include + ${LLVM_BINARY_DIR}/tools/mlir/include) target_link_libraries(check-gdb-mlir-support PRIVATE MLIRIR) list(APPEND DEBUGINFO_TEST_DEPS check-gdb-mlir-support) set(MLIR_SOURCE_DIR ${LLVM_EXTERNAL_MLIR_SOURCE_DIR}) ___ 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] [debuginfo-tests] 9e1aaa9 - Fix check-gdb-mlir-support build after MLIR API changed to take Context as first argument
Author: Mehdi Amini Date: 2021-01-07T21:30:39Z New Revision: 9e1aaa9943b814c22ae03f4abb3171dac8062801 URL: https://github.com/llvm/llvm-project/commit/9e1aaa9943b814c22ae03f4abb3171dac8062801 DIFF: https://github.com/llvm/llvm-project/commit/9e1aaa9943b814c22ae03f4abb3171dac8062801.diff LOG: Fix check-gdb-mlir-support build after MLIR API changed to take Context as first argument Added: Modified: debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp Removed: diff --git a/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp b/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp index a65f62404de8..629ef1668c8f 100644 --- a/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp +++ b/debuginfo-tests/llvm-prettyprinters/gdb/mlir-support.cpp @@ -15,13 +15,13 @@ mlir::Value Value({reinterpret_cast(0x8), mlir::Type Type(nullptr); mlir::Type IndexType = mlir::IndexType::get(&Context); mlir::Type IntegerType = -mlir::IntegerType::get(3, mlir::IntegerType::Unsigned, &Context); +mlir::IntegerType::get(&Context, 3, mlir::IntegerType::Unsigned); mlir::Type FloatType = mlir::Float32Type::get(&Context); mlir::Type MemRefType = mlir::MemRefType::get({4, 5}, FloatType); mlir::Type UnrankedMemRefType = mlir::UnrankedMemRefType::get(IntegerType, 6); mlir::Type VectorType = mlir::VectorType::get({1, 2}, FloatType); mlir::Type TupleType = -mlir::TupleType::get(mlir::TypeRange({IndexType, FloatType}), &Context); +mlir::TupleType::get(&Context, mlir::TypeRange({IndexType, FloatType})); auto UnknownLoc = mlir::UnknownLoc::get(&Context); auto FileLineColLoc = mlir::FileLineColLoc::get("file", 7, 8, &Context); ___ 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] f02e61a - Fix MLIR DRR matching when attributes are interleaved with operands
Author: Mehdi Amini Date: 2021-01-08T03:18:26Z New Revision: f02e61a8b957871292e092aa440964c0f4e2bb21 URL: https://github.com/llvm/llvm-project/commit/f02e61a8b957871292e092aa440964c0f4e2bb21 DIFF: https://github.com/llvm/llvm-project/commit/f02e61a8b957871292e092aa440964c0f4e2bb21.diff LOG: Fix MLIR DRR matching when attributes are interleaved with operands The ODSOperand indexing should ignore the attributes. Differential Revision: https://reviews.llvm.org/D94281 Added: Modified: mlir/test/mlir-tblgen/rewriter-indexing.td mlir/tools/mlir-tblgen/RewriterGen.cpp Removed: diff --git a/mlir/test/mlir-tblgen/rewriter-indexing.td b/mlir/test/mlir-tblgen/rewriter-indexing.td index c21b04f6d0f6..a6b403285765 100644 --- a/mlir/test/mlir-tblgen/rewriter-indexing.td +++ b/mlir/test/mlir-tblgen/rewriter-indexing.td @@ -51,6 +51,9 @@ def test2 : Pat<(COp $attr1, $op1, $attr2, (AOp $op2)), // Check rewriting with a DAG subtree in the result and remapping a location. // CHECK: struct test3 : public ::mlir::RewritePattern { +// We expect ODSOperand 0 here, the attribute before the operand in BOp +// definition shouldn't shift the counter. +// CHECK: op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); // CHECK: rewriter.create((*a.getODSResults(0).begin()).getLoc() def test3 : Pat<(BOp $attr, (AOp:$a $input)), (BOp $attr, (AOp $input), (location $a))>; diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 9fca15b416ba..1a665174 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -83,9 +83,10 @@ class PatternEmitter { void emitOpMatch(DagNode tree, StringRef opName, int depth); // Emits C++ statements for matching the `argIndex`-th argument of the given - // DAG `tree` as an operand. + // DAG `tree` as an operand. operandIndex is the index in the DAG excluding + // the preceding attributes. void emitOperandMatch(DagNode tree, StringRef opName, int argIndex, -int depth); +int operandIndex, int depth); // Emits C++ statements for matching the `argIndex`-th argument of the given // DAG `tree` as an attribute. @@ -379,7 +380,7 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) { // Next handle DAG leaf: operand or attribute if (opArg.is()) { // emitOperandMatch's argument indexing counts attributes. - emitOperandMatch(tree, castedName, i, depth); + emitOperandMatch(tree, castedName, i, nextOperand, depth); ++nextOperand; } else if (opArg.is()) { emitAttributeMatch(tree, opName, i, depth); @@ -393,7 +394,8 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) { } void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName, - int argIndex, int depth) { + int argIndex, int operandIndex, + int depth) { Operator &op = tree.getDialectOp(opMap); auto *operand = op.getArg(argIndex).get(); auto matcher = tree.getArgAsLeaf(argIndex); @@ -418,7 +420,7 @@ void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName, PrintFatalError(loc, error); } auto self = formatv("(*{0}.getODSOperands({1}).begin()).getType()", - opName, argIndex); + opName, operandIndex); emitMatchCheck( opName, tgfmt(constraint.getConditionTemplate(), &fmtCtx.withSelf(self)), ___ 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] 03d2493 - [mlir] Enhance mlir-opt show-dialects test case
Author: Lewuathe Date: 2021-01-09T20:43:51Z New Revision: 03d249396d6b736447d529915e77dfeb84f2eeae URL: https://github.com/llvm/llvm-project/commit/03d249396d6b736447d529915e77dfeb84f2eeae DIFF: https://github.com/llvm/llvm-project/commit/03d249396d6b736447d529915e77dfeb84f2eeae.diff LOG: [mlir] Enhance mlir-opt show-dialects test case mlir-opt supports many more test cases. All available dialects supported by latest mlir-opt should be coverted in the test case. Reviewed By: aartbik, stephenneuendorffer, mehdi_amini Differential Revision: https://reviews.llvm.org/D93821 Added: Modified: mlir/test/mlir-opt/commandline.mlir Removed: diff --git a/mlir/test/mlir-opt/commandline.mlir b/mlir/test/mlir-opt/commandline.mlir index 4cf6ea9d8a69..94eb94483790 100644 --- a/mlir/test/mlir-opt/commandline.mlir +++ b/mlir/test/mlir-opt/commandline.mlir @@ -1,16 +1,29 @@ // RUN: mlir-opt --show-dialects | FileCheck %s // CHECK: Available Dialects: -// CHECK: affine -// CHECK: gpu -// CHECK: linalg -// CHECK: llvm -// CHECK: nvvm -// CHECK: omp -// CHECK: quant -// CHECK: rocdl -// CHECK: scf -// CHECK: sdbm -// CHECK: spv -// CHECK: std -// CHECK: test -// CHECK: vector +// CHECK-NEXT: acc +// CHECK-NEXT: affine +// CHECK-NEXT: arm_neon +// CHECK-NEXT: arm_sve +// CHECK-NEXT: async +// CHECK-NEXT: avx512 +// CHECK-NEXT: gpu +// CHECK-NEXT: linalg +// CHECK-NEXT: llvm +// CHECK-NEXT: llvm_arm_neon +// CHECK-NEXT: llvm_arm_sve +// CHECK-NEXT: llvm_avx512 +// CHECK-NEXT: nvvm +// CHECK-NEXT: omp +// CHECK-NEXT: pdl +// CHECK-NEXT: pdl_interp +// CHECK-NEXT: quant +// CHECK-NEXT: rocdl +// CHECK-NEXT: scf +// CHECK-NEXT: sdbm +// CHECK-NEXT: shape +// CHECK-NEXT: spv +// CHECK-NEXT: std +// CHECK-NEXT: tensor +// CHECK-NEXT: test +// CHECK-NEXT: tosa +// CHECK-NEXT: vector ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits