rollup merge of #21818: dotdash/llvm_up

This commit is contained in:
Alex Crichton 2015-02-02 10:58:15 -08:00
commit 04213ebd98
9 changed files with 283 additions and 205 deletions

View File

@ -63,8 +63,9 @@ use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
use libc::{c_longlong, c_ulonglong, c_void}; use libc::{c_longlong, c_ulonglong, c_void};
use debuginfo::{DIBuilderRef, DIDescriptor, use debuginfo::{DIBuilderRef, DIDescriptor,
DIFile, DILexicalBlock, DISubprogram, DIType, DIFile, DILexicalBlock, DISubprogram, DIType,
DIBasicType, DIDerivedType, DICompositeType, DIBasicType, DIDerivedType, DICompositeType, DIScope,
DIVariable, DIGlobalVariable, DIArray, DISubrange}; DIVariable, DIGlobalVariable, DIArray, DISubrange,
DITemplateTypeParameter, DIEnumerator, DINameSpace};
pub mod archive_ro; pub mod archive_ro;
pub mod diagnostic; pub mod diagnostic;
@ -442,6 +443,9 @@ pub type TypeRef = *mut Type_opaque;
pub enum Value_opaque {} pub enum Value_opaque {}
pub type ValueRef = *mut Value_opaque; pub type ValueRef = *mut Value_opaque;
#[allow(missing_copy_implementations)] #[allow(missing_copy_implementations)]
pub enum Metadata_opaque {}
pub type MetadataRef = *mut Metadata_opaque;
#[allow(missing_copy_implementations)]
pub enum BasicBlock_opaque {} pub enum BasicBlock_opaque {}
pub type BasicBlockRef = *mut BasicBlock_opaque; pub type BasicBlockRef = *mut BasicBlock_opaque;
#[allow(missing_copy_implementations)] #[allow(missing_copy_implementations)]
@ -501,18 +505,19 @@ pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_v
pub mod debuginfo { pub mod debuginfo {
pub use self::DIDescriptorFlags::*; pub use self::DIDescriptorFlags::*;
use super::{ValueRef}; use super::{MetadataRef};
#[allow(missing_copy_implementations)] #[allow(missing_copy_implementations)]
pub enum DIBuilder_opaque {} pub enum DIBuilder_opaque {}
pub type DIBuilderRef = *mut DIBuilder_opaque; pub type DIBuilderRef = *mut DIBuilder_opaque;
pub type DIDescriptor = ValueRef; pub type DIDescriptor = MetadataRef;
pub type DIScope = DIDescriptor; pub type DIScope = DIDescriptor;
pub type DILocation = DIDescriptor; pub type DILocation = DIDescriptor;
pub type DIFile = DIScope; pub type DIFile = DIScope;
pub type DILexicalBlock = DIScope; pub type DILexicalBlock = DIScope;
pub type DISubprogram = DIScope; pub type DISubprogram = DIScope;
pub type DINameSpace = DIScope;
pub type DIType = DIDescriptor; pub type DIType = DIDescriptor;
pub type DIBasicType = DIType; pub type DIBasicType = DIType;
pub type DIDerivedType = DIType; pub type DIDerivedType = DIType;
@ -521,6 +526,8 @@ pub mod debuginfo {
pub type DIGlobalVariable = DIDescriptor; pub type DIGlobalVariable = DIDescriptor;
pub type DIArray = DIDescriptor; pub type DIArray = DIDescriptor;
pub type DISubrange = DIDescriptor; pub type DISubrange = DIDescriptor;
pub type DIEnumerator = DIDescriptor;
pub type DITemplateTypeParameter = DIDescriptor;
#[derive(Copy)] #[derive(Copy)]
pub enum DIDescriptorFlags { pub enum DIDescriptorFlags {
@ -1778,8 +1785,8 @@ extern {
Flags: c_uint, Flags: c_uint,
isOptimized: bool, isOptimized: bool,
Fn: ValueRef, Fn: ValueRef,
TParam: ValueRef, TParam: DIArray,
Decl: ValueRef) Decl: DIDescriptor)
-> DISubprogram; -> DISubprogram;
pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
@ -1807,7 +1814,7 @@ extern {
DerivedFrom: DIType, DerivedFrom: DIType,
Elements: DIArray, Elements: DIArray,
RunTimeLang: c_uint, RunTimeLang: c_uint,
VTableHolder: ValueRef, VTableHolder: DIType,
UniqueId: *const c_char) UniqueId: *const c_char)
-> DICompositeType; -> DICompositeType;
@ -1824,14 +1831,14 @@ extern {
-> DIDerivedType; -> DIDerivedType;
pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
Scope: DIDescriptor, Scope: DIScope,
File: DIFile, File: DIFile,
Line: c_uint, Line: c_uint,
Col: c_uint) Col: c_uint)
-> DILexicalBlock; -> DILexicalBlock;
pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
Context: DIDescriptor, Context: DIScope,
Name: *const c_char, Name: *const c_char,
LinkageName: *const c_char, LinkageName: *const c_char,
File: DIFile, File: DIFile,
@ -1839,10 +1846,10 @@ extern {
Ty: DIType, Ty: DIType,
isLocalToUnit: bool, isLocalToUnit: bool,
Val: ValueRef, Val: ValueRef,
Decl: ValueRef) Decl: DIDescriptor)
-> DIGlobalVariable; -> DIGlobalVariable;
pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef,
Tag: c_uint, Tag: c_uint,
Scope: DIDescriptor, Scope: DIDescriptor,
Name: *const c_char, Name: *const c_char,
@ -1851,6 +1858,8 @@ extern {
Ty: DIType, Ty: DIType,
AlwaysPreserve: bool, AlwaysPreserve: bool,
Flags: c_uint, Flags: c_uint,
AddrOps: *const i64,
AddrOpsCount: c_uint,
ArgNo: c_uint) ArgNo: c_uint)
-> DIVariable; -> DIVariable;
@ -1881,79 +1890,80 @@ extern {
pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef, pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
Val: ValueRef, Val: ValueRef,
VarInfo: DIVariable, VarInfo: DIVariable,
AddrOps: *const i64,
AddrOpsCount: c_uint,
InsertAtEnd: BasicBlockRef) InsertAtEnd: BasicBlockRef)
-> ValueRef; -> ValueRef;
pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef, pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
Val: ValueRef, Val: ValueRef,
VarInfo: DIVariable, VarInfo: DIVariable,
AddrOps: *const i64,
AddrOpsCount: c_uint,
InsertBefore: ValueRef) InsertBefore: ValueRef)
-> ValueRef; -> ValueRef;
pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
Name: *const c_char, Name: *const c_char,
Val: c_ulonglong) Val: c_ulonglong)
-> ValueRef; -> DIEnumerator;
pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
Scope: ValueRef, Scope: DIScope,
Name: *const c_char, Name: *const c_char,
File: ValueRef, File: DIFile,
LineNumber: c_uint, LineNumber: c_uint,
SizeInBits: c_ulonglong, SizeInBits: c_ulonglong,
AlignInBits: c_ulonglong, AlignInBits: c_ulonglong,
Elements: ValueRef, Elements: DIArray,
ClassType: ValueRef) ClassType: DIType)
-> ValueRef; -> DIType;
pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
Scope: ValueRef, Scope: DIScope,
Name: *const c_char, Name: *const c_char,
File: ValueRef, File: DIFile,
LineNumber: c_uint, LineNumber: c_uint,
SizeInBits: c_ulonglong, SizeInBits: c_ulonglong,
AlignInBits: c_ulonglong, AlignInBits: c_ulonglong,
Flags: c_uint, Flags: c_uint,
Elements: ValueRef, Elements: DIArray,
RunTimeLang: c_uint, RunTimeLang: c_uint,
UniqueId: *const c_char) UniqueId: *const c_char)
-> ValueRef; -> DIType;
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool); pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
Scope: ValueRef, Scope: DIScope,
Name: *const c_char, Name: *const c_char,
Ty: ValueRef, Ty: DIType,
File: ValueRef, File: DIFile,
LineNo: c_uint, LineNo: c_uint,
ColumnNo: c_uint) ColumnNo: c_uint)
-> ValueRef; -> DITemplateTypeParameter;
pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef; pub fn LLVMDIBuilderCreateOpDeref() -> i64;
pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef; pub fn LLVMDIBuilderCreateOpPlus() -> i64;
pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
Tag: c_uint,
Scope: ValueRef,
Name: *const c_char,
File: ValueRef,
LineNo: c_uint,
Ty: ValueRef,
AddrOps: *const ValueRef,
AddrOpsCount: c_uint,
ArgNo: c_uint)
-> ValueRef;
pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef, pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
Scope: ValueRef, Scope: DIScope,
Name: *const c_char, Name: *const c_char,
File: ValueRef, File: DIFile,
LineNo: c_uint) LineNo: c_uint)
-> ValueRef; -> DINameSpace;
pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef); pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef,
Line: c_uint,
Column: c_uint,
Scope: DIScope,
InlinedAt: MetadataRef)
-> ValueRef;
pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
CompositeType: DIType,
TypeArray: DIArray);
pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef); pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef); pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);

