[llvm] ec1e7fa - [ExecutionEngine] Add JITSymbolFlags::fromSummary(GlobalValueSummary*)
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 29 03:57:33 PST 2020
Author: Stefan Gränitz
Date: 2020-02-29T11:54:03Z
New Revision: ec1e7faf65aecf3dd6c325ff7ef585fd3fce6b08
URL: https://github.com/llvm/llvm-project/commit/ec1e7faf65aecf3dd6c325ff7ef585fd3fce6b08
DIFF: https://github.com/llvm/llvm-project/commit/ec1e7faf65aecf3dd6c325ff7ef585fd3fce6b08.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITSymbol.h
llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITSymbol.h b/llvm/include/llvm/ExecutionEngine/JITSymbol.h
index 67e531afb9b9..a7e8b3aef7c1 100644
--- a/llvm/include/llvm/ExecutionEngine/JITSymbol.h
+++ b/llvm/include/llvm/ExecutionEngine/JITSymbol.h
@@ -30,6 +30,7 @@
namespace llvm {
class GlobalValue;
+class GlobalValueSummary;
namespace object {
@@ -160,6 +161,10 @@ class JITSymbolFlags {
/// 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>
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
index 4e2d0f422f39..031a055a7959 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
+++ b/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 @@ JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
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;
More information about the llvm-commits
mailing list