[PATCH] D26437: Use -fno-unit-at-a-time and -funit-at-a-time
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 13 11:44:28 PST 2016
mehdi_amini added a comment.
> In https://reviews.llvm.org/D26437#593867, @tejohnson wrote:
>> I tried to look at the history of when/why DisableUnitAtATime was added to llvm, but wasn't able to find the commit log either via git (it was moved from a different file) or via google searches.
> IIRC, it was a compatibility mode from the early days to be able to match what GCC was doing.
Here is the GCC doc: https://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Optimize-Options.html
Parse the whole compilation unit before starting to produce code. This allows some extra optimizations to take place but consumes more memory (in general). There are some compatibility issues with unit-at-a-time mode:
enabling unit-at-a-time mode may change the order in which functions, variables, and top-level asm statements are emitted, and will likely break code relying on some particular ordering. The majority of such top-level asm statements, though, can be replaced by section attributes. The fno-toplevel-reorder option may be used to keep the ordering used in the input file, at the cost of some optimizations.
unit-at-a-time mode removes unreferenced static variables and functions. This may result in undefined references when an asm statement refers directly to variables or functions that are otherwise unused. In that case either the variable/function shall be listed as an operand of the asm statement operand or, in the case of top-level asm statements the attribute used shall be used on the declaration.
Static functions now can use non-standard passing conventions that may break asm statements calling functions directly. Again, attribute used will prevent this behavior.
As a temporary workaround, -fno-unit-at-a-time can be used, but this scheme may not be supported by future releases of GCC.
Enabled at levels -O, -O2, -O3, -Os.
More information about the llvm-commits