Revision 7bba1757c575525403403994ac6408714067c5af authored by Yichao Yu on 07 November 2017, 04:38:14 UTC, committed by Yichao Yu on 13 December 2017, 19:13:16 UTC
LLVM has really bad support for returns_twice functions and can incorrectly move memory operations
(both at IR and machine code level) due to missing control flow edge.
By outlining the exception body, we can hide these functions from LLVM completely
(they only exist in C code) and prevent all miscompilation.
This also makes it much easier to check the correctness of heap to stack allocation optimization
especially since not all memory operation intrinsics in LLVM has a volatile counterpart.

This will obviously inhibit some valid optimizations too.
These are mainly forwarding of memory operations from the caller to the exception body
(since the other way around is almost always invalid) and can be improved with some simple IPO.

This also makes it unnecessary to mark any memory operations on the stack with `volatile`
this should also improve optimization in certain cases.

Since we are scanning all the instructions in the outlined code anyway this also includes
a simple optimization to delete exception frame that can't trigger.

This implements a tweaked version of https://discourse.julialang.org/t/avoid-llvm-setjmp-bug/1140

Fix #17288
1 parent 87c1d4f
History
File Mode Size
flisp
support
.gitignore -rw-r--r-- 257 bytes
APInt-C.cpp -rw-r--r-- 15.0 KB
APInt-C.h -rw-r--r-- 5.2 KB
Makefile -rw-r--r-- 13.9 KB
Windows.mk -rw-r--r-- 2.6 KB
abi_aarch64.cpp -rw-r--r-- 15.0 KB
abi_arm.cpp -rw-r--r-- 8.9 KB
abi_llvm.cpp -rw-r--r-- 2.4 KB
abi_ppc64le.cpp -rw-r--r-- 5.7 KB
abi_win32.cpp -rw-r--r-- 2.9 KB
abi_win64.cpp -rw-r--r-- 2.9 KB
abi_x86.cpp -rw-r--r-- 3.3 KB
abi_x86_64.cpp -rw-r--r-- 8.4 KB
anticodegen.c -rw-r--r-- 2.8 KB
array.c -rw-r--r-- 38.1 KB
ast.c -rw-r--r-- 38.4 KB
ast.scm -rw-r--r-- 14.7 KB
atomics.h -rw-r--r-- 10.4 KB
bin2hex.scm -rw-r--r-- 388 bytes
builtin_proto.h -rw-r--r-- 1.2 KB
builtins.c -rw-r--r-- 43.2 KB
ccall.cpp -rw-r--r-- 80.9 KB
ccalltest.c -rw-r--r-- 24.5 KB
cgmemmgr.cpp -rw-r--r-- 28.8 KB
cgutils.cpp -rw-r--r-- 101.4 KB
codegen.cpp -rw-r--r-- 272.5 KB
codegen_shared.h -rw-r--r-- 1.3 KB
common_symbols1.inc -rw-r--r-- 1.3 KB
common_symbols2.inc -rw-r--r-- 5.4 KB
crc32c-tables.c -rw-r--r-- 43.4 KB
crc32c.c -rw-r--r-- 19.4 KB
datatype.c -rw-r--r-- 30.0 KB
debuginfo.cpp -rw-r--r-- 59.9 KB
debuginfo.h -rw-r--r-- 568 bytes
disasm.cpp -rw-r--r-- 31.3 KB
dlload.c -rw-r--r-- 8.5 KB
dump.c -rw-r--r-- 106.2 KB
features_aarch32.h -rw-r--r-- 888 bytes
features_aarch64.h -rw-r--r-- 893 bytes
features_x86.h -rw-r--r-- 3.3 KB
file_constants.h -rw-r--r-- 708 bytes
gc-debug.c -rw-r--r-- 46.3 KB
gc-pages.c -rw-r--r-- 12.9 KB
gc.c -rw-r--r-- 109.1 KB
gc.h -rw-r--r-- 21.0 KB
gen_sysimg_symtab.jl -rw-r--r-- 955 bytes
getopt.c -rw-r--r-- 4.3 KB
getopt.h -rw-r--r-- 1.8 KB
gf.c -rw-r--r-- 94.0 KB
init.c -rw-r--r-- 28.2 KB
interpreter-stacktrace.c -rw-r--r-- 12.2 KB
interpreter.c -rw-r--r-- 27.2 KB
intrinsics.cpp -rw-r--r-- 46.5 KB
intrinsics.h -rw-r--r-- 2.9 KB
jitlayers.cpp -rw-r--r-- 45.5 KB
jitlayers.h -rw-r--r-- 7.1 KB
jl_uv.c -rw-r--r-- 28.4 KB
jlapi.c -rw-r--r-- 10.4 KB
jlfrontend.scm -rw-r--r-- 8.7 KB
jloptions.c -rw-r--r-- 25.9 KB
jltypes.c -rw-r--r-- 81.7 KB
julia-parser.scm -rw-r--r-- 99.9 KB
julia-syntax.scm -rw-r--r-- 189.1 KB
julia.expmap -rw-r--r-- 684 bytes
julia.h -rw-r--r-- 72.1 KB
julia_assert.h -rw-r--r-- 988 bytes
julia_internal.h -rw-r--r-- 42.1 KB
julia_threads.h -rw-r--r-- 7.5 KB
llvm-alloc-opt.cpp -rw-r--r-- 27.9 KB
llvm-api.cpp -rw-r--r-- 6.2 KB
llvm-eh-lowering.cpp -rw-r--r-- 15.9 KB
llvm-eh-outlining.cpp -rw-r--r-- 20.8 KB
llvm-gc-invariant-verifier.cpp -rw-r--r-- 6.4 KB
llvm-late-gc-lowering.cpp -rw-r--r-- 86.8 KB
llvm-muladd.cpp -rw-r--r-- 3.7 KB
llvm-multiversioning.cpp -rw-r--r-- 39.4 KB
llvm-propagate-addrspaces.cpp -rw-r--r-- 7.4 KB
llvm-ptls.cpp -rw-r--r-- 8.9 KB
llvm-simdloop.cpp -rw-r--r-- 7.0 KB
llvm-version.h -rw-r--r-- 568 bytes
locks.h -rw-r--r-- 5.0 KB
macroexpand.scm -rw-r--r-- 22.5 KB
match.scm -rw-r--r-- 9.8 KB
method.c -rw-r--r-- 28.7 KB
mk_julia_flisp_boot.scm -rw-r--r-- 128 bytes
module.c -rw-r--r-- 22.3 KB
options.h -rw-r--r-- 4.6 KB
precompile.c -rw-r--r-- 11.7 KB
processor.cpp -rw-r--r-- 26.6 KB
processor.h -rw-r--r-- 9.4 KB
processor_arm.cpp -rw-r--r-- 49.1 KB
processor_fallback.cpp -rw-r--r-- 4.5 KB
processor_x86.cpp -rw-r--r-- 32.9 KB
rtutils.c -rw-r--r-- 37.2 KB
runtime_ccall.cpp -rw-r--r-- 6.1 KB
runtime_intrinsics.c -rw-r--r-- 30.7 KB
safepoint.c -rw-r--r-- 7.3 KB
signal-handling.c -rw-r--r-- 8.9 KB
signals-mach.c -rw-r--r-- 18.6 KB
signals-unix.c -rw-r--r-- 23.4 KB
signals-win.c -rw-r--r-- 16.0 KB
simplevector.c -rw-r--r-- 2.4 KB
stackwalk.c -rw-r--r-- 15.1 KB
staticdata.c -rw-r--r-- 61.4 KB
subtype.c -rw-r--r-- 95.9 KB
symbol.c -rw-r--r-- 4.0 KB
sys.c -rw-r--r-- 16.5 KB
table.c -rw-r--r-- 4.5 KB
task.c -rw-r--r-- 21.7 KB
threadgroup.c -rw-r--r-- 5.8 KB
threadgroup.h -rw-r--r-- 1.4 KB
threading.c -rw-r--r-- 24.8 KB
threading.h -rw-r--r-- 1.1 KB
timing.c -rw-r--r-- 1.6 KB
timing.h -rw-r--r-- 4.3 KB
tls.h -rw-r--r-- 1.1 KB
toplevel.c -rw-r--r-- 26.2 KB
typemap.c -rw-r--r-- 43.1 KB
utils.scm -rw-r--r-- 2.6 KB
uv_constants.h -rw-r--r-- 708 bytes

back to top