-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8345265: Minor improvements for LTO across all compilers #22464
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@TheShermanTanker The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only noticed this had been changed back to Draft after I was mostly done looking
at it. But I don't think this should be done this way, esp. since it didn't seem to work
(as in suppressing warnings from LTO) for me.
src/hotspot/share/jvmci/jvmciEnv.cpp
Outdated
@@ -613,7 +613,7 @@ JVMCIEnv::~JVMCIEnv() { | |||
if (_init_error_msg != nullptr) { | |||
// The memory allocated in libjvmci was not allocated with os::malloc | |||
// so must not be freed with os::free. | |||
ALLOW_C_FUNCTION(::free((void*) _init_error_msg)); | |||
ALLOW_C_FUNCTION(::free, ::free((void*) _init_error_msg);) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do this bug fix change under a separate JBS issue & PR. I've created a JBS issue for it:
https://bugs.openjdk.org/browse/JDK-8345267
Fix memory leak in JVMCIEnv dtor
@@ -86,7 +86,7 @@ | |||
// so uses of functions that are both forbidden and fortified won't cause | |||
// forbidden warnings in such builds. | |||
#define FORBID_C_FUNCTION(signature, alternative) \ | |||
extern "C" __attribute__((__warning__(alternative))) signature; | |||
[[gnu::warning(alternative)]] signature noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you making this change at all, let alone under this JBS issue?
Among other problems, noexcept
is mostly irrelevant in HotSpot, since we build with
exceptions disabled. (There are a few places where noexcept
affects semantics, like for
operator new
, but otherwise there is no point.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the extern "C" and I think it might not be needed. A method that was already declared extern "C" in a C library header will keep that linkage when it is declared again, even without extern "C". There's also the issue that this forbidding macro could declare methods that don't actually exist on the current platform, which I think(?) removing extern "C" helps prevent. There's also the strange case that not all platforms have C library methods that are extern "C" (Windows is a notable example), so this helps declaring things with conflicting linkages and causing an error. The noexcept was just to match the declarations in standard library headers, since they are supposed to be noexcept according to the Standard
src/hotspot/share/runtime/os.cpp
Outdated
@@ -22,6 +22,9 @@ | |||
* | |||
*/ | |||
|
|||
// Stopgap fix until FORBID_C_FUNCTION can work properly with LTO | |||
#define DISABLE_POISONING_STOPGAP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed if not using LTO.
src/hotspot/share/runtime/os.cpp
Outdated
@@ -22,6 +22,9 @@ | |||
* | |||
*/ | |||
|
|||
// Stopgap fix until FORBID_C_FUNCTION can work properly with LTO | |||
#define DISABLE_POISONING_STOPGAP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far as I can tell, this doesn't work. I still get tons of -Wattribute-warning
s when building
with LTO, because of similar problem from other files.
src/hotspot/share/runtime/os.cpp
Outdated
@@ -22,6 +22,9 @@ | |||
* | |||
*/ | |||
|
|||
// Stopgap fix until FORBID_C_FUNCTION can work properly with LTO | |||
#define DISABLE_POISONING_STOPGAP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents precompiled headers from being used for this file. -Winvalid-pch
will warn if enabled.
Yeah, I had noticed that it didn't work too, which is why I returned it to draft. It also causes VC to explode when compiling the Windows HotSpot, so that isn't ideal. I guess returning g1ParScanThreadState.cpp to LTO status will have to wait until FORBID_C_FUNCTION is properly fixed up to be LTO proof |
This needs a name and description change, I'll do so later. @MBaesken does this fix LTO on your end? Kim also reports that LTO hangs indefinitely alongside several warning messages, do you have similar issues when you try to enable LTO? |
When I try to build with this change (with and without lto enabled) I run into
(maybe it is related to the devkit, maybe to pch I don't know) |
It's related to the subtle change in FORBID_C_FUNCTION, I think unistd.h is being included before compilerWarnings.hpp somewhere. Well, at least I now know the current approach has this issue |
Reverted the change in compilerWarnings_gcc.hpp since it was causing problems like Matthias reported. This still needs a title and description change since it now tries to improve LTO for all compilers, will do that later |
I believe this is now ready |
Hi, the workaround 'disable lto in g1ParScanThreadState because of special inlining/flattening used there' is removed , why this works now ? |
The issue there was the I'm trying this new version, and I still get a few other warnings and then seem to have a process hang in lto1-ltrans. |
Turns out I didn't wait long enough. It does terminate after about 40 minutes, though not successfully. Instead the
I've not tried to debug this. Maybe it's a consequence of one of those problems of bypassing an intentional implicit |
That seems definitely likely. With LTO the linker has a whole lot of room to try many exciting optimizations. I think it is more than likely that this can trigger some UB holes. The question is: should we decouple "fixing LTO build" from "fixing a working LTO JVM"? I tend to think so; that the problem for the build system is to be able to build the product, and if it then crashes during use, it's the problem of the component owners instead. OTOH, this fix is relatively trivial, and if the JVM is DOA so we can't even finish the build, then maybe it makes no point to integrate it until that is fixed. |
Fixing the JVM under LTO is likely to be a heavy undertaking, much more so than just unbreaking compilation and linking of the JVM (Ignoring that the JVM later crashes when the newly compiled JDK is used to build parts of itself), I'm not sure it would be feasible under the current Pull Request |
This is a general cleanup and improvement of LTO, as well as a quick fix to remove a workaround in the Makefiles that disabled LTO for g1ParScanThreadState.cpp due to the old poisoning mechanism causing trouble. The -Wno-attribute-warning change here can be removed once Kim's new poisoning solution is integrated.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22464/head:pull/22464
$ git checkout pull/22464
Update a local copy of the PR:
$ git checkout pull/22464
$ git pull https://git.openjdk.org/jdk.git pull/22464/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22464
View PR using the GUI difftool:
$ git pr show -t 22464
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22464.diff
Using Webrev
Link to Webrev Comment