9 Commits

Author SHA1 Message Date
Paul Kirth
f2916becc5 Reland [pgo] Avoid introducing relocations by using private alias
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a ".local" suffix to the alias
name just as we do for relative vtables aliases.

https://reviews.llvm.org/rG20894a478da224bdd69c91a22a5175b28bc08ed9
removed an incorrect assertion on Mach-O which caused assertion failures in LLD.

We prevent duplicate symbols under ThinLTO + PGO + CFI by disabling
alias generation when the target function has MD_type metadata used in
CFI.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2023-01-25 22:19:19 +00:00
Arthur Eubanks
1f3f3c0ea7 Revert "Reland [pgo] Avoid introducing relocations by using private alias"
This reverts commit da5a8d14b8cc6cea16ee0929413c0672b47c93d9.

Causes more duplicate symbol errors, see https://bugs.chromium.org/p/chromium/issues/detail?id=1408161.
2023-01-19 10:20:38 -08:00
Paul Kirth
da5a8d14b8 Reland [pgo] Avoid introducing relocations by using private alias
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a ".local" suffix to the alias
name just as we do for relative vtables aliases.

https://reviews.llvm.org/rG20894a478da224bdd69c91a22a5175b28bc08ed9
removed an incorrect assertion on Mach-O which caused assertion failures in LLD.

We addressed the link errors under ThinLTO + PGO + CFI by being more
selective about which comdat functions can be given aliases.
Specifically, we now do not emit an alias in the case of a comdat
function with hidden visibility, since the alias would have the same
linkage and visibility, giving no benefit over using the symbol
directly. This also prevents LowerTypeTest from incorrectly updating the
dangling alias after GlobalOpt replaces uses, and introducing a
duplicate symbol.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2023-01-18 23:56:35 +00:00
Arthur Eubanks
c43f38ec63 Revert ""Reland "[pgo] Avoid introducing relocations by using private alias""
This reverts commit 6e5cbc097a5ac7fa95a8f425af8b03958151c763.

Causes link errors, see http://go/crb/1408161.
2023-01-17 15:41:26 -08:00
Paul Kirth
6e5cbc097a "Reland "[pgo] Avoid introducing relocations by using private alias"
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a .local suffix to the alias
name just as we do for relative vtables aliases.

This should be safe to land after an incorrect LLD assertion was removed
in https://reviews.llvm.org/rG20894a478da224bdd69c91a22a5175b28bc08ed9
which caused assertion failures in LLD on Mac.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2023-01-11 21:53:21 +00:00
Paul Kirth
7710e0e270 Revert "Reland "[pgo] Avoid introducing relocations by using private alias""
This reverts commit 3cfaea2d499970c2fd14389ade59f792156be0f8.

The runtime test fails on Mac.
2022-12-09 00:23:57 +00:00
Paul Kirth
3cfaea2d49 Reland "[pgo] Avoid introducing relocations by using private alias"
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

This disables the failing runtime test on Windows, since the compiler
options (-fPIC) are unsupported on that platform.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2022-12-08 21:03:37 +00:00
Paul Kirth
0adc577c11 Revert "Reland "[pgo] Avoid introducing relocations by using private alias"""
This reverts commit 071c39df8632561b599f7b1debd81b3cf6b5b396.

One of the new runtimes tests causes a failure with MSVC, so I'm
reverting until the test can be fixed.
2022-12-08 18:15:55 +00:00
Paul Kirth
071c39df86 Reland "[pgo] Avoid introducing relocations by using private alias""
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2022-12-08 17:37:17 +00:00