@@ -219,8 +219,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
219219 << " -mattr=-code-object-v3 "
220220 << target.substr (4 , target.length () - 4 );
221221 std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine (config.str ());
222- std::unique_ptr<CodeGenAMDGPU> cg (new CodeGenAMDGPU ());
223222 std::unique_ptr<llvm::LLVMContext> ctx (new llvm::LLVMContext ());
223+ // careful: cg will hold a naked pointer reference to ctx, so it should
224+ // have a shorter lifetime than the ctx.
225+ std::unique_ptr<CodeGenAMDGPU> cg (new CodeGenAMDGPU ());
224226
225227 cg->Init (" TVMAMDGPUModule" , tm.get (), ctx.get (), false , false );
226228
@@ -233,10 +235,10 @@ runtime::Module BuildAMDGPU(IRModule mod, std::string target) {
233235
234236 const auto *find_rocm_bitcodes =
235237 tvm::runtime::Registry::Get (" tvm_callback_rocm_bitcode_path" );
236- Array<PrimExpr > bitcode_files = (*find_rocm_bitcodes)();
238+ Array<runtime::String > bitcode_files = (*find_rocm_bitcodes)();
237239
238- for (auto &bitcode : bitcode_files) {
239- std::string path = bitcode. as <StringImmNode>()-> value ;
240+ for (auto &bitcode_path : bitcode_files) {
241+ std::string path = bitcode_path ;
240242 llvm::SMDiagnostic err;
241243 std::unique_ptr<llvm::Module> mlib = llvm::parseIRFile (path, err, *ctx);
242244 if (mlib.get () == nullptr ) {
0 commit comments