-
Notifications
You must be signed in to change notification settings - Fork 13.5k
ThinLTO seems to break computed goto #38589
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
Comments
assigned to @eleviant |
A workaround is to add attribute((noinline)) to direct_run in direct_machine.cpp. |
... which, in fact, seems to be the core problem: here is what the GCC docs say about labels as values: The &&foo expressions for the same label might have different values if the containing function is inlined or cloned. If a program relies on them being always the same, attribute((noinline,noclone)) should be used to prevent inlining and cloning. https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html That said, it also follows with: And here it is, so arguably, clang should forbid inlining here. |
I'm not sure if this is limited to is_return or if other uses of Machine::getOpcodeTable have the same problem, but specifically for is_return, if I add attribute((noinline)) to it, this is what it compiles to: Dump of assembler code for function (anonymous namespace)::is_return(void*): This can't be right. |
As I've submitted a PR to add attribute((noinline)), the STR may eventually fail to reproduce. Checkout any commit up to (and including) 201162775ae48c1ac364c4af500b85f8224756c4 in order to reproduce. |
I'm looking at it at the moment. Will get back when I find something. |
Possible fix: https://reviews.llvm.org/D53139 |
Interestingly, the patch works for the STR I gave, but it doesn't when building Firefox with ThinLTO enabled. |
Are you using thinlto cache? If so please clear it first and rebuild from scratch. If nothing helps, please create an issue. |
Not using a ThinLTO cache. But FWIW, I filed this bug because we originally had this problem in Firefox (in the bundled graphite), which I reproduced with graphite separately. |
Ok, please file a bug then |
But this bug is still open, and this is the same problem, on the same function, inlined the same wrong way in the same source file, but linked in something bigger (and with the same workaround with attribute((noinline))). |
Do you have steps to reproduce this with Firefox? |
$ hg clone https://hg.mozilla.org/mozilla-central (--enable-lto enables thinlto, not full lto) A failing build will say something like "FAIL image comparison, max difference: 255, number of differing pixels: 896" |
Actually, I can't reproduce locally, there might be some other cache involved in the failure I got on Firefox. Waiting for confirmation. |
Ok, sorry for the noise, there was a separate level of caching that was breaking my test of the patched version of clang. I now confirmed the patch fixed it for Firefox too. |
Teresa, is this OK to merge to the release_70 branch? |
Yes thanks |
Merged: r345401 |
Extended Description
STR:
git clone https://github.com/silnrsi/graphite
cd graphite
mkdir build
cd build
cmake -GNinja -DCMAKE_C_COMPILER=/path/to/bin/clang -DCMAKE_CXX_COMPILER=/path/to/bin/clang++ -DCMAKE_CXX_FLAGS=-flto=thin -DCMAKE_SHARED_LINKER_FLAGS=-flto=thin -DCMAKE_EXE_LINKER_FLAGS=-flto=thin -DCMAKE_MODULE_LINKER_FLAGS=-flto=thin -DCMAKE_C_FLAGS=-flto=thin -DCMAKE_AR=/path/to/bin/llvm-ar -DCMAKE_RANLIB=/path/to/bin/llvm-ranlib ..
ninja
ninja test
This results in many tests failing (84 out of 93 on my machine). A non-LTO build only fails only 8 tests on my machine.
This worked fine with clang 6, so I bisected it down to:
commit 11b0e47 (refs/bisect/bad)
Author: Eugene Leviant [email protected]
Date: Fri Feb 16 08:11:04 2018 +0000
I haven't dug into how exactly the generated code is broken, but adding the following to the cmake command line makes it work: -DGRAPHITE2_VM_TYPE=call
That makes call_machine.cpp be used instead of direct_machine.cpp. The main difference between both is that the latter is using computed gotos.
The text was updated successfully, but these errors were encountered: