10 #ifndef LLVM_IR_MODULESUMMARYINDEXYAML_H 11 #define LLVM_IR_MODULESUMMARYINDEXYAML_H 31 io.mapOptional(
"Kind", res.
TheKind);
33 io.mapOptional(
"AlignLog2", res.
AlignLog2);
34 io.mapOptional(
"SizeM1", res.
SizeM1);
35 io.mapOptional(
"BitMask", res.
BitMask);
45 io.enumCase(value,
"UniformRetVal",
47 io.enumCase(value,
"UniqueRetVal",
49 io.enumCase(value,
"VirtualConstProp",
56 io.mapOptional(
"Kind", res.
TheKind);
57 io.mapOptional(
"Info", res.
Info);
58 io.mapOptional(
"Byte", res.
Byte);
59 io.mapOptional(
"Bit", res.
Bit);
64 struct CustomMappingTraits<
65 std::map<std::vector<uint64_t>, WholeProgramDevirtResolution::ByArg>> {
69 std::vector<uint64_t>
Args;
70 std::pair<StringRef, StringRef>
P = {
"", Key};
71 while (!P.second.empty()) {
72 P = P.second.
split(
',');
74 if (P.first.getAsInteger(0, Arg)) {
75 io.setError(
"key not an integer");
80 io.mapRequired(Key.
str().c_str(), V[
Args]);
87 for (uint64_t
Arg :
P.first) {
92 io.mapRequired(Key.c_str(),
P.second);
101 io.enumCase(value,
"BranchFunnel",
108 io.mapOptional(
"Kind", res.
TheKind);
110 io.mapOptional(
"ResByArg", res.
ResByArg);
115 struct CustomMappingTraits<
std::map<uint64_t, WholeProgramDevirtResolution>> {
117 std::map<uint64_t, WholeProgramDevirtResolution> &V) {
120 io.setError(
"key not an integer");
123 io.mapRequired(Key.
str().c_str(), V[KeyInt]);
125 static void output(IO &io, std::map<uint64_t, WholeProgramDevirtResolution> &V) {
133 io.mapOptional(
"TTRes", summary.
TTRes);
134 io.mapOptional(
"WPDRes", summary.
WPDRes);
144 TypeCheckedLoadVCalls;
146 TypeCheckedLoadConstVCalls;
157 io.mapOptional(
"GUID",
id.GUID);
158 io.mapOptional(
"Offset",
id.
Offset);
164 io.mapOptional(
"VFunc",
id.VFunc);
165 io.mapOptional(
"Args",
id.
Args);
180 io.mapOptional(
"Linkage", summary.
Linkage);
182 io.mapOptional(
"Live", summary.
Live);
183 io.mapOptional(
"Local", summary.
IsLocal);
184 io.mapOptional(
"Refs", summary.
Refs);
185 io.mapOptional(
"TypeTests", summary.
TypeTests);
188 io.mapOptional(
"TypeTestAssumeConstVCalls",
190 io.mapOptional(
"TypeCheckedLoadConstVCalls",
206 std::vector<FunctionSummaryYaml> FSums;
207 io.mapRequired(Key.
str().c_str(), FSums);
210 io.setError(
"key not an integer");
213 if (!V.count(KeyInt))
214 V.emplace(KeyInt,
false);
215 auto &Elem = V.find(KeyInt)->second;
216 for (
auto &FSum : FSums) {
217 std::vector<ValueInfo> Refs;
218 for (
auto &RefGUID : FSum.Refs) {
219 if (!V.count(RefGUID))
220 V.emplace(RefGUID,
false);
221 Refs.push_back(
ValueInfo(
false, &*V.find(RefGUID)));
223 Elem.SummaryList.push_back(llvm::make_unique<FunctionSummary>(
225 static_cast<GlobalValue::LinkageTypes>(FSum.Linkage),
226 FSum.NotEligibleToImport, FSum.Live, FSum.IsLocal),
229 std::move(FSum.TypeTestAssumeVCalls),
230 std::move(FSum.TypeCheckedLoadVCalls),
231 std::move(FSum.TypeTestAssumeConstVCalls),
232 std::move(FSum.TypeCheckedLoadConstVCalls)));
237 std::vector<FunctionSummaryYaml> FSums;
238 for (
auto &Sum :
P.second.SummaryList) {
239 if (
auto *FSum = dyn_cast<FunctionSummary>(Sum.get())) {
240 std::vector<uint64_t> Refs;
241 for (
auto &
VI : FSum->refs())
242 Refs.push_back(
VI.getGUID());
245 static_cast<bool>(FSum->flags().NotEligibleToImport),
246 static_cast<bool>(FSum->flags().Live),
247 static_cast<bool>(FSum->flags().DSOLocal), Refs,
248 FSum->type_tests(), FSum->type_test_assume_vcalls(),
249 FSum->type_checked_load_vcalls(),
250 FSum->type_test_assume_const_vcalls(),
251 FSum->type_checked_load_const_vcalls()});
263 io.mapRequired(Key.
str().c_str(), TId);
267 for (
auto TidIter = V.begin(); TidIter != V.end(); TidIter++)
268 io.mapRequired(TidIter->second.first.c_str(), TidIter->second.second);
274 io.mapOptional(
"GlobalValueMap", index.GlobalValueMap);
275 io.mapOptional(
"TypeIdMap", index.TypeIdMap);
276 io.mapOptional(
"WithGlobalValueDeadStripping",
277 index.WithGlobalValueDeadStripping);
279 if (io.outputting()) {
280 std::vector<std::string> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
281 index.CfiFunctionDefs.end());
282 io.mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
283 std::vector<std::string> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
284 index.CfiFunctionDecls.end());
285 io.mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
287 std::vector<std::string> CfiFunctionDefs;
288 io.mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
289 index.CfiFunctionDefs = {CfiFunctionDefs.begin(), CfiFunctionDefs.end()};
290 std::vector<std::string> CfiFunctionDecls;
291 io.mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
292 index.CfiFunctionDecls = {CfiFunctionDecls.begin(),
293 CfiFunctionDecls.end()};
std::vector< FunctionSummary::ConstVCall > TypeCheckedLoadConstVCalls
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
This class represents lattice values for constants.
std::multimap< GlobalValue::GUID, std::pair< std::string, TypeIdSummary > > TypeIdSummaryMapTy
Map of a type GUID to type id string and summary (multimap used in case of GUID conflicts).
Unsatisfiable type (i.e. no global has this type metadata)
uint64_t Info
Additional information for the resolution:
static void enumeration(IO &io, WholeProgramDevirtResolution::ByArg::Kind &value)
static void enumeration(IO &io, WholeProgramDevirtResolution::Kind &value)
Kind
Specifies which kind of type check we should emit for this byte array.
Virtual constant propagation.
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair...
std::vector< uint64_t > TypeTests
static void inputOne(IO &io, StringRef Key, GlobalValueSummaryMapTy &V)
static void mapping(IO &io, WholeProgramDevirtResolution::ByArg &res)
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module...
Just do a regular virtual call.
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
enum llvm::WholeProgramDevirtResolution::Kind TheKind
std::vector< FunctionSummary::VFuncId > TypeCheckedLoadVCalls
Uniform return value optimization.
static void output(IO &io, GlobalValueSummaryMapTy &V)
std::vector< uint64_t > Refs
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static void output(IO &io, std::map< uint64_t, WholeProgramDevirtResolution > &V)
Class to hold module path string table and global value map, and encapsulate methods for operating on...
static void output(IO &io, std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > &V)
static void mapping(IO &io, FunctionSummary::VFuncId &id)
static void inputOne(IO &io, StringRef Key, std::map< uint64_t, WholeProgramDevirtResolution > &V)
static void mapping(IO &io, ModuleSummaryIndex &index)
static void inputOne(IO &io, StringRef Key, std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > &V)
Single element (last example in "Short Inline Bit Vectors")
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
An "identifier" for a virtual function.
Struct that holds a reference to a particular GUID in a global value summary.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Single implementation devirtualization.
std::vector< FunctionSummary::VFuncId > TypeTestAssumeVCalls
static void mapping(IO &io, TypeTestResolution &res)
std::vector< FunctionSummary::ConstVCall > TypeTestAssumeConstVCalls
std::string utostr(uint64_t X, bool isNeg=false)
std::string SingleImplName
enum llvm::TypeTestResolution::Kind TheKind
A specification for a virtual function call with all constant integer arguments.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
amdgpu Simplify well known AMD library false Value Value * Arg
Test a byte array (first example)
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument, "this"), where the key is the argument vector.
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors") ...
Flags specific to function summaries.
Inlined bit vector ("Short Inline Bit Vectors")
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
Function summary information to aid decisions and implementation of importing.
static void mapping(IO &io, TypeIdSummary &summary)
static void mapping(IO &io, FunctionSummaryYaml &summary)
static void output(IO &io, TypeIdSummaryMapTy &V)
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
static void enumeration(IO &io, TypeTestResolution::Kind &value)
Just do a regular virtual call.
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
StringRef - Represent a constant reference to a string, i.e.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Unique return value optimization.
static void mapping(IO &io, FunctionSummary::ConstVCall &id)
static void mapping(IO &io, WholeProgramDevirtResolution &res)