-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[Flang][Driver] Emit module summary for Full LTO #164302
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
Changes from 1 commit
3309893
1ecbeb9
51e02c1
c050671
ee40244
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,35 @@ | ||
| ! Test that the output is LLVM bitcode for LTO and not a native objectfile by | ||
| ! disassembling it to LLVM IR. | ||
| ! Right now there is nothing special about it and it is similar to non-lto IR, | ||
| ! more work is needed to add things like module summaries. | ||
| ! disassembling it to LLVM IR. Also tests module summaries are emitted for LTO | ||
tarunprabhu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ! RUN: %flang %s -c -o - | not llvm-dis -o %t | ||
| ! RUN: %flang_fc1 %s -emit-llvm-bc -o - | llvm-dis -o - | FileCheck %s | ||
|
|
||
| ! RUN: %flang -flto %s -c -o - | llvm-dis -o - | FileCheck %s | ||
| ! RUN: %flang -flto=thin %s -c -o - | llvm-dis -o - | FileCheck %s | ||
|
|
||
| ! CHECK: define void @_QQmain() | ||
| ! CHECK-NEXT: ret void | ||
| ! CHECK-NEXT: } | ||
| ! CHECK-NOT: !{{.*}} = !{i32 1, !"ThinLTO", i32 0} | ||
| ! CHECK-NOT: ^{{.*}} = module: | ||
| ! CHECK-NOT: ^{{.*}} = gv: (name: | ||
| ! CHECK-NOT: ^{{.*}} = blockcount: | ||
|
|
||
| ! RUN: %flang -flto %s -c -o - | llvm-dis -o - | FileCheck %s --check-prefix=FULL | ||
tarunprabhu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ! THIN: define void @_QQmain() | ||
| ! THIN-NEXT: ret void | ||
| ! THIN-NEXT: } | ||
| ! THIN-NOT: !{{.*}} = !{i32 1, !"ThinLTO", i32 0} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When setting Also, it looks like the output in both the thin and full LTO cases are the same - or at least, what is being checked in this test is the same. What is the difference between the two schemes? I apologize for my ignorance - as I said, I am not very familiar with LLVM's LTO implementation. Do you mind clarifying some of this? Thanks.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the clarification (in the response to a separate comment) To be clear, if testing the output of full vs. thin is too much, we need not do it - presumably that will have been tested elsewhere, perhaps in llvm/LTO. But if we can test something other than the presence/absence of "ThinLTO" metadata, we probably should.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! Working on these.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, ThinLTO requires more work to enable module summaries. I was wrong to test only the emitted module summary. At least https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/BackendUtil.cpp#L1168C9-L1182C8 needs to be enabled. I have removed the tests for thinLTO. This PR enables only module summary for Full LTO by default (same as https://reviews.llvm.org/D34156). Thank you for pointing out this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this, will
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now, flto = thin does not emit the summary, only flto = full emits. Thin LTO summary emission logic does not change - it is same as previous:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flang hello.f90 -c -emit-llvm -o -| llvm-dis -o - and flang -flto=thin hello.f90 -c -o -| llvm-dis -o - will produce the same output in ll files.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I got a bit confused and asked a strange question. Let me try again. In this test, when However, when
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is the module summary. Thanks a lot for reviewing this and helping me to improve my change. Since I am learning through this as well, there are misses which I try to correct. As this is a work in progress and as is a feature not yet implemented, I did not have preferences for checking or not checking this. I have added it back since it is more consistent with the existed test case. |
||
| ! THIN: ^{{.*}} = module: | ||
| ! THIN: ^{{.*}} = gv: (name: | ||
| ! THIN: ^{{.*}} = blockcount: | ||
|
|
||
| ! CHECK-NOT: ^0 = module: | ||
| ! CHECK-NOT: ^1 = gv: (name: | ||
| ! CHECK-NOT: ^2 = flags: | ||
| ! CHECK-NOT: ^3 = blockcount: | ||
| ! RUN: %flang -flto=thin %s -c -o - | llvm-dis -o - | FileCheck %s --check-prefix=THIN | ||
| ! FULL: define void @_QQmain() | ||
| ! FULL-NEXT: ret void | ||
| ! FULL-NEXT: } | ||
| ! FULL: !{{.*}} = !{i32 1, !"ThinLTO", i32 0} | ||
| ! FULL: ^{{.*}} = module: | ||
| ! FULL: ^{{.*}} = gv: (name: | ||
| ! FULL: ^{{.*}} = blockcount: | ||
|
|
||
| ! RUN: %flang_fc1 -flto -emit-llvm-bc %s -o - | llvm-bcanalyzer -dump| FileCheck --check-prefix=MOD-SUMM %s | ||
| ! MOD-SUMM: FULL_LTO_GLOBALVAL_SUMMARY_BLOCK | ||
| program main | ||
| end program | ||
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.
Since ThinLTO support is not being enabled here, should
emitSummaryonly be true ifopt.PrepareForFullLTOis set? ShouldPrepareForThinLTObe ignored here?Uh oh!
There was an error while loading. Please reload this page.
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.
Summary should be emitted for thinLTO. I will work on this as a follow upThe flag set logic is correct. However it is not used for thin LTO right now.
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 that since
emitSummaryis ignored in theif (opts.PrepareForThinLTO)branch on line 1038, the code should look like this for now:When support for summaries with ThinLTO is implemented, it can become:
However, since you intend to work on enabling summaries for thin LTO right away (if I understand you correctly), it should be ok to leave this code as it is. Otherwise, it can be a bit confusing.
What do you think?
Uh oh!
There was an error while loading. Please reload this page.
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.
Updated. Agree that it can be confusing.