View File

@ -2019,7 +2019,11 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let bcx = match dest { let bcx = match dest {
expr::SaveIn(_) => bcx, expr::SaveIn(_) => bcx,
expr::Ignore => { expr::Ignore => {
glue::drop_ty(bcx, llresult, result_ty, debug_loc) let bcx = glue::drop_ty(bcx, llresult, result_ty, debug_loc);
if !type_is_zero_size(ccx, result_ty) {
call_lifetime_end(bcx, llresult);
}
bcx
} }
}; };

View File

@ -778,10 +778,6 @@ pub fn C_i32(ccx: &CrateContext, i: i32) -> ValueRef {
C_integral(Type::i32(ccx), i as u64, true) C_integral(Type::i32(ccx), i as u64, true)
} }
pub fn C_i64(ccx: &CrateContext, i: i64) -> ValueRef {
C_integral(Type::i64(ccx), i as u64, true)
}
pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef { pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef {
C_integral(Type::i64(ccx), i, false) C_integral(Type::i64(ccx), i, false)
} }

View File

@ -199,6 +199,9 @@ impl KindOps for Rvalue {
-> Block<'blk, 'tcx> { -> Block<'blk, 'tcx> {
// No cleanup is scheduled for an rvalue, so we don't have // No cleanup is scheduled for an rvalue, so we don't have
// to do anything after a move to cancel or duplicate it. // to do anything after a move to cancel or duplicate it.
if self.is_by_ref() {
call_lifetime_end(bcx, _val);
}
bcx bcx
} }
@ -320,6 +323,7 @@ impl<'tcx> Datum<'tcx, Rvalue> {
ByValue => DatumBlock::new(bcx, self), ByValue => DatumBlock::new(bcx, self),
ByRef => { ByRef => {
let llval = load_ty(bcx, self.val, self.ty); let llval = load_ty(bcx, self.val, self.ty);
call_lifetime_end(bcx, self.val);
DatumBlock::new(bcx, Datum::new(llval, self.ty, Rvalue::new(ByValue))) DatumBlock::new(bcx, Datum::new(llval, self.ty, Rvalue::new(ByValue)))
} }
} }

