From 602e508db0fd3566ef59a6a4833b68c3a55ddc79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Fri, 30 Jan 2015 19:25:07 +0100 Subject: [PATCH] Update LLVM to rust-llvm-2015-01-30 --- src/librustc_llvm/lib.rs | 96 +++++---- src/librustc_trans/trans/common.rs | 4 - src/librustc_trans/trans/debuginfo.rs | 77 +++---- src/llvm | 2 +- src/rustllvm/ExecutionEngineWrapper.cpp | 21 +- src/rustllvm/RustWrapper.cpp | 269 +++++++++++++++--------- src/rustllvm/llvm-auto-clean-trigger | 2 +- 7 files changed, 268 insertions(+), 203 deletions(-) diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 5ce916f536047..eb7dae66538fb 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -64,8 +64,9 @@ use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char}; use libc::{c_longlong, c_ulonglong, c_void}; use debuginfo::{DIBuilderRef, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType, - DIBasicType, DIDerivedType, DICompositeType, - DIVariable, DIGlobalVariable, DIArray, DISubrange}; + DIBasicType, DIDerivedType, DICompositeType, DIScope, + DIVariable, DIGlobalVariable, DIArray, DISubrange, + DITemplateTypeParameter, DIEnumerator, DINameSpace}; pub mod archive_ro; pub mod diagnostic; @@ -443,6 +444,9 @@ pub type TypeRef = *mut Type_opaque; pub enum Value_opaque {} pub type ValueRef = *mut Value_opaque; #[allow(missing_copy_implementations)] +pub enum Metadata_opaque {} +pub type MetadataRef = *mut Metadata_opaque; +#[allow(missing_copy_implementations)] pub enum BasicBlock_opaque {} pub type BasicBlockRef = *mut BasicBlock_opaque; #[allow(missing_copy_implementations)] @@ -502,18 +506,19 @@ pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_v pub mod debuginfo { pub use self::DIDescriptorFlags::*; - use super::{ValueRef}; + use super::{MetadataRef}; #[allow(missing_copy_implementations)] pub enum DIBuilder_opaque {} pub type DIBuilderRef = *mut DIBuilder_opaque; - pub type DIDescriptor = ValueRef; + pub type DIDescriptor = MetadataRef; pub type DIScope = DIDescriptor; pub type DILocation = DIDescriptor; pub type DIFile = DIScope; pub type DILexicalBlock = DIScope; pub type DISubprogram = DIScope; + pub type DINameSpace = DIScope; pub type DIType = DIDescriptor; pub type DIBasicType = DIType; pub type DIDerivedType = DIType; @@ -522,6 +527,8 @@ pub mod debuginfo { pub type DIGlobalVariable = DIDescriptor; pub type DIArray = DIDescriptor; pub type DISubrange = DIDescriptor; + pub type DIEnumerator = DIDescriptor; + pub type DITemplateTypeParameter = DIDescriptor; #[derive(Copy)] pub enum DIDescriptorFlags { @@ -1779,8 +1786,8 @@ extern { Flags: c_uint, isOptimized: bool, Fn: ValueRef, - TParam: ValueRef, - Decl: ValueRef) + TParam: DIArray, + Decl: DIDescriptor) -> DISubprogram; pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef, @@ -1808,7 +1815,7 @@ extern { DerivedFrom: DIType, Elements: DIArray, RunTimeLang: c_uint, - VTableHolder: ValueRef, + VTableHolder: DIType, UniqueId: *const c_char) -> DICompositeType; @@ -1825,14 +1832,14 @@ extern { -> DIDerivedType; pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef, - Scope: DIDescriptor, + Scope: DIScope, File: DIFile, Line: c_uint, Col: c_uint) -> DILexicalBlock; pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef, - Context: DIDescriptor, + Context: DIScope, Name: *const c_char, LinkageName: *const c_char, File: DIFile, @@ -1840,10 +1847,10 @@ extern { Ty: DIType, isLocalToUnit: bool, Val: ValueRef, - Decl: ValueRef) + Decl: DIDescriptor) -> DIGlobalVariable; - pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef, + pub fn LLVMDIBuilderCreateVariable(Builder: DIBuilderRef, Tag: c_uint, Scope: DIDescriptor, Name: *const c_char, @@ -1852,6 +1859,8 @@ extern { Ty: DIType, AlwaysPreserve: bool, Flags: c_uint, + AddrOps: *const i64, + AddrOpsCount: c_uint, ArgNo: c_uint) -> DIVariable; @@ -1882,79 +1891,80 @@ extern { pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef, Val: ValueRef, VarInfo: DIVariable, + AddrOps: *const i64, + AddrOpsCount: c_uint, InsertAtEnd: BasicBlockRef) -> ValueRef; pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef, Val: ValueRef, VarInfo: DIVariable, + AddrOps: *const i64, + AddrOpsCount: c_uint, InsertBefore: ValueRef) -> ValueRef; pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef, Name: *const c_char, Val: c_ulonglong) - -> ValueRef; + -> DIEnumerator; pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef, - Scope: ValueRef, + Scope: DIScope, Name: *const c_char, - File: ValueRef, + File: DIFile, LineNumber: c_uint, SizeInBits: c_ulonglong, AlignInBits: c_ulonglong, - Elements: ValueRef, - ClassType: ValueRef) - -> ValueRef; + Elements: DIArray, + ClassType: DIType) + -> DIType; pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef, - Scope: ValueRef, + Scope: DIScope, Name: *const c_char, - File: ValueRef, + File: DIFile, LineNumber: c_uint, SizeInBits: c_ulonglong, AlignInBits: c_ulonglong, Flags: c_uint, - Elements: ValueRef, + Elements: DIArray, RunTimeLang: c_uint, UniqueId: *const c_char) - -> ValueRef; + -> DIType; pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool); pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef, - Scope: ValueRef, + Scope: DIScope, Name: *const c_char, - Ty: ValueRef, - File: ValueRef, + Ty: DIType, + File: DIFile, LineNo: c_uint, ColumnNo: c_uint) - -> ValueRef; - - pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef; + -> DITemplateTypeParameter; - pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef; + pub fn LLVMDIBuilderCreateOpDeref() -> 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 LLVMDIBuilderCreateOpPlus() -> i64; pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef, - Scope: ValueRef, + Scope: DIScope, Name: *const c_char, - File: ValueRef, + File: DIFile, LineNo: c_uint) - -> ValueRef; + -> DINameSpace; + + pub fn LLVMDIBuilderCreateDebugLocation(Context: ContextRef, + Line: c_uint, + Column: c_uint, + Scope: DIScope, + InlinedAt: MetadataRef) + -> ValueRef; - pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef); + pub fn LLVMDICompositeTypeSetTypeArray(Builder: DIBuilderRef, + CompositeType: DIType, + TypeArray: DIArray); pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef); pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef); diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 7d4e6aed876a5..1aac612299d03 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -780,10 +780,6 @@ pub fn C_i32(ccx: &CrateContext, i: i32) -> ValueRef { 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 { C_integral(Type::i64(ccx), i, false) } diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index ce9af3162a089..7edac00257869 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -197,7 +197,7 @@ use metadata::csearch; use middle::subst::{self, Substs}; use trans::{self, adt, machine, type_of}; 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::monomorphize; use trans::type_::Type; @@ -702,7 +702,7 @@ enum VariableAccess<'a> { DirectVariable { alloca: ValueRef }, // The llptr given is an alloca containing the start of some pointer chain // leading to the variable's content. - IndirectVariable { alloca: ValueRef, address_operations: &'a [ValueRef] } + IndirectVariable { alloca: ValueRef, address_operations: &'a [i64] } } enum VariableKind { @@ -928,10 +928,10 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, env_index); let address_operations = unsafe { - [llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref()), - llvm::LLVMDIBuilderCreateOpPlus(Type::i64(cx).to_ref()), - C_i64(cx, byte_offset_of_var_in_env as i64), - llvm::LLVMDIBuilderCreateOpDeref(Type::i64(cx).to_ref())] + [llvm::LLVMDIBuilderCreateOpDeref(), + llvm::LLVMDIBuilderCreateOpPlus(), + byte_offset_of_var_in_env as i64, + llvm::LLVMDIBuilderCreateOpDeref()] }; 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 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) // for the binding. For ByRef bindings that's a `T*` but for ByMove bindings we @@ -1699,11 +1699,11 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }; let name = CString::from_slice(name.get().as_bytes()); - let (var_alloca, var_metadata) = match variable_access { - DirectVariable { alloca } => ( - alloca, - unsafe { - llvm::LLVMDIBuilderCreateLocalVariable( + match (variable_access, [].as_slice()) { + (DirectVariable { alloca }, address_operations) | + (IndirectVariable {alloca, address_operations}, _) => { + let metadata = unsafe { + llvm::LLVMDIBuilderCreateVariable( DIB(cx), dwarf_tag, scope_metadata, @@ -1713,38 +1713,25 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, type_metadata, cx.sess().opts.optimize != config::No, 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.len() as c_uint, argument_index) - } - ) - }; - - set_debug_location(cx, InternalDebugLocation::new(scope_metadata, + }; + set_debug_location(cx, InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize())); - unsafe { - let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd( - DIB(cx), - var_alloca, - var_metadata, - bcx.llbb); + unsafe { + let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd( + DIB(cx), + alloca, + metadata, + 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 { @@ -2716,7 +2703,7 @@ fn set_members_of_composite_type(cx: &CrateContext, unsafe { 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); } } @@ -3150,12 +3137,14 @@ fn set_debug_location(cx: &CrateContext, debug_location: InternalDebugLocation) // Always set the column to zero like Clang and GCC let col = UNKNOWN_COLUMN_NUMBER; 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 { - metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext, - elements.as_ptr(), - elements.len() as c_uint); + metadata_node = llvm::LLVMDIBuilderCreateDebugLocation( + debug_context(cx).llcontext, + line as c_uint, + col as c_uint, + scope, + ptr::null_mut()); } } UnknownLocation => { diff --git a/src/llvm b/src/llvm index b820135911e17..2d54c4f559b1a 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit b820135911e17c7a46b901db56baa48e5155bf46 +Subproject commit 2d54c4f559b1acbfe1867950c3a25bfb2f76b693 diff --git a/src/rustllvm/ExecutionEngineWrapper.cpp b/src/rustllvm/ExecutionEngineWrapper.cpp index d37cf9d12a5e0..8ca81ab3d68ea 100644 --- a/src/rustllvm/ExecutionEngineWrapper.cpp +++ b/src/rustllvm/ExecutionEngineWrapper.cpp @@ -82,21 +82,24 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine( InitializeNativeTargetAsmPrinter(); InitializeNativeTargetAsmParser(); - std::unique_ptr m(unwrap(mod)); - RustJITMemoryManager *mm = unwrap(mref); - std::string error_str; TargetOptions options; options.JITEmitDebugInfo = true; options.NoFramePointerElim = true; - ExecutionEngine *ee = EngineBuilder(std::move(m)) - .setEngineKind(EngineKind::JIT) - .setErrorStr(&error_str) - .setMCJITMemoryManager(mm) - .setTargetOptions(options) - .create(); + ExecutionEngine *ee = + #if LLVM_VERSION_MINOR <= 5 + EngineBuilder(unwrap(mod)) + .setMCJITMemoryManager(unwrap(mref)) + #else + EngineBuilder(std::unique_ptr(unwrap(mod))) + .setMCJITMemoryManager(std::unique_ptr(unwrap(mref))) + #endif + .setEngineKind(EngineKind::JIT) + .setErrorStr(&error_str) + .setTargetOptions(options) + .create(); if (!ee) LLVMRustSetLastError(error_str.c_str()); diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 728ff1461fc2b..aaf6d8df29cad 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -228,8 +228,22 @@ extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty, 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(Vals); +} +} +#else +typedef LLVMValueRef LLVMMetadataRef; +#endif + template -DIT unwrapDI(LLVMValueRef ref) { +DIT unwrapDI(LLVMMetadataRef ref) { return DIT(ref ? unwrap(ref) : NULL); } @@ -257,7 +271,7 @@ extern "C" void LLVMDIBuilderFinalize(DIBuilderRef Builder) { Builder->finalize(); } -extern "C" LLVMValueRef LLVMDIBuilderCreateCompileUnit( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateCompileUnit( DIBuilderRef Builder, unsigned Lang, const char* File, @@ -277,17 +291,17 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateCompileUnit( SplitName)); } -extern "C" LLVMValueRef LLVMDIBuilderCreateFile( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateFile( DIBuilderRef Builder, const char* Filename, const char* Directory) { return wrap(Builder->createFile(Filename, Directory)); } -extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType( DIBuilderRef Builder, - LLVMValueRef File, - LLVMValueRef ParameterTypes) { + LLVMMetadataRef File, + LLVMMetadataRef ParameterTypes) { return wrap(Builder->createSubroutineType( unwrapDI(File), #if LLVM_VERSION_MINOR >= 6 @@ -297,22 +311,22 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType( #endif } -extern "C" LLVMValueRef LLVMDIBuilderCreateFunction( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction( DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, const char* LinkageName, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNo, - LLVMValueRef Ty, + LLVMMetadataRef Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized, LLVMValueRef Fn, - LLVMValueRef TParam, - LLVMValueRef Decl) { + LLVMMetadataRef TParam, + LLVMMetadataRef Decl) { return wrap(Builder->createFunction( unwrapDI(Scope), Name, LinkageName, unwrapDI(File), LineNo, @@ -323,7 +337,7 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateFunction( unwrapDI(Decl))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateBasicType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateBasicType( DIBuilderRef Builder, const char* Name, uint64_t SizeInBits, @@ -334,9 +348,9 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateBasicType( AlignInBits, Encoding)); } -extern "C" LLVMValueRef LLVMDIBuilderCreatePointerType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreatePointerType( DIBuilderRef Builder, - LLVMValueRef PointeeTy, + LLVMMetadataRef PointeeTy, uint64_t SizeInBits, uint64_t AlignInBits, const char* Name) { @@ -344,19 +358,19 @@ extern "C" LLVMValueRef LLVMDIBuilderCreatePointerType( unwrapDI(PointeeTy), SizeInBits, AlignInBits, Name)); } -extern "C" LLVMValueRef LLVMDIBuilderCreateStructType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType( DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, - LLVMValueRef DerivedFrom, - LLVMValueRef Elements, + LLVMMetadataRef DerivedFrom, + LLVMMetadataRef Elements, unsigned RunTimeLang, - LLVMValueRef VTableHolder, + LLVMMetadataRef VTableHolder, const char *UniqueId) { return wrap(Builder->createStructType( unwrapDI(Scope), @@ -376,17 +390,17 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStructType( )); } -extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateMemberType( DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, - LLVMValueRef Ty) { + LLVMMetadataRef Ty) { return wrap(Builder->createMemberType( unwrapDI(Scope), Name, unwrapDI(File), LineNo, @@ -394,10 +408,10 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType( unwrapDI(Ty))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock( DIBuilderRef Builder, - LLVMValueRef Scope, - LLVMValueRef File, + LLVMMetadataRef Scope, + LLVMMetadataRef File, unsigned Line, unsigned Col) { return wrap(Builder->createLexicalBlock( @@ -409,17 +423,17 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock( )); } -extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable( DIBuilderRef Builder, - LLVMValueRef Context, + LLVMMetadataRef Context, const char* Name, const char* LinkageName, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNo, - LLVMValueRef Ty, + LLVMMetadataRef Ty, bool isLocalToUnit, LLVMValueRef Val, - LLVMValueRef Decl = NULL) { + LLVMMetadataRef Decl = NULL) { #if LLVM_VERSION_MINOR == 6 return wrap(Builder->createGlobalVariable(unwrapDI(Context), #else @@ -431,21 +445,42 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable( LineNo, unwrapDI(Ty), isLocalToUnit, - unwrap(Val), + cast(unwrap(Val)), unwrapDI(Decl))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable( DIBuilderRef Builder, unsigned Tag, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNo, - LLVMValueRef Ty, + LLVMMetadataRef Ty, bool AlwaysPreserve, unsigned Flags, + int64_t* AddrOps, + unsigned AddrOpsCount, unsigned ArgNo) { +#if LLVM_VERSION_MINOR < 6 + if (AddrOpsCount > 0) { + SmallVector 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(Scope), + Name, + unwrapDI(File), + LineNo, + unwrapDI(Ty), + addr_ops, + ArgNo + )); + } +#endif return wrap(Builder->createLocalVariable(Tag, unwrapDI(Scope), Name, unwrapDI(File), @@ -453,66 +488,94 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable( unwrapDI(Ty), AlwaysPreserve, Flags, ArgNo)); } -extern "C" LLVMValueRef LLVMDIBuilderCreateArrayType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateArrayType( DIBuilderRef Builder, uint64_t Size, uint64_t AlignInBits, - LLVMValueRef Ty, - LLVMValueRef Subscripts) { + LLVMMetadataRef Ty, + LLVMMetadataRef Subscripts) { return wrap(Builder->createArrayType(Size, AlignInBits, unwrapDI(Ty), unwrapDI(Subscripts))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateVectorType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateVectorType( DIBuilderRef Builder, uint64_t Size, uint64_t AlignInBits, - LLVMValueRef Ty, - LLVMValueRef Subscripts) { + LLVMMetadataRef Ty, + LLVMMetadataRef Subscripts) { return wrap(Builder->createVectorType(Size, AlignInBits, unwrapDI(Ty), unwrapDI(Subscripts))); } -extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateSubrange( +extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange( DIBuilderRef Builder, int64_t Lo, int64_t Count) { return wrap(Builder->getOrCreateSubrange(Lo, Count)); } -extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateArray( +extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray( DIBuilderRef Builder, - LLVMValueRef* Ptr, + LLVMMetadataRef* Ptr, unsigned Count) { return wrap(Builder->getOrCreateArray( - ArrayRef(reinterpret_cast(Ptr), Count))); + ArrayRef(unwrap(Ptr), Count))); } extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( DIBuilderRef Builder, LLVMValueRef Val, - LLVMValueRef VarInfo, + LLVMMetadataRef VarInfo, + int64_t* AddrOps, + unsigned AddrOpsCount, LLVMBasicBlockRef InsertAtEnd) { +#if LLVM_VERSION_MINOR >= 6 + DIExpression Expr; + if (AddrOpsCount == 0) { + Expr = Builder->createExpression(); + } else { + llvm::ArrayRef addr_ops(AddrOps, AddrOpsCount); + Expr = Builder->createExpression(addr_ops); + } +#endif return wrap(Builder->insertDeclare( unwrap(Val), unwrapDI(VarInfo), +#if LLVM_VERSION_MINOR >= 6 + Expr, +#endif unwrap(InsertAtEnd))); } extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore( DIBuilderRef Builder, LLVMValueRef Val, - LLVMValueRef VarInfo, + LLVMMetadataRef VarInfo, + int64_t* AddrOps, + unsigned AddrOpsCount, LLVMValueRef InsertBefore) { +#if LLVM_VERSION_MINOR >= 6 + DIExpression Expr; + if (AddrOpsCount == 0) { + Expr = Builder->createExpression(); + } else { + llvm::ArrayRef addr_ops(AddrOps, AddrOpsCount); + Expr = Builder->createExpression(addr_ops); + } +#endif return wrap(Builder->insertDeclare( unwrap(Val), unwrapDI(VarInfo), +#if LLVM_VERSION_MINOR >= 6 + Expr, +#endif unwrap(InsertBefore))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerator( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerator( DIBuilderRef Builder, const char* Name, uint64_t Val) @@ -520,16 +583,16 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerator( return wrap(Builder->createEnumerator(Name, Val)); } -extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerationType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerationType( DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, - LLVMValueRef Elements, - LLVMValueRef ClassType) + LLVMMetadataRef Elements, + LLVMMetadataRef ClassType) { return wrap(Builder->createEnumerationType( unwrapDI(Scope), @@ -542,16 +605,16 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateEnumerationType( unwrapDI(ClassType))); } -extern "C" LLVMValueRef LLVMDIBuilderCreateUnionType( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType( DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, - LLVMValueRef Elements, + LLVMMetadataRef Elements, unsigned RunTimeLang, const char* UniqueId) { @@ -577,12 +640,12 @@ extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) { } #endif -extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter( +extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter( DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef Ty, - LLVMValueRef File, + LLVMMetadataRef Ty, + LLVMMetadataRef File, unsigned LineNo, unsigned ColumnNo) { @@ -595,47 +658,21 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter( 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, - unsigned Tag, - LLVMValueRef Scope, - const char *Name, - LLVMValueRef File, - unsigned LineNo, - LLVMValueRef Ty, - LLVMValueRef* AddrOps, - unsigned AddrOpsCount, - unsigned ArgNo) -{ - llvm::ArrayRef addr_ops((llvm::Value**)AddrOps, AddrOpsCount); - - return wrap(Builder->createComplexVariable( - Tag, - unwrapDI(Scope), - Name, - unwrapDI(File), - LineNo, - unwrapDI(Ty), - addr_ops, - ArgNo - )); -} - -extern "C" LLVMValueRef LLVMDIBuilderCreateNameSpace( - DIBuilderRef Builder, - LLVMValueRef Scope, + LLVMMetadataRef Scope, const char* Name, - LLVMValueRef File, + LLVMMetadataRef File, unsigned LineNo) { return wrap(Builder->createNameSpace( @@ -646,16 +683,39 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateNameSpace( } extern "C" void LLVMDICompositeTypeSetTypeArray( - LLVMValueRef CompositeType, - LLVMValueRef TypeArray) + DIBuilderRef Builder, + LLVMMetadataRef CompositeType, + LLVMMetadataRef TypeArray) { #if LLVM_VERSION_MINOR >= 6 - unwrapDI(CompositeType).setArrays(unwrapDI(TypeArray)); + DICompositeType tmp = unwrapDI(CompositeType); + Builder->replaceArrays(tmp, unwrapDI(TypeArray)); #else unwrapDI(CompositeType).setTypeArray(unwrapDI(TypeArray)); #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(Scope), + unwrapDI(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) { raw_rust_string_ostream os(str); unwrap(Type)->print(os); @@ -690,7 +750,14 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { } 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)) { +#endif LLVMRustSetLastError(Err.c_str()); return false; } @@ -772,7 +839,7 @@ extern "C" const char* #if LLVM_VERSION_MINOR >= 6 LLVMRustArchiveReadSection(OwningBinary *ob, char *name, size_t *size) { - std::unique_ptr &ar = ob->getBinary(); + Archive *ar = ob->getBinary(); #else LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) { #endif diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index 9dd66ac0a3059..e159e9729b635 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2015-01-18 +2015-01-30