From 8cd935f52a9af8620f608e1baad94282f038a864 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 27 Jan 2014 12:45:48 -0800 Subject: [PATCH] Upgrade LLVM This upgrade brings commit by @eddyb to help optimizations of virtual calls in a few places (https://github.com/llvm-mirror/llvm/commit/6d2bd95) as well as a commit by @c-a to *greatly* improve the runtime of the optimization passes (https://github.com/rust-lang/llvm/pull/3). Nice work to these guys! --- configure | 4 ++++ src/librustc/lib/llvm.rs | 2 ++ src/librustc/middle/trans/base.rs | 6 +++--- src/llvm | 2 +- src/rustllvm/PassWrapper.cpp | 2 +- src/rustllvm/RustWrapper.cpp | 20 +++++++++++++------- src/rustllvm/llvm-auto-clean-trigger | 2 +- src/rustllvm/rustllvm.h | 4 +--- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/configure b/configure index 8a9daabaf61..b771e3923ce 100755 --- a/configure +++ b/configure @@ -916,6 +916,10 @@ do LLVM_OPTS="$LLVM_OPTS --disable-terminfo" # Try to have LLVM pull in as few dependencies as possible (#9397) LLVM_OPTS="$LLVM_OPTS --disable-zlib --disable-libffi" + # LLVM says it needs a "new" clang/gcc, but we seem to get by ok with + # older versions on the bots. Get by for a little longer by asking it to + # not do version detection + LLVM_OPTS="$LLVM_OPTS --disable-compiler-version-checks" # Use win32 native thread/lock apis instead of pthread wrapper. # (llvm's configure tries to find pthread first, so we have to disable it explicitly.) diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 3693b00951b..c7d5789aebc 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1762,6 +1762,8 @@ pub fn LLVMRustRunRestrictionPass(M: ModuleRef, pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *c_char, out_len: *mut size_t) -> *c_char; pub fn LLVMRustDestroyArchive(AR: ArchiveRef); + + pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef); } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c71469f0c3d..2e3217aa469 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2531,12 +2531,12 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta, llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf) } }); + lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage); + // On windows we'd like to export the toplevel cratemap // such that we can find it from libstd. if targ_cfg.os == OsWin32 && is_top { - lib::llvm::SetLinkage(map, lib::llvm::DLLExportLinkage); - } else { - lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage); + unsafe { llvm::LLVMRustSetDLLExportStorageClass(map) } } return (sym_name, map); diff --git a/src/llvm b/src/llvm index 535989a92ce..e1dabb48f0f 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 535989a92ce1f6f6488c94a2c8f4ed438349f162 +Subproject commit e1dabb48f0f898d1a808b3de3a26f5ee3735c7dd diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index cab9c187eae..c5a75762fcc 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -185,7 +185,7 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR, std::string ErrorInfo; raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_Binary); formatted_raw_ostream FOS(OS); - PM->add(createPrintModulePass(&FOS)); + PM->add(createPrintModulePass(FOS)); PM->run(*unwrap(M)); } diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 280df8cb10f..9b077e2254e 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -537,15 +537,15 @@ extern "C" bool LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { Module *Dst = unwrap(dst); MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len)); - std::string Err; - Module *Src = llvm::getLazyBitcodeModule(buf, Dst->getContext(), &Err); - if (Src == NULL) { - LLVMRustError = Err.c_str(); + ErrorOr Src = llvm::getLazyBitcodeModule(buf, Dst->getContext()); + if (!Src) { + LLVMRustError = Src.getError().message().c_str(); delete buf; return false; } - if (Linker::LinkModules(Dst, Src, Linker::DestroySource, &Err)) { + std::string Err; + if (Linker::LinkModules(Dst, *Src, Linker::DestroySource, &Err)) { LLVMRustError = Err.c_str(); return false; } @@ -570,8 +570,8 @@ LLVMRustOpenArchive(char *path) { extern "C" const char* LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) { - for (Archive::child_iterator child = ar->begin_children(), - end = ar->end_children(); + for (Archive::child_iterator child = ar->child_begin(), + end = ar->child_end(); child != end; ++child) { StringRef sect_name; error_code err = child->getName(sect_name); @@ -589,3 +589,9 @@ extern "C" void LLVMRustDestroyArchive(Archive *ar) { delete ar; } + +extern "C" void +LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) { + GlobalValue *V = unwrap(Value); + V->setDLLStorageClass(GlobalValue::DLLExportStorageClass); +} diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index 96cd67dcec4..5b16a89b69f 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2014-01-22 +2014-01-27 diff --git a/src/rustllvm/rustllvm.h b/src/rustllvm/rustllvm.h index ef7199a6ca8..e45a910fc8c 100644 --- a/src/rustllvm/rustllvm.h +++ b/src/rustllvm/rustllvm.h @@ -16,14 +16,12 @@ #include "llvm/PassManager.h" #include "llvm/IR/InlineAsm.h" #include "llvm/IR/LLVMContext.h" -#include "llvm/Analysis/Verifier.h" +#include "llvm/IR/IRPrintingPasses.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Lint.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Triple.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/Assembly/Parser.h" -#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h"