OSDN Git Service

[MachineOutliner] Disable outlining from LinkOnceODRs by default
authorJessica Paquette <jpaquette@apple.com>
Sat, 7 Oct 2017 00:16:34 +0000 (00:16 +0000)
committerJessica Paquette <jpaquette@apple.com>
Sat, 7 Oct 2017 00:16:34 +0000 (00:16 +0000)
commit98224a5b7b20eeab5d025e65020425a380eb787c
tree143b7157b43db454efcf70230f43ddae5fccf944
parent1b2747a59f6910eafd0641082f1f655a26468cbf
[MachineOutliner] Disable outlining from LinkOnceODRs by default

Say you have two identical linkonceodr functions, one in M1 and one in M2.
Say that the outliner outlines A,B,C from one function, and D,E,F from another
function (where letters are instructions). Now those functions are not
identical, and cannot be deduped. Locally to M1 and M2, these outlining
choices would be good-- to the whole program, however, this might not be true!

To mitigate this, this commit makes it so that the outliner sees linkonceodr
functions as unsafe to outline from. It also adds a flag,
-enable-linkonceodr-outlining, which allows the user to specify that they
want to outline from such functions when they know what they're doing.

Changing this handles most code size regressions in the test suite caused by
competing with linker dedupe. It also doesn't have a huge impact on the code
size improvements from the outliner. There are 6 tests that regress > 5% from
outlining WITH linkonceodrs to outlining WITHOUT linkonceodrs. Overall, most
tests either improve or are not impacted.

Not outlined vs outlined without linkonceodrs:
https://hastebin.com/raw/qeguxavuda

Not outlined vs outlined with linkonceodrs:
https://hastebin.com/raw/edepoqoqic

Outlined with linkonceodrs vs outlined without linkonceodrs:
https://hastebin.com/raw/awiqifiheb

Numbers generated using compare.py with -m size.__text. Tests run for AArch64
with -Oz -mllvm -enable-machine-outliner -mno-red-zone.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315136 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/Passes.h
include/llvm/Target/TargetInstrInfo.h
lib/CodeGen/MachineOutliner.cpp
lib/CodeGen/TargetPassConfig.cpp
lib/Target/AArch64/AArch64InstrInfo.cpp
lib/Target/AArch64/AArch64InstrInfo.h
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrInfo.h
test/CodeGen/AArch64/machine-outliner.ll