From 9a6eb10c783ed6794d0d739e561576d17ffff9b8 Mon Sep 17 00:00:00 2001 From: Dwight Guth Date: Mon, 11 Mar 2024 10:13:41 -0500 Subject: [PATCH] make sure to insert return value of CreateMalloc --- lib/codegen/Decision.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/codegen/Decision.cpp b/lib/codegen/Decision.cpp index d1c2b0a0c..df4a030af 100644 --- a/lib/codegen/Decision.cpp +++ b/lib/codegen/Decision.cpp @@ -977,11 +977,14 @@ std::pair, llvm::BasicBlock *> step_function_header( auto *arr = module->getOrInsertGlobal("gc_roots", root_ty); std::vector> root_ptrs; std::vector are_block; - llvm::AllocaInst *are_block_val = new llvm::AllocaInst( - llvm::Type::getInt1Ty(module->getContext()), 0, + llvm::Instruction *are_block_val = llvm::CallInst::CreateMalloc( + collect, llvm::Type::getInt64Ty(block->getContext()), + llvm::Type::getInt1Ty(module->getContext()), + llvm::ConstantInt::get(llvm::Type::getInt64Ty(module->getContext()), 1), llvm::ConstantInt::get( llvm::Type::getInt64Ty(module->getContext()), nroots), - "are_block", block->getParent()->getEntryBlock().getFirstNonPHI()); + nullptr); + are_block_val->insertAfter(&collect->back()); llvm::Type *voidptrptr = llvm::PointerType::getUnqual( llvm::Type::getInt8PtrTy(module->getContext())); auto *zero