Skip to content

Commit

Permalink
misc fixes for ROCm (pointer lifetime, runtime::String refactor) (apa…
Browse files Browse the repository at this point in the history
  • Loading branch information
t-vi authored and Trevor Morris committed Jun 8, 2020
1 parent 8519c67 commit 5b73599
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/target/llvm/codegen_amdgpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
<< " -mattr=-code-object-v3 "
<< target.substr(4, target.length() - 4);
std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine(config.str());
std::unique_ptr<CodeGenAMDGPU> cg(new CodeGenAMDGPU());
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext());
// careful: cg will hold a naked pointer reference to ctx, so it should
// have a shorter lifetime than the ctx.
std::unique_ptr<CodeGenAMDGPU> cg(new CodeGenAMDGPU());

cg->Init("TVMAMDGPUModule", tm.get(), ctx.get(), false, false);

Expand All @@ -233,10 +235,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {

const auto *find_rocm_bitcodes =
tvm::runtime::Registry::Get("tvm_callback_rocm_bitcode_path");
Array<PrimExpr> bitcode_files = (*find_rocm_bitcodes)();
Array<runtime::String> bitcode_files = (*find_rocm_bitcodes)();

for (auto &bitcode : bitcode_files) {
std::string path = bitcode.as<StringImmNode>()->value;
for (auto &bitcode_path : bitcode_files) {
std::string path = bitcode_path;
llvm::SMDiagnostic err;
std::unique_ptr<llvm::Module> mlib = llvm::parseIRFile(path, err, *ctx);
if (mlib.get() == nullptr) {
Expand Down

0 comments on commit 5b73599

Please sign in to comment.