diff options
author | Shilei Tian <i@tianshilei.me> | 2025-04-12 18:22:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-12 18:22:22 -0400 |
commit | b0fede358fea768ead2dc5d59ad0b6b2decc4217 (patch) | |
tree | 80bf741aa2c299833b7dd40cf5fadf039bbb8b02 /llvm/lib/LTO/LTO.cpp | |
parent | 5f744cc6301abb3be5a500b2fcbc944fe2bd3241 (diff) | |
download | llvm-b0fede358fea768ead2dc5d59ad0b6b2decc4217.zip llvm-b0fede358fea768ead2dc5d59ad0b6b2decc4217.tar.gz llvm-b0fede358fea768ead2dc5d59ad0b6b2decc4217.tar.bz2 |
[ThinLTO] Don't convert functions to declarations if `force-import-all` is enabled (#134541)
On one hand, we intend to force import all functions when the option is
enabled.
On the other hand, we currently drop definitions of some functions and
convert
them to declarations, which contradicts this intent.
With this PR, functions will no longer be converted to declarations when
`force-import-all` is enabled.
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 97d23fe..4b6a87e 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -75,6 +75,8 @@ static cl::opt<bool> extern cl::opt<bool> CodeGenDataThinLTOTwoRounds; +extern cl::opt<bool> ForceImportAll; + namespace llvm { /// Enable global value internalization in LTO. cl::opt<bool> EnableLTOInternalization( @@ -406,8 +408,11 @@ static void thinLTOResolvePrevailingGUID( Visibility = S->getVisibility(); } // Alias and aliasee can't be turned into available_externally. + // When force-import-all is used, it indicates that object linking is not + // supported by the target. In this case, we can't change the linkage as + // well in case the global is converted to declaration. else if (!isa<AliasSummary>(S.get()) && - !GlobalInvolvedWithAlias.count(S.get())) + !GlobalInvolvedWithAlias.count(S.get()) && !ForceImportAll) S->setLinkage(GlobalValue::AvailableExternallyLinkage); // For ELF, set visibility to the computed visibility from summaries. We |