Skip to content

Commit

Permalink
fix JuliaLang#10225, regression in how constant conditions are generated
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 7, 2015
1 parent 4a43960 commit 6507574
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ template<class T>
static T* addComdat(T *G) { return G; }
#endif

static Value *tbaa_decorate(MDNode* md, Instruction* load_or_store)
{
load_or_store->setMetadata( llvm::LLVMContext::MD_tbaa, md );
return load_or_store;
}

// Fixing up references to other modules for MCJIT
static GlobalVariable *prepare_global(GlobalVariable *G)
{
Expand Down Expand Up @@ -413,6 +419,13 @@ static Value *literal_pointer_val(jl_value_t *p)
// also, try to give it a nice name for gdb, for easy identification
if (p == NULL)
return ConstantPointerNull::get((PointerType*)jl_pvalue_llvmt);
// some common constant values
if (p == jl_false)
return tbaa_decorate(tbaa_const, builder.CreateLoad(prepare_global(jlfalse_var)));
if (p == jl_true)
return tbaa_decorate(tbaa_const, builder.CreateLoad(prepare_global(jltrue_var)));
if (p == (jl_value_t*)jl_null)
return tbaa_decorate(tbaa_const, builder.CreateLoad(prepare_global(jlnull_var)));
if (!imaging_mode)
return literal_static_pointer_val(p, jl_pvalue_llvmt);
if (jl_is_datatype(p)) {
Expand Down Expand Up @@ -764,11 +777,6 @@ static Value *mark_julia_type(Value *v, jl_value_t *jt)
return v;
}

static Value *tbaa_decorate(MDNode* md, Instruction* load_or_store) {
load_or_store->setMetadata( llvm::LLVMContext::MD_tbaa, md );
return load_or_store;
}

// --- generating various error checks ---

static jl_value_t *llvm_type_to_julia(Type *t, bool err=true);
Expand Down

0 comments on commit 6507574

Please sign in to comment.