[ExecutionEngine] Add JITSymbolFlags::fromSummary(GlobalValueSummary*)

Summary: A function that creates JITSymbolFlags from a GlobalValueSummary. Similar functions exist: fromGlobalValue(), fromObjectSymbol()

Reviewers: lhames

Reviewed By: lhames

Subscribers: hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75082
This commit is contained in:
Stefan Gränitz 2020-02-29 11:52:19 +00:00
parent bd9cd2fc4c
commit ec1e7faf65
2 changed files with 22 additions and 0 deletions

View File

@ -30,6 +30,7 @@
namespace llvm { namespace llvm {
class GlobalValue; class GlobalValue;
class GlobalValueSummary;
namespace object { namespace object {
@ -160,6 +161,10 @@ public:
/// value. /// value.
static JITSymbolFlags fromGlobalValue(const GlobalValue &GV); static JITSymbolFlags fromGlobalValue(const GlobalValue &GV);
/// Construct a JITSymbolFlags value based on the flags of the given global
/// value summary.
static JITSymbolFlags fromSummary(GlobalValueSummary *S);
/// Construct a JITSymbolFlags value based on the flags of the given libobject /// Construct a JITSymbolFlags value based on the flags of the given libobject
/// symbol. /// symbol.
static Expected<JITSymbolFlags> static Expected<JITSymbolFlags>

View File

@ -14,6 +14,7 @@
#include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalValue.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
using namespace llvm; using namespace llvm;
@ -36,6 +37,22 @@ JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
return Flags; return Flags;
} }
JITSymbolFlags llvm::JITSymbolFlags::fromSummary(GlobalValueSummary *S) {
JITSymbolFlags Flags = JITSymbolFlags::None;
auto L = S->linkage();
if (GlobalValue::isWeakLinkage(L) || GlobalValue::isLinkOnceLinkage(L))
Flags |= JITSymbolFlags::Weak;
if (GlobalValue::isCommonLinkage(L))
Flags |= JITSymbolFlags::Common;
if (GlobalValue::isExternalLinkage(L) || GlobalValue::isExternalWeakLinkage(L))
Flags |= JITSymbolFlags::Exported;
if (isa<FunctionSummary>(S))
Flags |= JITSymbolFlags::Callable;
return Flags;
}
Expected<JITSymbolFlags> Expected<JITSymbolFlags>
llvm::JITSymbolFlags::fromObjectSymbol(const object::SymbolRef &Symbol) { llvm::JITSymbolFlags::fromObjectSymbol(const object::SymbolRef &Symbol) {
JITSymbolFlags Flags = JITSymbolFlags::None; JITSymbolFlags Flags = JITSymbolFlags::None;