// always be Some.
llretptr: Option<ValueRef>,
+ entry_bcx: Option<block>,
+
// These elements: "hoisted basic blocks" containing
// administrative activities that have to happen in only one place in
// the function, due to LLVM's quirks.
- // A block for all the function's static allocas, so that LLVM
- // will coalesce them into a single alloca call.
- llstaticallocas: Option<BasicBlockRef>,
- // A block containing code that copies incoming arguments to space
- // already allocated by code in one of the llallocas blocks.
- // (LLVM requires that arguments be copied to local allocas before
- // allowing most any operation to be performed on them.)
- llloadenv: Option<BasicBlockRef>,
+ // A marker for the place where we want to insert the function's static
+ // allocas, so that LLVM will coalesce them into a single alloca call.
+ alloca_insert_pt: Option<ValueRef>,
llreturn: Option<BasicBlockRef>,
// The 'self' value currently in use in this function, if there
// is one.
}
}
- pub fn get_llstaticallocas(&mut self) -> BasicBlockRef {
- if self.llstaticallocas.is_none() {
- self.llstaticallocas = Some(base::mk_staticallocas_basic_block(self.llfn));
+ pub fn cleanup(&mut self) {
+ unsafe {
+ llvm::LLVMInstructionEraseFromParent(self.alloca_insert_pt.get());
}
-
- self.llstaticallocas.get()
+ // Remove the cycle between fcx and bcx, so memory can be freed
+ self.entry_bcx = None;
}
pub fn get_llreturn(&mut self) -> BasicBlockRef {