[llvm-branch-commits] [llvm] [mlir] [clang] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)

Fabian Mora via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 3 05:26:01 PDT 2023


================
@@ -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<llvm::TargetMachine> ModuleToObject::createTargetMachine() {
+std::optional<llvm::TargetMachine *>
+ModuleToObject::getOrCreateTargetMachine() {
   std::string error;
----------------
fabianmcg wrote:

Is there a reason why the cached `targetMachine` is not immediately returned? 
```suggestion
  if (targetMachine)
    return targetMachine.get();
  std::string error;
```

https://github.com/llvm/llvm-project/pull/71165


More information about the llvm-branch-commits mailing list