Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some codegen tests & fixes #15632

Merged
merged 5 commits into from
Mar 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,9 @@ ifeq ($(OS), Darwin)
INSTALL_NAME_ID_DIR := @rpath/
INSTALL_NAME_CMD := install_name_tool -id $(INSTALL_NAME_ID_DIR)
INSTALL_NAME_CHANGE_CMD := install_name_tool -change
ifeq ($(shell test `dsymutil -v | cut -d\- -f2 | cut -d. -f1` -gt 102 && echo yes), yes)
ifneq (,$(findstring LLVM,$(shell dsymutil --version)))
DSYMUTIL := dsymutil
else ifeq ($(shell test `dsymutil -v | cut -d\- -f2 | cut -d. -f1` -gt 102 && echo yes), yes)
DSYMUTIL := dsymutil
else
DSYMUTIL := true -ignore
Expand Down
18 changes: 4 additions & 14 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,11 @@ static Module *shadow_output;
#define jl_builderModule builder.GetInsertBlock()->getParent()->getParent()
static MDBuilder *mbuilder;
static std::map<int, std::string> argNumberStrings;
#ifndef USE_ORCJIT
#ifdef LLVM38
static legacy::PassManager *PM;
#else
static PassManager *PM;
#endif
#endif

#ifdef LLVM37
// No DataLayout pass needed anymore.
Expand Down Expand Up @@ -1193,6 +1191,8 @@ void *jl_get_llvmf(jl_function_t *f, jl_tupletype_t *tt, bool getwrapper, bool g
Function *f, *specf;
jl_llvm_functions_t declarations;
std::unique_ptr<Module> m = emit_function(linfo, &declarations);
finalize_gc_frame(m.get());
PM->run(*m.get());
f = (llvm::Function*)declarations.functionObject;
specf = (llvm::Function*)declarations.specFunctionObject;
// swap declarations for definitions and destroy declarations
Expand All @@ -1214,7 +1214,7 @@ void *jl_get_llvmf(jl_function_t *f, jl_tupletype_t *tt, bool getwrapper, bool g
if (f_decl) {
f->setName(f_decl->getName());
}
finalize_gc_frame(m.release()); // the return object `llvmf` will be the owning pointer
m.release(); // the return object `llvmf` will be the owning pointer
JL_GC_POP();
if (getwrapper || !specf) {
return f;
Expand Down Expand Up @@ -1393,9 +1393,7 @@ const jl_value_t *jl_dump_function_asm(void *f, int raw_mc)
#endif
const object::ObjectFile *object = NULL;
assert(fptr != 0);
bool isJIT = true;
if (!jl_DI_for_fptr(fptr, &symsize, &slide, &section_slide, &object, &context)) {
isJIT = false;
if (!jl_dylib_DI_for_fptr(fptr, &object, &objcontext, &slide, &section_slide, false,
NULL, NULL, NULL, NULL)) {
jl_printf(JL_STDERR, "WARNING: Unable to find function pointer\n");
Expand All @@ -1410,9 +1408,6 @@ const jl_value_t *jl_dump_function_asm(void *f, int raw_mc)
}

if (raw_mc) {
#ifdef LLVM37
jl_cleanup_DI(context);
#endif
return (jl_value_t*)jl_pchar_to_array((char*)fptr, symsize);
}

Expand All @@ -1428,10 +1423,7 @@ const jl_value_t *jl_dump_function_asm(void *f, int raw_mc)
#endif
);

#ifdef LLVM37
if (isJIT)
jl_cleanup_DI(context);
#else
#ifndef LLVM37
fstream.flush();
#endif

Expand Down Expand Up @@ -5631,7 +5623,6 @@ static void init_julia_llvm_env(Module *m)
jl_data_layout = new DataLayout(*jl_ExecutionEngine->getDataLayout());
#endif

#ifndef USE_ORCJIT
#ifdef LLVM38
PM = new legacy::PassManager();
#else
Expand All @@ -5646,7 +5637,6 @@ static void init_julia_llvm_env(Module *m)
PM->add(jl_data_layout);
#endif
addOptimizationPasses(PM);
#endif
}

// Helper to figure out what features to set for the LLVM target
Expand Down
4 changes: 0 additions & 4 deletions src/codegen_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ extern int jl_DI_for_fptr(uint64_t fptr, uint64_t *symsize, int64_t *slide, int6
extern bool jl_dylib_DI_for_fptr(size_t pointer, const object::ObjectFile **object, llvm::DIContext **context, int64_t *slide, int64_t *section_slide,
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename);

#ifdef USE_MCJIT
extern void jl_cleanup_DI(llvm::DIContext *context);
#endif

#ifdef USE_ORCJIT
extern JL_DLLEXPORT void ORCNotifyObjectEmitted(JITEventListener *Listener,
const object::ObjectFile &obj,
Expand Down
25 changes: 2 additions & 23 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ struct ObjectInfo {
const object::ObjectFile *object;
size_t SectionSize;
ptrdiff_t slide;
#ifdef LLVM39
#ifdef LLVM37
DIContext *context;
#elif defined(LLVM37)
const llvm::LoadedObjectInfo *L;
#endif
#if defined(_OS_DARWIN_) && !defined(LLVM37)
const char *name;
Expand Down Expand Up @@ -444,11 +442,7 @@ class JuliaJITEventListener: public JITEventListener
ObjectInfo tmp = {&debugObj,
(size_t)SectionSize,
(ptrdiff_t)(SectionAddr - SectionLoadAddr),
#ifdef LLVM39
new DWARFContextInMemory(debugObj, &L),
#else
L.clone().release(),
#endif
};
objectmap[SectionLoadAddr] = tmp;
first = false;
Expand Down Expand Up @@ -524,11 +518,6 @@ class JuliaJITEventListener: public JITEventListener
#endif
ObjectInfo tmp = {objfile, (size_t)Size,
(ptrdiff_t)(SectionAddr - SectionLoadAddr),
#ifdef LLVM39
new DWARFContextInMemory(*objfile, &L),
#elif defined(LLVM37)
L.clone().release(),
#endif
#ifdef _OS_DARWIN_
strndup(sName.data(), sName.size()),
#endif
Expand Down Expand Up @@ -1066,10 +1055,8 @@ int jl_DI_for_fptr(uint64_t fptr, uint64_t *symsize, int64_t *slide, int64_t *se
*section_slide = fit->second.slide;
*object = fit->second.object;
if (context) {
#if defined(LLVM39)
#if defined(LLVM37)
*context = fit->second.context;
#elif defined(LLVM37)
*context = new DWARFContextInMemory(*fit->second.object, fit->second.L);
#else
*context = DIContext::getDWARFContext(*fit->second.object);
#endif
Expand Down Expand Up @@ -1121,13 +1108,6 @@ JL_DLLEXPORT uint64_t jl_get_section_start(uint64_t fptr)

#endif

void jl_cleanup_DI(llvm::DIContext *context)
{
#ifndef LLVM39
delete context;
#endif
}

// Set *name and *filename to either NULL or malloc'd string
void jl_getFunctionInfo(char **name, char **filename, size_t *line,
char **inlinedat_file, size_t *inlinedat_line, jl_lambda_info_t **outer_linfo,
Expand All @@ -1151,7 +1131,6 @@ void jl_getFunctionInfo(char **name, char **filename, size_t *line,
if (jl_DI_for_fptr(pointer, &symsize, &slide, NULL, &object, &context)) {
*outer_linfo = jl_jit_events->lookupLinfo(pointer);
lookup_pointer(context, name, line, filename, inlinedat_line, inlinedat_file, pointer+slide, 1, fromC);
jl_cleanup_DI(context);
return;
}
#else // !USE_MCJIT
Expand Down
Loading