llvm.org GIT mirror llvm / 04638a6
[PGO] Enable compression in pgo instrumentation This reduces sizes of instrumented object files, final binaries, process images, and raw profile data. The format of the indexed profile data remain the same. Differential Revision: http://reviews.llvm.org/D16388 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260117 91177308-0d34-0410-b5e6-96231b3b80d8 Xinliang David Li 4 years ago
17 changed file(s) with 217 addition(s) and 110 deletion(s). Raw diff Collapse all Expand all
259259 i32 20, ; The length of the string that contains the encoded coverage mapping data
260260 i32 0, ; Coverage mapping format version
261261 },
262 [2 x { i8*, i32, i32, i64 }] [ ; Function records
263 { i8*, i32, i32, i64 } { i8* getelementptr inbounds ([3 x i8]* @__profn_foo, i32 0, i32 0), ; Function's name
264 i32 3, ; Function's name length
262 [2 x { i64, i32, i64 }] [ ; Function records
263 { i64, i32, i64 } {
264 i64 0x5cf8c24cdb18bdac, ; Function's name MD5
265265 i32 9, ; Function's encoded coverage mapping data string length
266266 i64 0 ; Function's structural hash
267267 },
268 { i8*, i32, i32, i64 } { i8* getelementptr inbounds ([3 x i8]* @__profn_bar, i32 0, i32 0), ; Function's name
269 i32 3, ; Function's name length
268 { i64, i32, i64 } {
269 i64 0xe413754a191db537, ; Function's name MD5
270270 i32 9, ; Function's encoded coverage mapping data string length
271271 i64 0 ; Function's structural hash
272272 }],
273273 [40 x i8] c"..." ; Encoded data (dissected later)
274274 }, section "__llvm_covmap", align 8
275275
276 The function record layout has evolved since version 1. In version 1, the function record for *foo* is defined as follows:
277
278 .. code-block:: llvm
279
280 { i8*, i32, i32, i64 } { i8* getelementptr inbounds ([3 x i8]* @__profn_foo, i32 0, i32 0), ; Function's name
281 i32 3, ; Function's name length
282 i32 9, ; Function's encoded coverage mapping data string length
283 i64 0 ; Function's structural hash
284 }
285
286
276287 Coverage Mapping Header:
277288 ------------------------
278289
295306
296307 .. code-block:: llvm
297308
298 { i8*, i32, i32, i64 }
299
300 It contains the pointer to the function's name, function's name length,
301 the length of the encoded mapping data for that function, and function's
302 hash value.
309 { i64, i32, i64 }
310
311 It contains function name's MD5, the length of the encoded mapping data for that function, and function's
312 structural hash value.
303313
304314 Encoded data:
305315 -------------
487487 // [ArrayEnd]
488488 // [Encoded Region Mapping Data]
489489 LLVM_PACKED_START
490 template struct CovMapFunctionRecord {
490 template struct CovMapFunctionRecordV1 {
491 #define COVMAP_V1
491492 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
492493 #include "llvm/ProfileData/InstrProfData.inc"
494 #undef COVMAP_V1
493495
494496 // Return the structural hash associated with the function.
495497 template uint64_t getFuncHash() const {
515517 return std::error_code();
516518 }
517519 };
520
521 template struct CovMapFunctionRecord {
522 #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
523 #include "llvm/ProfileData/InstrProfData.inc"
524
525 // Return the structural hash associated with the function.
526 template uint64_t getFuncHash() const {
527 return support::endian::byte_swap(FuncHash);
528 }
529 // Return the coverage map data size for the funciton.
530 template uint32_t getDataSize() const {
531 return support::endian::byte_swap(DataSize);
532 }
533 // Return function lookup key. The value is consider opaque.
534 template uint64_t getFuncNameRef() const {
535 return support::endian::byte_swap(NameRef);
536 }
537 // Return the PGO name of the function */
538 template
539 std::error_code getFuncName(InstrProfSymtab &ProfileNames,
540 StringRef &FuncName) const {
541 IntPtrT NameRef = getFuncNameRef();
542 FuncName = ProfileNames.getFuncName(NameRef);
543 return std::error_code();
544 }
545 };
546
518547 // Per module coverage mapping data header, i.e. CoverageMapFileHeader
519548 // documented above.
520549 struct CovMapHeader {
538567
539568 enum CovMapVersion {
540569 Version1 = 0,
541 // The current version is Version1
570 // Function's name reference from CovMapFuncRecord is changed from raw
571 // name string pointer to MD5 to support name section compression. Name
572 // section is also compressed.
573 Version2 = 1,
574 // The current version is Version2
542575 CurrentVersion = INSTR_PROF_COVMAP_VERSION
543576 };
544577
545578 template struct CovMapTraits {
546579 typedef CovMapFunctionRecord CovMapFuncRecordType;
580 typedef uint64_t NameRefType;
581 };
582
583 template struct CovMapTraits {
584 typedef CovMapFunctionRecordV1 CovMapFuncRecordType;
547585 typedef IntPtrT NameRefType;
548586 };
549587
8484 /// associated with a COMDAT function.
8585 inline StringRef getInstrProfComdatPrefix() { return "__profv_"; }
8686
87 /// Return the name of the variable holding the strings (possibly compressed)
88 /// of all function's PGO names.
89 inline StringRef getInstrProfNamesVarName() {
90 return "__llvm_prf_nm";
91 }
92
8793 /// Return the name of a covarage mapping variable (internal linkage)
8894 /// for each instrumented source module. Such variables are allocated
8995 /// in the __llvm_covmap section.
112118 /// data for one instrumented function.
113119 inline StringRef getInstrProfRegFuncName() {
114120 return "__llvm_profile_register_function";
121 }
122
123 /// Return the name of the runtime interface that registers the PGO name strings.
124 inline StringRef getInstrProfNamesRegFuncName() {
125 return "__llvm_profile_register_names_function";
115126 }
116127
117128 /// Return the name of the runtime initialization method that is generated by
765776
766777 namespace RawInstrProf {
767778
779 // Version 1: First version
780 // Version 2: Added value profile data section. Per-function control data
781 // struct has more fields to describe value profile information.
782 // Version 3: Compressed name section support. Function PGO name reference
783 // from control data struct is changed from raw pointer to Name's MD5 value.
768784 const uint64_t Version = INSTR_PROF_RAW_VERSION;
769785
770786 template inline uint64_t getMagic();
6363 #else
6464 #define INSTR_PROF_DATA_DEFINED
6565 #endif
66
67 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
68 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
69 NamePtr->getType()->getPointerElementType()->getArrayNumElements()))
70 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
71 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
66 INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \
67 ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
68 IndexedInstrProf::ComputeHash(getPGOFuncNameVarInitializer(Inc->getName()))))
7269 INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
7370 ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
7471 Inc->getHash()->getZExtValue()))
75 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), NamePtr, \
76 ConstantExpr::getBitCast(NamePtr, llvm::Type::getInt8PtrTy(Ctx)))
7772 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
7873 ConstantExpr::getBitCast(CounterPtr, \
7974 llvm::Type::getInt64PtrTy(Ctx)))
8176 FunctionAddr)
8277 INSTR_PROF_DATA(IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \
8378 ConstantPointerNull::get(Int8PtrTy))
79 INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \
80 ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters))
8481 INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \
8582 ConstantArray::get(Int16ArrayTy, Int16ArrayVals))
8683 #undef INSTR_PROF_DATA
152149 #else
153150 #define INSTR_PROF_DATA_DEFINED
154151 #endif
152 #ifdef COVMAP_V1
155153 COVMAP_FUNC_RECORD(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), \
156154 NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, \
157155 llvm::Type::getInt8PtrTy(Ctx)))
158156 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), NameSize, \
159 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
157 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), \
160158 NameValue.size()))
159 #else
160 COVMAP_FUNC_RECORD(const int64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \
161 llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \
162 llvm::IndexedInstrProf::ComputeHash(NameValue)))
163 #endif
161164 COVMAP_FUNC_RECORD(const uint32_t, llvm::Type::getInt32Ty(Ctx), DataSize, \
162165 llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx),\
163166 CoverageMapping.size()))
690693 (uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
691694 (uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
692695
693 /* Raw profile format version. */
694 #define INSTR_PROF_RAW_VERSION 2
696 /* Raw profile format version (start from 1). */
697 #define INSTR_PROF_RAW_VERSION 3
698 /* Indexed profile format version (start from 1). */
695699 #define INSTR_PROF_INDEX_VERSION 4
696 #define INSTR_PROF_COVMAP_VERSION 0
700 /* Coverage mapping format vresion (start from 0). */
701 #define INSTR_PROF_COVMAP_VERSION 1
697702
698703 /* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
699704 * version for other variants of profile. We set the lowest bit of the upper 8
159159 const RawInstrProf::ProfileData *DataEnd;
160160 const uint64_t *CountersStart;
161161 const char *NamesStart;
162 uint64_t NamesSize;
162163 const uint8_t *ValueDataStart;
163164 const char *ProfileEnd;
164165 uint32_t ValueKindLast;
215216 ptrdiff_t Offset = (swap(CounterPtr) - CountersDelta) / sizeof(uint64_t);
216217 return CountersStart + Offset;
217218 }
218 const char *getName(IntPtrT NamePtr) const {
219 ptrdiff_t Offset = (swap(NamePtr) - NamesDelta) / sizeof(char);
220 return NamesStart + Offset;
219 StringRef getName(uint64_t NameRef) const {
220 return Symtab->getFuncName(swap(NameRef));
221221 }
222222 };
223223
425425 case CovMapVersion::Version1:
426426 return llvm::make_unique
427427 CovMapVersion::Version1, IntPtrT, Endian>>(P, R, F);
428 case CovMapVersion::Version2:
429 // Decompress the name data.
430 P.create(P.getNameData());
431 return llvm::make_unique
432 CovMapVersion::Version2, IntPtrT, Endian>>(P, R, F);
428433 }
429434 llvm_unreachable("Unsupported version");
430435 }
279279
280280 template
281281 void RawInstrProfReader::createSymtab(InstrProfSymtab &Symtab) {
282 Symtab.create(StringRef(NamesStart, NamesSize));
282283 for (const RawInstrProf::ProfileData *I = Data; I != DataEnd; ++I) {
283 StringRef FunctionName(getName(I->NamePtr), swap(I->NameSize));
284 Symtab.addFuncName(FunctionName);
285284 const IntPtrT FPtr = swap(I->FunctionPointer);
286285 if (!FPtr)
287286 continue;
288 Symtab.mapAddress(FPtr, IndexedInstrProf::ComputeHash(FunctionName));
287 Symtab.mapAddress(FPtr, I->NameRef);
289288 }
290289 Symtab.finalizeSymtab();
291290 }
300299 NamesDelta = swap(Header.NamesDelta);
301300 auto DataSize = swap(Header.DataSize);
302301 auto CountersSize = swap(Header.CountersSize);
303 auto NamesSize = swap(Header.NamesSize);
302 NamesSize = swap(Header.NamesSize);
304303 auto ValueDataSize = swap(Header.ValueDataSize);
305304 ValueKindLast = swap(Header.ValueKindLast);
306305
333332
334333 template
335334 std::error_code RawInstrProfReader::readName(InstrProfRecord &Record) {
336 Record.Name = StringRef(getName(Data->NamePtr), swap(Data->NameSize));
337 if (Record.Name.data() < NamesStart ||
338 Record.Name.data() + Record.Name.size() >
339 reinterpret_cast(ValueDataStart))
340 return error(instrprof_error::malformed);
335 Record.Name = getName(Data->NameRef);
341336 return success();
342337 }
343338
2626
2727 namespace {
2828
29 cl::opt DoNameCompression("enable-name-compression",
30 cl::desc("Enable name string compression"),
31 cl::init(true));
32
2933 class InstrProfiling : public ModulePass {
3034 public:
3135 static char ID;
5862 } PerFunctionProfileData;
5963 DenseMap ProfileDataMap;
6064 std::vector UsedVars;
65 std::vector ReferencedNames;
66 GlobalVariable *NamesVar;
67 size_t NamesSize;
6168
6269 bool isMachO() const {
6370 return Triple(M->getTargetTriple()).isOSBinFormatMachO();
101108 /// referring to them will also be created.
102109 GlobalVariable *getOrCreateRegionCounters(InstrProfIncrementInst *Inc);
103110
111 /// Emit the section with compressed function names.
112 void emitNameData();
113
104114 /// Emit runtime registration functions for each profile data variable.
105115 void emitRegistration();
106116
130140 bool MadeChange = false;
131141
132142 this->M = &M;
143 NamesVar = nullptr;
144 NamesSize = 0;
133145 ProfileDataMap.clear();
134146 UsedVars.clear();
135147
173185 if (!MadeChange)
174186 return false;
175187
188 emitNameData();
176189 emitRegistration();
177190 emitRuntimeHook();
178191 emitUses();
251264 assert(isa(V) && "Missing reference to function name");
252265 GlobalVariable *Name = cast(V);
253266
254 // Move the name variable to the right section.
255 Name->setSection(getNameSection());
256 Name->setAlignment(1);
267 Name->setLinkage(GlobalValue::PrivateLinkage);
268 ReferencedNames.push_back(Name);
257269 }
258270 }
259271
278290 // COFF format requires a COMDAT section to have a key symbol with the same
279291 // name. The linker targeting COFF also requires that the COMDAT
280292 // a section is associated to must precede the associating section. For this
281 // reason, we must choose the name var's name as the name of the comdat.
293 // reason, we must choose the counter var's name as the name of the comdat.
282294 StringRef ComdatPrefix = (Triple(M.getTargetTriple()).isOSBinFormatCOFF()
283 ? getInstrProfNameVarPrefix()
295 ? getInstrProfCountersVarPrefix()
284296 : getInstrProfComdatPrefix());
285297 return M.getOrInsertComdat(StringRef(getVarName(Inc, ComdatPrefix)));
286298 }
304316 Comdat *ProfileVarsComdat = nullptr;
305317 if (Fn->hasComdat())
306318 ProfileVarsComdat = getOrCreateProfileComdat(*M, Inc);
307 NamePtr->setSection(getNameSection());
308 NamePtr->setAlignment(1);
309 NamePtr->setComdat(ProfileVarsComdat);
310319
311320 uint64_t NumCounters = Inc->getNumCounters()->getZExtValue();
312321 LLVMContext &Ctx = M->getContext();
358367
359368 // Mark the data variable as used so that it isn't stripped out.
360369 UsedVars.push_back(Data);
370 // Now that the linkage set by the FE has been passed to the data and counter
371 // variables, reset Name variable's linkage and visibility to private so that
372 // it can be removed later by the compiler.
373 NamePtr->setLinkage(GlobalValue::PrivateLinkage);
374 // Collect the referenced names to be used by emitNameData.
375 ReferencedNames.push_back(NamePtr);
361376
362377 return CounterPtr;
378 }
379
380 void InstrProfiling::emitNameData() {
381 std::string UncompressedData;
382
383 if (ReferencedNames.empty())
384 return;
385
386 std::string CompressedNameStr;
387 collectPGOFuncNameStrings(ReferencedNames, CompressedNameStr,
388 DoNameCompression);
389
390 auto &Ctx = M->getContext();
391 auto *NamesVal = llvm::ConstantDataArray::getString(
392 Ctx, StringRef(CompressedNameStr), false);
393 NamesVar = new llvm::GlobalVariable(*M, NamesVal->getType(), true,
394 llvm::GlobalValue::PrivateLinkage,
395 NamesVal, getInstrProfNamesVarName());
396 NamesSize = CompressedNameStr.size();
397 NamesVar->setSection(getNameSection());
398 UsedVars.push_back(NamesVar);
363399 }
364400
365401 void InstrProfiling::emitRegistration() {
375411 // Construct the function.
376412 auto *VoidTy = Type::getVoidTy(M->getContext());
377413 auto *VoidPtrTy = Type::getInt8PtrTy(M->getContext());
414 auto *Int64Ty = Type::getInt64Ty(M->getContext());
378415 auto *RegisterFTy = FunctionType::get(VoidTy, false);
379416 auto *RegisterF = Function::Create(RegisterFTy, GlobalValue::InternalLinkage,
380417 getInstrProfRegFuncsName(), M);
388425
389426 IRBuilder<> IRB(BasicBlock::Create(M->getContext(), "", RegisterF));
390427 for (Value *Data : UsedVars)
391 IRB.CreateCall(RuntimeRegisterF, IRB.CreateBitCast(Data, VoidPtrTy));
428 if (Data != NamesVar)
429 IRB.CreateCall(RuntimeRegisterF, IRB.CreateBitCast(Data, VoidPtrTy));
430
431 if (NamesVar) {
432 Type *ParamTypes[] = {VoidPtrTy, Int64Ty};
433 auto *NamesRegisterTy =
434 FunctionType::get(VoidTy, makeArrayRef(ParamTypes), false);
435 auto *NamesRegisterF =
436 Function::Create(NamesRegisterTy, GlobalVariable::ExternalLinkage,
437 getInstrProfNamesRegFuncName(), M);
438 IRB.CreateCall(NamesRegisterF, {IRB.CreateBitCast(NamesVar, VoidPtrTy),
439 IRB.getInt64(NamesSize)});
440 }
441
392442 IRB.CreateRetVoid();
393443 }
394444
99
1010 @__profn__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", align 1
1111
12 ; CHECK: @__profn__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", section "{{.*}}__llvm_prf_names", comdat($__profv__Z3barIvEvv), align 1
12 ; CHECK: @__profn__Z3barIvEvv = private constant [11 x i8] c"_Z3barIvEvv", align 1
1313 ; CHECK: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat($__profv__Z3barIvEvv), align 8
14 ; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i32, i32, i64, i8*, i64*, i8*, i8*, [1 x i16] } { i32 11, i32 1, i64 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn__Z3barIvEvv, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8* null, i8* null, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__profv__Z3barIvEvv), align 8
14 ; CHECK: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8* null, i8* null, i32 1, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__profv__Z3barIvEvv), align 8
15 ; CHECK: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names"
1516
16 ; COFF: @__profn__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", section "{{.*}}__llvm_prf_names", comdat, align 1
17 ; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat($__profn__Z3barIvEvv), align 8
18 ; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i32, i32, i64, i8*, i64*, i8*, i8*, [1 x i16] } { i32 11, i32 1, i64 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn__Z3barIvEvv, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8* null, i8* null, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__profn__Z3barIvEvv), align 8
17
18 ; COFF: @__profn__Z3barIvEvv = private constant [11 x i8] c"_Z3barIvEvv", align 1
19 ; COFF: @__profc__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat, align 8
20 ; COFF: @__profd__Z3barIvEvv = linkonce_odr hidden global { i64, i64, i64*, i8*, i8*, i32, [1 x i16] } { i64 4947693190065689389, i64 0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc__Z3barIvEvv, i32 0, i32 0), i8* null, i8* null, i32 1, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__profc__Z3barIvEvv), align 8
1921
2022
2123 declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1
55 ; RUN: opt < %s -mtriple=x86_64-pc-solaris -instrprof -S | FileCheck %s -check-prefix=SOLARIS
66
77 @__profn_foo = hidden constant [3 x i8] c"foo"
8 ; MACHO: @__profn_foo = hidden constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1
9 ; ELF: @__profn_foo = hidden constant [3 x i8] c"foo", section "__llvm_prf_names", align 1
8 ; MACHO: @__profn_foo = private constant [3 x i8] c"foo"
9 ; ELF: @__profn_foo = private constant [3 x i8] c"foo"
1010
1111 ; MACHO: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
1212 ; ELF: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
1515 ; LINUX: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
1616 ; FREEBSD: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
1717 ; SOLARIS: @__profd_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
18
19 ; ELF: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names"
1820
1921 define void @foo() {
2022 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
22 target triple = "x86_64-apple-macosx10.10.0"
33
44 @__profn_foo = hidden constant [3 x i8] c"foo"
5 ; CHECK: @__profn_foo = hidden constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1
5 ; CHECK: @__profn_foo = private constant [3 x i8] c"foo"
66 @__profn_bar = hidden constant [4 x i8] c"bar\00"
7 ; CHECK: @__profn_bar = hidden constant [4 x i8] c"bar\00", section "__DATA,__llvm_prf_names", align 1
7 ; CHECK: @__profn_bar = private constant [4 x i8] c"bar\00"
88 @__profn_baz = hidden constant [3 x i8] c"baz"
9 ; CHECK: @__profn_baz = hidden constant [3 x i8] c"baz", section "__DATA,__llvm_prf_names", align 1
9 ; CHECK: @__profn_baz = private constant [3 x i8] c"baz"
1010
1111 ; CHECK: @__profc_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
1212 ; CHECK: @__profd_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
0 RUN: printf '\377lprofR\201' > %t
1 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
1 RUN: printf '\0\0\0\0\0\0\0\3' >> %t
22 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
33 RUN: printf '\0\0\0\0\0\0\0\3' >> %t
4 RUN: printf '\0\0\0\0\0\0\0\6' >> %t
4 RUN: printf '\0\0\0\0\0\0\0\20' >> %t
55 RUN: printf '\0\0\0\0\1\0\0\0' >> %t
66 RUN: printf '\0\0\0\0\2\0\0\0' >> %t
77 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
88 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
99 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1010
11 RUN: printf '\0\0\0\3' >> %t
12 RUN: printf '\0\0\0\1' >> %t
11 RUN: printf '\134\370\302\114\333\030\275\254' >> %t
1312 RUN: printf '\0\0\0\0\0\0\0\1' >> %t
14 RUN: printf '\2\0\0\0' >> %t
1513 RUN: printf '\1\0\0\0' >> %t
1614 RUN: printf '\0\0\0\0' >> %t
1715 RUN: printf '\0\0\0\0' >> %t
16 RUN: printf '\0\0\0\1' >> %t
1817 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1918
20 RUN: printf '\0\0\0\3' >> %t
21 RUN: printf '\0\0\0\2' >> %t
19 RUN: printf '\344\023\165\112\031\035\265\067' >> %t
2220 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
23 RUN: printf '\2\0\0\03' >> %t
2421 RUN: printf '\1\0\0\10' >> %t
2522 RUN: printf '\0\0\0\0' >> %t
2623 RUN: printf '\0\0\0\0' >> %t
24 RUN: printf '\0\0\0\2' >> %t
2725 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
2826
2927 RUN: printf '\0\0\0\0\0\0\0\023' >> %t
3028 RUN: printf '\0\0\0\0\0\0\0\067' >> %t
3129 RUN: printf '\0\0\0\0\0\0\0\101' >> %t
32 RUN: printf 'foobar\0\0' >> %t
30 RUN: printf '\7\0foo bar\0\0\0\0\0\0\0' >> %t
3331
3432 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
3533
0 RUN: printf '\201Rforpl\377' > %t
1 RUN: printf '\2\0\0\0\0\0\0\0' >> %t
1 RUN: printf '\3\0\0\0\0\0\0\0' >> %t
22 RUN: printf '\2\0\0\0\0\0\0\0' >> %t
33 RUN: printf '\3\0\0\0\0\0\0\0' >> %t
4 RUN: printf '\6\0\0\0\0\0\0\0' >> %t
4 RUN: printf '\20\0\0\0\0\0\0\0' >> %t
55 RUN: printf '\0\0\0\1\0\0\0\0' >> %t
66 RUN: printf '\0\0\0\2\0\0\0\0' >> %t
77 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
88 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
99 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1010
11 RUN: printf '\3\0\0\0' >> %t
12 RUN: printf '\1\0\0\0' >> %t
11 RUN: printf '\254\275\030\333\114\302\370\134' >> %t
1312 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
14 RUN: printf '\0\0\0\2' >> %t
1513 RUN: printf '\0\0\0\1' >> %t
1614 RUN: printf '\0\0\0\0' >> %t
1715 RUN: printf '\0\0\0\0' >> %t
16 RUN: printf '\1\0\0\0' >> %t
1817 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1918
20 RUN: printf '\3\0\0\0' >> %t
21 RUN: printf '\2\0\0\0' >> %t
19 RUN: printf '\067\265\035\031\112\165\023\344' >> %t
2220 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
23 RUN: printf '\03\0\0\2' >> %t
2421 RUN: printf '\10\0\0\1' >> %t
2522 RUN: printf '\0\0\0\0' >> %t
2623 RUN: printf '\0\0\0\0' >> %t
24 RUN: printf '\2\0\0\0' >> %t
2725 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
2826
2927 RUN: printf '\023\0\0\0\0\0\0\0' >> %t
3028 RUN: printf '\067\0\0\0\0\0\0\0' >> %t
3129 RUN: printf '\101\0\0\0\0\0\0\0' >> %t
32 RUN: printf 'foobar\0\0' >> %t
30 RUN: printf '\7\0foo bar\0\0\0\0\0\0\0' >> %t
3331
3432 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
3533
0 RUN: printf '\377lprofr\201' > %t
1 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
1 RUN: printf '\0\0\0\0\0\0\0\3' >> %t
22 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
33 RUN: printf '\0\0\0\0\0\0\0\3' >> %t
4 RUN: printf '\0\0\0\0\0\0\0\6' >> %t
4 RUN: printf '\0\0\0\0\0\0\0\20' >> %t
55 RUN: printf '\0\0\0\1\0\4\0\0' >> %t
66 RUN: printf '\0\0\0\2\0\4\0\0' >> %t
77 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
88 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
99 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1010
11 RUN: printf '\0\0\0\3' >> %t
12 RUN: printf '\0\0\0\1' >> %t
11 RUN: printf '\134\370\302\114\333\030\275\254' >> %t
1312 RUN: printf '\0\0\0\0\0\0\0\1' >> %t
14 RUN: printf '\0\0\0\2\0\4\0\0' >> %t
1513 RUN: printf '\0\0\0\1\0\4\0\0' >> %t
1614 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1715 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
16 RUN: printf '\0\0\0\1\0\0\0\0' >> %t
1917
20 RUN: printf '\0\0\0\3' >> %t
21 RUN: printf '\0\0\0\2' >> %t
18 RUN: printf '\344\023\165\112\031\035\265\067' >> %t
2219 RUN: printf '\0\0\0\0\0\0\0\02' >> %t
23 RUN: printf '\0\0\0\2\0\4\0\03' >> %t
2420 RUN: printf '\0\0\0\1\0\4\0\10' >> %t
2521 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
2622 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
27 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
23 RUN: printf '\0\0\0\02\0\0\0\0' >> %t
2824
2925 RUN: printf '\0\0\0\0\0\0\0\023' >> %t
3026 RUN: printf '\0\0\0\0\0\0\0\067' >> %t
3127 RUN: printf '\0\0\0\0\0\0\0\101' >> %t
32 RUN: printf 'foobar\0\0' >> %t
28 RUN: printf '\7\0foo bar\0\0\0\0\0\0\0' >> %t
3329
3430 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
3531
0 RUN: printf '\201rforpl\377' > %t
1 RUN: printf '\2\0\0\0\0\0\0\0' >> %t
1 RUN: printf '\3\0\0\0\0\0\0\0' >> %t
22 RUN: printf '\2\0\0\0\0\0\0\0' >> %t
33 RUN: printf '\3\0\0\0\0\0\0\0' >> %t
4 RUN: printf '\6\0\0\0\0\0\0\0' >> %t
4 RUN: printf '\20\0\0\0\0\0\0\0' >> %t
55 RUN: printf '\0\0\4\0\1\0\0\0' >> %t
66 RUN: printf '\0\0\4\0\2\0\0\0' >> %t
77 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
88 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
99 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1010
11 RUN: printf '\3\0\0\0' >> %t
12 RUN: printf '\1\0\0\0' >> %t
11 RUN: printf '\254\275\030\333\114\302\370\134' >> %t
1312 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
14 RUN: printf '\0\0\4\0\2\0\0\0' >> %t
1513 RUN: printf '\0\0\4\0\1\0\0\0' >> %t
1614 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1715 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
16 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
1917
20 RUN: printf '\03\0\0\0' >> %t
21 RUN: printf '\02\0\0\0' >> %t
18 RUN: printf '\067\265\035\031\112\165\023\344' >> %t
2219 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
23 RUN: printf '\03\0\4\0\2\0\0\0' >> %t
2420 RUN: printf '\10\0\4\0\1\0\0\0' >> %t
2521 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
2622 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
27 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
23 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
2824
2925 RUN: printf '\023\0\0\0\0\0\0\0' >> %t
3026 RUN: printf '\067\0\0\0\0\0\0\0' >> %t
3127 RUN: printf '\101\0\0\0\0\0\0\0' >> %t
32 RUN: printf 'foobar\0\0' >> %t
28 RUN: printf '\7\0foo bar\0\0\0\0\0\0\0' >> %t
3329
3430 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
3531
0 RUN: printf '\201rforpl\377' > %t-foo.profraw
1 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-foo.profraw
1 RUN: printf '\3\0\0\0\0\0\0\0' >> %t-foo.profraw
22 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw
33 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw
4 RUN: printf '\3\0\0\0\0\0\0\0' >> %t-foo.profraw
4 RUN: printf '\10\0\0\0\0\0\0\0' >> %t-foo.profraw
55 RUN: printf '\0\0\4\0\1\0\0\0' >> %t-foo.profraw
66 RUN: printf '\0\0\4\0\2\0\0\0' >> %t-foo.profraw
77 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
88 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
99 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
1010
11 RUN: printf '\3\0\0\0' >> %t-foo.profraw
12 RUN: printf '\1\0\0\0' >> %t-foo.profraw
11 RUN: printf '\254\275\030\333\114\302\370\134' >> %t-foo.profraw
1312 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw
14 RUN: printf '\0\0\4\0\2\0\0\0' >> %t-foo.profraw
1513 RUN: printf '\0\0\4\0\1\0\0\0' >> %t-foo.profraw
1614 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
1715 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
16 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw
1917
2018 RUN: printf '\023\0\0\0\0\0\0\0' >> %t-foo.profraw
21 RUN: printf 'foo\0\0\0\0\0' >> %t-foo.profraw
19 RUN: printf '\3\0foo\0\0\0' >> %t-foo.profraw
2220
2321 RUN: printf '\201rforpl\377' > %t-bar.profraw
24 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw
22 RUN: printf '\3\0\0\0\0\0\0\0' >> %t-bar.profraw
2523 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-bar.profraw
2624 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw
27 RUN: printf '\3\0\0\0\0\0\0\0' >> %t-bar.profraw
25 RUN: printf '\10\0\0\0\0\0\0\0' >> %t-bar.profraw
2826 RUN: printf '\0\0\6\0\1\0\0\0' >> %t-bar.profraw
2927 RUN: printf '\0\0\6\0\2\0\0\0' >> %t-bar.profraw
3028 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
3129 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
3230 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
3331
34 RUN: printf '\3\0\0\0' >> %t-bar.profraw
35 RUN: printf '\2\0\0\0' >> %t-bar.profraw
36 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw
37 RUN: printf '\0\0\6\0\2\0\0\0' >> %t-bar.profraw
32 RUN: printf '\067\265\035\031\112\165\023\344' >> %t-bar.profraw
33 RUN: printf '\02\0\0\0\0\0\0\0' >> %t-bar.profraw
3834 RUN: printf '\0\0\6\0\1\0\0\0' >> %t-bar.profraw
3935 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
4036 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
41 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
37 RUN: printf '\02\0\0\0\0\0\0\0' >> %t-bar.profraw
4238
4339 RUN: printf '\067\0\0\0\0\0\0\0' >> %t-bar.profraw
4440 RUN: printf '\101\0\0\0\0\0\0\0' >> %t-bar.profraw
45 RUN: printf 'bar\0\0\0\0\0' >> %t-bar.profraw
41 RUN: printf '\3\0bar\0\0\0' >> %t-bar.profraw
4642
4743 RUN: cat %t-foo.profraw %t-bar.profraw > %t-pad.profraw
4844 RUN: llvm-profdata show %t-pad.profraw -all-functions -counts | FileCheck %s