From 1ad58d4dd6fb40e0833a094799717cc2b17fefc6 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 14 May 2011 00:48:51 -0400 Subject: [PATCH] rustllvm: Free TargetMachine in LLVMRustWriteOutputFile --- src/rustllvm/RustWrapper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 2a3d8aeb79e..2c50a6ccfa7 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -90,7 +90,7 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, std::string Err; const Target *TheTarget = TargetRegistry::lookupTarget(triple, Err); std::string FeaturesStr; - TargetMachine &Target = *TheTarget->createTargetMachine(triple, FeaturesStr); + TargetMachine *Target = TheTarget->createTargetMachine(triple, FeaturesStr); bool NoVerify = false; CodeGenOpt::Level OLvl = CodeGenOpt::Default; PassManager *PM = unwrap(PMR); @@ -101,10 +101,11 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, TargetMachine::CodeGenFileType FileType2 = static_cast(FileType); - bool foo = Target.addPassesToEmitFile(*PM, FOS, FileType2, OLvl, NoVerify); + bool foo = Target->addPassesToEmitFile(*PM, FOS, FileType2, OLvl, NoVerify); assert(!foo); (void)foo; PM->run(*unwrap(M)); + delete Target; } extern "C" LLVMModuleRef LLVMRustParseBitcode(LLVMMemoryBufferRef MemBuf) {