From e0577ce367759127893def95ce63910de15de1d5 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Tue, 2 May 2023 10:43:23 -0700 Subject: [PATCH] [MemProf] Removed unused allocation type Removes the 'notcoldandcold' allocation type summary (de)serialization support added in D135714, after realizing that this will never be generated in practice. There are 2 uses of the allocation type keywords in the summary. One is for the individual profiled memprof context summaries, and each context can only be assigned a single type of hotness. The second is in the clone version information produced by the MemProfContextDisambiguation whole program step, and we only create a clone for a specific allocation type. Differential Revision: https://reviews.llvm.org/D149669 --- llvm/include/llvm/AsmParser/LLToken.h | 1 - llvm/lib/AsmParser/LLLexer.cpp | 1 - llvm/lib/AsmParser/LLParser.cpp | 6 +----- llvm/lib/IR/AsmWriter.cpp | 7 +------ llvm/test/Assembler/thinlto-memprof-summary.ll | 4 ++-- 5 files changed, 4 insertions(+), 15 deletions(-) diff --git a/llvm/include/llvm/AsmParser/LLToken.h b/llvm/include/llvm/AsmParser/LLToken.h index 4f841c5..38e6170 100644 --- a/llvm/include/llvm/AsmParser/LLToken.h +++ b/llvm/include/llvm/AsmParser/LLToken.h @@ -434,7 +434,6 @@ enum Kind { kw_versions, kw_memProf, kw_notcold, - kw_notcoldandcold, // GV's with __attribute__((no_sanitize("address"))), or things in // -fsanitize-ignorelist when built with ASan. diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index f24c410..6525dfd 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -799,7 +799,6 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(versions); KEYWORD(memProf); KEYWORD(notcold); - KEYWORD(notcoldandcold); #undef KEYWORD diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 8ee1b66..d64a267 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -9979,7 +9979,7 @@ bool LLParser::parseMemProfs(std::vector &MIBs) { } /// AllocType -/// := ('none'|'notcold'|'cold'|'notcoldandcold') +/// := ('none'|'notcold'|'cold') bool LLParser::parseAllocType(uint8_t &AllocType) { switch (Lex.getKind()) { case lltok::kw_none: @@ -9991,10 +9991,6 @@ bool LLParser::parseAllocType(uint8_t &AllocType) { case lltok::kw_cold: AllocType = (uint8_t)AllocationType::Cold; break; - case lltok::kw_notcoldandcold: - AllocType = - (uint8_t)AllocationType::NotCold | (uint8_t)AllocationType::Cold; - break; default: return error(Lex.getLoc(), "invalid alloc type"); } diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index d9404bd..3e19b3c 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -3210,10 +3210,7 @@ void AssemblyWriter::printFunctionSummary(const FunctionSummary *FS) { printTypeIdInfo(*TIdInfo); // The AllocationType identifiers capture the profiled context behavior - // reaching a specific static allocation site (possibly cloned). Thus - // "notcoldandcold" implies there are multiple contexts which reach this site, - // some of which are cold and some of which are not, and that need to - // disambiguate via cloning or other context identification. + // reaching a specific static allocation site (possibly cloned). auto AllocTypeName = [](uint8_t Type) -> const char * { switch (Type) { case (uint8_t)AllocationType::None: @@ -3222,8 +3219,6 @@ void AssemblyWriter::printFunctionSummary(const FunctionSummary *FS) { return "notcold"; case (uint8_t)AllocationType::Cold: return "cold"; - case (uint8_t)AllocationType::NotCold | (uint8_t)AllocationType::Cold: - return "notcoldandcold"; } llvm_unreachable("Unexpected alloc type"); }; diff --git a/llvm/test/Assembler/thinlto-memprof-summary.ll b/llvm/test/Assembler/thinlto-memprof-summary.ll index 92e085e..20b1306 100644 --- a/llvm/test/Assembler/thinlto-memprof-summary.ll +++ b/llvm/test/Assembler/thinlto-memprof-summary.ll @@ -5,7 +5,7 @@ ^0 = module: (path: "thinlto-memprof-summary.o", hash: (1369602428, 2747878711, 259090915, 2507395659, 1141468049)) ;; Function with single alloc, multiple memprof MIBs, no versioning -^1 = gv: (guid: 23, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), allocs: ((versions: (none), memProf: ((type: notcold, stackIds: (8632435727821051414)), (type: cold, stackIds: (15025054523792398438, 12345678)), (type: notcoldandcold, stackIds: (23456789)))))))) +^1 = gv: (guid: 23, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), allocs: ((versions: (none), memProf: ((type: notcold, stackIds: (8632435727821051414)), (type: cold, stackIds: (15025054523792398438, 12345678)))))))) ;; Function with callsite stack ids calling above function, no versioning ^2 = gv: (guid: 25, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 22, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 1, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^1)), callsites: ((callee: ^1, clones: (0), stackIds: (8632435727821051414)), (callee: ^1, clones: (0), stackIds: (15025054523792398438, 12345678)), (callee: ^1, clones: (0), stackIds: (23456789)))))) ;; Function with multiple allocs, multiple memprof MIBs, multiple versions @@ -17,7 +17,7 @@ ; Make sure we get back from llvm-dis what we put in via llvm-as. ; CHECK: ^0 = module: (path: "thinlto-memprof-summary.o", hash: (1369602428, 2747878711, 259090915, 2507395659, 1141468049)) -; CHECK: ^1 = gv: (guid: 23, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), allocs: ((versions: (none), memProf: ((type: notcold, stackIds: (8632435727821051414)), (type: cold, stackIds: (15025054523792398438, 12345678)), (type: notcoldandcold, stackIds: (23456789)))))))) +; CHECK: ^1 = gv: (guid: 23, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), allocs: ((versions: (none), memProf: ((type: notcold, stackIds: (8632435727821051414)), (type: cold, stackIds: (15025054523792398438, 12345678)))))))) ; CHECK: ^2 = gv: (guid: 25, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 22, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 1, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^1)), callsites: ((callee: ^1, clones: (0), stackIds: (8632435727821051414)), (callee: ^1, clones: (0), stackIds: (15025054523792398438, 12345678)), (callee: ^1, clones: (0), stackIds: (23456789)))))) ; CHECK: ^3 = gv: (guid: 26, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 2, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), allocs: ((versions: (cold, notcold), memProf: ((type: notcold, stackIds: (3456789)), (type: cold, stackIds: (456789)))), (versions: (notcold, cold), memProf: ((type: cold, stackIds: (3456789)), (type: notcold, stackIds: (456789)))))))) ; CHECK: ^4 = gv: (guid: 27, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 22, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 1, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^3)), callsites: ((callee: ^3, clones: (0, 1), stackIds: (3456789)), (callee: ^3, clones: (1, 1), stackIds: (456789)))))) -- 2.7.4