Skip to content

Commit

Permalink
Merge pull request #35645 from JuliaLang/tb/strip_addrspace
Browse files Browse the repository at this point in the history
Add an LLVM pass to remove Julia-specific address space information.
  • Loading branch information
maleadt committed May 3, 2020
2 parents dd1e525 + dcd7b72 commit b8d9e78
Show file tree
Hide file tree
Showing 8 changed files with 517 additions and 84 deletions.
6 changes: 0 additions & 6 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,12 @@ endef
ifeq ($(LLVM_VER_SHORT),8.0)
$(eval $(call LLVM_PATCH,llvm-D27629-AArch64-large_model_6.0.1))
$(eval $(call LLVM_PATCH,llvm8-D34078-vectorize-fdiv))
$(eval $(call LLVM_PATCH,llvm-6.0-NVPTX-addrspaces)) # NVPTX -- warning: this fails check-llvm-codegen-nvptx
$(eval $(call LLVM_PATCH,llvm-7.0-D44650)) # mingw32 build fix
$(eval $(call LLVM_PATCH,llvm-6.0-DISABLE_ABI_CHECKS))
$(eval $(call LLVM_PATCH,llvm7-D50010-VNCoercion-ni))
$(eval $(call LLVM_PATCH,llvm-8.0-D50167-scev-umin))
$(eval $(call LLVM_PATCH,llvm7-windows-race))
$(eval $(call LLVM_PATCH,llvm-D57118-powerpc)) # remove for 9.0
$(eval $(call LLVM_PATCH,llvm8-WASM-addrspaces)) # WebAssembly
$(eval $(call LLVM_PATCH,llvm-exegesis-mingw)) # mingw build
$(eval $(call LLVM_PATCH,llvm-test-plugin-mingw)) # mingw build
$(eval $(call LLVM_PATCH,llvm-8.0-D66401-mingw-reloc)) # remove for 9.0
Expand All @@ -401,10 +399,8 @@ endif # LLVM_VER 8.0
ifeq ($(LLVM_VER_SHORT),9.0)
$(eval $(call LLVM_PATCH,llvm-D27629-AArch64-large_model_6.0.1))
$(eval $(call LLVM_PATCH,llvm8-D34078-vectorize-fdiv))
$(eval $(call LLVM_PATCH,llvm-6.0-NVPTX-addrspaces)) # NVPTX -- warning: this fails check-llvm-codegen-nvptx
$(eval $(call LLVM_PATCH,llvm-7.0-D44650)) # mingw32 build fix
$(eval $(call LLVM_PATCH,llvm9-D50010-VNCoercion-ni))
$(eval $(call LLVM_PATCH,llvm8-WASM-addrspaces)) # WebAssembly
$(eval $(call LLVM_PATCH,llvm-exegesis-mingw)) # mingw build
$(eval $(call LLVM_PATCH,llvm-test-plugin-mingw)) # mingw build
$(eval $(call LLVM_PATCH,llvm7-revert-D44485))
Expand All @@ -419,10 +415,8 @@ endif # LLVM_VER 9.0
ifeq ($(LLVM_VER_SHORT),10.0)
$(eval $(call LLVM_PATCH,llvm-D27629-AArch64-large_model_6.0.1))
$(eval $(call LLVM_PATCH,llvm8-D34078-vectorize-fdiv))
$(eval $(call LLVM_PATCH,llvm-6.0-NVPTX-addrspaces)) # NVPTX -- warning: this fails check-llvm-codegen-nvptx
$(eval $(call LLVM_PATCH,llvm-7.0-D44650)) # mingw32 build fix
$(eval $(call LLVM_PATCH,llvm9-D50010-VNCoercion-ni))
$(eval $(call LLVM_PATCH,llvm8-WASM-addrspaces)) # WebAssembly
$(eval $(call LLVM_PATCH,llvm-exegesis-mingw)) # mingw build
$(eval $(call LLVM_PATCH,llvm-test-plugin-mingw)) # mingw build
$(eval $(call LLVM_PATCH,llvm7-revert-D44485))
Expand Down
32 changes: 0 additions & 32 deletions deps/patches/llvm-6.0-NVPTX-addrspaces.patch

This file was deleted.

45 changes: 0 additions & 45 deletions deps/patches/llvm8-WASM-addrspaces.patch

This file was deleted.

2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ SRCS += codegen llvm-ptls
RUNTIME_SRCS += jitlayers aotcompile debuginfo disasm llvm-simdloop llvm-muladd \
llvm-final-gc-lowering llvm-pass-helpers llvm-late-gc-lowering \
llvm-lower-handlers llvm-gc-invariant-verifier llvm-propagate-addrspaces \
llvm-multiversioning llvm-alloc-opt cgmemmgr llvm-api
llvm-multiversioning llvm-alloc-opt cgmemmgr llvm-api llvm-remove-addrspaces
FLAGS += -I$(shell $(LLVM_CONFIG_HOST) --includedir)
LLVM_LIBS := all
ifeq ($(USE_POLLY),1)
Expand Down
10 changes: 10 additions & 0 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,14 @@ 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 @@ -842,6 +850,8 @@ 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
1 change: 1 addition & 0 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Pass *createLateLowerGCFramePass();
Pass *createLowerExcHandlersPass();
Pass *createGCInvariantVerifierPass(bool Strong);
Pass *createPropagateJuliaAddrspaces();
Pass *createRemoveJuliaAddrspacesPass();
Pass *createMultiVersioningPass();
Pass *createAllocOptPass();
// Whether the Function is an llvm or julia intrinsic.
Expand Down
Loading

0 comments on commit b8d9e78

Please sign in to comment.