//===- LocationSnapshot.cpp - Location Snapshot Utilities -----------------===// // // 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 // //===----------------------------------------------------------------------===// #include "mlir/Transforms/LocationSnapshot.h" #include "mlir/IR/AsmState.h" #include "mlir/IR/Builders.h" #include "mlir/Pass/Pass.h" #include "mlir/Support/FileUtilities.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/ToolOutputFile.h" #include <optional> namespace mlir { #define GEN_PASS_DEF_LOCATIONSNAPSHOT #include "mlir/Transforms/Passes.h.inc" } // namespace mlir usingnamespacemlir; /// This function generates new locations from the given IR by snapshotting the /// IR to the given stream, and using the printed locations within that stream. /// If a 'tag' is non-empty, the generated locations are represented as a /// NameLoc with the given tag as the name, and then fused with the existing /// locations. Otherwise, the existing locations are replaced. static void generateLocationsFromIR(raw_ostream &os, StringRef fileName, Operation *op, const OpPrintingFlags &flags, StringRef tag) { … } /// This function generates new locations from the given IR by snapshotting the /// IR to the given file, and using the printed locations within that file. If /// `filename` is empty, a temporary file is generated instead. static LogicalResult generateLocationsFromIR(StringRef fileName, Operation *op, OpPrintingFlags flags, StringRef tag) { … } /// This function generates new locations from the given IR by snapshotting the /// IR to the given stream, and using the printed locations within that stream. /// The generated locations replace the current operation locations. void mlir::generateLocationsFromIR(raw_ostream &os, StringRef fileName, Operation *op, OpPrintingFlags flags) { … } /// This function generates new locations from the given IR by snapshotting the /// IR to the given file, and using the printed locations within that file. If /// `filename` is empty, a temporary file is generated instead. LogicalResult mlir::generateLocationsFromIR(StringRef fileName, Operation *op, OpPrintingFlags flags) { … } /// This function generates new locations from the given IR by snapshotting the /// IR to the given stream, and using the printed locations within that stream. /// The generated locations are represented as a NameLoc with the given tag as /// the name, and then fused with the existing locations. void mlir::generateLocationsFromIR(raw_ostream &os, StringRef fileName, StringRef tag, Operation *op, OpPrintingFlags flags) { … } /// This function generates new locations from the given IR by snapshotting the /// IR to the given file, and using the printed locations within that file. If /// `filename` is empty, a temporary file is generated instead. LogicalResult mlir::generateLocationsFromIR(StringRef fileName, StringRef tag, Operation *op, OpPrintingFlags flags) { … } namespace { struct LocationSnapshotPass : public impl::LocationSnapshotBase<LocationSnapshotPass> { … }; } // namespace std::unique_ptr<Pass> mlir::createLocationSnapshotPass(OpPrintingFlags flags, StringRef fileName, StringRef tag) { … } std::unique_ptr<Pass> mlir::createLocationSnapshotPass() { … }