[Mlir-commits] [mlir] 4455f3c - Capture the name for mlir::OpPassManager in std::string instead of StringRef (NFC)

Mehdi Amini llvmlistbot at llvm.org
Wed Nov 4 21:29:05 PST 2020


Author: Mehdi Amini
Date: 2020-11-05T05:28:44Z
New Revision: 4455f3ce72ba2bb0276200f6f29629afca8812d4

URL: https://github.com/llvm/llvm-project/commit/4455f3ce72ba2bb0276200f6f29629afca8812d4
DIFF: https://github.com/llvm/llvm-project/commit/4455f3ce72ba2bb0276200f6f29629afca8812d4.diff

LOG: Capture the name for mlir::OpPassManager in std::string instead of StringRef (NFC)

The previous behavior was fragile when building an OpPassManager using a
string, as it was forcing the client to ensure the string to outlive the
entire PassManager.
This isn't a performance sensitive area either that would justify
optimizing further.

Added: 
    

Modified: 
    mlir/lib/Pass/Pass.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index 610786574ff5..a1aecf6ffb20 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -92,7 +92,7 @@ namespace mlir {
 namespace detail {
 struct OpPassManagerImpl {
   OpPassManagerImpl(Identifier identifier, OpPassManager::Nesting nesting)
-      : name(identifier), identifier(identifier), nesting(nesting) {}
+      : name(identifier.str()), identifier(identifier), nesting(nesting) {}
   OpPassManagerImpl(StringRef name, OpPassManager::Nesting nesting)
       : name(name), nesting(nesting) {}
 
@@ -123,7 +123,7 @@ struct OpPassManagerImpl {
   }
 
   /// The name of the operation that passes of this pass manager operate on.
-  StringRef name;
+  std::string name;
 
   /// The cached identifier (internalized in the context) for the name of the
   /// operation that passes of this pass manager operate on.
@@ -164,7 +164,7 @@ void OpPassManagerImpl::addPass(std::unique_ptr<Pass> pass) {
   // If this pass runs on a 
diff erent operation than this pass manager, then
   // implicitly nest a pass manager for this operation if enabled.
   auto passOpName = pass->getOpName();
-  if (passOpName && passOpName != name) {
+  if (passOpName && passOpName->str() != name) {
     if (nesting == OpPassManager::Nesting::Implicit)
       return nest(*passOpName).addPass(std::move(pass));
     llvm::report_fatal_error(llvm::Twine("Can't add pass '") + pass->getName() +


        


More information about the Mlir-commits mailing list