[PATCH] D75082: [ExecutionEngine] Add JITSymbolFlags::fromSummary(GlobalValueSummary*)
Stefan Gränitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 24 14:38:37 PST 2020
sgraenitz created this revision.
sgraenitz added a reviewer: lhames.
Herald added subscribers: arphaman, dexonsmith, steven_wu, hiraditya.
Herald added a project: LLVM.
A function that creates JITSymbolFlags from a GlobalValueSummary. Similar functions exist: fromGlobalValue(), fromObjectSymbol()
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75082
Files:
llvm/examples/ThinLtoJIT/ModuleIndex.cpp
llvm/include/llvm/ExecutionEngine/JITSymbol.h
llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
Index: llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
===================================================================
--- llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
+++ llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
@@ -14,6 +14,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/Object/ObjectFile.h"
using namespace llvm;
@@ -36,6 +37,22 @@
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>
llvm::JITSymbolFlags::fromObjectSymbol(const object::SymbolRef &Symbol) {
JITSymbolFlags Flags = JITSymbolFlags::None;
Index: llvm/include/llvm/ExecutionEngine/JITSymbol.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/JITSymbol.h
+++ llvm/include/llvm/ExecutionEngine/JITSymbol.h
@@ -30,6 +30,7 @@
namespace llvm {
class GlobalValue;
+class GlobalValueSummary;
namespace object {
@@ -161,6 +162,10 @@
/// value.
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
/// symbol.
static Expected<JITSymbolFlags>
Index: llvm/examples/ThinLtoJIT/ModuleIndex.cpp
===================================================================
--- llvm/examples/ThinLtoJIT/ModuleIndex.cpp
+++ llvm/examples/ThinLtoJIT/ModuleIndex.cpp
@@ -425,7 +425,7 @@
if (GlobalValueSummary *S = getSummary(Guid)) {
ModuleInfo &MI = MIs[S->modulePath()];
- // TODO: Infer symbol flags from the ThinLTO module summary.
+ MI.SymbolFlags[KV.first] = JITSymbolFlags::fromSummary(S);
MI.Guids.push_back(Guid);
if (!isa<FunctionSummary>(S))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75082.246311.patch
Type: text/x-patch
Size: 2466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200224/9db5df58/attachment.bin>
More information about the llvm-commits
mailing list