-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[flang][Driver] Enables lto-partitions and fat-lto-object. #158125
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
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 |
|---|---|---|
|
|
@@ -182,6 +182,29 @@ void Flang::addCodegenOptions(const ArgList &Args, | |
| CmdArgs.push_back("-fcoarray"); | ||
| } | ||
|
|
||
| void Flang::addLTOOptions(const ArgList &Args, ArgStringList &CmdArgs) const { | ||
| const auto &TC = getToolChain(); | ||
tarunprabhu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const Driver &D = TC.getDriver(); | ||
| DiagnosticsEngine &Diags = D.getDiags(); | ||
| LTOKind LTOMode = D.getLTOMode(); | ||
| // LTO mode is parsed by the Clang driver library. | ||
| assert(LTOMode != LTOK_Unknown && "Unknown LTO mode."); | ||
| if (LTOMode == LTOK_Full) | ||
| CmdArgs.push_back("-flto=full"); | ||
| else if (LTOMode == LTOK_Thin) { | ||
| Diags.Report( | ||
|
||
| Diags.getCustomDiagID(DiagnosticsEngine::Warning, | ||
| "the option '-flto=thin' is a work in progress")); | ||
| CmdArgs.push_back("-flto=thin"); | ||
| } | ||
| if (Args.hasArg(options::OPT_flto_partitions_EQ)) { | ||
| StringRef A = Args.getLastArgValue(options::OPT_flto_partitions_EQ, "8"); | ||
tarunprabhu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| CmdArgs.push_back(Args.MakeArgString("-flto-partitions=" + A)); | ||
| } | ||
| Args.addAllArgs(CmdArgs, {options::OPT_ffat_lto_objects, | ||
| options::OPT_fno_fat_lto_objects}); | ||
| } | ||
|
|
||
| void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const { | ||
| // ParsePICArgs parses -fPIC/-fPIE and their variants and returns a tuple of | ||
| // (RelocationModel, PICLevel, IsPIE). | ||
|
|
@@ -821,7 +844,6 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA, | |
|
|
||
| const Driver &D = TC.getDriver(); | ||
| ArgStringList CmdArgs; | ||
| DiagnosticsEngine &Diags = D.getDiags(); | ||
|
|
||
| // Invoke ourselves in -fc1 mode. | ||
| CmdArgs.push_back("-fc1"); | ||
|
|
@@ -884,17 +906,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA, | |
|
|
||
| handleColorDiagnosticsArgs(D, Args, CmdArgs); | ||
|
|
||
| // LTO mode is parsed by the Clang driver library. | ||
| LTOKind LTOMode = D.getLTOMode(); | ||
| assert(LTOMode != LTOK_Unknown && "Unknown LTO mode."); | ||
| if (LTOMode == LTOK_Full) | ||
| CmdArgs.push_back("-flto=full"); | ||
| else if (LTOMode == LTOK_Thin) { | ||
| Diags.Report( | ||
| Diags.getCustomDiagID(DiagnosticsEngine::Warning, | ||
| "the option '-flto=thin' is a work in progress")); | ||
| CmdArgs.push_back("-flto=thin"); | ||
| } | ||
| addLTOOptions(Args, CmdArgs); | ||
|
|
||
| // -fPIC and related options. | ||
| addPicOptions(Args, CmdArgs); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ! REQUIRES: x86-registered-target | ||
| ! checks fatlto objects: that valid bitcode is included in the object file generated. | ||
|
|
||
| ! RUN: %flang -fc1 -triple x86_64-unknown-linux-gnu -flto -ffat-lto-objects -emit-obj %s -o %t.o | ||
| ! RUN: llvm-readelf -S %t.o | FileCheck %s --check-prefixes=ELF | ||
| ! RUN: llvm-objcopy --dump-section=.llvm.lto=%t.bc %t.o | ||
| ! RUN: llvm-dis %t.bc -o - | FileCheck %s --check-prefixes=DIS | ||
|
|
||
| ! ELF: .llvm.lto | ||
| ! DIS: define void @_QQmain() | ||
| ! DIS-NEXT: ret void | ||
| ! DIS-NEXT: } | ||
|
|
||
| ! RUN: %flang -fc1 -triple x86_64-unknown-linux-gnu -flto -ffat-lto-objects -S %s -o - | FileCheck %s --check-prefixes=ASM | ||
|
|
||
| ! ASM: .section .llvm.lto,"e",@llvm_lto | ||
| ! ASM-NEXT: .Lllvm.embedded.object: | ||
| ! ASM-NEXT: .asciz "BC | ||
| ! ASM-NEXT: .size .Lllvm.embedded.object | ||
| end program |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ! UNSUPPORTED: system-windows | ||
| ! check flto-partitions is passed to lld, fc1 | ||
| ! RUN: %flang -### -fuse-ld=lld -flto=full -flto-partitions=16 %s 2>&1 | FileCheck %s --check-prefixes=LLD-PART,FC1-PART | ||
|
|
||
| ! FC1-PART: "-fc1" | ||
| ! FC1-PART-SAME: "-flto=full" | ||
| ! FC1-PART-SAME: "-flto-partitions=16" | ||
| ! LLD-PART: ld.lld | ||
| ! LLD-PART-SAME: "--lto-partitions=16" | ||
|
|
||
| ! check fat-lto-objects is passed to lld, fc1 | ||
| ! RUN: %flang -### -fuse-ld=lld -flto -ffat-lto-objects %s 2>&1 | FileCheck %s --check-prefixes=LLD-FAT,FC1-FAT | ||
|
|
||
| ! FC1-FAT: "-fc1" | ||
| ! FC1-FAT-SAME: "-flto=full" | ||
| ! FC1-FAT-SAME: "-ffat-lto-objects" | ||
| ! LLD-FAT: ld.lld | ||
| ! LLD-FAT-SAME: "--fat-lto-objects" | ||
| end program | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.