View File

@ -197,7 +197,7 @@ use metadata::csearch;
use middle::subst::{self, Substs}; use middle::subst::{self, Substs};
use trans::{self, adt, machine, type_of}; use trans::{self, adt, machine, type_of};
use trans::common::{self, NodeIdAndSpan, CrateContext, FunctionContext, Block, use trans::common::{self, NodeIdAndSpan, CrateContext, FunctionContext, Block,
C_bytes, C_i32, C_i64, NormalizingClosureTyper}; C_bytes, NormalizingClosureTyper};
use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef}; use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef};
use trans::monomorphize; use trans::monomorphize;
use trans::type_::Type; use trans::type_::Type;
@ -702,7 +702,7 @@ enum VariableAccess<'a> {
DirectVariable { alloca: ValueRef }, DirectVariable { alloca: ValueRef },
// The llptr given is an alloca containing the start of some pointer chain // The llptr given is an alloca containing the start of some pointer chain
// leading to the variable's content. // leading to the variable's content.
IndirectVariable { alloca: ValueRef, address_operations: &'a [ValueRef] } IndirectVariable { alloca: ValueRef, address_operations: &'a [i64] }
} }
enum VariableKind { enum VariableKind {
@ -928,10 +928,10 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
env_index); env_index);
let address_operations = unsafe { let address_operations = unsafe {
[llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref()), [llvm::LLVMDIBuilderCreateOpDeref(),
llvm::LLVMDIBuilderCreateOpPlus(Type::i64(cx).to_ref()), llvm::LLVMDIBuilderCreateOpPlus(),
C_i64(cx, byte_offset_of_var_in_env as i64), byte_offset_of_var_in_env as i64,
llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref())] llvm::LLVMDIBuilderCreateOpDeref()]
}; };
let address_op_count = if captured_by_ref { let address_op_count = if captured_by_ref {
@ -969,7 +969,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let scope_metadata = scope_metadata(bcx.fcx, binding.id, binding.span); let scope_metadata = scope_metadata(bcx.fcx, binding.id, binding.span);
let aops = unsafe { let aops = unsafe {
[llvm::LLVMDIBuilderCreateOpDeref(bcx.ccx().int_type().to_ref())] [llvm::LLVMDIBuilderCreateOpDeref()]
}; };
// Regardless of the actual type (`T`) we're always passed the stack slot (alloca) // Regardless of the actual type (`T`) we're always passed the stack slot (alloca)
// for the binding. For ByRef bindings that's a `T*` but for ByMove bindings we // for the binding. For ByRef bindings that's a `T*` but for ByMove bindings we
@ -1657,11 +1657,11 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}; };
let name = CString::from_slice(name.get().as_bytes()); let name = CString::from_slice(name.get().as_bytes());
let (var_alloca, var_metadata) = match variable_access { match (variable_access, [].as_slice()) {
DirectVariable { alloca } => ( (DirectVariable { alloca }, address_operations) |
alloca, (IndirectVariable {alloca, address_operations}, _) => {
unsafe { let metadata = unsafe {
llvm::LLVMDIBuilderCreateLocalVariable( llvm::LLVMDIBuilderCreateVariable(
DIB(cx), DIB(cx),
dwarf_tag, dwarf_tag,
scope_metadata, scope_metadata,
@ -1671,38 +1671,25 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
type_metadata, type_metadata,
cx.sess().opts.optimize != config::No, cx.sess().opts.optimize != config::No,
0, 0,
argument_index)
}
),
IndirectVariable { alloca, address_operations } => (
alloca,
unsafe {
llvm::LLVMDIBuilderCreateComplexVariable(
DIB(cx),
dwarf_tag,
scope_metadata,
name.as_ptr(),
file_metadata,
loc.line as c_uint,
type_metadata,
address_operations.as_ptr(), address_operations.as_ptr(),
address_operations.len() as c_uint, address_operations.len() as c_uint,
argument_index) argument_index)
} };
) set_debug_location(cx, InternalDebugLocation::new(scope_metadata,
};
set_debug_location(cx, InternalDebugLocation::new(scope_metadata,
loc.line, loc.line,
loc.col.to_usize())); loc.col.to_usize()));
unsafe { unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd( let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
DIB(cx), DIB(cx),
var_alloca, alloca,
var_metadata, metadata,
bcx.llbb); address_operations.as_ptr(),
address_operations.len() as c_uint,
bcx.llbb);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr); llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
}
}
} }
match variable_kind { match variable_kind {
@ -2674,7 +2661,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
unsafe { unsafe {
let type_array = create_DIArray(DIB(cx), &member_metadata[]); let type_array = create_DIArray(DIB(cx), &member_metadata[]);
llvm::LLVMDICompositeTypeSetTypeArray(composite_type_metadata, type_array); llvm::LLVMDICompositeTypeSetTypeArray(DIB(cx), composite_type_metadata, type_array);
} }
} }
@ -3108,12 +3095,14 @@ fn set_debug_location(cx: &CrateContext, debug_location: InternalDebugLocation)
// Always set the column to zero like Clang and GCC // Always set the column to zero like Clang and GCC
let col = UNKNOWN_COLUMN_NUMBER; let col = UNKNOWN_COLUMN_NUMBER;
debug!("setting debug location to {} {}", line, col); debug!("setting debug location to {} {}", line, col);
let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32),
scope, ptr::null_mut()];
unsafe { unsafe {
metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext, metadata_node = llvm::LLVMDIBuilderCreateDebugLocation(
elements.as_ptr(), debug_context(cx).llcontext,
elements.len() as c_uint); line as c_uint,
col as c_uint,
scope,
ptr::null_mut());
} }
} }
UnknownLocation => { UnknownLocation => {

View File

@ -243,7 +243,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
dest dest
}; };
fcx.pop_custom_cleanup_scope(cleanup_scope); fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
return match dest { return match dest {
expr::SaveIn(d) => Result::new(bcx, d), expr::SaveIn(d) => Result::new(bcx, d),
@ -268,7 +269,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
false, false,
RustIntrinsic); RustIntrinsic);
fcx.pop_custom_cleanup_scope(cleanup_scope); fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
let call_debug_location = DebugLoc::At(call_info.id, call_info.span); let call_debug_location = DebugLoc::At(call_info.id, call_info.span);
@ -276,9 +277,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
if name.get() == "abort" { if name.get() == "abort" {
let llfn = ccx.get_intrinsic(&("llvm.trap")); let llfn = ccx.get_intrinsic(&("llvm.trap"));
Call(bcx, llfn, &[], None, call_debug_location); Call(bcx, llfn, &[], None, call_debug_location);
fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
Unreachable(bcx); Unreachable(bcx);
return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to())); return Result::new(bcx, C_undef(Type::nil(ccx).ptr_to()));
} else if name.get() == "unreachable" { } else if name.get() == "unreachable" {
fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
Unreachable(bcx); Unreachable(bcx);
return Result::new(bcx, C_nil(ccx)); return Result::new(bcx, C_nil(ccx));
} }
@ -765,6 +768,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
expr::SaveIn(_) => {} expr::SaveIn(_) => {}
} }
fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
Result::new(bcx, llresult) Result::new(bcx, llresult)
} }

