[PATCH] D129401: [libLTO] Set data-sections by default in libLTO for ELF and XCOFF.

Quinn Pham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 08:50:11 PDT 2022


quinnp added a comment.

I've realized that `getExplicitDataSections()` interacts with the `clang` options `-fdata-sections` and `-fno-data-sections` differently than the `llc` versions of these options, `--data-sections=true` and `--data-sections=false`. In particular,

- when `-fdata-sections` is specified with `clang`, `getExplicitDataSections()` returns `1`
- when `-fno-data-sections` is specified with `clang`, `getExplicitDataSections()` returns `None`.
- when no `data-sections` options are specified with `clang`, `getExplicitDataSections()` returns `None`.
- when `--data-sections=true` is specified with `llvm-lto`, `getExplicitDataSections()` returns `1`
- when `--data-sections=false` is specified with `llvm-lto`, `getExplicitDataSections()` returns `0`
- when no `data-sections` options are specified with `llvm-lto`, `getExplicitDataSections()` returns `None`.

When `getExplicitDataSections()` returns `None`, we may enter the conditional added in this patch because the user did not explicitly set/unset `data-sections`. However, if  `getExplicitDataSections()` returns `0` or `1`, we will not enter the conditional because the user has explicitly set/unset `data-sections`. Therefore, when running `clang -flto -fno-data-sections` to link, we will enter the conditional added in this patch despite the user specifying `-fno-data-setions` because `getExplicitDataSections()` returns `None`. The tests added in this patch are testing the `llc` options with `llvm-lto` which always prevent the compiler from entering the conditional. I'm not sure if this is a concern because `gold plugin` is using `getExplicitDataSections()` in the same way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401



More information about the llvm-commits mailing list