diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:01:25 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:01:25 +0000 |
commit | d8e91e46262bc44006913e6796843909f1ac7bcd (patch) | |
tree | 7d0c143d9b38190e0fa0180805389da22cd834c5 /lib/LTO/UpdateCompilerUsed.cpp | |
parent | b7eb8e35e481a74962664b63dfb09483b200209a (diff) |
Notes
Diffstat (limited to 'lib/LTO/UpdateCompilerUsed.cpp')
-rw-r--r-- | lib/LTO/UpdateCompilerUsed.cpp | 16 |
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; } |