Skip to content

Commit 8e836b2

Browse files
z0w0brson
authored andcommitted
---
yaml --- r: 28221 b: refs/heads/try c: 19ea3ab h: refs/heads/master i: 28219: 6dab011 v: v3
1 parent f73decb commit 8e836b2

File tree

5 files changed

+27
-45
lines changed

5 files changed

+27
-45
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: 795acb73950adf632d1e3fb48ea6104b4d61f3cd
5+
refs/heads/try: 19ea3ab480ad273420837da25e428fae597ef9f7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/src/rustc/back/link.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,14 @@ mod write {
152152
if opts.jit {
153153
// If we are using JIT, go ahead and create and
154154
// execute the engine now.
155-
156-
/*llvm::LLVMAddBasicAliasAnalysisPass(pm.llpm);
157-
llvm::LLVMAddInstructionCombiningPass(pm.llpm);
158-
llvm::LLVMAddReassociatePass(pm.llpm);
159-
llvm::LLVMAddGVNPass(pm.llpm);
160-
llvm::LLVMAddCFGSimplificationPass(pm.llpm);*/
161-
162155
// JIT execution takes ownership of the module,
163-
// so don't dispose and return. Due to a weird bug
164-
// with dynamic libraries, we need to separate jitting
165-
// into two functions and load crates inbetween.
166-
167-
if !llvm::LLVMRustPrepareJIT(pm.llpm,
168-
llmod,
169-
CodeGenOptLevel,
170-
true) {
171-
llvm_err(sess, ~"Could not JIT");
172-
}
156+
// so don't dispose and return.
173157

174158
// We need to tell LLVM where to resolve all linked
175159
// symbols from. The equivalent of -lstd, -lcore, etc.
160+
// By default the JIT will resolve symbols from the std and
161+
// core linked into rustc. We don't want that,
162+
// incase the user wants to use an older std library.
176163
/*let cstore = sess.cstore;
177164
for cstore::get_used_crate_files(cstore).each |cratepath| {
178165
debug!{"linking: %s", cratepath};
@@ -187,7 +174,10 @@ mod write {
187174
});
188175
}*/
189176

190-
if !llvm::LLVMRustExecuteJIT() {
177+
if !llvm::LLVMRustJIT(pm.llpm,
178+
llmod,
179+
CodeGenOptLevel,
180+
true) {
191181
llvm_err(sess, ~"Could not JIT");
192182
}
193183

branches/try/src/rustc/lib/llvm.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -989,15 +989,12 @@ extern mod llvm {
989989
/** Load a shared library to resolve symbols against. */
990990
fn LLVMRustLoadLibrary(Filename: *c_char) -> bool;
991991

992-
/** Create the JIT engine. */
993-
fn LLVMRustPrepareJIT(PM: PassManagerRef,
992+
/** Create and execute the JIT engine. */
993+
fn LLVMRustJIT(PM: PassManagerRef,
994994
M: ModuleRef,
995995
OptLevel: c_int,
996996
EnableSegmentedStacks: bool) -> bool;
997997

998-
/** Execute the JIT engine. */
999-
fn LLVMRustExecuteJIT() -> bool;
1000-
1001998
/** Parses the bitcode in the given memory buffer. */
1002999
fn LLVMRustParseBitcode(MemBuf: MemoryBufferRef) -> ModuleRef;
10031000

branches/try/src/rustllvm/RustWrapper.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "llvm/LLVMContext.h"
1616
#include "llvm/Linker.h"
1717
#include "llvm/PassManager.h"
18+
#include "llvm/Analysis/Verifier.h"
19+
#include "llvm/Analysis/Passes.h"
20+
#include "llvm/Transforms/Scalar.h"
1821
#include "llvm/ADT/Triple.h"
1922
#include "llvm/Assembly/Parser.h"
2023
#include "llvm/Assembly/PrintModulePass.h"
@@ -35,7 +38,6 @@
3538
#include "llvm/ExecutionEngine/JITMemoryManager.h"
3639
#include "llvm/ExecutionEngine/MCJIT.h"
3740
#include "llvm/ExecutionEngine/Interpreter.h"
38-
#include "llvm/ExecutionEngine/GenericValue.h"
3941
#include "llvm-c/Core.h"
4042
#include "llvm-c/BitReader.h"
4143
#include "llvm-c/Object.h"
@@ -291,11 +293,8 @@ RustMCJITMemoryManager::~RustMCJITMemoryManager() {
291293
free(AllocatedDataMem[i].base());
292294
}
293295

294-
// Separated functions because loading libraries before creating
295-
// an execution engine seems to break stuff.
296-
297296
extern "C" bool
298-
LLVMRustPrepareJIT(LLVMPassManagerRef PMR,
297+
LLVMRustJIT(LLVMPassManagerRef PMR,
299298
LLVMModuleRef M,
300299
CodeGenOpt::Level OptLevel,
301300
bool EnableSegmentedStacks) {
@@ -309,8 +308,16 @@ LLVMRustPrepareJIT(LLVMPassManagerRef PMR,
309308
Options.JITEmitDebugInfo = true;
310309
Options.NoFramePointerElim = true;
311310
Options.EnableSegmentedStacks = EnableSegmentedStacks;
311+
PassManager *PM = unwrap<PassManager>(PMR);
312312

313-
unwrap<PassManager>(PMR)->run(*unwrap(M));
313+
PM->add(createBasicAliasAnalysisPass());
314+
PM->add(createInstructionCombiningPass());
315+
PM->add(createReassociatePass());
316+
PM->add(createGVNPass());
317+
PM->add(createPromoteMemoryToRegisterPass());
318+
PM->add(createCFGSimplificationPass());
319+
PM->add(createFunctionInliningPass());
320+
PM->run(*unwrap(M));
314321

315322
RustMCJITMemoryManager* MM = new RustMCJITMemoryManager();
316323
EE = EngineBuilder(unwrap(M))
@@ -326,29 +333,18 @@ LLVMRustPrepareJIT(LLVMPassManagerRef PMR,
326333
}
327334

328335
MM->invalidateInstructionCache();
329-
330-
return true;
331-
}
332-
333-
extern "C" bool
334-
LLVMRustExecuteJIT() {
335-
assert(EE);
336-
337-
std::string Err;
338336
Function* func = EE->FindFunctionNamed("main");
339337

340338
if(!func || Err != "") {
341339
LLVMRustError = Err.c_str();
342340
return false;
343341
}
344342

345-
//std::vector<GenericValue> args;
346-
typedef int (*entry_t)(int, int);
347-
entry_t entry = (entry_t) EE->getPointerToFunction(func);
343+
typedef int (*Entry)(int, int);
344+
Entry entry = (Entry) EE->getPointerToFunction(func);
348345

349346
assert(entry);
350347
entry(0, 0);
351-
//EE->runFunction(func, args);
352348

353349
return true;
354350
}

branches/try/src/rustllvm/rustllvm.def.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ LLVMRustGetLastError
55
LLVMRustConstSmallInt
66
LLVMRustConstInt
77
LLVMRustLoadLibrary
8-
LLVMRustPrepareJIT
9-
LLVMRustExecuteJIT
8+
LLVMRustJIT
109
LLVMRustParseBitcode
1110
LLVMRustParseAssemblyFile
1211
LLVMRustPrintPassTimings

0 commit comments

Comments
 (0)