Skip to content

Commit fef5b99

Browse files
committed
Fix releasing DeviceInstance
1 parent ae0605f commit fef5b99

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

clang/lib/Interpreter/DeviceOffload.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ IncrementalCUDADeviceParser::IncrementalCUDADeviceParser(
3434
TargetOpts(HostInstance.getTargetOpts()) {
3535
if (Err)
3636
return;
37-
DeviceCI = std::move(DeviceInstance);
3837
StringRef Arch = TargetOpts.CPU;
3938
if (!Arch.starts_with("sm_") || Arch.substr(3).getAsInteger(10, SMVersion)) {
39+
DeviceInstance.release();
4040
Err = llvm::joinErrors(std::move(Err), llvm::make_error<llvm::StringError>(
4141
"Invalid CUDA architecture",
4242
llvm::inconvertibleErrorCode()));
4343
return;
4444
}
45+
DeviceCI = std::move(DeviceInstance);
4546
}
4647

4748
llvm::Expected<TranslationUnitDecl *>

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,29 +460,25 @@ Interpreter::create(std::unique_ptr<CompilerInstance> CI,
460460
return std::move(Err);
461461

462462
if (DeviceCI) {
463-
// Create a fresh LLVM context for the CUDA device interpreter
464463
// auto DeviceLLVMCtx = std::make_unique<llvm::LLVMContext>();
465464
// auto DeviceTSCtx =
466465
// std::make_unique<llvm::orc::ThreadSafeContext>(std::move(DeviceLLVMCtx));
467466

468467
// llvm::Error DeviceErr = llvm::Error::success();
469468
// llvm::ErrorAsOutParameter EAO(&DeviceErr);
470469

471-
// // Create an IncrementalAction for the device CompilerInstance
472470
// auto DeviceAct = std::make_unique<IncrementalAction>(
473471
// *DeviceCI, *DeviceTSCtx->getContext(), DeviceErr, *Interp);
474472

475473
// if (DeviceErr)
476474
// return std::move(DeviceErr);
477475

478-
// Execute the device-side action (this will create Sema etc.)
476+
//DeviceCI->ExecuteAction(*DeviceAct);
479477
DeviceCI->ExecuteAction(*Interp->Act);
480478

481-
// Set up a virtual file system to emit fatbin to memory
482479
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> IMVFS =
483480
std::make_unique<llvm::vfs::InMemoryFileSystem>();
484481

485-
// Create the CUDA device parser using the initialized device CI
486482
auto DeviceParser = std::make_unique<IncrementalCUDADeviceParser>(
487483
std::move(DeviceCI), *Interp->getCompilerInstance(), IMVFS, Err,
488484
Interp->PTUs);

0 commit comments

Comments
 (0)