-
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 all commits
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 that module summaries are emitted for LTO | ||
|
|
||
| ! 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=thin %s -c -o - | llvm-dis -o - | FileCheck %s --check-prefix=THIN | ||
| ! 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-NOT: ^{{.*}} = module: | ||
| ! THIN-NOT: ^{{.*}} = gv: (name: | ||
| ! THIN-NOT: ^{{.*}} = blockcount: | ||
|
|
||
| ! CHECK-NOT: ^0 = module: | ||
| ! CHECK-NOT: ^1 = gv: (name: | ||
| ! CHECK-NOT: ^2 = flags: | ||
| ! CHECK-NOT: ^3 = blockcount: | ||
| ! RUN: %flang -flto %s -c -o - | llvm-dis -o - | FileCheck %s --check-prefix=FULL | ||
| ! 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.
Does
-flto=thinimply that module summaries are enabled? If so, it may be a good idea to issue a diagnostic saying that thin-lto support is incomplete. Do you intend to implement module summaries for thin-lto? If that is likely to land relatively soon, it may be ok not to emit a diagnostic.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.
The warning exists: https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/lto-flags.f90#L33 I will work on this.
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.
Thanks for working on this