-
Notifications
You must be signed in to change notification settings - Fork 32
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
LLD LTO Failing to optimize and Crashing Compiler #313
Comments
Hey @DanielDeLayo, thanks for the issue report. Here's what I found from looking into the issues you mentioned. First, the way you're building the cilkpracer tool does not support LTO. The build system in the productivity-tools repo builds each Cilk tool to an ordinary static library, that is, an archive or ordinary object files. The If you would like to use LTO, you will need to compile the cilkpracer tool, at least in part, to LLVM bitcode and then link that LLVM bitcode with your program.
Second, whatever causes the crash on your version of the compiler is fixed in the latest development branch, Note that, if you choose to rebase your changes onto the I hope that helps. Let us know if you have more questions or run into more issues. |
Thanks! Good to know-- I guess I assumed the LTO flags would be passed through, especially since the original CSI paper stresses the importance of LTO. Would it be possible to add a warning if a cilktool and LTO are both enabled? It'll probably save someone time in the future. We've swapped over to using For Cilkprace, we get this: [Edit: the difference in build directories is cosmetic, ../build is symlinked to ../../../../build]
The cilkprace commit is 35406a Is there something we're doing wrong with bitcode, or should we rebase to dev/19.x? Thanks again for all the help, |
Compared to the CSI paper, we removed the requirement to use LTO for the Cilktools because LTO isn't well supported across all the systems and use cases where we want OpenCilk to run. To work around the performance issues from lacking LTO, we added Cilktool-specific compiler support to avoid inserting instrumentation hooks that specific Cilktools don't need. Specifically, we added the We have been working on an alternative to LTO for CSI and Cilktools. That alternative is essentially the I believe there are technical reasons why some parts of a Cilktool, such as Have you tried using both a bitcode file and a traditional library together for your tool? You should be able to compile your tool to a traditional library, plus part of your tool — with the hook implementations — to a bitcode file. You can then pass the bitcode file to the compiler, using the I don't know why you're getting assertion failures from using your Hope this helps. Let us know if you still encounter problems. |
Thanks for the explanation and the recommendation. I've managed to solve the bug and approximately understand what was going on. While separating the hook implementations into their own .cpp file, I had to take away the I removed it from the other tool as well and it worked as is. I also peaked back at the fed tables and, as expected, saw that they're We can also write up a minimal example if it would be useful for you. Thanks again. |
Describe the bug
Compiling and Linking with LLD's LTO causes either 1. Debug (or just unexpected) output with ineffective optimization or 2. a compiler crash.
Expected behavior
Note: cilksort.out (instrumented with cilkprace) asserting almost immediately is correct behavior, at least as far as the compiler is concerned.
OpenCilk version
Built from source (with modifications):
opencilk-project
:cilkprace
af4ec7fcheetah
:5a80d8a534e8d56a5e354997bbfea23257c1c36b
productivity-tools
:cilkprace
af31596System information
Steps to reproduce (include relevant output)
Build command:
../build/bin/clang -fopencilk -fcilktool=cilkprace -g -O3 -DTIMING_COUNT=3 -fuse-ld=lld -flto -lm cilksort.c ktiming.c getoptions.c -o cilksort.out
Sample unexpected output:
Calling objdump to check for LTO
objdump -D cilksort.out
The code is littered with calls to __csi_after_store
15438: e8 93 6f ff ff callq c3d0 <__csi_after_store>
Which are prime targets for LTO to opimize away:
Instrumenting the same code with cilksan instead gives us a compiler crash:
../build/bin/clang -fopencilk -fsanitize=cilk -mllvm -enable-static-race-detection=false -g -O3 -DTIMING_COUNT=3 -lm -g -O3 -DTIMING_COUNT=3 -fuse-ld=lld -flto cilksort.c ktiming.c getoptions.c -o cilksort.csan
cilksort backtrace.txt
Requested attached (bonus .txt extensions to appease github)
cilksort-d7b45f.sh.txt
getoptions-ff4d8b.c.txt
ktiming-2759e6.c.txt
cilksort-d7b45f.c.txt
Additionally, using LTO to compile and link cilksort without either cilktool gives the unexpected output and does not crash. I haven't verified if LTO is being applied properly.
Working example code
cilksort.c, ktiming.c, and getoptions.c can be found in the cilkprace subdirectory of cilktools
cilkprace/bench_cheetah
There's also a makefile there, but the
all
target doesn't work. I'd recommend usingmake cilksort.out
andmake cilksort.csan
instead ofmake
.Additional comments
Add any other comments about the issue here.
The text was updated successfully, but these errors were encountered: