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

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 13 18:56:09 PDT 2023


MaskRay added a comment.

Thanks for the update. Can you add a comment for the `-funified-lto` combination? It's unclear what it does...

`clang -flto=thin -ffat-lto-objects -funified-lto -fuse-ld=lld foo.c`

I've left some comments about missing test coverage.



================
Comment at: clang/lib/Driver/Driver.cpp:4733
+      types::ID Output;
+      if (Args.hasArg(options::OPT_S))
+        Output = types::TY_LTO_IR;
----------------
This part is not tested. 


================
Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:621
+  } else {
+    // For LLD we need to enable fat object support
+    if (Args.hasArg(options::OPT_ffat_lto_objects))
----------------
Tell LLD to find and use .llvm.lto section in regular relocatable object files.


================
Comment at: clang/test/CodeGen/embed-fat-lto-objects.c:1
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -fsplit-lto-unit -emit-llvm < %s  | FileCheck %s --check-prefixes=FULL,SPLIT
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -emit-llvm < %s  | FileCheck %s --check-prefixes=FULL,SPLIT
----------------
`embed-` in the filename seems unneeded? Perhaps just `fat-lto-objects.c`


================
Comment at: clang/test/CodeGen/embed-fat-lto-objects.c:3
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -emit-llvm < %s  | FileCheck %s --check-prefixes=FULL,SPLIT
+
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -fsplit-lto-unit -ffat-lto-objects -emit-llvm < %s  | FileCheck %s --check-prefixes=THIN,SPLIT
----------------
We need a `-emit-obj` test with `// REQUIRES: x86-registered-target`.
Use llvm-readelf to check that .llvm.lto section is present.

We also need a `-S` test, otherwise the behavior of driver `clang -S -ffat-lto-objects` is untested.




================
Comment at: clang/test/Driver/fat-lto-objects.c:10
+// CHECK-CC-NOLTO-NOT: -ffat-lto-objects
+// CHECK-CC-NOLTO-NOT: warning: argument unused during compilation: '-ffat-lto-objects'
+
----------------
This NOT pattern has no effect as warnings are usually emitted before -cc1.

You can use `--implicit-check-not=warning:`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777



More information about the cfe-commits mailing list