@ -1 +1 @@
Subproject commit b820135911e17c7a46b901db56baa48e5155bf46 Subproject commit 2d54c4f559b1acbfe1867950c3a25bfb2f76b693

View File

@ -82,21 +82,24 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine(
InitializeNativeTargetAsmPrinter(); InitializeNativeTargetAsmPrinter();
InitializeNativeTargetAsmParser(); InitializeNativeTargetAsmParser();
std::unique_ptr<Module> m(unwrap(mod));
RustJITMemoryManager *mm = unwrap(mref);
std::string error_str; std::string error_str;
TargetOptions options; TargetOptions options;
options.JITEmitDebugInfo = true; options.JITEmitDebugInfo = true;
options.NoFramePointerElim = true; options.NoFramePointerElim = true;
ExecutionEngine *ee = EngineBuilder(std::move(m)) ExecutionEngine *ee =
.setEngineKind(EngineKind::JIT) #if LLVM_VERSION_MINOR <= 5
.setErrorStr(&error_str) EngineBuilder(unwrap(mod))
.setMCJITMemoryManager(mm) .setMCJITMemoryManager(unwrap(mref))
.setTargetOptions(options) #else
.create(); EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
.setMCJITMemoryManager(std::unique_ptr<RustJITMemoryManager>(unwrap(mref)))
#endif
.setEngineKind(EngineKind::JIT)
.setErrorStr(&error_str)
.setTargetOptions(options)
.create();
if (!ee) if (!ee)
LLVMRustSetLastError(error_str.c_str()); LLVMRustSetLastError(error_str.c_str());

View File

@ -228,8 +228,22 @@ extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty,
typedef DIBuilder* DIBuilderRef; typedef DIBuilder* DIBuilderRef;
#if LLVM_VERSION_MINOR >= 6
typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
namespace llvm {
DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef)
inline Metadata **unwrap(LLVMMetadataRef *Vals) {
return reinterpret_cast<Metadata**>(Vals);
}
}
#else
typedef LLVMValueRef LLVMMetadataRef;
#endif
template<typename DIT> template<typename DIT>
DIT unwrapDI(LLVMValueRef ref) { DIT unwrapDI(LLVMMetadataRef ref) {
return DIT(ref ? unwrap<MDNode>(ref) : NULL); return DIT(ref ? unwrap<MDNode>(ref) : NULL);
} }
@ -257,7 +271,7 @@ extern "C" void LLVMDIBuilderFinalize(DIBuilderRef Builder) {
Builder->finalize(); Builder->finalize();
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateCompileUnit( extern "C" LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(
DIBuilderRef Builder, DIBuilderRef Builder,
unsigned Lang, unsigned Lang,
const char* File, const char* File,
@ -277,17 +291,17 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateCompileUnit(
SplitName)); SplitName));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateFile( extern "C" LLVMMetadataRef LLVMDIBuilderCreateFile(
DIBuilderRef Builder, DIBuilderRef Builder,
const char* Filename, const char* Filename,
const char* Directory) { const char* Directory) {
return wrap(Builder->createFile(Filename, Directory)); return wrap(Builder->createFile(Filename, Directory));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef File, LLVMMetadataRef File,
LLVMValueRef ParameterTypes) { LLVMMetadataRef ParameterTypes) {
return wrap(Builder->createSubroutineType( return wrap(Builder->createSubroutineType(
unwrapDI<DIFile>(File), unwrapDI<DIFile>(File),
#if LLVM_VERSION_MINOR >= 6 #if LLVM_VERSION_MINOR >= 6
@ -297,22 +311,22 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType(
#endif #endif
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateFunction( extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
const char* LinkageName, const char* LinkageName,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNo, unsigned LineNo,
LLVMValueRef Ty, LLVMMetadataRef Ty,
bool isLocalToUnit, bool isLocalToUnit,
bool isDefinition, bool isDefinition,
unsigned ScopeLine, unsigned ScopeLine,
unsigned Flags, unsigned Flags,
bool isOptimized, bool isOptimized,
LLVMValueRef Fn, LLVMValueRef Fn,
LLVMValueRef TParam, LLVMMetadataRef TParam,
LLVMValueRef Decl) { LLVMMetadataRef Decl) {
return wrap(Builder->createFunction( return wrap(Builder->createFunction(
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIScope>(Scope), Name, LinkageName,
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIFile>(File), LineNo,
@ -323,7 +337,7 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
unwrapDI<MDNode*>(Decl))); unwrapDI<MDNode*>(Decl)));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateBasicType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateBasicType(
DIBuilderRef Builder, DIBuilderRef Builder,
const char* Name, const char* Name,
uint64_t SizeInBits, uint64_t SizeInBits,
@ -334,9 +348,9 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateBasicType(
AlignInBits, Encoding)); AlignInBits, Encoding));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreatePointerType( extern "C" LLVMMetadataRef LLVMDIBuilderCreatePointerType(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef PointeeTy, LLVMMetadataRef PointeeTy,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
const char* Name) { const char* Name) {
@ -344,19 +358,19 @@ extern "C" LLVMValueRef LLVMDIBuilderCreatePointerType(
unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits, Name)); unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits, Name));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateStructType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNumber, unsigned LineNumber,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
unsigned Flags, unsigned Flags,
LLVMValueRef DerivedFrom, LLVMMetadataRef DerivedFrom,
LLVMValueRef Elements, LLVMMetadataRef Elements,
unsigned RunTimeLang, unsigned RunTimeLang,
LLVMValueRef VTableHolder, LLVMMetadataRef VTableHolder,
const char *UniqueId) { const char *UniqueId) {
return wrap(Builder->createStructType( return wrap(Builder->createStructType(
unwrapDI<DIDescriptor>(Scope), unwrapDI<DIDescriptor>(Scope),
@ -376,17 +390,17 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStructType(
)); ));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateMemberType(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNo, unsigned LineNo,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, uint64_t OffsetInBits,
unsigned Flags, unsigned Flags,
LLVMValueRef Ty) { LLVMMetadataRef Ty) {
return wrap(Builder->createMemberType( return wrap(Builder->createMemberType(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIDescriptor>(Scope), Name,
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIFile>(File), LineNo,
@ -394,10 +408,10 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType(
unwrapDI<DIType>(Ty))); unwrapDI<DIType>(Ty)));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock( extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
LLVMValueRef File, LLVMMetadataRef File,
unsigned Line, unsigned Line,
unsigned Col) { unsigned Col) {
return wrap(Builder->createLexicalBlock( return wrap(Builder->createLexicalBlock(
@ -409,17 +423,17 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock(
)); ));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable( extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Context, LLVMMetadataRef Context,
const char* Name, const char* Name,
const char* LinkageName, const char* LinkageName,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNo, unsigned LineNo,
LLVMValueRef Ty, LLVMMetadataRef Ty,
bool isLocalToUnit, bool isLocalToUnit,
LLVMValueRef Val, LLVMValueRef Val,
LLVMValueRef Decl = NULL) { LLVMMetadataRef Decl = NULL) {
#if LLVM_VERSION_MINOR == 6 #if LLVM_VERSION_MINOR == 6
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context), return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
#else #else
@ -431,21 +445,42 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable(
LineNo, LineNo,
unwrapDI<DIType>(Ty), unwrapDI<DIType>(Ty),
isLocalToUnit, isLocalToUnit,
unwrap(Val), cast<Constant>(unwrap(Val)),
unwrapDI<MDNode*>(Decl))); unwrapDI<MDNode*>(Decl)));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable( extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
DIBuilderRef Builder, DIBuilderRef Builder,
unsigned Tag, unsigned Tag,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNo, unsigned LineNo,
LLVMValueRef Ty, LLVMMetadataRef Ty,
bool AlwaysPreserve, bool AlwaysPreserve,
unsigned Flags, unsigned Flags,
int64_t* AddrOps,
unsigned AddrOpsCount,
unsigned ArgNo) { unsigned ArgNo) {
#if LLVM_VERSION_MINOR < 6
if (AddrOpsCount > 0) {
SmallVector<llvm::Value *, 16> addr_ops;
llvm::Type *Int64Ty = Type::getInt64Ty(VMContext);
for (int i = 0; i < AddrOpsCount; ++i)
addr_ops.push_back(ConstantInt::get(Int64Ty, AddrOps[i]));
return wrap(Builder->createComplexVariable(
Tag,
unwrapDI<DIDescriptor>(Scope),
Name,
unwrapDI<DIFile>(File),
LineNo,
unwrapDI<DIType>(Ty),
addr_ops,
ArgNo
));
}
#endif
return wrap(Builder->createLocalVariable(Tag, return wrap(Builder->createLocalVariable(Tag,
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIDescriptor>(Scope), Name,
unwrapDI<DIFile>(File), unwrapDI<DIFile>(File),
@ -453,66 +488,94 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable(
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo)); unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateArrayType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateArrayType(
DIBuilderRef Builder, DIBuilderRef Builder,
uint64_t Size, uint64_t Size,
uint64_t AlignInBits, uint64_t AlignInBits,
LLVMValueRef Ty, LLVMMetadataRef Ty,
LLVMValueRef Subscripts) { LLVMMetadataRef Subscripts) {
return wrap(Builder->createArrayType(Size, AlignInBits, return wrap(Builder->createArrayType(Size, AlignInBits,
unwrapDI<DIType>(Ty), unwrapDI<DIType>(Ty),
unwrapDI<DIArray>(Subscripts))); unwrapDI<DIArray>(Subscripts)));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateVectorType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateVectorType(
DIBuilderRef Builder, DIBuilderRef Builder,
uint64_t Size, uint64_t Size,
uint64_t AlignInBits, uint64_t AlignInBits,
LLVMValueRef Ty, LLVMMetadataRef Ty,
LLVMValueRef Subscripts) { LLVMMetadataRef Subscripts) {
return wrap(Builder->createVectorType(Size, AlignInBits, return wrap(Builder->createVectorType(Size, AlignInBits,
unwrapDI<DIType>(Ty), unwrapDI<DIType>(Ty),
unwrapDI<DIArray>(Subscripts))); unwrapDI<DIArray>(Subscripts)));
} }
extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateSubrange( extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(
DIBuilderRef Builder, DIBuilderRef Builder,
int64_t Lo, int64_t Lo,
int64_t Count) { int64_t Count) {
return wrap(Builder->getOrCreateSubrange(Lo, Count)); return wrap(Builder->getOrCreateSubrange(Lo, Count));
} }
extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateArray( extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef* Ptr, LLVMMetadataRef* Ptr,
unsigned Count) { unsigned Count) {
return wrap(Builder->getOrCreateArray( return wrap(Builder->getOrCreateArray(
ArrayRef<Value*>(reinterpret_cast<Value**>(Ptr), Count))); ArrayRef<Metadata*>(unwrap(Ptr), Count)));
} }
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Val, LLVMValueRef Val,
LLVMValueRef VarInfo, LLVMMetadataRef VarInfo,
int64_t* AddrOps,
unsigned AddrOpsCount,
LLVMBasicBlockRef InsertAtEnd) { LLVMBasicBlockRef InsertAtEnd) {
#if LLVM_VERSION_MINOR >= 6
DIExpression Expr;
if (AddrOpsCount == 0) {
Expr = Builder->createExpression();
} else {
llvm::ArrayRef<int64_t> addr_ops(AddrOps, AddrOpsCount);
Expr = Builder->createExpression(addr_ops);
}
#endif
return wrap(Builder->insertDeclare( return wrap(Builder->insertDeclare(
unwrap(Val), unwrap(Val),
unwrapDI<DIVariable>(VarInfo), unwrapDI<DIVariable>(VarInfo),
#if LLVM_VERSION_MINOR >= 6
Expr,
#endif
unwrap(InsertAtEnd))); unwrap(InsertAtEnd)));
} }
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore( extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Val, LLVMValueRef Val,
LLVMValueRef VarInfo, LLVMMetadataRef VarInfo,
int64_t* AddrOps,
unsigned AddrOpsCount,
LLVMValueRef InsertBefore) { LLVMValueRef InsertBefore) {
#if LLVM_VERSION_MINOR >= 6
DIExpression Expr;
if (AddrOpsCount == 0) {
Expr = Builder->createExpression();
} else {
llvm::ArrayRef<int64_t> addr_ops(AddrOps, AddrOpsCount);
Expr = Builder->createExpression(addr_ops);
}
#endif
return wrap(Builder->insertDeclare( return wrap(Builder->insertDeclare(
unwrap(Val), unwrap(Val),
unwrapDI<DIVariable>(VarInfo), unwrapDI<DIVariable>(VarInfo),
#if LLVM_VERSION_MINOR >= 6
Expr,
#endif
unwrap<Instruction>(InsertBefore))); unwrap<Instruction>(InsertBefore)));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerator( extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerator(
DIBuilderRef Builder, DIBuilderRef Builder,
const char* Name, const char* Name,
uint64_t Val) uint64_t Val)
@ -520,16 +583,16 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerator(
return wrap(Builder->createEnumerator(Name, Val)); return wrap(Builder->createEnumerator(Name, Val));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerationType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNumber, unsigned LineNumber,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
LLVMValueRef Elements, LLVMMetadataRef Elements,
LLVMValueRef ClassType) LLVMMetadataRef ClassType)
{ {
return wrap(Builder->createEnumerationType( return wrap(Builder->createEnumerationType(
unwrapDI<DIDescriptor>(Scope), unwrapDI<DIDescriptor>(Scope),
@ -542,16 +605,16 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerationType(
unwrapDI<DIType>(ClassType))); unwrapDI<DIType>(ClassType)));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateUnionType( extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNumber, unsigned LineNumber,
uint64_t SizeInBits, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t AlignInBits,
unsigned Flags, unsigned Flags,
LLVMValueRef Elements, LLVMMetadataRef Elements,
unsigned RunTimeLang, unsigned RunTimeLang,
const char* UniqueId) const char* UniqueId)
{ {
@ -577,12 +640,12 @@ extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) {
} }
#endif #endif
extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter( extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter(
DIBuilderRef Builder, DIBuilderRef Builder,
LLVMValueRef Scope, LLVMMetadataRef Scope,
const char* Name, const char* Name,
LLVMValueRef Ty, LLVMMetadataRef Ty,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNo, unsigned LineNo,
unsigned ColumnNo) unsigned ColumnNo)
{ {
@ -595,47 +658,21 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter(
ColumnNo)); ColumnNo));
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateOpDeref(LLVMTypeRef IntTy) extern "C" int64_t LLVMDIBuilderCreateOpDeref()
{ {
return LLVMConstInt(IntTy, DIBuilder::OpDeref, true); return dwarf::DW_OP_deref;
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateOpPlus(LLVMTypeRef IntTy) extern "C" int64_t LLVMDIBuilderCreateOpPlus()
{ {
return LLVMConstInt(IntTy, DIBuilder::OpPlus, true); return dwarf::DW_OP_plus;
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateComplexVariable( extern "C" LLVMMetadataRef LLVMDIBuilderCreateNameSpace(
DIBuilderRef Builder, DIBuilderRef Builder,
unsigned Tag, LLVMMetadataRef Scope,
LLVMValueRef Scope,
const char *Name,
LLVMValueRef File,
unsigned LineNo,
LLVMValueRef Ty,
LLVMValueRef* AddrOps,
unsigned AddrOpsCount,
unsigned ArgNo)
{
llvm::ArrayRef<llvm::Value*> addr_ops((llvm::Value**)AddrOps, AddrOpsCount);
return wrap(Builder->createComplexVariable(
Tag,
unwrapDI<DIDescriptor>(Scope),
Name,
unwrapDI<DIFile>(File),
LineNo,
unwrapDI<DIType>(Ty),
addr_ops,
ArgNo
));
}
extern "C" LLVMValueRef LLVMDIBuilderCreateNameSpace(
DIBuilderRef Builder,
LLVMValueRef Scope,
const char* Name, const char* Name,
LLVMValueRef File, LLVMMetadataRef File,
unsigned LineNo) unsigned LineNo)
{ {
return wrap(Builder->createNameSpace( return wrap(Builder->createNameSpace(
@ -646,16 +683,39 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateNameSpace(
} }
extern "C" void LLVMDICompositeTypeSetTypeArray( extern "C" void LLVMDICompositeTypeSetTypeArray(
LLVMValueRef CompositeType, DIBuilderRef Builder,
LLVMValueRef TypeArray) LLVMMetadataRef CompositeType,
LLVMMetadataRef TypeArray)
{ {
#if LLVM_VERSION_MINOR >= 6 #if LLVM_VERSION_MINOR >= 6
unwrapDI<DICompositeType>(CompositeType).setArrays(unwrapDI<DIArray>(TypeArray)); DICompositeType tmp = unwrapDI<DICompositeType>(CompositeType);
Builder->replaceArrays(tmp, unwrapDI<DIArray>(TypeArray));
#else #else
unwrapDI<DICompositeType>(CompositeType).setTypeArray(unwrapDI<DIArray>(TypeArray)); unwrapDI<DICompositeType>(CompositeType).setTypeArray(unwrapDI<DIArray>(TypeArray));
#endif #endif
} }
extern "C" LLVMValueRef LLVMDIBuilderCreateDebugLocation(
LLVMContextRef Context,
unsigned Line,
unsigned Column,
LLVMMetadataRef Scope,
LLVMMetadataRef InlinedAt) {
LLVMContext& context = *unwrap(Context);
DebugLoc debug_loc = DebugLoc::get(Line,
Column,
unwrapDI<MDNode*>(Scope),
unwrapDI<MDNode*>(InlinedAt));
#if LLVM_VERSION_MINOR >= 6
return wrap(MetadataAsValue::get(context, debug_loc.getAsMDNode(context)));
#else
return wrap(debug_loc.getAsMDNode(context));
#endif
}
extern "C" void LLVMWriteTypeToString(LLVMTypeRef Type, RustStringRef str) { extern "C" void LLVMWriteTypeToString(LLVMTypeRef Type, RustStringRef str) {
raw_rust_string_ostream os(str); raw_rust_string_ostream os(str);
unwrap<llvm::Type>(Type)->print(os); unwrap<llvm::Type>(Type)->print(os);
@ -690,7 +750,14 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
} }
std::string Err; std::string Err;
#if LLVM_VERSION_MINOR >= 6
raw_string_ostream Stream(Err);
DiagnosticPrinterRawOStream DP(Stream);
if (Linker::LinkModules(Dst, *Src, [&](const DiagnosticInfo &DI) { DI.print(DP); })) {
#else
if (Linker::LinkModules(Dst, *Src, Linker::DestroySource, &Err)) { if (Linker::LinkModules(Dst, *Src, Linker::DestroySource, &Err)) {
#endif
LLVMRustSetLastError(Err.c_str()); LLVMRustSetLastError(Err.c_str());
return false; return false;
} }
@ -772,7 +839,7 @@ extern "C" const char*
#if LLVM_VERSION_MINOR >= 6 #if LLVM_VERSION_MINOR >= 6
LLVMRustArchiveReadSection(OwningBinary<Archive> *ob, char *name, size_t *size) { LLVMRustArchiveReadSection(OwningBinary<Archive> *ob, char *name, size_t *size) {
std::unique_ptr<Archive> &ar = ob->getBinary(); Archive *ar = ob->getBinary();
#else #else
LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) { LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) {
#endif #endif