[llvm] a2692ac - [llvm-split] Correctly deallocate TargetMachine

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 04:15:00 PDT 2024


Author: pvanhout
Date: 2024-04-22T13:14:53+02:00
New Revision: a2692ac23f1421097f0d51c7325045ed38db6408

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

LOG: [llvm-split] Correctly deallocate TargetMachine

Should fix the ASAN error.

Added: 
    

Modified: 
    llvm/tools/llvm-split/llvm-split.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-split/llvm-split.cpp b/llvm/tools/llvm-split/llvm-split.cpp
index 41f392bcc53117..39a89cb1d2e75c 100644
--- a/llvm/tools/llvm-split/llvm-split.cpp
+++ b/llvm/tools/llvm-split/llvm-split.cpp
@@ -72,7 +72,7 @@ int main(int argc, char **argv) {
   cl::HideUnrelatedOptions({&SplitCategory, &getColorCategory()});
   cl::ParseCommandLineOptions(argc, argv, "LLVM module splitter\n");
 
-  TargetMachine *TM = nullptr;
+  std::unique_ptr<TargetMachine> TM;
   if (!MTriple.empty()) {
     InitializeAllTargets();
     InitializeAllTargetMCs();
@@ -85,8 +85,8 @@ int main(int argc, char **argv) {
     }
 
     TargetOptions Options;
-    TM = T->createTargetMachine(MTriple, MCPU, /*FS*/ "", Options, std::nullopt,
-                                std::nullopt);
+    TM = std::unique_ptr<TargetMachine>(T->createTargetMachine(
+        MTriple, MCPU, /*FS*/ "", Options, std::nullopt, std::nullopt));
   }
 
   std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);


        


More information about the llvm-commits mailing list