Skip to content
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
10 changes: 0 additions & 10 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,6 @@ void *jl_get_llvmf_defn(jl_method_instance_t *mi, size_t world, char getwrapper,
PM = new legacy::PassManager();
addTargetPasses(PM, jl_TargetMachine);
addOptimizationPasses(PM, jl_options.opt_level);
PM->add(createRemoveJuliaAddrspacesPass());
}

static legacy::PassManager *PM_minimal;
if (!PM_minimal) {
PM_minimal = new legacy::PassManager();
addTargetPasses(PM_minimal, jl_TargetMachine);
PM_minimal->add(createRemoveJuliaAddrspacesPass());
}

// get the source code for this function
Expand Down Expand Up @@ -874,8 +866,6 @@ void *jl_get_llvmf_defn(jl_method_instance_t *mi, size_t world, char getwrapper,
// if compilation succeeded, prepare to return the result
if (optimize)
PM->run(*m.get());
else
PM_minimal->run(*m.get());
const std::string *fname;
if (decls.functionObject == "jl_fptr_args" || decls.functionObject == "jl_fptr_sparam")
getwrapper = false;
Expand Down
16 changes: 15 additions & 1 deletion src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@
#include <llvm/IR/Module.h>
#include <llvm/IR/IntrinsicInst.h>
#include "llvm/IR/AssemblyAnnotationWriter.h"
#include "llvm/IR/LegacyPassManager.h"

#include "julia.h"
#include "julia_internal.h"
#include "jitlayers.h"
#include "processor.h"

using namespace llvm;
Expand Down Expand Up @@ -431,6 +433,13 @@ void jl_strip_llvm_debug(Module *m)
jl_strip_llvm_debug(m, false, NULL);
}

void jl_strip_llvm_addrspaces(Module *m)
{
legacy::PassManager PM;
PM.add(createRemoveJuliaAddrspacesPass());
PM.run(*m);
}

// print an llvm IR acquired from jl_get_llvmf
// warning: this takes ownership of, and destroys, f->getParent()
extern "C" JL_DLLEXPORT
Expand All @@ -452,8 +461,13 @@ jl_value_t *jl_dump_function_ir(void *f, char strip_ir_metadata, char dump_modul
}
else {
Module *m = llvmf->getParent();
if (strip_ir_metadata)
if (strip_ir_metadata) {
std::string llvmfn = llvmf->getName();
jl_strip_llvm_debug(m, true, &AAW);
jl_strip_llvm_addrspaces(m);
// rewriting the function type creates a new function, so look it up again
llvmf = m->getFunction(llvmfn);
}
if (dump_module) {
m->print(stream, &AAW);
}
Expand Down
2 changes: 2 additions & 0 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <llvm/Target/TargetMachine.h>
#include "julia_assert.h"

using namespace llvm;

extern "C" {
extern int globalUnique;
}
Expand Down