2013-05-28 11:15:31 +12:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-10 15:44:02 -08:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
2011-03-15 14:57:26 -07:00
|
|
|
//
|
2012-12-10 15:44:02 -08:00
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-05-28 11:15:31 +12:00
|
|
|
#include "rustllvm.h"
|
2013-12-16 20:58:21 -08:00
|
|
|
#include "llvm/Object/Archive.h"
|
2014-04-03 10:45:36 -07:00
|
|
|
#include "llvm/Object/ObjectFile.h"
|
2014-09-12 08:17:58 -07:00
|
|
|
#include "llvm/IR/DiagnosticInfo.h"
|
|
|
|
#include "llvm/IR/DiagnosticPrinter.h"
|
2013-05-28 11:15:31 +12:00
|
|
|
|
2014-05-21 15:07:48 -04:00
|
|
|
#include "llvm/IR/CallSite.h"
|
|
|
|
|
2011-10-21 17:35:52 -07:00
|
|
|
//===----------------------------------------------------------------------===
|
2011-03-15 14:57:26 -07:00
|
|
|
//
|
|
|
|
// This file defines alternate interfaces to core functions that are more
|
|
|
|
// readily callable by Rust's FFI.
|
|
|
|
//
|
2011-10-21 17:35:52 -07:00
|
|
|
//===----------------------------------------------------------------------===
|
2011-03-15 14:57:26 -07:00
|
|
|
|
2011-04-15 17:35:46 -04:00
|
|
|
using namespace llvm;
|
2012-09-11 16:05:51 +10:00
|
|
|
using namespace llvm::sys;
|
2013-12-16 20:58:21 -08:00
|
|
|
using namespace llvm::object;
|
2011-04-15 17:35:46 -04:00
|
|
|
|
2014-04-15 07:25:22 -07:00
|
|
|
static char *LastError;
|
2013-04-05 17:17:49 -07:00
|
|
|
|
2014-07-18 07:07:15 -07:00
|
|
|
extern "C" LLVMMemoryBufferRef
|
|
|
|
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
|
|
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> buf_or = MemoryBuffer::getFile(Path,
|
|
|
|
-1,
|
|
|
|
false);
|
|
|
|
if (!buf_or) {
|
|
|
|
LLVMRustSetLastError(buf_or.getError().message().c_str());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return wrap(buf_or.get().release());
|
|
|
|
}
|
2011-03-15 14:57:26 -07:00
|
|
|
|
2014-04-15 07:25:22 -07:00
|
|
|
extern "C" char *LLVMRustGetLastError(void) {
|
|
|
|
char *ret = LastError;
|
|
|
|
LastError = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMRustSetLastError(const char *err) {
|
|
|
|
free((void*) LastError);
|
|
|
|
LastError = strdup(err);
|
2011-03-15 14:57:26 -07:00
|
|
|
}
|
|
|
|
|
2013-08-22 20:58:42 -07:00
|
|
|
extern "C" void
|
|
|
|
LLVMRustSetNormalizedTarget(LLVMModuleRef M, const char *triple) {
|
|
|
|
unwrap(M)->setTargetTriple(Triple::normalize(triple));
|
2011-05-05 11:34:15 -07:00
|
|
|
}
|
|
|
|
|
2011-05-07 18:54:23 +00:00
|
|
|
extern "C" LLVMValueRef LLVMRustConstSmallInt(LLVMTypeRef IntTy, unsigned N,
|
|
|
|
LLVMBool SignExtend) {
|
|
|
|
return LLVMConstInt(IntTy, (unsigned long long)N, SignExtend);
|
|
|
|
}
|
2011-05-10 16:10:08 -07:00
|
|
|
|
2013-05-03 19:25:04 -04:00
|
|
|
extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy,
|
|
|
|
unsigned N_hi,
|
|
|
|
unsigned N_lo,
|
|
|
|
LLVMBool SignExtend) {
|
2011-11-16 12:15:54 -08:00
|
|
|
unsigned long long N = N_hi;
|
|
|
|
N <<= 32;
|
|
|
|
N |= N_lo;
|
|
|
|
return LLVMConstInt(IntTy, N, SignExtend);
|
|
|
|
}
|
|
|
|
|
2011-05-10 16:10:08 -07:00
|
|
|
extern "C" void LLVMRustPrintPassTimings() {
|
|
|
|
raw_fd_ostream OS (2, false); // stderr.
|
|
|
|
TimerGroup::printAll(OS);
|
|
|
|
}
|
2011-10-31 14:42:17 -07:00
|
|
|
|
2015-02-27 13:37:33 +02:00
|
|
|
extern "C" LLVMValueRef LLVMGetNamedValue(LLVMModuleRef M,
|
|
|
|
const char* Name) {
|
|
|
|
return wrap(unwrap(M)->getNamedValue(Name));
|
|
|
|
}
|
|
|
|
|
2011-11-15 00:32:31 +08:00
|
|
|
extern "C" LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M,
|
|
|
|
const char* Name,
|
|
|
|
LLVMTypeRef FunctionTy) {
|
|
|
|
return wrap(unwrap(M)->getOrInsertFunction(Name,
|
|
|
|
unwrap<FunctionType>(FunctionTy)));
|
|
|
|
}
|
2011-11-10 00:55:09 -05:00
|
|
|
|
2015-03-04 00:57:44 +02:00
|
|
|
extern "C" LLVMValueRef LLVMGetOrInsertGlobal(LLVMModuleRef M,
|
|
|
|
const char* Name,
|
|
|
|
LLVMTypeRef Ty) {
|
|
|
|
return wrap(unwrap(M)->getOrInsertGlobal(Name, unwrap(Ty)));
|
|
|
|
}
|
|
|
|
|
2011-11-10 00:55:09 -05:00
|
|
|
extern "C" LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) {
|
|
|
|
return wrap(Type::getMetadataTy(*unwrap(C)));
|
|
|
|
}
|
2012-06-21 15:01:32 -07:00
|
|
|
|
2014-05-21 15:07:48 -04:00
|
|
|
extern "C" void LLVMAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, uint64_t Val) {
|
|
|
|
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addRawValue(Val);
|
|
|
|
Call.setAttributes(
|
|
|
|
Call.getAttributes().addAttributes(Call->getContext(), index,
|
|
|
|
AttributeSet::get(Call->getContext(),
|
|
|
|
index, B)));
|
2013-08-05 21:21:37 -07:00
|
|
|
}
|
|
|
|
|
2014-07-25 19:47:29 -07:00
|
|
|
|
2014-07-25 16:06:44 -07:00
|
|
|
extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned idx, uint64_t b) {
|
|
|
|
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addDereferenceableAttr(b);
|
|
|
|
Call.setAttributes(
|
|
|
|
Call.getAttributes().addAttributes(Call->getContext(), idx,
|
|
|
|
AttributeSet::get(Call->getContext(),
|
|
|
|
idx, B)));
|
|
|
|
}
|
|
|
|
|
2015-07-20 13:27:38 -07:00
|
|
|
extern "C" void LLVMAddFunctionAttribute(LLVMValueRef Fn, unsigned index,
|
|
|
|
uint64_t Val) {
|
2014-05-21 15:07:48 -04:00
|
|
|
Function *A = unwrap<Function>(Fn);
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addRawValue(Val);
|
|
|
|
A->addAttributes(index, AttributeSet::get(A->getContext(), index, B));
|
|
|
|
}
|
|
|
|
|
2014-07-25 16:06:44 -07:00
|
|
|
extern "C" void LLVMAddDereferenceableAttr(LLVMValueRef Fn, unsigned index, uint64_t bytes) {
|
|
|
|
Function *A = unwrap<Function>(Fn);
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addDereferenceableAttr(bytes);
|
|
|
|
A->addAttributes(index, AttributeSet::get(A->getContext(), index, B));
|
|
|
|
}
|
|
|
|
|
2014-05-21 15:07:48 -04:00
|
|
|
extern "C" void LLVMAddFunctionAttrString(LLVMValueRef Fn, unsigned index, const char *Name) {
|
|
|
|
Function *F = unwrap<Function>(Fn);
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addAttribute(Name);
|
|
|
|
F->addAttributes(index, AttributeSet::get(F->getContext(), index, B));
|
|
|
|
}
|
|
|
|
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
extern "C" void LLVMAddFunctionAttrStringValue(LLVMValueRef Fn, unsigned index,
|
|
|
|
const char *Name,
|
|
|
|
const char *Value) {
|
|
|
|
Function *F = unwrap<Function>(Fn);
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addAttribute(Name, Value);
|
|
|
|
F->addAttributes(index, AttributeSet::get(F->getContext(), index, B));
|
|
|
|
}
|
|
|
|
|
2014-05-21 15:07:48 -04:00
|
|
|
extern "C" void LLVMRemoveFunctionAttrString(LLVMValueRef fn, unsigned index, const char *Name) {
|
2014-04-19 10:33:46 -07:00
|
|
|
Function *f = unwrap<Function>(fn);
|
|
|
|
LLVMContext &C = f->getContext();
|
|
|
|
AttrBuilder B;
|
|
|
|
B.addAttribute(Name);
|
2014-05-21 15:07:48 -04:00
|
|
|
AttributeSet to_remove = AttributeSet::get(C, index, B);
|
2014-04-19 10:33:46 -07:00
|
|
|
|
|
|
|
AttributeSet attrs = f->getAttributes();
|
|
|
|
f->setAttributes(attrs.removeAttributes(f->getContext(),
|
2014-05-21 15:07:48 -04:00
|
|
|
index,
|
2014-04-19 10:33:46 -07:00
|
|
|
to_remove));
|
|
|
|
}
|
2013-09-09 02:32:30 -04:00
|
|
|
|
2013-05-12 21:22:20 +02:00
|
|
|
extern "C" LLVMValueRef LLVMBuildAtomicLoad(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef source,
|
|
|
|
const char* Name,
|
2013-05-20 17:28:06 -07:00
|
|
|
AtomicOrdering order,
|
|
|
|
unsigned alignment) {
|
2013-05-12 21:22:20 +02:00
|
|
|
LoadInst* li = new LoadInst(unwrap(source),0);
|
|
|
|
li->setAtomic(order);
|
2013-05-20 17:28:06 -07:00
|
|
|
li->setAlignment(alignment);
|
2013-05-17 14:48:24 +12:00
|
|
|
return wrap(unwrap(B)->Insert(li, Name));
|
2013-05-12 21:22:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef LLVMBuildAtomicStore(LLVMBuilderRef B,
|
2013-05-20 17:28:06 -07:00
|
|
|
LLVMValueRef val,
|
|
|
|
LLVMValueRef target,
|
|
|
|
AtomicOrdering order,
|
|
|
|
unsigned alignment) {
|
2013-05-12 21:22:20 +02:00
|
|
|
StoreInst* si = new StoreInst(unwrap(val),unwrap(target));
|
|
|
|
si->setAtomic(order);
|
2013-05-20 17:28:06 -07:00
|
|
|
si->setAlignment(alignment);
|
2013-05-12 21:22:20 +02:00
|
|
|
return wrap(unwrap(B)->Insert(si));
|
|
|
|
}
|
|
|
|
|
2012-10-21 22:23:50 -04:00
|
|
|
extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef target,
|
|
|
|
LLVMValueRef old,
|
|
|
|
LLVMValueRef source,
|
2014-03-31 14:43:19 -07:00
|
|
|
AtomicOrdering order,
|
|
|
|
AtomicOrdering failure_order) {
|
2012-10-21 22:23:50 -04:00
|
|
|
return wrap(unwrap(B)->CreateAtomicCmpXchg(unwrap(target), unwrap(old),
|
2015-03-14 13:14:04 +01:00
|
|
|
unwrap(source), order,
|
|
|
|
failure_order
|
2014-03-31 14:43:19 -07:00
|
|
|
));
|
2012-10-21 22:23:50 -04:00
|
|
|
}
|
2015-02-14 23:48:10 -07:00
|
|
|
extern "C" LLVMValueRef LLVMBuildAtomicFence(LLVMBuilderRef B,
|
|
|
|
AtomicOrdering order,
|
|
|
|
SynchronizationScope scope) {
|
|
|
|
return wrap(unwrap(B)->CreateFence(order, scope));
|
2013-07-28 19:48:16 +12:00
|
|
|
}
|
2012-07-25 12:06:03 -07:00
|
|
|
|
|
|
|
extern "C" void LLVMSetDebug(int Enabled) {
|
2012-10-08 21:40:09 +02:00
|
|
|
#ifndef NDEBUG
|
2012-07-25 12:06:03 -07:00
|
|
|
DebugFlag = Enabled;
|
2012-10-08 21:40:09 +02:00
|
|
|
#endif
|
2012-07-25 12:06:03 -07:00
|
|
|
}
|
2013-03-09 22:37:50 -08:00
|
|
|
|
|
|
|
extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty,
|
|
|
|
char *AsmString,
|
|
|
|
char *Constraints,
|
|
|
|
LLVMBool HasSideEffects,
|
2013-03-10 00:38:29 -08:00
|
|
|
LLVMBool IsAlignStack,
|
2013-03-08 20:44:37 -05:00
|
|
|
unsigned Dialect) {
|
2013-03-09 22:37:50 -08:00
|
|
|
return wrap(InlineAsm::get(unwrap<FunctionType>(Ty), AsmString,
|
|
|
|
Constraints, HasSideEffects,
|
2013-03-08 20:44:37 -05:00
|
|
|
IsAlignStack, (InlineAsm::AsmDialect) Dialect));
|
2013-03-09 22:37:50 -08:00
|
|
|
}
|
2013-06-13 21:25:12 -07:00
|
|
|
|
2013-06-14 11:38:29 -07:00
|
|
|
typedef DIBuilder* DIBuilderRef;
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
#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
|
|
|
|
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
template<typename DIT>
|
|
|
|
DIT* unwrapDIptr(LLVMMetadataRef ref) {
|
|
|
|
return (DIT*) (ref ? unwrap<MDNode>(ref) : NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if LLVM_VERSION_MINOR <= 6
|
2013-06-14 11:38:29 -07:00
|
|
|
template<typename DIT>
|
2015-01-30 19:25:07 +01:00
|
|
|
DIT unwrapDI(LLVMMetadataRef ref) {
|
2013-07-02 18:10:24 +02:00
|
|
|
return DIT(ref ? unwrap<MDNode>(ref) : NULL);
|
2013-06-17 08:42:05 -07:00
|
|
|
}
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#else
|
|
|
|
#define DIDescriptor DIScope
|
|
|
|
#define DIArray DINodeArray
|
|
|
|
#define unwrapDI unwrapDIptr
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LLVM_VERSION_MINOR <= 5
|
|
|
|
#define DISubroutineType DICompositeType
|
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2015-05-30 09:50:12 -04:00
|
|
|
extern "C" uint32_t LLVMRustDebugMetadataVersion() {
|
2015-05-11 21:07:38 -07:00
|
|
|
return DEBUG_METADATA_VERSION;
|
|
|
|
}
|
2014-01-28 00:05:33 -05:00
|
|
|
|
2015-01-24 12:00:35 +01:00
|
|
|
extern "C" uint32_t LLVMVersionMinor() {
|
|
|
|
return LLVM_VERSION_MINOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" uint32_t LLVMVersionMajor() {
|
|
|
|
return LLVM_VERSION_MAJOR;
|
|
|
|
}
|
|
|
|
|
2014-01-28 00:05:33 -05:00
|
|
|
extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M,
|
|
|
|
const char *name,
|
|
|
|
uint32_t value) {
|
|
|
|
unwrap(M)->addModuleFlag(Module::Warning, name, value);
|
|
|
|
}
|
|
|
|
|
2013-06-11 00:57:25 -07:00
|
|
|
extern "C" DIBuilderRef LLVMDIBuilderCreate(LLVMModuleRef M) {
|
2013-06-14 11:38:29 -07:00
|
|
|
return new DIBuilder(*unwrap(M));
|
|
|
|
}
|
|
|
|
|
2013-06-11 00:57:25 -07:00
|
|
|
extern "C" void LLVMDIBuilderDispose(DIBuilderRef Builder) {
|
2013-06-14 11:38:29 -07:00
|
|
|
delete Builder;
|
|
|
|
}
|
|
|
|
|
2013-06-11 00:57:25 -07:00
|
|
|
extern "C" void LLVMDIBuilderFinalize(DIBuilderRef Builder) {
|
2013-06-14 11:38:29 -07:00
|
|
|
Builder->finalize();
|
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
unsigned Lang,
|
|
|
|
const char* File,
|
|
|
|
const char* Dir,
|
|
|
|
const char* Producer,
|
|
|
|
bool isOptimized,
|
|
|
|
const char* Flags,
|
|
|
|
unsigned RuntimeVer,
|
|
|
|
const char* SplitName) {
|
2014-12-03 14:48:18 -08:00
|
|
|
return wrap(Builder->createCompileUnit(Lang,
|
|
|
|
File,
|
|
|
|
Dir,
|
|
|
|
Producer,
|
|
|
|
isOptimized,
|
|
|
|
Flags,
|
|
|
|
RuntimeVer,
|
|
|
|
SplitName));
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateFile(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
const char* Filename,
|
|
|
|
const char* Directory) {
|
|
|
|
return wrap(Builder->createFile(Filename, Directory));
|
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
|
|
|
LLVMMetadataRef ParameterTypes) {
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->createSubroutineType(
|
2015-10-24 18:42:23 +09:00
|
|
|
#if LLVM_VERSION_MINOR <= 7
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIFile>(File),
|
2015-10-24 18:42:23 +09:00
|
|
|
#endif
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DITypeRefArray(unwrap<MDTuple>(ParameterTypes))));
|
|
|
|
#elif LLVM_VERSION_MINOR >= 6
|
2014-08-01 02:23:05 -07:00
|
|
|
unwrapDI<DITypeArray>(ParameterTypes)));
|
2014-08-15 16:36:05 +02:00
|
|
|
#else
|
|
|
|
unwrapDI<DIArray>(ParameterTypes)));
|
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-06-14 11:38:29 -07:00
|
|
|
const char* Name,
|
|
|
|
const char* LinkageName,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned LineNo,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty,
|
2013-06-14 11:38:29 -07:00
|
|
|
bool isLocalToUnit,
|
|
|
|
bool isDefinition,
|
|
|
|
unsigned ScopeLine,
|
|
|
|
unsigned Flags,
|
|
|
|
bool isOptimized,
|
|
|
|
LLVMValueRef Fn,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef TParam,
|
|
|
|
LLVMMetadataRef Decl) {
|
2015-10-22 22:07:19 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
DITemplateParameterArray TParams =
|
|
|
|
DITemplateParameterArray(unwrap<MDTuple>(TParam));
|
|
|
|
DISubprogram *Sub = Builder->createFunction(
|
|
|
|
unwrapDI<DIScope>(Scope), Name, LinkageName,
|
|
|
|
unwrapDI<DIFile>(File), LineNo,
|
|
|
|
unwrapDI<DISubroutineType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
|
|
|
|
Flags, isOptimized,
|
|
|
|
TParams,
|
|
|
|
unwrapDIptr<DISubprogram>(Decl));
|
|
|
|
unwrap<Function>(Fn)->setSubprogram(Sub);
|
|
|
|
return wrap(Sub);
|
|
|
|
#else
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->createFunction(
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIScope>(Scope), Name, LinkageName,
|
|
|
|
unwrapDI<DIFile>(File), LineNo,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
unwrapDI<DISubroutineType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
|
2013-06-14 11:38:29 -07:00
|
|
|
Flags, isOptimized,
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrap<Function>(Fn),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
unwrapDIptr<MDNode>(TParam),
|
|
|
|
unwrapDIptr<MDNode>(Decl)));
|
2015-10-22 22:07:19 -07:00
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateBasicType(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
const char* Name,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
unsigned Encoding) {
|
|
|
|
return wrap(Builder->createBasicType(
|
2013-07-02 18:10:24 +02:00
|
|
|
Name, SizeInBits,
|
2013-06-14 11:38:29 -07:00
|
|
|
AlignInBits, Encoding));
|
|
|
|
}
|
2013-07-02 18:10:24 +02:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreatePointerType(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef PointeeTy,
|
2013-06-14 11:38:29 -07:00
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
const char* Name) {
|
|
|
|
return wrap(Builder->createPointerType(
|
|
|
|
unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits, Name));
|
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-06-14 11:38:29 -07:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
unsigned Flags,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef DerivedFrom,
|
|
|
|
LLVMMetadataRef Elements,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned RunTimeLang,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef VTableHolder,
|
2013-10-01 12:24:50 +02:00
|
|
|
const char *UniqueId) {
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->createStructType(
|
2013-10-01 12:24:50 +02:00
|
|
|
unwrapDI<DIDescriptor>(Scope),
|
|
|
|
Name,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNumber,
|
|
|
|
SizeInBits,
|
|
|
|
AlignInBits,
|
|
|
|
Flags,
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIType>(DerivedFrom),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DINodeArray(unwrapDI<MDTuple>(Elements)),
|
|
|
|
#else
|
2013-10-01 12:24:50 +02:00
|
|
|
unwrapDI<DIArray>(Elements),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2013-10-01 12:24:50 +02:00
|
|
|
RunTimeLang,
|
2015-03-14 13:14:04 +01:00
|
|
|
unwrapDI<DIType>(VTableHolder),
|
|
|
|
UniqueId
|
2014-03-31 14:43:19 -07:00
|
|
|
));
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateMemberType(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-06-14 11:38:29 -07:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned LineNo,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits,
|
|
|
|
unsigned Flags,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty) {
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->createMemberType(
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIDescriptor>(Scope), Name,
|
2013-06-14 11:38:29 -07:00
|
|
|
unwrapDI<DIFile>(File), LineNo,
|
2013-07-02 18:10:24 +02:00
|
|
|
SizeInBits, AlignInBits, OffsetInBits, Flags,
|
2013-06-14 11:38:29 -07:00
|
|
|
unwrapDI<DIType>(Ty)));
|
|
|
|
}
|
2013-07-02 18:10:24 +02:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
|
|
|
LLVMMetadataRef File,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned Line,
|
2014-09-30 17:20:22 -04:00
|
|
|
unsigned Col) {
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->createLexicalBlock(
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIDescriptor>(Scope),
|
2014-03-31 14:43:19 -07:00
|
|
|
unwrapDI<DIFile>(File), Line, Col
|
2014-09-30 17:20:22 -04:00
|
|
|
#if LLVM_VERSION_MINOR == 5
|
|
|
|
, 0
|
2014-03-31 14:43:19 -07:00
|
|
|
#endif
|
|
|
|
));
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
2013-07-02 18:10:24 +02:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable(
|
2014-02-20 20:44:29 -05:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Context,
|
2014-02-20 20:44:29 -05:00
|
|
|
const char* Name,
|
|
|
|
const char* LinkageName,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2014-02-20 20:44:29 -05:00
|
|
|
unsigned LineNo,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty,
|
2014-02-20 20:44:29 -05:00
|
|
|
bool isLocalToUnit,
|
|
|
|
LLVMValueRef Val,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Decl = NULL) {
|
2015-04-20 10:19:02 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
2014-09-30 17:20:22 -04:00
|
|
|
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
|
|
|
|
#else
|
2014-02-20 20:44:29 -05:00
|
|
|
return wrap(Builder->createStaticVariable(unwrapDI<DIDescriptor>(Context),
|
2014-09-30 17:20:22 -04:00
|
|
|
#endif
|
2014-02-20 20:44:29 -05:00
|
|
|
Name,
|
|
|
|
LinkageName,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNo,
|
|
|
|
unwrapDI<DIType>(Ty),
|
|
|
|
isLocalToUnit,
|
2015-01-30 19:25:07 +01:00
|
|
|
cast<Constant>(unwrap(Val)),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
unwrapDIptr<MDNode>(Decl)));
|
2014-02-20 20:44:29 -05:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
unsigned Tag,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-06-14 11:38:29 -07:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned LineNo,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty,
|
2013-06-14 11:38:29 -07:00
|
|
|
bool AlwaysPreserve,
|
|
|
|
unsigned Flags,
|
2015-01-30 19:25:07 +01:00
|
|
|
int64_t* AddrOps,
|
|
|
|
unsigned AddrOpsCount,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned ArgNo) {
|
2015-04-20 10:19:02 -07:00
|
|
|
#if LLVM_VERSION_MINOR == 5
|
2015-01-30 19:25:07 +01:00
|
|
|
if (AddrOpsCount > 0) {
|
|
|
|
SmallVector<llvm::Value *, 16> addr_ops;
|
2015-03-14 13:14:04 +01:00
|
|
|
llvm::Type *Int64Ty = Type::getInt64Ty(unwrap<MDNode>(Scope)->getContext());
|
|
|
|
for (unsigned i = 0; i < AddrOpsCount; ++i)
|
2015-01-30 19:25:07 +01:00
|
|
|
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
|
2015-10-24 18:42:23 +09:00
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
if (Tag == 0x100) { // DW_TAG_auto_variable
|
|
|
|
return wrap(Builder->createAutoVariable(
|
|
|
|
unwrapDI<DIDescriptor>(Scope), Name,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNo,
|
|
|
|
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags));
|
|
|
|
} else {
|
|
|
|
return wrap(Builder->createParameterVariable(
|
|
|
|
unwrapDI<DIDescriptor>(Scope), Name, ArgNo,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNo,
|
|
|
|
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags));
|
|
|
|
}
|
|
|
|
#else
|
2013-07-02 18:10:24 +02:00
|
|
|
return wrap(Builder->createLocalVariable(Tag,
|
|
|
|
unwrapDI<DIDescriptor>(Scope), Name,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNo,
|
2013-06-14 11:38:29 -07:00
|
|
|
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo));
|
2015-10-24 18:42:23 +09:00
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateArrayType(
|
2013-06-14 12:23:42 -07:00
|
|
|
DIBuilderRef Builder,
|
2013-07-02 18:10:24 +02:00
|
|
|
uint64_t Size,
|
|
|
|
uint64_t AlignInBits,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty,
|
|
|
|
LLVMMetadataRef Subscripts) {
|
2013-06-14 12:23:42 -07:00
|
|
|
return wrap(Builder->createArrayType(Size, AlignInBits,
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIType>(Ty),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DINodeArray(unwrapDI<MDTuple>(Subscripts))
|
|
|
|
#else
|
|
|
|
unwrapDI<DIArray>(Subscripts)
|
|
|
|
#endif
|
|
|
|
));
|
2013-06-14 12:23:42 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateVectorType(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2013-07-02 18:10:24 +02:00
|
|
|
uint64_t Size,
|
|
|
|
uint64_t AlignInBits,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty,
|
|
|
|
LLVMMetadataRef Subscripts) {
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->createVectorType(Size, AlignInBits,
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIType>(Ty),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DINodeArray(unwrapDI<MDTuple>(Subscripts))
|
|
|
|
#else
|
|
|
|
unwrapDI<DIArray>(Subscripts)
|
|
|
|
#endif
|
|
|
|
));
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(
|
2013-07-02 18:10:24 +02:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
int64_t Lo,
|
2013-06-14 11:38:29 -07:00
|
|
|
int64_t Count) {
|
|
|
|
return wrap(Builder->getOrCreateSubrange(Lo, Count));
|
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef* Ptr,
|
2013-06-14 11:38:29 -07:00
|
|
|
unsigned Count) {
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
Metadata **DataValue = unwrap(Ptr);
|
|
|
|
return wrap(Builder->getOrCreateArray(
|
|
|
|
ArrayRef<Metadata*>(DataValue, Count)).get());
|
|
|
|
#else
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->getOrCreateArray(
|
2015-03-14 13:14:04 +01:00
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
2015-01-30 19:25:07 +01:00
|
|
|
ArrayRef<Metadata*>(unwrap(Ptr), Count)));
|
2015-03-14 13:14:04 +01:00
|
|
|
#else
|
|
|
|
ArrayRef<Value*>(reinterpret_cast<Value**>(Ptr), Count)));
|
|
|
|
#endif
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
}
|
|
|
|
|
2013-06-11 00:57:25 -07:00
|
|
|
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
|
|
|
|
DIBuilderRef Builder,
|
|
|
|
LLVMValueRef Val,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef VarInfo,
|
|
|
|
int64_t* AddrOps,
|
|
|
|
unsigned AddrOpsCount,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
LLVMValueRef DL,
|
2013-06-11 00:57:25 -07:00
|
|
|
LLVMBasicBlockRef InsertAtEnd) {
|
|
|
|
return wrap(Builder->insertDeclare(
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrap(Val),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
unwrap<DILocalVariable>(VarInfo),
|
|
|
|
#else
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIVariable>(VarInfo),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2015-01-30 19:25:07 +01:00
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
Builder->createExpression(
|
|
|
|
llvm::ArrayRef<int64_t>(AddrOps, AddrOpsCount)),
|
|
|
|
#endif
|
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DebugLoc(cast<MDNode>(unwrap<MetadataAsValue>(DL)->getMetadata())),
|
2015-01-30 19:25:07 +01:00
|
|
|
#endif
|
2013-06-11 00:57:25 -07:00
|
|
|
unwrap(InsertAtEnd)));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
|
2013-06-14 11:38:29 -07:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
LLVMValueRef Val,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef VarInfo,
|
|
|
|
int64_t* AddrOps,
|
|
|
|
unsigned AddrOpsCount,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
LLVMValueRef DL,
|
2013-06-14 11:38:29 -07:00
|
|
|
LLVMValueRef InsertBefore) {
|
2015-01-30 19:25:07 +01:00
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
return wrap(Builder->insertDeclare(
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrap(Val),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
unwrap<DILocalVariable>(VarInfo),
|
|
|
|
#else
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIVariable>(VarInfo),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2015-01-30 19:25:07 +01:00
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
Builder->createExpression(
|
|
|
|
llvm::ArrayRef<int64_t>(AddrOps, AddrOpsCount)),
|
|
|
|
#endif
|
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DebugLoc(cast<MDNode>(unwrap<MetadataAsValue>(DL)->getMetadata())),
|
2015-01-30 19:25:07 +01:00
|
|
|
#endif
|
2013-06-14 11:38:29 -07:00
|
|
|
unwrap<Instruction>(InsertBefore)));
|
|
|
|
}
|
2013-07-02 10:33:51 +02:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerator(
|
2013-07-02 10:33:51 +02:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
const char* Name,
|
|
|
|
uint64_t Val)
|
|
|
|
{
|
|
|
|
return wrap(Builder->createEnumerator(Name, Val));
|
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(
|
2013-07-02 10:33:51 +02:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-07-02 10:33:51 +02:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-07-02 10:33:51 +02:00
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Elements,
|
|
|
|
LLVMMetadataRef ClassType)
|
2013-07-02 10:33:51 +02:00
|
|
|
{
|
|
|
|
return wrap(Builder->createEnumerationType(
|
|
|
|
unwrapDI<DIDescriptor>(Scope),
|
|
|
|
Name,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNumber,
|
|
|
|
SizeInBits,
|
|
|
|
AlignInBits,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DINodeArray(unwrapDI<MDTuple>(Elements)),
|
|
|
|
#else
|
2013-07-02 10:33:51 +02:00
|
|
|
unwrapDI<DIArray>(Elements),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2013-07-02 10:33:51 +02:00
|
|
|
unwrapDI<DIType>(ClassType)));
|
2013-07-02 18:10:24 +02:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType(
|
2013-07-02 18:10:24 +02:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-07-02 18:10:24 +02:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-07-02 18:10:24 +02:00
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
unsigned Flags,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Elements,
|
2014-01-02 15:20:43 +01:00
|
|
|
unsigned RunTimeLang,
|
|
|
|
const char* UniqueId)
|
2013-07-02 18:10:24 +02:00
|
|
|
{
|
|
|
|
return wrap(Builder->createUnionType(
|
|
|
|
unwrapDI<DIDescriptor>(Scope),
|
|
|
|
Name,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNumber,
|
|
|
|
SizeInBits,
|
|
|
|
AlignInBits,
|
|
|
|
Flags,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DINodeArray(unwrapDI<MDTuple>(Elements)),
|
|
|
|
#else
|
2013-07-02 18:10:24 +02:00
|
|
|
unwrapDI<DIArray>(Elements),
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2015-03-14 13:14:04 +01:00
|
|
|
RunTimeLang,
|
|
|
|
UniqueId
|
2014-03-31 14:43:19 -07:00
|
|
|
));
|
2013-07-28 19:48:16 +12:00
|
|
|
}
|
2013-08-09 13:47:00 -07:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter(
|
2013-08-08 18:33:06 +02:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-08-08 18:33:06 +02:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Ty,
|
|
|
|
LLVMMetadataRef File,
|
2013-09-05 13:29:30 +02:00
|
|
|
unsigned LineNo,
|
|
|
|
unsigned ColumnNo)
|
2013-08-08 18:33:06 +02:00
|
|
|
{
|
|
|
|
return wrap(Builder->createTemplateTypeParameter(
|
|
|
|
unwrapDI<DIDescriptor>(Scope),
|
|
|
|
Name,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
unwrapDI<DIType>(Ty)
|
|
|
|
#if LLVM_VERSION_MINOR <= 6
|
|
|
|
,
|
2013-08-08 18:33:06 +02:00
|
|
|
unwrapDI<MDNode*>(File),
|
|
|
|
LineNo,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
ColumnNo
|
|
|
|
#endif
|
|
|
|
));
|
2013-08-08 18:33:06 +02:00
|
|
|
}
|
2013-08-23 18:45:02 +02:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" int64_t LLVMDIBuilderCreateOpDeref()
|
2013-08-23 18:45:02 +02:00
|
|
|
{
|
2015-01-30 19:25:07 +01:00
|
|
|
return dwarf::DW_OP_deref;
|
2013-08-23 18:45:02 +02:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" int64_t LLVMDIBuilderCreateOpPlus()
|
2013-08-23 18:45:02 +02:00
|
|
|
{
|
2015-01-30 19:25:07 +01:00
|
|
|
return dwarf::DW_OP_plus;
|
2013-08-23 18:45:02 +02:00
|
|
|
}
|
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
extern "C" LLVMMetadataRef LLVMDIBuilderCreateNameSpace(
|
2013-08-23 18:45:02 +02:00
|
|
|
DIBuilderRef Builder,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef Scope,
|
2013-09-05 13:29:30 +02:00
|
|
|
const char* Name,
|
2015-01-30 19:25:07 +01:00
|
|
|
LLVMMetadataRef File,
|
2013-09-05 13:29:30 +02:00
|
|
|
unsigned LineNo)
|
|
|
|
{
|
|
|
|
return wrap(Builder->createNameSpace(
|
|
|
|
unwrapDI<DIDescriptor>(Scope),
|
|
|
|
Name,
|
|
|
|
unwrapDI<DIFile>(File),
|
|
|
|
LineNo));
|
|
|
|
}
|
2013-09-11 16:37:43 +02:00
|
|
|
|
|
|
|
extern "C" void LLVMDICompositeTypeSetTypeArray(
|
2015-01-30 19:25:07 +01:00
|
|
|
DIBuilderRef Builder,
|
|
|
|
LLVMMetadataRef CompositeType,
|
|
|
|
LLVMMetadataRef TypeArray)
|
2013-09-11 16:37:43 +02:00
|
|
|
{
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
DICompositeType *tmp = unwrapDI<DICompositeType>(CompositeType);
|
|
|
|
Builder->replaceArrays(tmp, DINodeArray(unwrap<MDTuple>(TypeArray)));
|
|
|
|
#elif LLVM_VERSION_MINOR >= 6
|
2015-01-30 19:25:07 +01:00
|
|
|
DICompositeType tmp = unwrapDI<DICompositeType>(CompositeType);
|
|
|
|
Builder->replaceArrays(tmp, unwrapDI<DIArray>(TypeArray));
|
2014-08-15 16:36:05 +02:00
|
|
|
#else
|
|
|
|
unwrapDI<DICompositeType>(CompositeType).setTypeArray(unwrapDI<DIArray>(TypeArray));
|
|
|
|
#endif
|
2013-09-11 16:37:43 +02:00
|
|
|
}
|
2013-10-11 19:56:11 -04:00
|
|
|
|
2015-01-30 19:25:07 +01:00
|
|
|
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,
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
unwrapDIptr<MDNode>(Scope),
|
|
|
|
unwrapDIptr<MDNode>(InlinedAt));
|
2015-01-30 19:25:07 +01:00
|
|
|
|
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
return wrap(MetadataAsValue::get(context, debug_loc.getAsMDNode(
|
|
|
|
#if LLVM_VERSION_MINOR <= 6
|
|
|
|
context
|
|
|
|
#endif
|
|
|
|
)));
|
2015-01-30 19:25:07 +01:00
|
|
|
#else
|
|
|
|
return wrap(debug_loc.getAsMDNode(context));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-09-09 23:12:09 -07:00
|
|
|
extern "C" void LLVMWriteTypeToString(LLVMTypeRef Type, RustStringRef str) {
|
|
|
|
raw_rust_string_ostream os(str);
|
2013-10-11 19:56:11 -04:00
|
|
|
unwrap<llvm::Type>(Type)->print(os);
|
|
|
|
}
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
|
2014-09-09 23:12:09 -07:00
|
|
|
extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) {
|
|
|
|
raw_rust_string_ostream os(str);
|
2014-01-15 14:39:08 -05:00
|
|
|
os << "(";
|
|
|
|
unwrap<llvm::Value>(Value)->getType()->print(os);
|
|
|
|
os << ":";
|
|
|
|
unwrap<llvm::Value>(Value)->print(os);
|
|
|
|
os << ")";
|
|
|
|
}
|
|
|
|
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
extern "C" bool
|
|
|
|
LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
|
|
|
|
Module *Dst = unwrap(dst);
|
2015-04-20 10:19:02 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
2014-09-30 17:20:22 -04:00
|
|
|
std::unique_ptr<MemoryBuffer> buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
ErrorOr<std::unique_ptr<Module>> Src =
|
|
|
|
llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext());
|
|
|
|
#else
|
2014-09-30 17:20:22 -04:00
|
|
|
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext());
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2015-04-20 10:19:02 -07:00
|
|
|
#else
|
|
|
|
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
|
|
|
|
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
|
2014-09-30 17:20:22 -04:00
|
|
|
#endif
|
2014-01-27 12:45:48 -08:00
|
|
|
if (!Src) {
|
2014-04-15 07:25:22 -07:00
|
|
|
LLVMRustSetLastError(Src.getError().message().c_str());
|
2014-09-30 17:20:22 -04:00
|
|
|
#if LLVM_VERSION_MINOR == 5
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
delete buf;
|
2014-09-30 17:20:22 -04:00
|
|
|
#endif
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-27 12:45:48 -08:00
|
|
|
std::string Err;
|
2015-01-30 19:25:07 +01:00
|
|
|
|
|
|
|
#if LLVM_VERSION_MINOR >= 6
|
|
|
|
raw_string_ostream Stream(Err);
|
|
|
|
DiagnosticPrinterRawOStream DP(Stream);
|
2015-10-22 22:07:19 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
if (Linker::linkModules(*Dst, std::move(Src.get()))) {
|
|
|
|
#elif LLVM_VERSION_MINOR >= 7
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
if (Linker::LinkModules(Dst, Src->get(), [&](const DiagnosticInfo &DI) { DI.print(DP); })) {
|
|
|
|
#else
|
2015-01-30 19:25:07 +01:00
|
|
|
if (Linker::LinkModules(Dst, *Src, [&](const DiagnosticInfo &DI) { DI.print(DP); })) {
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2015-01-30 19:25:07 +01:00
|
|
|
#else
|
2014-01-27 12:45:48 -08:00
|
|
|
if (Linker::LinkModules(Dst, *Src, Linker::DestroySource, &Err)) {
|
2015-01-30 19:25:07 +01:00
|
|
|
#endif
|
2014-04-15 07:25:22 -07:00
|
|
|
LLVMRustSetLastError(Err.c_str());
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2013-12-16 20:58:21 -08:00
|
|
|
|
2014-01-27 12:45:48 -08:00
|
|
|
extern "C" void
|
2015-05-11 12:24:12 -07:00
|
|
|
LLVMRustSetDLLStorageClass(LLVMValueRef Value,
|
|
|
|
GlobalValue::DLLStorageClassTypes Class) {
|
2014-01-27 12:45:48 -08:00
|
|
|
GlobalValue *V = unwrap<GlobalValue>(Value);
|
2015-05-11 12:24:12 -07:00
|
|
|
V->setDLLStorageClass(Class);
|
2014-01-27 12:45:48 -08:00
|
|
|
}
|
2014-03-05 15:14:16 -08:00
|
|
|
|
2014-04-03 10:45:36 -07:00
|
|
|
// Note that the two following functions look quite similar to the
|
|
|
|
// LLVMGetSectionName function. Sadly, it appears that this function only
|
|
|
|
// returns a char* pointer, which isn't guaranteed to be null-terminated. The
|
|
|
|
// function provided by LLVM doesn't return the length, so we've created our own
|
|
|
|
// function which returns the length as well as the data pointer.
|
|
|
|
//
|
|
|
|
// For an example of this not returning a null terminated string, see
|
|
|
|
// lib/Object/COFFObjectFile.cpp in the getSectionName function. One of the
|
|
|
|
// branches explicitly creates a StringRef without a null terminator, and then
|
|
|
|
// that's returned.
|
|
|
|
|
|
|
|
inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
|
|
|
|
return reinterpret_cast<section_iterator*>(SI);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int
|
|
|
|
LLVMRustGetSectionName(LLVMSectionIteratorRef SI, const char **ptr) {
|
|
|
|
StringRef ret;
|
2014-06-17 18:34:50 +02:00
|
|
|
if (std::error_code ec = (*unwrap(SI))->getName(ret))
|
2014-04-03 10:45:36 -07:00
|
|
|
report_fatal_error(ec.message());
|
|
|
|
*ptr = ret.data();
|
|
|
|
return ret.size();
|
|
|
|
}
|
2014-05-10 17:30:55 +09:00
|
|
|
|
|
|
|
// LLVMArrayType function does not support 64-bit ElementCount
|
|
|
|
extern "C" LLVMTypeRef
|
|
|
|
LLVMRustArrayType(LLVMTypeRef ElementType, uint64_t ElementCount) {
|
|
|
|
return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
|
|
|
|
}
|
2014-09-12 08:17:58 -07:00
|
|
|
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Twine, LLVMTwineRef)
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DebugLoc, LLVMDebugLocRef)
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
LLVMWriteTwineToString(LLVMTwineRef T, RustStringRef str) {
|
|
|
|
raw_rust_string_ostream os(str);
|
|
|
|
unwrap(T)->print(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
LLVMUnpackOptimizationDiagnostic(
|
|
|
|
LLVMDiagnosticInfoRef di,
|
|
|
|
const char **pass_name_out,
|
|
|
|
LLVMValueRef *function_out,
|
|
|
|
LLVMDebugLocRef *debugloc_out,
|
|
|
|
LLVMTwineRef *message_out)
|
|
|
|
{
|
|
|
|
// Undefined to call this not on an optimization diagnostic!
|
|
|
|
llvm::DiagnosticInfoOptimizationBase *opt
|
|
|
|
= static_cast<llvm::DiagnosticInfoOptimizationBase*>(unwrap(di));
|
|
|
|
|
|
|
|
*pass_name_out = opt->getPassName();
|
|
|
|
*function_out = wrap(&opt->getFunction());
|
|
|
|
*debugloc_out = wrap(&opt->getDebugLoc());
|
|
|
|
*message_out = wrap(&opt->getMsg());
|
|
|
|
}
|
|
|
|
|
2015-01-22 19:43:39 +01:00
|
|
|
extern "C" void
|
|
|
|
LLVMUnpackInlineAsmDiagnostic(
|
|
|
|
LLVMDiagnosticInfoRef di,
|
|
|
|
unsigned *cookie_out,
|
|
|
|
LLVMTwineRef *message_out,
|
|
|
|
LLVMValueRef *instruction_out)
|
|
|
|
{
|
|
|
|
// Undefined to call this not on an inline assembly diagnostic!
|
|
|
|
llvm::DiagnosticInfoInlineAsm *ia
|
|
|
|
= static_cast<llvm::DiagnosticInfoInlineAsm*>(unwrap(di));
|
|
|
|
|
|
|
|
*cookie_out = ia->getLocCookie();
|
|
|
|
*message_out = wrap(&ia->getMsgStr());
|
|
|
|
*instruction_out = wrap(ia->getInstruction());
|
|
|
|
}
|
|
|
|
|
2014-09-12 08:17:58 -07:00
|
|
|
extern "C" void LLVMWriteDiagnosticInfoToString(LLVMDiagnosticInfoRef di, RustStringRef str) {
|
|
|
|
raw_rust_string_ostream os(str);
|
|
|
|
DiagnosticPrinterRawOStream dp(os);
|
|
|
|
unwrap(di)->print(dp);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int LLVMGetDiagInfoKind(LLVMDiagnosticInfoRef di) {
|
|
|
|
return unwrap(di)->getKind();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void LLVMWriteDebugLocToString(
|
|
|
|
LLVMContextRef C,
|
|
|
|
LLVMDebugLocRef dl,
|
|
|
|
RustStringRef str)
|
|
|
|
{
|
|
|
|
raw_rust_string_ostream os(str);
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#if LLVM_VERSION_MINOR >= 7
|
|
|
|
unwrap(dl)->print(os);
|
|
|
|
#else
|
2014-09-12 08:17:58 -07:00
|
|
|
unwrap(dl)->print(*unwrap(C), os);
|
rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:
* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
`PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
`no-frame-pointer-elim` function attribute instead.
Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-05-14 12:10:43 -07:00
|
|
|
#endif
|
2014-09-12 08:17:58 -07:00
|
|
|
}
|
2014-09-27 01:33:36 -07:00
|
|
|
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef)
|
|
|
|
|
|
|
|
extern "C" void LLVMSetInlineAsmDiagnosticHandler(
|
|
|
|
LLVMContextRef C,
|
|
|
|
LLVMContext::InlineAsmDiagHandlerTy H,
|
|
|
|
void *CX)
|
|
|
|
{
|
|
|
|
unwrap(C)->setInlineAsmDiagnosticHandler(H, CX);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void LLVMWriteSMDiagnosticToString(LLVMSMDiagnosticRef d, RustStringRef str) {
|
|
|
|
raw_rust_string_ostream os(str);
|
|
|
|
unwrap(d)->print("", os);
|
|
|
|
}
|
2015-06-30 08:56:56 -07:00
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildLandingPad(LLVMBuilderRef Builder,
|
|
|
|
LLVMTypeRef Ty,
|
|
|
|
LLVMValueRef PersFn,
|
|
|
|
unsigned NumClauses,
|
|
|
|
const char* Name,
|
|
|
|
LLVMValueRef F) {
|
|
|
|
return LLVMBuildLandingPad(Builder, Ty, PersFn, NumClauses, Name);
|
|
|
|
}
|
2015-10-23 18:18:44 -07:00
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCleanupPad(LLVMBuilderRef Builder,
|
|
|
|
LLVMValueRef ParentPad,
|
|
|
|
unsigned ArgCnt,
|
|
|
|
LLVMValueRef *LLArgs,
|
|
|
|
const char *Name) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
Value **Args = unwrap(LLArgs);
|
|
|
|
if (ParentPad == NULL) {
|
|
|
|
Type *Ty = Type::getTokenTy(unwrap(Builder)->getContext());
|
|
|
|
ParentPad = wrap(Constant::getNullValue(Ty));
|
|
|
|
}
|
|
|
|
return wrap(unwrap(Builder)->CreateCleanupPad(unwrap(ParentPad),
|
|
|
|
ArrayRef<Value*>(Args, ArgCnt),
|
|
|
|
Name));
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCleanupRet(LLVMBuilderRef Builder,
|
|
|
|
LLVMValueRef CleanupPad,
|
|
|
|
LLVMBasicBlockRef UnwindBB) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
CleanupPadInst *Inst = cast<CleanupPadInst>(unwrap(CleanupPad));
|
|
|
|
return wrap(unwrap(Builder)->CreateCleanupRet(Inst, unwrap(UnwindBB)));
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCatchPad(LLVMBuilderRef Builder,
|
|
|
|
LLVMValueRef ParentPad,
|
|
|
|
unsigned ArgCnt,
|
|
|
|
LLVMValueRef *LLArgs,
|
|
|
|
const char *Name) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
Value **Args = unwrap(LLArgs);
|
|
|
|
return wrap(unwrap(Builder)->CreateCatchPad(unwrap(ParentPad),
|
|
|
|
ArrayRef<Value*>(Args, ArgCnt),
|
|
|
|
Name));
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCatchRet(LLVMBuilderRef Builder,
|
|
|
|
LLVMValueRef Pad,
|
|
|
|
LLVMBasicBlockRef BB) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
return wrap(unwrap(Builder)->CreateCatchRet(cast<CatchPadInst>(unwrap(Pad)),
|
|
|
|
unwrap(BB)));
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCatchSwitch(LLVMBuilderRef Builder,
|
|
|
|
LLVMValueRef ParentPad,
|
|
|
|
LLVMBasicBlockRef BB,
|
|
|
|
unsigned NumHandlers,
|
|
|
|
const char *Name) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
if (ParentPad == NULL) {
|
|
|
|
Type *Ty = Type::getTokenTy(unwrap(Builder)->getContext());
|
|
|
|
ParentPad = wrap(Constant::getNullValue(Ty));
|
|
|
|
}
|
|
|
|
return wrap(unwrap(Builder)->CreateCatchSwitch(unwrap(ParentPad),
|
|
|
|
unwrap(BB),
|
|
|
|
NumHandlers,
|
|
|
|
Name));
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
LLVMRustAddHandler(LLVMValueRef CatchSwitchRef,
|
|
|
|
LLVMBasicBlockRef Handler) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
Value *CatchSwitch = unwrap(CatchSwitchRef);
|
|
|
|
cast<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Handler));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
LLVMRustSetPersonalityFn(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef Personality) {
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
unwrap(B)->GetInsertBlock()
|
|
|
|
->getParent()
|
|
|
|
->setPersonalityFn(cast<Function>(unwrap(Personality)));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if LLVM_VERSION_MINOR >= 8
|
|
|
|
extern "C" OperandBundleDef*
|
|
|
|
LLVMRustBuildOperandBundleDef(const char *Name,
|
|
|
|
LLVMValueRef *Inputs,
|
|
|
|
unsigned NumInputs) {
|
|
|
|
return new OperandBundleDef(Name, makeArrayRef(unwrap(Inputs), NumInputs));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
LLVMRustFreeOperandBundleDef(OperandBundleDef* Bundle) {
|
|
|
|
delete Bundle;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCall(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef Fn,
|
|
|
|
LLVMValueRef *Args,
|
|
|
|
unsigned NumArgs,
|
|
|
|
OperandBundleDef *Bundle,
|
|
|
|
const char *Name) {
|
|
|
|
unsigned len = Bundle ? 1 : 0;
|
|
|
|
ArrayRef<OperandBundleDef> Bundles = makeArrayRef(Bundle, len);
|
|
|
|
return wrap(unwrap(B)->CreateCall(unwrap(Fn),
|
|
|
|
makeArrayRef(unwrap(Args), NumArgs),
|
|
|
|
Bundles,
|
|
|
|
Name));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildInvoke(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef Fn,
|
|
|
|
LLVMValueRef *Args,
|
|
|
|
unsigned NumArgs,
|
|
|
|
LLVMBasicBlockRef Then,
|
|
|
|
LLVMBasicBlockRef Catch,
|
|
|
|
OperandBundleDef *Bundle,
|
|
|
|
const char *Name) {
|
|
|
|
unsigned len = Bundle ? 1 : 0;
|
|
|
|
ArrayRef<OperandBundleDef> Bundles = makeArrayRef(Bundle, len);
|
|
|
|
return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch),
|
|
|
|
makeArrayRef(unwrap(Args), NumArgs),
|
|
|
|
Bundles,
|
|
|
|
Name));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
extern "C" void*
|
|
|
|
LLVMRustBuildOperandBundleDef(const char *Name,
|
|
|
|
LLVMValueRef *Inputs,
|
|
|
|
unsigned NumInputs) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
LLVMRustFreeOperandBundleDef(void* Bundle) {
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildCall(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef Fn,
|
|
|
|
LLVMValueRef *Args,
|
|
|
|
unsigned NumArgs,
|
|
|
|
void *Bundle,
|
|
|
|
const char *Name) {
|
|
|
|
return LLVMBuildCall(B, Fn, Args, NumArgs, Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" LLVMValueRef
|
|
|
|
LLVMRustBuildInvoke(LLVMBuilderRef B,
|
|
|
|
LLVMValueRef Fn,
|
|
|
|
LLVMValueRef *Args,
|
|
|
|
unsigned NumArgs,
|
|
|
|
LLVMBasicBlockRef Then,
|
|
|
|
LLVMBasicBlockRef Catch,
|
|
|
|
void *Bundle,
|
|
|
|
const char *Name) {
|
|
|
|
return LLVMBuildInvoke(B, Fn, Args, NumArgs, Then, Catch, Name);
|
|
|
|
}
|
|
|
|
#endif
|