summaryrefslogtreecommitdiff
path: root/lib/LTO/UpdateCompilerUsed.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/LTO/UpdateCompilerUsed.cpp')
-rw-r--r--lib/LTO/UpdateCompilerUsed.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/LTO/UpdateCompilerUsed.cpp b/lib/LTO/UpdateCompilerUsed.cpp
index c982a5b0e5aa..00482dee6e10 100644
--- a/lib/LTO/UpdateCompilerUsed.cpp
+++ b/lib/LTO/UpdateCompilerUsed.cpp
@@ -95,12 +95,18 @@ private:
if (GV.hasPrivateLinkage())
return;
- // Conservatively append user-supplied runtime library functions to
- // llvm.compiler.used. These could be internalized and deleted by
- // optimizations like -globalopt, causing problems when later optimizations
- // add new library calls (e.g., llvm.memset => memset and printf => puts).
+ // Conservatively append user-supplied runtime library functions (supplied
+ // either directly, or via a function alias) to llvm.compiler.used. These
+ // could be internalized and deleted by optimizations like -globalopt,
+ // causing problems when later optimizations add new library calls (e.g.,
+ // llvm.memset => memset and printf => puts).
// Leave it to the linker to remove any dead code (e.g. with -dead_strip).
- if (isa<Function>(GV) && Libcalls.count(GV.getName())) {
+ GlobalValue *FuncAliasee = nullptr;
+ if (isa<GlobalAlias>(GV)) {
+ auto *A = cast<GlobalAlias>(&GV);
+ FuncAliasee = dyn_cast<Function>(A->getAliasee());
+ }
+ if ((isa<Function>(GV) || FuncAliasee) && Libcalls.count(GV.getName())) {
LLVMUsed.push_back(&GV);
return;
}