[PATCH] D146777: [clang] Preliminary fat-lto-object support

Paul Kirth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 14 13:57:37 PDT 2023


paulkirth updated this revision to Diff 540559.
paulkirth marked an inline comment as done.
paulkirth edited the summary of this revision.
paulkirth added a comment.

Revise tests + update summary

- Add driver tests for -S
- Add codegen tests for -S
- Test Unified LTO codegen
- Use -fdriver-only to test that -ffat-lto-objects isn't unused
- Test that the embedded bitcode has the correct module options set in object files
- Check that the .llvm.lto section exists when we generate ELF
- Make sure we set any FatLTO related module flags, even for other BackendActions(e.g., -emit-llvm), so that the IR emitted will match the IR embedded in the object file

I realized when writing the UnifiedLTO test that the existing implementation
wouldn't actually emit the correct IR using `-emit-llvm` for FatLTO. The flags
were set correctly in the .llvm.lto section, so I slightly adjusted the way we
set flags for the FatLTO case, so that `-ffat-lto-objects -emit-llvm` will have
the same module flags. The issue was that FatLTO isn't mutually exclusive w/
the other BackendActions, so my use of `if else` wasn't correct, and stopped us
from adding any flags when we used `-emit-llvm`. I missed this, since we set the
flags the same way.

The new tests in CodeGen may be a bit overkill, but they were already helpful in
finding this subtle bug.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146777/new/

https://reviews.llvm.org/D146777

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/CodeGen/fat-lto-objects.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fat-lto-objects.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146777.540559.patch
Type: text/x-patch
Size: 14251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230714/d377546b/attachment.bin>


More information about the cfe-commits mailing list