diff --git a/llvm/include/llvm/CodeGen/RuntimeLibcalls.h b/llvm/include/llvm/CodeGen/RuntimeLibcalls.h index 016bef1702c4c9..28567a1ce43753 100644 --- a/llvm/include/llvm/CodeGen/RuntimeLibcalls.h +++ b/llvm/include/llvm/CodeGen/RuntimeLibcalls.h @@ -29,7 +29,7 @@ namespace RTLIB { /// enum Libcall { #define HANDLE_LIBCALL(code, name) code, - #include "RuntimeLibcalls.def" + #include "llvm/IR/RuntimeLibcalls.def" #undef HANDLE_LIBCALL }; diff --git a/llvm/include/llvm/CodeGen/RuntimeLibcalls.def b/llvm/include/llvm/IR/RuntimeLibcalls.def similarity index 100% rename from llvm/include/llvm/CodeGen/RuntimeLibcalls.def rename to llvm/include/llvm/IR/RuntimeLibcalls.def diff --git a/llvm/include/llvm/module.modulemap b/llvm/include/llvm/module.modulemap index 6fc728295f6e88..649cdf3b0a89c8 100644 --- a/llvm/include/llvm/module.modulemap +++ b/llvm/include/llvm/module.modulemap @@ -26,7 +26,6 @@ module LLVM_Backend { // These are intended for (repeated) textual inclusion. textual header "CodeGen/CommandFlags.inc" textual header "CodeGen/DIEValue.def" - textual header "CodeGen/RuntimeLibcalls.def" } module Target { @@ -222,6 +221,7 @@ module LLVM_IR { textual header "IR/Instruction.def" textual header "IR/Metadata.def" textual header "IR/Value.def" + textual header "IR/RuntimeLibcalls.def" } module LLVM_IRReader { requires cplusplus umbrella "IRReader" module * { export * } } diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 96e03388d5c14b..43f4bad595e306 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -118,7 +118,7 @@ static cl::opt MinPercentageForPredictableBranch( void TargetLoweringBase::InitLibcalls(const Triple &TT) { #define HANDLE_LIBCALL(code, name) \ setLibcallName(RTLIB::code, name); -#include "llvm/CodeGen/RuntimeLibcalls.def" +#include "llvm/IR/RuntimeLibcalls.def" #undef HANDLE_LIBCALL // Initialize calling conventions to their default. for (int LC = 0; LC < RTLIB::UNKNOWN_LIBCALL; ++LC) diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 51081d8b5e642e..344d565349c093 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; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp index e5180ad7f2e933..fe8a5e4c06f1aa 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp @@ -470,7 +470,7 @@ struct StaticLibcallNameMap { StaticLibcallNameMap() { static const std::pair NameLibcalls[] = { #define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code}, -#include "llvm/CodeGen/RuntimeLibcalls.def" +#include "llvm/IR/RuntimeLibcalls.def" #undef HANDLE_LIBCALL }; for (const auto &NameLibcall : NameLibcalls) {