[compiler-rt] [llvm] [InstrProf] Add vtables with type metadata into symtab (PR #81051)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 13:52:27 PDT 2024
================
@@ -476,11 +476,46 @@ Error InstrProfSymtab::create(Module &M, bool InLTO) {
return E;
}
+ SmallVector<MDNode *, 2> Types;
+ for (GlobalVariable &G : M.globals()) {
+ if (!G.hasName() || !G.hasMetadata(LLVMContext::MD_type))
+ continue;
+ if (Error E = addVTableWithName(
+ G, getIRPGOObjectName(G, InLTO, /* PGONameMetadata */ nullptr)))
+ return E;
+ }
+
Sorted = false;
finalizeSymtab();
return Error::success();
}
+Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
+ StringRef VTablePGOName) {
+
+ auto mapName = [&](StringRef Name) -> Error {
+ // Use 'addSymbolName' rather than 'addVTableName' as 'VTableNames' is
----------------
minglotus-6 wrote:
`MD5VTableMap` and `MD5FuncMap` have different container types (`DenseMap` vs `vector`), which makes hard to unify the container methods (`try_emplace` vs `emplace_back`) in a lambda function.
I added a TODO (in InstrProf.h) to unify the container type (but aim to use separate container instances), which would help to unify the lambda function.
https://github.com/llvm/llvm-project/pull/81051
More information about the llvm-commits
mailing list