Skip to content
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

merge_llvm_401 #5400

Merged
merged 9 commits into from
Jan 31, 2018
Merged

merge_llvm_401 #5400

merged 9 commits into from
Jan 31, 2018

Conversation

juj
Copy link
Collaborator

@juj juj commented Jul 20, 2017

Update from LLVM 4.0 to LLVM 4.0.1, add new llvm_lifetime_start and _end intrinsics.

@juj
Copy link
Collaborator Author

juj commented Jul 20, 2017

This is to match when emscripten-core/emscripten-fastcomp#191 lands.

src/library.js Outdated
@@ -1464,6 +1464,8 @@ LibraryManager.library = {

llvm_lifetime_start: function() {},
llvm_lifetime_end: function() {},
llvm_lifetime_start_p0i8: function() {},
llvm_lifetime_end_p0i8: function() {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be implemented in CallHanders.h in fastcomp, so that we emit no-ops for them (instead of emitting ffi calls that are then no-ops).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a great idea. Applied that treatment to all of these no-ops.

# For fastcomp backend, no LLVM IR functions should ever be annotated 'optnone', because that would skip running the SimplifyCFG pass on them, which is required to always run to
# clean up LandingPadInst instructions that are not needed.
if not shared.Settings.WASM_BACKEND:
args += ['-Xclang', '-disable-O0-optnone']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying that llvm changed semantics so that the SimplifyCFG pass will not run on optnone methods now? Or is optnone a new thing in this merge?

Perhaps there are other consequences to not doing optnone? Like slower compile times for -O0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying that llvm changed semantics so that the SimplifyCFG pass will not run on optnone methods now?

That semantic has not changed, all optimization passes have a test for if (func is optnone) skip this pass on this function;

Or is optnone a new thing in this merge?

The new thing is that the optnone attribute is now getting slapped to all functions when compiling code with -O0 optimization level, whereas it used to not be added. When this change was done, the -disable-O0-optnone flag was added to allow reverting to the earlier behavior of not producing all functions with optnone.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does still worry me, but the only concrete concern I have is compile times. Can you please check if -O0 compile times vary much with and without that flag? (on a file where it doesn't crash the compiler to not run that pass that optnone disables).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check, running timing benchmarks now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running default suite with -disable-O0-optnone present gives 1367 seconds, and running default suite without -disable-O0-optnone gives 1303 seconds (-4.68%), though that suite fails on 7 tests, so not sure if that has a bearing.

However, I don't think it's fair to compare compile times to the version where the optnone flag is present, since that is not the original status quo - we have never generated code with that attribute applied to all functions. I.e. we used to behave as if optnone did not exist. See this commit that introduced the -disable-O0-optnone flag: juj/emscripten-fastcomp-clang@7a45503 It is that commit which also introduced the sprinkling of optnone attribute everywhere in -O0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running a comparison against pre-merge branch next.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran default suite in current incoming branch, getting 1433 seconds as runtime. So at least the update will not regress overall compilation performance, but improves it by a little (-4.61% less time).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that seems ok then.

@@ -62,12 +62,12 @@ llvm_floor_f64 -2.0
llvm_round_f64 20.0
llvm_round_f64 21.0
llvm_round_f64 42.0
llvm_round_f64 -20.0
llvm_round_f64 -21.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm a little worried about changing rounding semantics as part of this merge. optimally we'd do it separately.

I think I remember you having good reasons for this change, where are they documented?

Copy link
Collaborator Author

@juj juj Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation of round was incorrect, round*() and llvm_round_f* are specced to always round away from zero. They don't have a controllable rounding mode: #5716 and 7036e58.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sounds good. But please add to that test, as before it showed the decision point (one result was -20, one was -21). I.e., can add

  printf("llvm_round_f32 %.1f\n", llvm_round_f32(-20.49)); // new line, should have different result
  printf("llvm_round_f32 %.1f\n", llvm_round_f32(-20.5));
  printf("llvm_round_f32 %.1f\n", llvm_round_f32(-20.51));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, added.

@juj juj force-pushed the merge_llvm_401 branch 2 times, most recently from 936a6e4 to be8dee2 Compare January 15, 2018 10:58
juj and others added 9 commits January 31, 2018 03:34
…om zero, independent of current active rounding mode, and rint() family should respect the active rounding mode (we only implement one - FE_TONEAREST i.e. round-to-even, or banker's rounding)
…s/LangRef.html#id508 states that llvm.round 'returns the same values as the libm round functions would', and http://en.cppreference.com/w/c/numeric/math/round says that round should always round away from zero, regardless of the current rounding mode.
…LVM 4.0.1 tagged release in LLVM upstream SVN has
…n -O0 optimization level is present, since optnone would prevent SimplifyCFG pass from being run, which is needed in fastcomp to remove LandingPadInsts when exception catching is not enabled.
@juj juj merged commit fd7038d into emscripten-core:incoming Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants