提交 3eb50358 编写于 作者: I Irina Popa

rustc_codegen_llvm: use safe references for BasicBlock.

上级 f3751853
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef}; use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef};
use llvm::{self, BasicBlockRef}; use llvm::{self, BasicBlock};
use common::*; use common::*;
use type_::Type; use type_::Type;
use value::Value; use value::Value;
...@@ -102,7 +102,7 @@ pub fn llfn(&self) -> &'ll Value { ...@@ -102,7 +102,7 @@ pub fn llfn(&self) -> &'ll Value {
} }
} }
pub fn llbb(&self) -> BasicBlockRef { pub fn llbb(&self) -> &'ll BasicBlock {
unsafe { unsafe {
llvm::LLVMGetInsertBlock(self.llbuilder) llvm::LLVMGetInsertBlock(self.llbuilder)
} }
...@@ -134,13 +134,13 @@ pub fn position_before(&self, insn: &'ll Value) { ...@@ -134,13 +134,13 @@ pub fn position_before(&self, insn: &'ll Value) {
} }
} }
pub fn position_at_end(&self, llbb: BasicBlockRef) { pub fn position_at_end(&self, llbb: &'ll BasicBlock) {
unsafe { unsafe {
llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb); llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb);
} }
} }
pub fn position_at_start(&self, llbb: BasicBlockRef) { pub fn position_at_start(&self, llbb: &'ll BasicBlock) {
unsafe { unsafe {
llvm::LLVMRustPositionBuilderAtStart(self.llbuilder, llbb); llvm::LLVMRustPositionBuilderAtStart(self.llbuilder, llbb);
} }
...@@ -168,21 +168,21 @@ pub fn aggregate_ret(&self, ret_vals: &[&'ll Value]) { ...@@ -168,21 +168,21 @@ pub fn aggregate_ret(&self, ret_vals: &[&'ll Value]) {
} }
} }
pub fn br(&self, dest: BasicBlockRef) { pub fn br(&self, dest: &'ll BasicBlock) {
self.count_insn("br"); self.count_insn("br");
unsafe { unsafe {
llvm::LLVMBuildBr(self.llbuilder, dest); llvm::LLVMBuildBr(self.llbuilder, dest);
} }
} }
pub fn cond_br(&self, cond: &'ll Value, then_llbb: BasicBlockRef, else_llbb: BasicBlockRef) { pub fn cond_br(&self, cond: &'ll Value, then_llbb: &'ll BasicBlock, else_llbb: &'ll BasicBlock) {
self.count_insn("condbr"); self.count_insn("condbr");
unsafe { unsafe {
llvm::LLVMBuildCondBr(self.llbuilder, cond, then_llbb, else_llbb); llvm::LLVMBuildCondBr(self.llbuilder, cond, then_llbb, else_llbb);
} }
} }
pub fn switch(&self, v: &'ll Value, else_llbb: BasicBlockRef, num_cases: usize) -> &'ll Value { pub fn switch(&self, v: &'ll Value, else_llbb: &'ll BasicBlock, num_cases: usize) -> &'ll Value {
unsafe { unsafe {
llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, num_cases as c_uint) llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, num_cases as c_uint)
} }
...@@ -198,8 +198,8 @@ pub fn indirect_br(&self, addr: &'ll Value, num_dests: usize) { ...@@ -198,8 +198,8 @@ pub fn indirect_br(&self, addr: &'ll Value, num_dests: usize) {
pub fn invoke(&self, pub fn invoke(&self,
llfn: &'ll Value, llfn: &'ll Value,
args: &[&'ll Value], args: &[&'ll Value],
then: BasicBlockRef, then: &'ll BasicBlock,
catch: BasicBlockRef, catch: &'ll BasicBlock,
bundle: Option<&OperandBundleDef>) -> &'ll Value { bundle: Option<&OperandBundleDef>) -> &'ll Value {
self.count_insn("invoke"); self.count_insn("invoke");
...@@ -830,7 +830,7 @@ pub fn empty_phi(&self, ty: &'ll Type) -> &'ll Value { ...@@ -830,7 +830,7 @@ pub fn empty_phi(&self, ty: &'ll Type) -> &'ll Value {
} }
} }
pub fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[BasicBlockRef]) -> &'ll Value { pub fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value {
assert_eq!(vals.len(), bbs.len()); assert_eq!(vals.len(), bbs.len());
let phi = self.empty_phi(ty); let phi = self.empty_phi(ty);
self.count_insn("addincoming"); self.count_insn("addincoming");
...@@ -1167,10 +1167,11 @@ pub fn cleanup_pad(&self, ...@@ -1167,10 +1167,11 @@ pub fn cleanup_pad(&self,
ret.expect("LLVM does not have support for cleanuppad") ret.expect("LLVM does not have support for cleanuppad")
} }
pub fn cleanup_ret(&self, cleanup: &'ll Value, pub fn cleanup_ret(
unwind: Option<BasicBlockRef>) -> &'ll Value { &self, cleanup: &'ll Value,
unwind: Option<&'ll BasicBlock>,
) -> &'ll Value {
self.count_insn("cleanupret"); self.count_insn("cleanupret");
let unwind = unwind.and_then(NonNull::new);
let ret = unsafe { let ret = unsafe {
llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind) llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind)
}; };
...@@ -1190,7 +1191,7 @@ pub fn catch_pad(&self, ...@@ -1190,7 +1191,7 @@ pub fn catch_pad(&self,
ret.expect("LLVM does not have support for catchpad") ret.expect("LLVM does not have support for catchpad")
} }
pub fn catch_ret(&self, pad: &'ll Value, unwind: BasicBlockRef) -> &'ll Value { pub fn catch_ret(&self, pad: &'ll Value, unwind: &'ll BasicBlock) -> &'ll Value {
self.count_insn("catchret"); self.count_insn("catchret");
let ret = unsafe { let ret = unsafe {
llvm::LLVMRustBuildCatchRet(self.llbuilder, pad, unwind) llvm::LLVMRustBuildCatchRet(self.llbuilder, pad, unwind)
...@@ -1201,11 +1202,10 @@ pub fn catch_ret(&self, pad: &'ll Value, unwind: BasicBlockRef) -> &'ll Value { ...@@ -1201,11 +1202,10 @@ pub fn catch_ret(&self, pad: &'ll Value, unwind: BasicBlockRef) -> &'ll Value {
pub fn catch_switch( pub fn catch_switch(
&self, &self,
parent: Option<&'ll Value>, parent: Option<&'ll Value>,
unwind: Option<BasicBlockRef>, unwind: Option<&'ll BasicBlock>,
num_handlers: usize, num_handlers: usize,
) -> &'ll Value { ) -> &'ll Value {
self.count_insn("catchswitch"); self.count_insn("catchswitch");
let unwind = unwind.and_then(NonNull::new);
let name = CString::new("catchswitch").unwrap(); let name = CString::new("catchswitch").unwrap();
let ret = unsafe { let ret = unsafe {
llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind, llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind,
...@@ -1215,7 +1215,7 @@ pub fn catch_switch( ...@@ -1215,7 +1215,7 @@ pub fn catch_switch(
ret.expect("LLVM does not have support for catchswitch") ret.expect("LLVM does not have support for catchswitch")
} }
pub fn add_handler(&self, catch_switch: &'ll Value, handler: BasicBlockRef) { pub fn add_handler(&self, catch_switch: &'ll Value, handler: &'ll BasicBlock) {
unsafe { unsafe {
llvm::LLVMRustAddHandler(catch_switch, handler); llvm::LLVMRustAddHandler(catch_switch, handler);
} }
...@@ -1260,13 +1260,13 @@ pub fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope) { ...@@ -1260,13 +1260,13 @@ pub fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope) {
} }
} }
pub fn add_case(&self, s: &'ll Value, on_val: &'ll Value, dest: BasicBlockRef) { pub fn add_case(&self, s: &'ll Value, on_val: &'ll Value, dest: &'ll BasicBlock) {
unsafe { unsafe {
llvm::LLVMAddCase(s, on_val, dest) llvm::LLVMAddCase(s, on_val, dest)
} }
} }
pub fn add_incoming_to_phi(&self, phi: &'ll Value, val: &'ll Value, bb: BasicBlockRef) { pub fn add_incoming_to_phi(&self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock) {
self.count_insn("addincoming"); self.count_insn("addincoming");
unsafe { unsafe {
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint); llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
......
...@@ -381,7 +381,6 @@ pub enum ThreadLocalMode { ...@@ -381,7 +381,6 @@ pub enum ThreadLocalMode {
extern { pub type Value; } extern { pub type Value; }
extern { pub type Metadata; } extern { pub type Metadata; }
extern { pub type BasicBlock; } extern { pub type BasicBlock; }
pub type BasicBlockRef = *mut BasicBlock;
extern { pub type Builder; } extern { pub type Builder; }
extern { pub type MemoryBuffer; } extern { pub type MemoryBuffer; }
pub type MemoryBufferRef = *mut MemoryBuffer; pub type MemoryBufferRef = *mut MemoryBuffer;
...@@ -716,18 +715,18 @@ pub fn LLVMRustAddFunctionAttrStringValue(Fn: &Value, ...@@ -716,18 +715,18 @@ pub fn LLVMRustAddFunctionAttrStringValue(Fn: &Value,
pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value; pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
// Operations on basic blocks // Operations on basic blocks
pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> &'a Value; pub fn LLVMBasicBlockAsValue(BB: &BasicBlock) -> &Value;
pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> &'a Value; pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
pub fn LLVMAppendBasicBlockInContext(C: &'a Context, pub fn LLVMAppendBasicBlockInContext(C: &'a Context,
Fn: &'a Value, Fn: &'a Value,
Name: *const c_char) Name: *const c_char)
-> BasicBlockRef; -> &'a BasicBlock;
pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef); pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
// Operations on instructions // Operations on instructions
pub fn LLVMGetInstructionParent(Inst: &Value) -> BasicBlockRef; pub fn LLVMGetInstructionParent(Inst: &Value) -> &BasicBlock;
pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> BasicBlockRef; pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> &'a Value; pub fn LLVMGetFirstInstruction(BB: &BasicBlock) -> &'a Value;
pub fn LLVMInstructionEraseFromParent(Inst: &Value); pub fn LLVMInstructionEraseFromParent(Inst: &Value);
// Operations on call sites // Operations on call sites
...@@ -745,15 +744,15 @@ pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, ...@@ -745,15 +744,15 @@ pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value,
// Operations on phi nodes // Operations on phi nodes
pub fn LLVMAddIncoming(PhiNode: &'a Value, pub fn LLVMAddIncoming(PhiNode: &'a Value,
IncomingValues: *const &'a Value, IncomingValues: *const &'a Value,
IncomingBlocks: *const BasicBlockRef, IncomingBlocks: *const &'a BasicBlock,
Count: c_uint); Count: c_uint);
// Instruction builders // Instruction builders
pub fn LLVMCreateBuilderInContext(C: &Context) -> &Builder; pub fn LLVMCreateBuilderInContext(C: &Context) -> &Builder;
pub fn LLVMPositionBuilder(Builder: &'a Builder, Block: BasicBlockRef, Instr: &'a Value); pub fn LLVMPositionBuilder(Builder: &'a Builder, Block: &'a BasicBlock, Instr: &'a Value);
pub fn LLVMPositionBuilderBefore(Builder: &'a Builder, Instr: &'a Value); pub fn LLVMPositionBuilderBefore(Builder: &'a Builder, Instr: &'a Value);
pub fn LLVMPositionBuilderAtEnd(Builder: &Builder, Block: BasicBlockRef); pub fn LLVMPositionBuilderAtEnd(Builder: &'a Builder, Block: &'a BasicBlock);
pub fn LLVMGetInsertBlock(Builder: &Builder) -> BasicBlockRef; pub fn LLVMGetInsertBlock(Builder: &Builder) -> &BasicBlock;
pub fn LLVMDisposeBuilder(Builder: &Builder); pub fn LLVMDisposeBuilder(Builder: &Builder);
// Metadata // Metadata
...@@ -765,15 +764,15 @@ pub fn LLVMAddIncoming(PhiNode: &'a Value, ...@@ -765,15 +764,15 @@ pub fn LLVMAddIncoming(PhiNode: &'a Value,
pub fn LLVMBuildRetVoid(B: &Builder) -> &Value; pub fn LLVMBuildRetVoid(B: &Builder) -> &Value;
pub fn LLVMBuildRet(B: &'a Builder, V: &'a Value) -> &'a Value; pub fn LLVMBuildRet(B: &'a Builder, V: &'a Value) -> &'a Value;
pub fn LLVMBuildAggregateRet(B: &'a Builder, RetVals: *const &'a Value, N: c_uint) -> &'a Value; pub fn LLVMBuildAggregateRet(B: &'a Builder, RetVals: *const &'a Value, N: c_uint) -> &'a Value;
pub fn LLVMBuildBr(B: &Builder, Dest: BasicBlockRef) -> &Value; pub fn LLVMBuildBr(B: &'a Builder, Dest: &'a BasicBlock) -> &'a Value;
pub fn LLVMBuildCondBr(B: &'a Builder, pub fn LLVMBuildCondBr(B: &'a Builder,
If: &'a Value, If: &'a Value,
Then: BasicBlockRef, Then: &'a BasicBlock,
Else: BasicBlockRef) Else: &'a BasicBlock)
-> &'a Value; -> &'a Value;
pub fn LLVMBuildSwitch(B: &'a Builder, pub fn LLVMBuildSwitch(B: &'a Builder,
V: &'a Value, V: &'a Value,
Else: BasicBlockRef, Else: &'a BasicBlock,
NumCases: c_uint) NumCases: c_uint)
-> &'a Value; -> &'a Value;
pub fn LLVMBuildIndirectBr(B: &'a Builder, Addr: &'a Value, NumDests: c_uint) -> &'a Value; pub fn LLVMBuildIndirectBr(B: &'a Builder, Addr: &'a Value, NumDests: c_uint) -> &'a Value;
...@@ -781,8 +780,8 @@ pub fn LLVMRustBuildInvoke(B: &'a Builder, ...@@ -781,8 +780,8 @@ pub fn LLVMRustBuildInvoke(B: &'a Builder,
Fn: &'a Value, Fn: &'a Value,
Args: *const &'a Value, Args: *const &'a Value,
NumArgs: c_uint, NumArgs: c_uint,
Then: BasicBlockRef, Then: &'a BasicBlock,
Catch: BasicBlockRef, Catch: &'a BasicBlock,
Bundle: Option<NonNull<OperandBundleDef>>, Bundle: Option<NonNull<OperandBundleDef>>,
Name: *const c_char) Name: *const c_char)
-> &'a Value; -> &'a Value;
...@@ -803,7 +802,7 @@ pub fn LLVMRustBuildCleanupPad(B: &'a Builder, ...@@ -803,7 +802,7 @@ pub fn LLVMRustBuildCleanupPad(B: &'a Builder,
-> Option<&'a Value>; -> Option<&'a Value>;
pub fn LLVMRustBuildCleanupRet(B: &'a Builder, pub fn LLVMRustBuildCleanupRet(B: &'a Builder,
CleanupPad: &'a Value, CleanupPad: &'a Value,
UnwindBB: Option<NonNull<BasicBlock>>) UnwindBB: Option<&'a BasicBlock>)
-> Option<&'a Value>; -> Option<&'a Value>;
pub fn LLVMRustBuildCatchPad(B: &'a Builder, pub fn LLVMRustBuildCatchPad(B: &'a Builder,
ParentPad: &'a Value, ParentPad: &'a Value,
...@@ -811,18 +810,18 @@ pub fn LLVMRustBuildCatchPad(B: &'a Builder, ...@@ -811,18 +810,18 @@ pub fn LLVMRustBuildCatchPad(B: &'a Builder,
Args: *const &'a Value, Args: *const &'a Value,
Name: *const c_char) Name: *const c_char)
-> Option<&'a Value>; -> Option<&'a Value>;
pub fn LLVMRustBuildCatchRet(B: &'a Builder, Pad: &'a Value, BB: BasicBlockRef) -> Option<&'a Value>; pub fn LLVMRustBuildCatchRet(B: &'a Builder, Pad: &'a Value, BB: &'a BasicBlock) -> Option<&'a Value>;
pub fn LLVMRustBuildCatchSwitch(Builder: &'a Builder, pub fn LLVMRustBuildCatchSwitch(Builder: &'a Builder,
ParentPad: Option<&'a Value>, ParentPad: Option<&'a Value>,
BB: Option<NonNull<BasicBlock>>, BB: Option<&'a BasicBlock>,
NumHandlers: c_uint, NumHandlers: c_uint,
Name: *const c_char) Name: *const c_char)
-> Option<&'a Value>; -> Option<&'a Value>;
pub fn LLVMRustAddHandler(CatchSwitch: &Value, Handler: BasicBlockRef); pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value); pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
// Add a case to the switch instruction // Add a case to the switch instruction
pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: BasicBlockRef); pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
// Add a clause to the landing pad instruction // Add a clause to the landing pad instruction
pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value); pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
...@@ -1503,7 +1502,7 @@ pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &'a DIBuilder, ...@@ -1503,7 +1502,7 @@ pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: &'a DIBuilder,
AddrOps: *const i64, AddrOps: *const i64,
AddrOpsCount: c_uint, AddrOpsCount: c_uint,
DL: &'a Value, DL: &'a Value,
InsertAtEnd: BasicBlockRef) InsertAtEnd: &'a BasicBlock)
-> &'a Value; -> &'a Value;
pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder, pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder,
...@@ -1691,7 +1690,7 @@ pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char, ...@@ -1691,7 +1690,7 @@ pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
-> OperandBundleDefRef; -> OperandBundleDefRef;
pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef); pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
pub fn LLVMRustPositionBuilderAtStart(B: &Builder, BB: BasicBlockRef); pub fn LLVMRustPositionBuilderAtStart(B: &'a Builder, BB: &'a BasicBlock);
pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char); pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
pub fn LLVMRustUnsetComdat(V: &Value); pub fn LLVMRustUnsetComdat(V: &Value);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use llvm::{self, BasicBlockRef}; use llvm::{self, BasicBlock};
use rustc::middle::lang_items; use rustc::middle::lang_items;
use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, LayoutOf}; use rustc::ty::layout::{self, LayoutOf};
...@@ -754,7 +754,7 @@ fn get_personality_slot(&mut self, bx: &Builder<'a, 'll, 'tcx>) -> PlaceRef<'ll, ...@@ -754,7 +754,7 @@ fn get_personality_slot(&mut self, bx: &Builder<'a, 'll, 'tcx>) -> PlaceRef<'ll,
/// Return the landingpad wrapper around the given basic block /// Return the landingpad wrapper around the given basic block
/// ///
/// No-op in MSVC SEH scheme. /// No-op in MSVC SEH scheme.
fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> BasicBlockRef { fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> &'ll BasicBlock {
if let Some(block) = self.landing_pads[target_bb] { if let Some(block) = self.landing_pads[target_bb] {
return block; return block;
} }
...@@ -765,7 +765,7 @@ fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> BasicBlockRef { ...@@ -765,7 +765,7 @@ fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> BasicBlockRef {
landing_pad landing_pad
} }
fn landing_pad_uncached(&mut self, target_bb: BasicBlockRef) -> BasicBlockRef { fn landing_pad_uncached(&mut self, target_bb: &'ll BasicBlock) -> &'ll BasicBlock {
if base::wants_msvc_seh(self.cx.sess()) { if base::wants_msvc_seh(self.cx.sess()) {
span_bug!(self.mir.span, "landing pad was not inserted?") span_bug!(self.mir.span, "landing pad was not inserted?")
} }
...@@ -790,7 +790,7 @@ fn landing_pad_type(&self) -> &'ll Type { ...@@ -790,7 +790,7 @@ fn landing_pad_type(&self) -> &'ll Type {
Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], false) Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], false)
} }
fn unreachable_block(&mut self) -> BasicBlockRef { fn unreachable_block(&mut self) -> &'ll BasicBlock {
self.unreachable_block.unwrap_or_else(|| { self.unreachable_block.unwrap_or_else(|| {
let bl = self.new_block("unreachable"); let bl = self.new_block("unreachable");
bl.unreachable(); bl.unreachable();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use common::{C_i32, C_null}; use common::{C_i32, C_null};
use libc::c_uint; use libc::c_uint;
use llvm::{self, BasicBlockRef}; use llvm::{self, BasicBlock};
use llvm::debuginfo::DIScope; use llvm::debuginfo::DIScope;
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts}; use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
use rustc::ty::layout::{LayoutOf, TyLayout}; use rustc::ty::layout::{LayoutOf, TyLayout};
...@@ -66,7 +66,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { ...@@ -66,7 +66,7 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> {
personality_slot: Option<PlaceRef<'ll, 'tcx>>, personality_slot: Option<PlaceRef<'ll, 'tcx>>,
/// A `Block` for each MIR `BasicBlock` /// A `Block` for each MIR `BasicBlock`
blocks: IndexVec<mir::BasicBlock, BasicBlockRef>, blocks: IndexVec<mir::BasicBlock, &'ll BasicBlock>,
/// The funclet status of each basic block /// The funclet status of each basic block
cleanup_kinds: IndexVec<mir::BasicBlock, analyze::CleanupKind>, cleanup_kinds: IndexVec<mir::BasicBlock, analyze::CleanupKind>,
...@@ -77,10 +77,10 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> { ...@@ -77,10 +77,10 @@ pub struct FunctionCx<'a, 'll: 'a, 'tcx: 'll> {
/// This stores the landing-pad block for a given BB, computed lazily on GNU /// This stores the landing-pad block for a given BB, computed lazily on GNU
/// and eagerly on MSVC. /// and eagerly on MSVC.
landing_pads: IndexVec<mir::BasicBlock, Option<BasicBlockRef>>, landing_pads: IndexVec<mir::BasicBlock, Option<&'ll BasicBlock>>,
/// Cached unreachable block /// Cached unreachable block
unreachable_block: Option<BasicBlockRef>, unreachable_block: Option<&'ll BasicBlock>,
/// The location where each MIR arg/var/tmp/ret is stored. This is /// The location where each MIR arg/var/tmp/ret is stored. This is
/// usually an `PlaceRef` representing an alloca, but not always: /// usually an `PlaceRef` representing an alloca, but not always:
...@@ -219,7 +219,7 @@ pub fn codegen_mir( ...@@ -219,7 +219,7 @@ pub fn codegen_mir(
// Allocate a `Block` for every basic block, except // Allocate a `Block` for every basic block, except
// the start block, if nothing loops back to it. // the start block, if nothing loops back to it.
let reentrant_start_block = !mir.predecessors_for(mir::START_BLOCK).is_empty(); let reentrant_start_block = !mir.predecessors_for(mir::START_BLOCK).is_empty();
let block_bxs: IndexVec<mir::BasicBlock, BasicBlockRef> = let block_bxs: IndexVec<mir::BasicBlock, &'ll BasicBlock> =
mir.basic_blocks().indices().map(|bb| { mir.basic_blocks().indices().map(|bb| {
if bb == mir::START_BLOCK && !reentrant_start_block { if bb == mir::START_BLOCK && !reentrant_start_block {
bx.llbb() bx.llbb()
...@@ -348,8 +348,8 @@ fn create_funclets( ...@@ -348,8 +348,8 @@ fn create_funclets(
mir: &'a Mir<'tcx>, mir: &'a Mir<'tcx>,
bx: &Builder<'a, 'll, 'tcx>, bx: &Builder<'a, 'll, 'tcx>,
cleanup_kinds: &IndexVec<mir::BasicBlock, CleanupKind>, cleanup_kinds: &IndexVec<mir::BasicBlock, CleanupKind>,
block_bxs: &IndexVec<mir::BasicBlock, BasicBlockRef>) block_bxs: &IndexVec<mir::BasicBlock, &'ll BasicBlock>)
-> (IndexVec<mir::BasicBlock, Option<BasicBlockRef>>, -> (IndexVec<mir::BasicBlock, Option<&'ll BasicBlock>>,
IndexVec<mir::BasicBlock, Option<Funclet<'ll>>>) IndexVec<mir::BasicBlock, Option<Funclet<'ll>>>)
{ {
block_bxs.iter_enumerated().zip(cleanup_kinds).map(|((bb, &llbb), cleanup_kind)| { block_bxs.iter_enumerated().zip(cleanup_kinds).map(|((bb, &llbb), cleanup_kind)| {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册