Skip to content

Commit cf19c88

Browse files
Krzysztof ParzyszekCahoon, Brendon
andauthored
[Hexagon] Change declaration order of unique_ptr objects to fix crash (#8859)
A crash occurs when automatically deleting an instance of CodeGenHexagon because the LLVMContext object has already been freed. Objects of both types are created using unique_ptr, but the object managed by the LLVMContext unique_ptr is passed to CodeGenHexagon object (not as a unique_ptr). This crash is fixed by moving the declaration of the LLVMContext object before the CodeGenHexagon object. I'm not sure if this is the best way to fix this, but it does fix the crash. Also, in other files, the LLVMContext object is always created first. Co-authored-by: Cahoon, Brendon <bcahoon@quicinc.com>
1 parent 3306857 commit cf19c88

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/target/llvm/codegen_hexagon.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ runtime::Module BuildHexagon(IRModule mod, Target target) {
704704
(void)CallOnce;
705705

706706
std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine(target);
707-
std::unique_ptr<CodeGenHexagon> cg(new CodeGenHexagon());
708707
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext());
708+
std::unique_ptr<CodeGenHexagon> cg(new CodeGenHexagon());
709709
cg->Init("TVMHexagonModule", tm.get(), ctx.get(), false, false, false);
710710
for (auto kv : mod->functions) {
711711
ICHECK(kv.second->IsInstance<PrimFuncNode>()) << "Can only lower IR Module with PrimFuncs";

0 commit comments

Comments
 (0)