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