]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/trans/common.rs
auto merge of #7903 : michaelwoerister/rust/end_of_spanned, r=jdm
[rust.git] / src / librustc / middle / trans / common.rs
index ed3b80700b4498ad6e71575375ed99a69ef48fac..995cda92d9b8ce6bb5bec456793b1b50d5f1a88b 100644 (file)
@@ -174,17 +174,14 @@ pub struct fn_ctxt_ {
     // 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.
@@ -252,12 +249,12 @@ pub fn env_arg_pos(&self) -> uint {
         }
     }
 
-    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 {