Skip to content

Commit 0b4c914

Browse files
Merge branch 'upstream-pnacl-llvm'
2 parents 9bc5fd4 + ab02da2 commit 0b4c914

File tree

10 files changed

+123
-70
lines changed

10 files changed

+123
-70
lines changed

.gitmodules

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[submodule "src/llvm"]
2-
path = src/llvm
3-
url = https://github.com/DiamondLovesYou/llvm.git
4-
branch = master
51
[submodule "src/compiler-rt"]
62
path = src/compiler-rt
73
url = https://github.com/rust-lang/compiler-rt.git
@@ -19,3 +15,7 @@
1915
path = src/nacl-binutils
2016
url = https://chromium.googlesource.com/native_client/nacl-binutils.git
2117
branch = pnacl/2.34/master
18+
[submodule "src/llvm"]
19+
path = src/llvm
20+
url = [email protected]:DiamondLovesYou/llvm.git
21+
branch = merge_36

src/librust-pnacl-trans/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub fn main() {
285285
llvm::LLVMRustAddLibraryInfo(pm, llmod, false);
286286

287287
assert!(llvm::LLVMRustAddPass(pm,
288-
"combine-vector-instructions\0"
288+
"backend-canonicalize\0"
289289
.as_ptr() as *const i8));
290290

291291
let out = format!("{}.o", i);

src/librustc_llvm/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,9 @@ extern {
19591959

19601960
pub fn LLVMDIBuilderCreateOpPlus() -> i64;
19611961

1962+
pub fn LLVMDIBuilderCreateExpression(Builder: DIBuilderRef,
1963+
AddrOps: *const ValueRef,
1964+
AddrOpsCount: c_uint) -> ValueRef;
19621965
pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
19631966
Scope: DIScope,
19641967
Name: *const c_char,

src/librustc_trans/back/link.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ pub fn link_pnacl_module(sess: &Session,
858858

859859
// Internalize everything.
860860
unsafe {
861-
let reachable = vec!("_start\0".as_ptr());
861+
let reachable = vec!("_start\0".as_ptr(),
862+
"__pnacl_eh_stack\0".as_ptr());
862863
llvm::LLVMRustRunRestrictionPass(llmod,
863864
reachable.as_ptr() as *const *const libc::c_char,
864865
reachable.len() as libc::size_t);
@@ -883,7 +884,8 @@ pub fn link_pnacl_module(sess: &Session,
883884
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
884885

885886
let ap = |&: s: &'static str| {
886-
assert!(llvm::LLVMRustAddPass(pm, s.as_ptr() as *const i8));
887+
assert!(llvm::LLVMRustAddPass(pm, s.as_ptr() as *const i8),
888+
"failed to add pass `{}`", s.slice(0, s.len() - 1));
887889
};
888890

889891
ap("pnacl-sjlj-eh\0");
@@ -912,15 +914,15 @@ pub fn link_pnacl_module(sess: &Session,
912914
ap("constmerge\0");
913915
ap("flatten-globals\0");
914916
ap("expand-constant-expr\0");
917+
ap("nacl-expand-ints\0");
915918
ap("nacl-promote-ints\0");
916919
ap("expand-getelementptr\0");
917920
ap("nacl-rewrite-atomics\0");
918921
ap("expand-struct-regs\0");
919922
ap("remove-asm-memory\0");
920923
ap("simplify-allocas\0");
921924
ap("replace-ptrs-with-ints\0");
922-
ap("combine-noop-casts\0");
923-
ap("expand-constant-expr\0");
925+
ap("expand-struct-regs\0");
924926
ap("strip-dead-prototypes\0");
925927
ap("die\0");
926928
ap("dce\0");
@@ -966,11 +968,13 @@ pub fn link_pnacl_module(sess: &Session,
966968
let pm = llvm::LLVMCreatePassManager();
967969

968970
let ap = |&: s: &'static str| {
969-
assert!(llvm::LLVMRustAddPass(pm, s.as_ptr() as *const i8));
971+
assert!(llvm::LLVMRustAddPass(pm, s.as_ptr() as *const i8),
972+
"failed to add pass `{}`", s.slice(0, s.len() - 1));
970973
};
971974

972975
// Strip unsupported metadata:
973976
ap("strip-metadata\0");
977+
ap("strip-module-flags\0");
974978
ap("nacl-strip-attributes\0");
975979

976980
if !sess.no_verify() {

src/librustc_trans/trans/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ pub fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<Valu
745745
// HACK(eddyb) dummy output type, shouln't affect anything.
746746
let f = base::decl_cdecl_fn(ccx, name, Type::func(&[], &$ret),
747747
ty::mk_nil(ccx.tcx()));
748+
if ccx.sess().targeting_pnacl() { llvm::SetUnnamedAddr(f, false); }
748749
ccx.intrinsics().borrow_mut().insert(name, f);
749750
return Some(f);
750751
} else if is_key { return None; }
@@ -759,6 +760,7 @@ pub fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<Valu
759760
let f = base::decl_cdecl_fn(ccx, name,
760761
Type::func(&[$($arg),*], &$ret),
761762
ty::mk_nil(ccx.tcx()));
763+
if ccx.sess().targeting_pnacl() { llvm::SetUnnamedAddr(f, false); }
762764
ccx.intrinsics().borrow_mut().insert(name, f);
763765
return Some(f);
764766
} else if is_key { return None; }

src/librustc_trans/trans/debuginfo.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16551655
CapturedVariable => (0, DW_TAG_auto_variable)
16561656
};
16571657

1658-
let name = CString::from_slice(name.get().as_bytes());
1658+
let name = CString::from_slice(name.as_bytes());
16591659
match (variable_access, [].as_slice()) {
16601660
(DirectVariable { alloca }, address_operations) |
16611661
(IndirectVariable {alloca, address_operations}, _) => {
@@ -4016,14 +4016,24 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
40164016
/// Inserts a side-effect free instruction sequence that makes sure that the
40174017
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
40184018
pub fn insert_reference_to_gdb_debug_scripts_section_global(ccx: &CrateContext) {
4019+
use trans::common::C_i32;
40194020
if needs_gdb_debug_scripts_section(ccx) {
40204021
let empty = CString::from_slice(b"");
40214022
let gdb_debug_scripts_section_global =
40224023
get_or_insert_gdb_debug_scripts_section_global(ccx);
40234024
unsafe {
4025+
// PNaCl's -nacl-rewrite-atomics can't rewrite loading directly from
4026+
// gdb_debug_scripts_section_global.
4027+
let indices = [C_i32(ccx, 0), C_i32(ccx, 0)];
4028+
let element =
4029+
llvm::LLVMBuildInBoundsGEP(ccx.raw_builder(),
4030+
gdb_debug_scripts_section_global,
4031+
indices.as_ptr(),
4032+
indices.len() as c_uint,
4033+
empty.as_ptr());
40244034
let volative_load_instruction =
40254035
llvm::LLVMBuildLoad(ccx.raw_builder(),
4026-
gdb_debug_scripts_section_global,
4036+
element,
40274037
empty.as_ptr());
40284038
llvm::LLVMSetVolatile(volative_load_instruction, llvm::True);
40294039
}

src/llvm

Submodule llvm updated 5161 files

src/rustllvm/ExecutionEngineWrapper.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,8 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine(
8989
options.NoFramePointerElim = true;
9090

9191
ExecutionEngine *ee =
92-
#if LLVM_VERSION_MINOR <= 5
93-
EngineBuilder(unwrap(mod))
92+
EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
9493
.setMCJITMemoryManager(unwrap(mref))
95-
#else
96-
EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
97-
.setMCJITMemoryManager(std::unique_ptr<RustJITMemoryManager>(unwrap(mref)))
98-
#endif
9994
.setEngineKind(EngineKind::JIT)
10095
.setErrorStr(&error_str)
10196
.setTargetOptions(options)

src/rustllvm/PassWrapper.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ LLVMInitializePasses() {
4747
initializeTarget(Registry);
4848

4949
initializeAddPNaClExternalDeclsPass(Registry);
50+
initializeBackendCanonicalizePass(Registry);
5051
initializeCanonicalizeMemIntrinsicsPass(Registry);
51-
initializeCombineNoopCastsPass(Registry);
52-
initializeCombineVectorInstructionsPass(Registry);
5352
initializeConstantInsertExtractElementIndexPass(Registry);
5453
initializeExpandArithWithOverflowPass(Registry);
5554
initializeExpandByValPass(Registry);
5655
initializeExpandConstantExprPass(Registry);
5756
initializeExpandCtorsPass(Registry);
5857
initializeExpandGetElementPtrPass(Registry);
5958
initializeExpandIndirectBrPass(Registry);
59+
initializeExpandLargeIntegersPass(Registry);
6060
initializeExpandShuffleVectorPass(Registry);
6161
initializeExpandSmallArgumentsPass(Registry);
6262
initializeExpandStructRegsPass(Registry);
@@ -80,9 +80,10 @@ LLVMInitializePasses() {
8080
initializeRewriteAtomicsPass(Registry);
8181
initializeRewriteLLVMIntrinsicsPass(Registry);
8282
initializeRewritePNaClLibraryCallsPass(Registry);
83+
initializeSimplifyAllocasPass(Registry);
8384
initializeStripAttributesPass(Registry);
8485
initializeStripMetadataPass(Registry);
85-
initializeSimplifyAllocasPass(Registry);
86+
initializeStripModuleFlagsPass(Registry);
8687
}
8788

8889
extern "C" bool
@@ -288,7 +289,12 @@ LLVMRustAddPrinterPass(LLVMPassManagerRef PMR,
288289
PassManager *PM = unwrap<PassManager>(PMR);
289290
std::string ErrorInfo;
290291

291-
#if LLVM_VERSION_MINOR >= 4
292+
#if LLVM_VERSION_MINOR >= 6
293+
std::error_code EC;
294+
raw_fd_ostream* OS = new raw_fd_ostream(path, EC, sys::fs::F_None);
295+
if (EC)
296+
ErrorInfo = EC.message();
297+
#elif LLVM_VERSION_MINOR >= 4
292298
raw_fd_ostream* OS = new raw_fd_ostream(path, ErrorInfo, sys::fs::F_None);
293299
#else
294300
raw_fd_ostream* OS = new raw_fd_ostream(path, ErrorInfo, raw_fd_ostream::F_Binary);

0 commit comments

Comments
 (0)