Skip to content

Commit

Permalink
Make sure the LLVM metadata is initialized before our custom LLVM passes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jul 27, 2016
1 parent 0030eec commit faa19d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4889,8 +4889,9 @@ extern "C" void jl_fptr_to_llvm(jl_fptr_t fptr, jl_lambda_info_t *lam, int specs
#define V128_BUG
#endif

static void init_julia_llvm_env(Module *m)
static void init_julia_llvm_meta(void)
{
mbuilder = new MDBuilder(jl_LLVMContext);
MDNode *tbaa_root = mbuilder->createTBAARoot("jtbaa");
tbaa_gcframe = tbaa_make_child("jtbaa_gcframe", tbaa_root);
tbaa_stack = tbaa_make_child("jtbaa_stack", tbaa_root);
Expand All @@ -4907,7 +4908,10 @@ static void init_julia_llvm_env(Module *m)
tbaa_arraylen = tbaa_make_child("jtbaa_arraylen", tbaa_array);
tbaa_arrayflags = tbaa_make_child("jtbaa_arrayflags", tbaa_array);
tbaa_const = tbaa_make_child("jtbaa_const", tbaa_root, true);
}

static void init_julia_llvm_env(Module *m)
{
// every variable or function mapped in this function must be
// exported from libjulia, to support static compilation
T_int1 = Type::getInt1Ty(jl_LLVMContext);
Expand Down Expand Up @@ -5735,6 +5739,8 @@ extern "C" void jl_init_codegen(void)
jl_TargetMachine->setFastISel(true);
#endif

init_julia_llvm_meta();

#ifdef USE_ORCJIT
jl_ExecutionEngine = new JuliaOJIT(*jl_TargetMachine);
#else
Expand All @@ -5751,8 +5757,6 @@ extern "C" void jl_init_codegen(void)
jl_ExecutionEngine->DisableLazyCompilation();
#endif

mbuilder = new MDBuilder(jl_LLVMContext);

// Now that the execution engine exists, initialize all modules
jl_setup_module(engine_module);
jl_setup_module(m);
Expand Down
1 change: 1 addition & 0 deletions src/llvm-gcroot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,5 +980,6 @@ void jl_dump_bb_uses(std::map<BasicBlock*, std::map<frame_register, liveness::id

Pass *createLowerGCFramePass(MDNode *tbaa_gcframe)
{
assert(tbaa_gcframe);
return new LowerGCFrame(tbaa_gcframe);
}
1 change: 1 addition & 0 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,6 @@ static RegisterPass<LowerPTLS> X("LowerPTLS", "LowerPTLS Pass",

Pass *createLowerPTLSPass(bool imaging_mode, MDNode *tbaa_const)
{
assert(tbaa_const);
return new LowerPTLS(imaging_mode, tbaa_const);
}

0 comments on commit faa19d2

Please sign in to comment.