Unverified Commit 9a989e57 by Thomas Viehmann Committed by GitHub

misc fixes for ROCm (pointer lifetime, runtime::String refactor) (#5431)

parent 8efd5460
...@@ -219,8 +219,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) { ...@@ -219,8 +219,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
<< " -mattr=-code-object-v3 " << " -mattr=-code-object-v3 "
<< target.substr(4, target.length() - 4); << target.substr(4, target.length() - 4);
std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine(config.str()); 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()); 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); cg->Init("TVMAMDGPUModule", tm.get(), ctx.get(), false, false);
...@@ -233,10 +235,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) { ...@@ -233,10 +235,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
const auto *find_rocm_bitcodes = const auto *find_rocm_bitcodes =
tvm::runtime::Registry::Get("tvm_callback_rocm_bitcode_path"); 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) { for (auto &bitcode_path : bitcode_files) {
std::string path = bitcode.as<StringImmNode>()->value; std::string path = bitcode_path;
llvm::SMDiagnostic err; llvm::SMDiagnostic err;
std::unique_ptr<llvm::Module> mlib = llvm::parseIRFile(path, err, *ctx); std::unique_ptr<llvm::Module> mlib = llvm::parseIRFile(path, err, *ctx);
if (mlib.get() == nullptr) { if (mlib.get() == nullptr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment