summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/IRSymtab.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2018-07-24 19:34:37 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2018-07-24 19:34:37 +0000
commite06bac4796bffed2b80649497afaadfb67d767cf (patch)
tree9169b6f8b74ec31cd36cb8233b294b0a56dd986a /llvm/lib/Object/IRSymtab.cpp
parentc9313a9ecbad7b571bb7e7411341b6aeb5a41ef7 (diff)
downloadbcm5719-llvm-e06bac4796bffed2b80649497afaadfb67d767cf.tar.gz
bcm5719-llvm-e06bac4796bffed2b80649497afaadfb67d767cf.zip
Put "built-in" function definitions in global Used list, for LTO. (fix bug 34169)
When building with LTO, builtin functions that are defined but whose calls have not been inserted yet, get internalized. The Global Dead Code Elimination phase in the new LTO implementation then removes these function definitions. Later optimizations add calls to those functions, and the linker then dies complaining that there are no definitions. This CL fixes the new LTO implementation to check if a function is builtin, and if so, to not internalize (and later DCE) the function. As part of this fix I needed to move the RuntimeLibcalls.{def,h} files from the CodeGen subidrectory to the IR subdirectory. I have updated all the files that accessed those two files to access their new location. Fixes PR34169 Patch by Caroline Tice! Differential Revision: https://reviews.llvm.org/D49434 llvm-svn: 337847
Diffstat (limited to 'llvm/lib/Object/IRSymtab.cpp')
-rw-r--r--llvm/lib/Object/IRSymtab.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp
index 51081d8b5e6..344d565349c 100644
--- a/llvm/lib/Object/IRSymtab.cpp
+++ b/llvm/lib/Object/IRSymtab.cpp
@@ -42,6 +42,12 @@
using namespace llvm;
using namespace irsymtab;
+static const char *LibcallRoutineNames[] = {
+#define HANDLE_LIBCALL(code, name) name,
+#include "llvm/IR/RuntimeLibcalls.def"
+#undef HANDLE_LIBCALL
+};
+
namespace {
const char *getExpectedProducerName() {
@@ -226,7 +232,13 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
setStr(Sym.IRName, GV->getName());
- if (Used.count(GV))
+ bool IsBuiltinFunc = false;
+
+ for (const char *LibcallName : LibcallRoutineNames)
+ if (GV->getName() == LibcallName)
+ IsBuiltinFunc = true;
+
+ if (Used.count(GV) || IsBuiltinFunc)
Sym.Flags |= 1 << storage::Symbol::FB_used;
if (GV->isThreadLocal())
Sym.Flags |= 1 << storage::Symbol::FB_tls;
OpenPOWER on IntegriCloud