llvm.org GIT mirror llvm / a5be9e3
[PGO] Value profiling support This change introduces an instrumentation intrinsic instruction for value profiling purposes, the lowering of the instrumentation intrinsic and raw reader updates. The raw profile data files for llvm-profdata testing are updated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253484 91177308-0d34-0410-b5e6-96231b3b80d8 Betul Buyukkurt 3 years ago
20 changed file(s) with 415 addition(s) and 78 deletion(s). Raw diff Collapse all Expand all
95139513 format that can be written out by a compiler runtime and consumed via
95149514 the ``llvm-profdata`` tool.
95159515
9516 '``llvm.instrprof_value_profile``' Intrinsic
9517 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9518
9519 Syntax:
9520 """""""
9521
9522 ::
9523
9524 declare void @llvm.instrprof_value_profile(i8* , i64 ,
9525 i64 , i32 ,
9526 i32 )
9527
9528 Overview:
9529 """""""""
9530
9531 The '``llvm.instrprof_value_profile``' intrinsic can be emitted by a
9532 frontend for use with instrumentation based profiling. This will be
9533 lowered by the ``-instrprof`` pass to find out the target values,
9534 instrumented expressions take in a program at runtime.
9535
9536 Arguments:
9537 """"""""""
9538
9539 The first argument is a pointer to a global variable containing the
9540 name of the entity being instrumented. ``name`` should generally be the
9541 (mangled) function name for a set of counters.
9542
9543 The second argument is a hash value that can be used by the consumer
9544 of the profile data to detect changes to the instrumented source. It
9545 is an error if ``hash`` differs between two instances of
9546 ``llvm.instrprof_*`` that refer to the same name.
9547
9548 The third argument is the value of the expression being profiled. The profiled
9549 expression's value should be representable as an unsigned 64-bit value. The
9550 fourth argument represents the kind of value profiling that is being done. The
9551 supported value profiling kinds are enumerated through the
9552 ``InstrProfValueKind`` type declared in the
9553 ```` header file. The last argument is the
9554 index of the instrumented expression within ``name``. It should be >= 0.
9555
9556 Semantics:
9557 """"""""""
9558
9559 This intrinsic represents the point where a call to a runtime routine
9560 should be inserted for value profiling of target expressions. ``-instrprof``
9561 pass will generate the appropriate data structures and replace the
9562 ``llvm.instrprof_value_profile`` intrinsic with the call to the profile
9563 runtime library with proper arguments.
9564
95169565 Standard C Library Intrinsics
95179566 -----------------------------
95189567
371371 return cast(const_cast(getArgOperand(3)));
372372 }
373373 };
374 }
374
375 /// This represents the llvm.instrprof_value_profile intrinsic.
376 class InstrProfValueProfileInst : public IntrinsicInst {
377 public:
378 static inline bool classof(const IntrinsicInst *I) {
379 return I->getIntrinsicID() == Intrinsic::instrprof_value_profile;
380 }
381 static inline bool classof(const Value *V) {
382 return isa(V) && classof(cast(V));
383 }
384
385 GlobalVariable *getName() const {
386 return cast(
387 const_cast(getArgOperand(0))->stripPointerCasts());
388 }
389
390 ConstantInt *getHash() const {
391 return cast(const_cast(getArgOperand(1)));
392 }
393
394 Value *getTargetValue() const {
395 return cast(const_cast(getArgOperand(2)));
396 }
397
398 ConstantInt *getValueKind() const {
399 return cast(const_cast(getArgOperand(3)));
400 }
401
402 // Returns the value site index.
403 ConstantInt *getIndex() const {
404 return cast(const_cast(getArgOperand(4)));
405 }
406 };
407 } // namespace llvm
375408
376409 #endif
318318 [llvm_ptr_ty, llvm_i64_ty,
319319 llvm_i32_ty, llvm_i32_ty],
320320 []>;
321
321
322 // A call to profile runtime for value profiling of target expressions
323 // through instrumentation based profiling.
324 def int_instrprof_value_profile : Intrinsic<[],
325 [llvm_ptr_ty, llvm_i64_ty,
326 llvm_i64_ty, llvm_i32_ty,
327 llvm_i32_ty],
328 []>;
329
322330 //===------------------- Standard C Library Intrinsics --------------------===//
323331 //
324332
264264 inline void addValueData(uint32_t ValueKind, uint32_t Site,
265265 InstrProfValueData *VData, uint32_t N,
266266 ValueMapType *HashKeys);
267 /// Merge Value Profile ddata from Src record to this record for ValueKind.
267 /// Merge Value Profile data from Src record to this record for ValueKind.
268268 inline instrprof_error mergeValueProfData(uint32_t ValueKind,
269269 InstrProfRecord &Src);
270270
271271 /// Used by InstrProfWriter: update the value strings to commoned strings in
272272 /// the writer instance.
273273 inline void updateStrings(InstrProfStringTable *StrTab);
274
275 /// Clear value data entries
276 inline void clearValueData() {
277 for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
278 getValueSitesForKind(Kind).clear();
279 }
274280
275281 private:
276282 std::vector IndirectCallSites;
291297 const_cast(this)
292298 ->getValueSitesForKind(ValueKind));
293299 }
300
294301 // Map indirect call target name hash to name string.
295302 uint64_t remapValue(uint64_t Value, uint32_t ValueKind,
296303 ValueMapType *HashKeys) {
302309 std::lower_bound(HashKeys->begin(), HashKeys->end(), Value,
303310 [](const std::pair &LHS,
304311 uint64_t RHS) { return LHS.first < RHS; });
305 assert(Result != HashKeys->end() &&
306 "Hash does not match any known keys\n");
307 Value = (uint64_t)Result->second;
312 if (Result != HashKeys->end())
313 Value = (uint64_t)Result->second;
308314 break;
309315 }
310316 }
463469 // The number of value profile kinds that has value profile data.
464470 // In this implementation, a value profile kind is considered to
465471 // have profile data if the number of value profile sites for the
466 // kind is not zero. More aggressively, the implemnetation can
472 // kind is not zero. More aggressively, the implementation can
467473 // choose to check the actual data value: if none of the value sites
468474 // has any profiled values, the kind can be skipped.
469475 uint32_t NumValueKinds;
544550
545551 namespace RawInstrProf {
546552
547 const uint64_t Version = 1;
553 const uint64_t Version = 2;
548554
549555 // Magic number to detect file format and endianness.
550556 // Use 255 at one end, since no UTF-8 file can use that character. Avoid 0,
576582 // compiler-rt/lib/profile/InstrProfiling.h.
577583 // It should also match the synthesized type in
578584 // Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters.
579 template struct ProfileData {
585 template struct LLVM_ALIGNAS(8) ProfileData {
580586 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name;
581587 #include "llvm/ProfileData/InstrProfData.inc"
582588 };
593599 const uint64_t NamesSize;
594600 const uint64_t CountersDelta;
595601 const uint64_t NamesDelta;
602 const uint64_t ValueKindLast;
603 const uint64_t ValueDataSize;
604 const uint64_t ValueDataDelta;
596605 };
597606
598607 } // end namespace RawInstrProf
5555 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
5656 ConstantExpr::getBitCast(CounterPtr, \
5757 llvm::Type::getInt64PtrTy(Ctx)))
58 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), FunctionPointer, \
59 FunctionAddr)
60 INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \
61 ConstantPointerNull::get(Int8PtrTy))
62 INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \
63 ConstantArray::get(Int16ArrayTy, Int16ArrayVals))
5864 // INSTR_PROF_DATA_END
5965
6066 #ifdef INSTR_PROF_DATA
1919 #include "llvm/ProfileData/InstrProf.h"
2020 #include "llvm/Support/EndianStream.h"
2121 #include "llvm/Support/ErrorOr.h"
22 #include "llvm/Support/raw_ostream.h"
2223 #include "llvm/Support/LineIterator.h"
2324 #include "llvm/Support/MemoryBuffer.h"
2425 #include "llvm/Support/OnDiskHashTable.h"
2526 #include
27 #include
2628
2729 namespace llvm {
2830
131133 private:
132134 /// The profile data file contents.
133135 std::unique_ptr DataBuffer;
134
135136 bool ShouldSwapBytes;
136137 uint64_t CountersDelta;
137138 uint64_t NamesDelta;
139 uint64_t ValueDataDelta;
138140 const RawInstrProf::ProfileData *Data;
139141 const RawInstrProf::ProfileData *DataEnd;
140142 const uint64_t *CountersStart;
141143 const char *NamesStart;
144 const uint8_t *ValueDataStart;
142145 const char *ProfileEnd;
146 uint32_t ValueKindLast;
147
148 // String table for holding a unique copy of all the strings in the profile.
149 InstrProfStringTable StringTable;
150 InstrProfRecord::ValueMapType FunctionPtrToNameMap;
143151
144152 RawInstrProfReader(const RawInstrProfReader &) = delete;
145153 RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
158166 IntT swap(IntT Int) const {
159167 return ShouldSwapBytes ? sys::getSwappedBytes(Int) : Int;
160168 }
161
169 inline uint8_t getNumPaddingBytes(uint64_t SizeInBytes) {
170 return 7 & (sizeof(uint64_t) - SizeInBytes % sizeof(uint64_t));
171 }
162172 std::error_code readName(InstrProfRecord &Record);
163173 std::error_code readFuncHash(InstrProfRecord &Record);
164174 std::error_code readRawCounts(InstrProfRecord &Record);
175 std::error_code readValueData(InstrProfRecord &Record);
165176 bool atEnd() const { return Data == DataEnd; }
166177 void advanceData() { Data++; }
167178
172183 const char *getName(IntPtrT NamePtr) const {
173184 ptrdiff_t Offset = (swap(NamePtr) - NamesDelta) / sizeof(char);
174185 return NamesStart + Offset;
186 }
187 const uint8_t *getValueDataCounts(IntPtrT ValueCountsPtr) const {
188 ptrdiff_t Offset = (swap(ValueCountsPtr) - ValueDataDelta) / sizeof(uint8_t);
189 return ValueDataStart + Offset;
190 }
191 // This accepts an already byte-swapped ValueDataPtr argument.
192 const InstrProfValueData *getValueData(IntPtrT ValueDataPtr) const {
193 ptrdiff_t Offset = (ValueDataPtr - ValueDataDelta) / sizeof(uint8_t);
194 return reinterpret_cast(ValueDataStart + Offset);
175195 }
176196 };
177197
302322 /// Fill Counts with the profile data for the given function name.
303323 std::error_code getFunctionCounts(StringRef FuncName, uint64_t FuncHash,
304324 std::vector &Counts);
325
305326 /// Return the maximum of all known function counts.
306327 uint64_t getMaximumFunctionCount() { return MaxFunctionCount; }
307328
52105210 }
52115211 case Intrinsic::instrprof_increment:
52125212 llvm_unreachable("instrprof failed to lower an increment");
5213
5213 case Intrinsic::instrprof_value_profile:
5214 llvm_unreachable("instrprof failed to lower a value profiling call");
52145215 case Intrinsic::localescape: {
52155216 MachineFunction &MF = DAG.getMachineFunction();
52165217 const TargetInstrInfo *TII = DAG.getSubtarget().getInstrInfo();
205205
206206 CountersDelta = swap(Header.CountersDelta);
207207 NamesDelta = swap(Header.NamesDelta);
208 ValueDataDelta = swap(Header.ValueDataDelta);
208209 auto DataSize = swap(Header.DataSize);
209210 auto CountersSize = swap(Header.CountersSize);
210211 auto NamesSize = swap(Header.NamesSize);
212 auto ValueDataSize = swap(Header.ValueDataSize);
213 ValueKindLast = swap(Header.ValueKindLast);
214
215 auto DataSizeInBytes = DataSize * sizeof(RawInstrProf::ProfileData);
216 auto PaddingSize = getNumPaddingBytes(NamesSize);
211217
212218 ptrdiff_t DataOffset = sizeof(RawInstrProf::Header);
213 ptrdiff_t CountersOffset =
214 DataOffset + sizeof(RawInstrProf::ProfileData) * DataSize;
219 ptrdiff_t CountersOffset = DataOffset + DataSizeInBytes;
215220 ptrdiff_t NamesOffset = CountersOffset + sizeof(uint64_t) * CountersSize;
216 size_t ProfileSize = NamesOffset + sizeof(char) * NamesSize;
221 ptrdiff_t ValueDataOffset = NamesOffset + NamesSize + PaddingSize;
222 size_t ProfileSize = ValueDataOffset + ValueDataSize;
217223
218224 auto *Start = reinterpret_cast(&Header);
219225 if (Start + ProfileSize > DataBuffer->getBufferEnd())
224230 DataEnd = Data + DataSize;
225231 CountersStart = reinterpret_cast(Start + CountersOffset);
226232 NamesStart = Start + NamesOffset;
233 ValueDataStart = reinterpret_cast(Start + ValueDataOffset);
227234 ProfileEnd = Start + ProfileSize;
228235
236 FunctionPtrToNameMap.clear();
237 for (const RawInstrProf::ProfileData *I = Data; I != DataEnd; ++I) {
238 const IntPtrT FPtr = swap(I->FunctionPointer);
239 if (!FPtr)
240 continue;
241 StringRef FunctionName(getName(I->NamePtr), swap(I->NameSize));
242 const char* NameEntryPtr = StringTable.insertString(FunctionName);
243 FunctionPtrToNameMap.push_back(std::pair
244 (FPtr, NameEntryPtr));
245 }
246 std::sort(FunctionPtrToNameMap.begin(), FunctionPtrToNameMap.end(), less_first());
247 FunctionPtrToNameMap.erase(std::unique(FunctionPtrToNameMap.begin(),
248 FunctionPtrToNameMap.end()),
249 FunctionPtrToNameMap.end());
229250 return success();
230251 }
231252
233254 std::error_code RawInstrProfReader::readName(InstrProfRecord &Record) {
234255 Record.Name = StringRef(getName(Data->NamePtr), swap(Data->NameSize));
235256 if (Record.Name.data() < NamesStart ||
236 Record.Name.data() + Record.Name.size() > DataBuffer->getBufferEnd())
237 return error(instrprof_error::malformed);
238
257 Record.Name.data() + Record.Name.size() > (char*)ValueDataStart)
258 return error(instrprof_error::malformed);
239259 return success();
240260 }
241261
274294 }
275295
276296 template
277 std::error_code
278 RawInstrProfReader::readNextRecord(InstrProfRecord &Record) {
297 std::error_code RawInstrProfReader::readValueData(
298 InstrProfRecord &Record) {
299
300 Record.clearValueData();
301 if (!Data->Values || (ValueDataDelta == 0))
302 return success();
303
304 // Read value data.
305 uint64_t NumVSites = 0;
306 for (uint32_t Kind = IPVK_First; Kind <= ValueKindLast; ++Kind)
307 NumVSites += swap(Data->NumValueSites[Kind]);
308 NumVSites += getNumPaddingBytes(NumVSites);
309
310 auto VDataCounts = makeArrayRef(getValueDataCounts(Data->Values), NumVSites);
311 // Check bounds.
312 if (VDataCounts.data() < ValueDataStart ||
313 VDataCounts.data() + VDataCounts.size() > (const uint8_t *)ProfileEnd)
314 return error(instrprof_error::malformed);
315
316 const InstrProfValueData *VDataPtr =
317 getValueData(swap(Data->Values) + NumVSites);
318 for (uint32_t Kind = IPVK_First; Kind <= ValueKindLast; ++Kind) {
319 NumVSites = swap(Data->NumValueSites[Kind]);
320 Record.reserveSites(Kind, NumVSites);
321 for (uint32_t VSite = 0; VSite < NumVSites; ++VSite) {
322
323 uint32_t VDataCount = VDataCounts[VSite];
324 if ((const char *)(VDataPtr + VDataCount) > ProfileEnd)
325 return error(instrprof_error::malformed);
326
327 std::vector CurrentValues;
328 CurrentValues.reserve(VDataCount);
329 for (uint32_t VIndex = 0; VIndex < VDataCount; ++VIndex) {
330 uint64_t TargetValue = swap(VDataPtr->Value);
331 uint64_t Count = swap(VDataPtr->Count);
332 CurrentValues.push_back({TargetValue, Count});
333 ++VDataPtr;
334 }
335 Record.addValueData(Kind, VSite, CurrentValues.data(),
336 VDataCount, &FunctionPtrToNameMap);
337 }
338 }
339 return success();
340 }
341
342 template
343 std::error_code RawInstrProfReader::readNextRecord(
344 InstrProfRecord &Record) {
279345 if (atEnd())
280346 if (std::error_code EC = readNextHeader(ProfileEnd))
281347 return EC;
291357 // Read raw counts and set Record.
292358 if (std::error_code EC = readRawCounts(Record))
293359 return EC;
360
361 // Read value data and set Record.
362 if (std::error_code EC = readValueData(Record)) return EC;
294363
295364 // Iterate.
296365 advanceData();
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This pass lowers instrprof_increment intrinsics emitted by a frontend for
10 // profiling. It also builds the data structures and initialization code needed
11 // for updating execution counts and emitting the profile at runtime.
9 // This pass lowers instrprof_* intrinsics emitted by a frontend for profiling.
10 // It also builds the data structures and initialization code needed for
11 // updating execution counts and emitting the profile at runtime.
1212 //
1313 //===----------------------------------------------------------------------===//
14
15 #include "llvm/ProfileData/InstrProf.h"
16 #include "llvm/Transforms/Instrumentation.h"
1714
1815 #include "llvm/ADT/Triple.h"
1916 #include "llvm/IR/IRBuilder.h"
2017 #include "llvm/IR/IntrinsicInst.h"
2118 #include "llvm/IR/Module.h"
19 #include "llvm/ProfileData/InstrProf.h"
20 #include "llvm/Transforms/Instrumentation.h"
2221 #include "llvm/Transforms/Utils/ModuleUtils.h"
2322
2423 using namespace llvm;
4948 private:
5049 InstrProfOptions Options;
5150 Module *M;
52 DenseMap RegionCounters;
51 typedef struct PerFunctionProfileData {
52 uint32_t NumValueSites[IPVK_Last+1];
53 GlobalVariable* RegionCounters;
54 GlobalVariable* DataVar;
55 PerFunctionProfileData() : RegionCounters(nullptr), DataVar(nullptr) {
56 memset(NumValueSites, 0, sizeof(uint32_t) * (IPVK_Last+1));
57 }
58 } PerFunctionProfileData;
59 DenseMap ProfileDataMap;
5360 std::vector UsedVars;
5461
5562 bool isMachO() const {
7582 StringRef getCoverageSection() const {
7683 return getInstrProfCoverageSectionName(isMachO());
7784 }
85
86 /// Count the number of instrumented value sites for the function.
87 void computeNumValueSiteCounts(InstrProfValueProfileInst *Ins);
88
89 /// Replace instrprof_value_profile with a call to runtime library.
90 void lowerValueProfileInst(InstrProfValueProfileInst *Ins);
7891
7992 /// Replace instrprof_increment with an increment of the appropriate value.
8093 void lowerIncrement(InstrProfIncrementInst *Inc);
117130 bool MadeChange = false;
118131
119132 this->M = &M;
120 RegionCounters.clear();
133 ProfileDataMap.clear();
121134 UsedVars.clear();
122135
136 // We did not know how many value sites there would be inside
137 // the instrumented function. This is counting the number of instrumented
138 // target value sites to enter it as field in the profile data variable.
123139 for (Function &F : M)
124140 for (BasicBlock &BB : F)
125141 for (auto I = BB.begin(), E = BB.end(); I != E;)
126 if (auto *Inc = dyn_cast(I++)) {
142 if (auto *Ind = dyn_cast(I++))
143 computeNumValueSiteCounts(Ind);
144
145 for (Function &F : M)
146 for (BasicBlock &BB : F)
147 for (auto I = BB.begin(), E = BB.end(); I != E;) {
148 auto Instr = I++;
149 if (auto *Inc = dyn_cast(Instr)) {
127150 lowerIncrement(Inc);
128151 MadeChange = true;
152 } else if (auto *Ind = dyn_cast(Instr)) {
153 lowerValueProfileInst(Ind);
154 MadeChange = true;
129155 }
156 }
157
130158 if (GlobalVariable *Coverage =
131159 M.getNamedGlobal(getCoverageMappingVarName())) {
132160 lowerCoverageData(Coverage);
133161 MadeChange = true;
134162 }
163
135164 if (!MadeChange)
136165 return false;
137166
140169 emitUses();
141170 emitInitialization();
142171 return true;
172 }
173
174 static Constant *getOrInsertValueProfilingCall(Module &M) {
175 auto *VoidTy = Type::getVoidTy(M.getContext());
176 auto *VoidPtrTy = Type::getInt8PtrTy(M.getContext());
177 auto *Int32Ty = Type::getInt32Ty(M.getContext());
178 auto *Int64Ty = Type::getInt64Ty(M.getContext());
179 Type *ArgTypes[] = {Int64Ty, VoidPtrTy, Int32Ty};
180 auto *ValueProfilingCallTy =
181 FunctionType::get(VoidTy, makeArrayRef(ArgTypes), false);
182 return M.getOrInsertFunction("__llvm_profile_instrument_target",
183 ValueProfilingCallTy);
184 }
185
186 void InstrProfiling::computeNumValueSiteCounts(InstrProfValueProfileInst *Ind) {
187
188 GlobalVariable *Name = Ind->getName();
189 uint64_t ValueKind = Ind->getValueKind()->getZExtValue();
190 uint64_t Index = Ind->getIndex()->getZExtValue();
191 auto It = ProfileDataMap.find(Name);
192 if (It == ProfileDataMap.end()) {
193 PerFunctionProfileData PD;
194 PD.NumValueSites[ValueKind] = Index + 1;
195 ProfileDataMap[Name] = PD;
196 } else if (It->second.NumValueSites[ValueKind] <= Index)
197 It->second.NumValueSites[ValueKind] = Index + 1;
198 }
199
200 void InstrProfiling::lowerValueProfileInst(InstrProfValueProfileInst *Ind) {
201
202 GlobalVariable *Name = Ind->getName();
203 auto It = ProfileDataMap.find(Name);
204 assert(It != ProfileDataMap.end() && It->second.DataVar &&
205 "value profiling detected in function with no counter incerement");
206
207 GlobalVariable *DataVar = It->second.DataVar;
208 uint64_t ValueKind = Ind->getValueKind()->getZExtValue();
209 uint64_t Index = Ind->getIndex()->getZExtValue();
210 for (uint32_t Kind = IPVK_First; Kind < ValueKind; ++Kind)
211 Index += It->second.NumValueSites[Kind];
212
213 IRBuilder<> Builder(Ind);
214 Value* Args[3] = {Ind->getTargetValue(),
215 Builder.CreateBitCast(DataVar, Builder.getInt8PtrTy()),
216 Builder.getInt32(Index)};
217 Ind->replaceAllUsesWith(
218 Builder.CreateCall(getOrInsertValueProfilingCall(*M), Args));
219 Ind->eraseFromParent();
143220 }
144221
145222 void InstrProfiling::lowerIncrement(InstrProfIncrementInst *Inc) {
173250 GlobalVariable *Name = cast(V);
174251
175252 // If we have region counters for this name, we've already handled it.
176 auto It = RegionCounters.find(Name);
177 if (It != RegionCounters.end())
178 continue;
253 auto It = ProfileDataMap.find(Name);
254 if (It != ProfileDataMap.end())
255 if (It->second.RegionCounters)
256 continue;
179257
180258 // Move the name variable to the right section.
181259 Name->setSection(getNameSection());
190268 return (Prefix + Name).str();
191269 }
192270
271 static inline bool shouldRecordFunctionAddr(Function *F) {
272 // Check the linkage
273 if (!F->hasLinkOnceLinkage() && !F->hasLocalLinkage() &&
274 !F->hasAvailableExternallyLinkage())
275 return true;
276 // Check uses of this function for other than direct calls or invokes to it.
277 return F->hasAddressTaken();
278 }
279
193280 GlobalVariable *
194281 InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
195282 GlobalVariable *NamePtr = Inc->getName();
196 auto It = RegionCounters.find(NamePtr);
197 if (It != RegionCounters.end())
198 return It->second;
283 auto It = ProfileDataMap.find(NamePtr);
284 PerFunctionProfileData PD;
285 if (It != ProfileDataMap.end()) {
286 if (It->second.RegionCounters)
287 return It->second.RegionCounters;
288 PD = It->second;
289 }
199290
200291 // Move the name variable to the right section. Place them in a COMDAT group
201292 // if the associated function is a COMDAT. This will make sure that
224315 CounterPtr->setAlignment(8);
225316 CounterPtr->setComdat(ProfileVarsComdat);
226317
227 RegionCounters[Inc->getName()] = CounterPtr;
228
229318 // Create data variable.
230
319 auto *Int8PtrTy = Type::getInt8PtrTy(Ctx);
320 auto *Int16Ty = Type::getInt16Ty(Ctx);
321 auto *Int16ArrayTy = ArrayType::get(Int16Ty, IPVK_Last+1);
231322 Type *DataTypes[] = {
232323 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) LLVMType,
233324 #include "llvm/ProfileData/InstrProfData.inc"
234325 };
235326 auto *DataTy = StructType::get(Ctx, makeArrayRef(DataTypes));
236327
328 Constant *FunctionAddr = shouldRecordFunctionAddr(Fn) ?
329 ConstantExpr::getBitCast(Fn, Int8PtrTy) :
330 ConstantPointerNull::get(Int8PtrTy);
331
332 Constant *Int16ArrayVals[IPVK_Last+1];
333 for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
334 Int16ArrayVals[Kind] = ConstantInt::get(Int16Ty, PD.NumValueSites[Kind]);
335
237336 Constant *DataVals[] = {
238337 #define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Init,
239338 #include "llvm/ProfileData/InstrProfData.inc"
240339 };
241
242 auto *Data = new GlobalVariable(*M, DataTy, true, NamePtr->getLinkage(),
340 auto *Data = new GlobalVariable(*M, DataTy, false, NamePtr->getLinkage(),
243341 ConstantStruct::get(DataTy, DataVals),
244342 getVarName(Inc, getInstrProfDataVarPrefix()));
245343 Data->setVisibility(NamePtr->getVisibility());
246344 Data->setSection(getDataSection());
247345 Data->setAlignment(8);
248346 Data->setComdat(ProfileVarsComdat);
347
348 PD.RegionCounters = CounterPtr;
349 PD.DataVar = Data;
350 ProfileDataMap[NamePtr] = PD;
249351
250352 // Mark the data variable as used so that it isn't stripped out.
251353 UsedVars.push_back(Data);
340442 LLVMUsed =
341443 new GlobalVariable(*M, ATy, false, GlobalValue::AppendingLinkage,
342444 ConstantArray::get(ATy, MergedVars), "llvm.used");
343
344445 LLVMUsed->setSection("llvm.metadata");
345446 }
346447
99
1010 ; CHECK: @__llvm_profile_name__Z3barIvEvv = linkonce_odr hidden constant [11 x i8] c"_Z3barIvEvv", section "{{.*}}__llvm_prf_names", comdat($__llvm_profile_vars__Z3barIvEvv), align 1
1111 ; CHECK: @__llvm_profile_counters__Z3barIvEvv = linkonce_odr hidden global [1 x i64] zeroinitializer, section "{{.*}}__llvm_prf_cnts", comdat($__llvm_profile_vars__Z3barIvEvv), align 8
12 ; CHECK: @__llvm_profile_data__Z3barIvEvv = linkonce_odr hidden constant { i32, i32, i64, i8*, i64* } { i32 11, i32 1, i64 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__llvm_profile_name__Z3barIvEvv, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_profile_counters__Z3barIvEvv, i32 0, i32 0) }, section "{{.*}}__llvm_prf_data", comdat($__llvm_profile_vars__Z3barIvEvv), align 8
12 ; CHECK: @__llvm_profile_data__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]* @__llvm_profile_name__Z3barIvEvv, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_profile_counters__Z3barIvEvv, i32 0, i32 0), i8* null, i8* null, [1 x i16] zeroinitializer }, section "{{.*}}__llvm_prf_data", comdat($__llvm_profile_vars__Z3barIvEvv), align 8
1313
1414 declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #1
1515
88 @__llvm_profile_name_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"
99
1010 ; COMMON: @__llvm_profile_counters_foo = hidden global
11 ; COMMON: @__llvm_profile_data_foo = hidden constant
11 ; COMMON: @__llvm_profile_data_foo = hidden global
1212 define void @foo() {
1313 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
1414 ret void
1515 }
1616
1717 ; COMMON: @__llvm_profile_counters_foo_weak = weak hidden global
18 ; COMMON: @__llvm_profile_data_foo_weak = weak hidden constant
18 ; COMMON: @__llvm_profile_data_foo_weak = weak hidden global
1919 define weak void @foo_weak() {
2020 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__llvm_profile_name_foo_weak, i32 0, i32 0), i64 0, i32 1, i32 0)
2121 ret void
2222 }
2323
2424 ; COMMON: @"__llvm_profile_counters_linkage.ll:foo_internal" = internal global
25 ; COMMON: @"__llvm_profile_data_linkage.ll:foo_internal" = internal constant
25 ; COMMON: @"__llvm_profile_data_linkage.ll:foo_internal" = internal global
2626 define internal void @foo_internal() {
2727 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @"__llvm_profile_name_linkage.ll:foo_internal", i32 0, i32 0), i64 0, i32 1, i32 0)
2828 ret void
2929 }
3030
3131 ; COMMON: @__llvm_profile_counters_foo_inline = linkonce_odr hidden global
32 ; COMMON: @__llvm_profile_data_foo_inline = linkonce_odr hidden constant
32 ; COMMON: @__llvm_profile_data_foo_inline = linkonce_odr hidden global
3333 define linkonce_odr void @foo_inline() {
3434 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__llvm_profile_name_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0)
3535 ret void
1111 ; MACHO: @__llvm_profile_counters_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
1212 ; ELF: @__llvm_profile_counters_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
1313
14 ; MACHO: @__llvm_profile_data_foo = hidden constant {{.*}}, section "__DATA,__llvm_prf_data", align 8
15 ; LINUX: @__llvm_profile_data_foo = hidden constant {{.*}}, section "__llvm_prf_data", align 8
16 ; FREEBSD: @__llvm_profile_data_foo = hidden constant {{.*}}, section "__llvm_prf_data", align 8
17 ; SOLARIS: @__llvm_profile_data_foo = hidden constant {{.*}}, section "__llvm_prf_data", align 8
14 ; MACHO: @__llvm_profile_data_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
15 ; LINUX: @__llvm_profile_data_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
16 ; FREEBSD: @__llvm_profile_data_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
17 ; SOLARIS: @__llvm_profile_data_foo = hidden {{.*}}, section "__llvm_prf_data", align 8
18
1819 define void @foo() {
1920 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
2021 ret void
99 ; CHECK: @baz_prof_name = hidden constant [3 x i8] c"baz", section "__DATA,__llvm_prf_names", align 1
1010
1111 ; CHECK: @__llvm_profile_counters_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
12 ; CHECK: @__llvm_profile_data_foo = hidden constant {{.*}}, section "__DATA,__llvm_prf_data", align 8
12 ; CHECK: @__llvm_profile_data_foo = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
1313 define void @foo() {
1414 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
1515 ret void
1616 }
1717
1818 ; CHECK: @__llvm_profile_counters_bar = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
19 ; CHECK: @__llvm_profile_data_bar = hidden constant {{.*}}, section "__DATA,__llvm_prf_data", align 8
19 ; CHECK: @__llvm_profile_data_bar = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
2020 define void @bar() {
2121 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__llvm_profile_name_bar, i32 0, i32 0), i64 0, i32 1, i32 0)
2222 ret void
2323 }
2424
2525 ; CHECK: @__llvm_profile_counters_baz = hidden global [3 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
26 ; CHECK: @__llvm_profile_data_baz = hidden constant {{.*}}, section "__DATA,__llvm_prf_data", align 8
26 ; CHECK: @__llvm_profile_data_baz = hidden {{.*}}, section "__DATA,__llvm_prf_data", align 8
2727 define void @baz() {
2828 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @baz_prof_name, i32 0, i32 0), i64 0, i32 3, i32 0)
2929 call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @baz_prof_name, i32 0, i32 0), i64 0, i32 3, i32 1)
55 REGENERATE: $ CFE=$SRC/tools/clang
66 REGENERATE: $ TESTDIR=$SRC/test/tools/llvm-profdata
77 REGENERATE: $ CFE_TESTDIR=$CFE/test/Profile
8 REGENERATE: $ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/test/Profile/c-general.c
8 REGENERATE: $ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/c-general.c
99 REGENERATE: $ LLVM_PROFILE_FILE=$TESTDIR/Inputs/c-general.profraw ./a.out
1010
1111 RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - | FileCheck %s -check-prefix=CHECK
1313
1414 SWITCHES-LABEL: Counters:
1515 SWITCHES-NEXT: switches:
16 SWITCHES-NEXT: Hash: 0x0000000000000013
16 SWITCHES-NEXT: Hash: 0x2618e4f23f2e8daa
1717 SWITCHES-NEXT: Counters: 19
1818 SWITCHES-NEXT: Function count: 1
1919 SWITCHES-LABEL: Functions shown: 1
2020
21 CHECK-LABEL: Total functions: 11
21 CHECK-LABEL: Total functions: 12
2222 CHECK-NEXT: Maximum function count: 1
2323 CHECK-NEXT: Maximum internal block count: 100
0 RUN: printf '\377lprofR\201' > %t
1 RUN: printf '\0\0\0\0\0\0\0\1' >> %t
1 RUN: printf '\0\0\0\0\0\0\0\2' >> %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
44 RUN: printf '\0\0\0\0\0\0\0\6' >> %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
7 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
8 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
9 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
710
811 RUN: printf '\0\0\0\3' >> %t
912 RUN: printf '\0\0\0\1' >> %t
1013 RUN: printf '\0\0\0\0\0\0\0\1' >> %t
1114 RUN: printf '\2\0\0\0' >> %t
1215 RUN: printf '\1\0\0\0' >> %t
16 RUN: printf '\0\0\0\0' >> %t
17 RUN: printf '\0\0\0\0' >> %t
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1319
1420 RUN: printf '\0\0\0\3' >> %t
1521 RUN: printf '\0\0\0\2' >> %t
1622 RUN: printf '\0\0\0\0\0\0\0\2' >> %t
1723 RUN: printf '\2\0\0\03' >> %t
1824 RUN: printf '\1\0\0\10' >> %t
25 RUN: printf '\0\0\0\0' >> %t
26 RUN: printf '\0\0\0\0' >> %t
27 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1928
2029 RUN: printf '\0\0\0\0\0\0\0\023' >> %t
2130 RUN: printf '\0\0\0\0\0\0\0\067' >> %t
2231 RUN: printf '\0\0\0\0\0\0\0\101' >> %t
23 RUN: printf 'foobar' >> %t
32 RUN: printf 'foobar\0\0' >> %t
2433
2534 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
2635
0 RUN: printf '\201Rforpl\377' > %t
1 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
1 RUN: printf '\2\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
44 RUN: printf '\6\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
7 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
8 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
9 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
710
811 RUN: printf '\3\0\0\0' >> %t
912 RUN: printf '\1\0\0\0' >> %t
1013 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
1114 RUN: printf '\0\0\0\2' >> %t
1215 RUN: printf '\0\0\0\1' >> %t
16 RUN: printf '\0\0\0\0' >> %t
17 RUN: printf '\0\0\0\0' >> %t
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1319
1420 RUN: printf '\3\0\0\0' >> %t
1521 RUN: printf '\2\0\0\0' >> %t
1622 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
1723 RUN: printf '\03\0\0\2' >> %t
1824 RUN: printf '\10\0\0\1' >> %t
25 RUN: printf '\0\0\0\0' >> %t
26 RUN: printf '\0\0\0\0' >> %t
27 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1928
2029 RUN: printf '\023\0\0\0\0\0\0\0' >> %t
2130 RUN: printf '\067\0\0\0\0\0\0\0' >> %t
2231 RUN: printf '\101\0\0\0\0\0\0\0' >> %t
23 RUN: printf 'foobar' >> %t
32 RUN: printf 'foobar\0\0' >> %t
2433
2534 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
2635
0 RUN: printf '\377lprofr\201' > %t
1 RUN: printf '\0\0\0\0\0\0\0\1' >> %t
1 RUN: printf '\0\0\0\0\0\0\0\2' >> %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
44 RUN: printf '\0\0\0\0\0\0\0\6' >> %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
7 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
8 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
9 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
710
811 RUN: printf '\0\0\0\3' >> %t
912 RUN: printf '\0\0\0\1' >> %t
1013 RUN: printf '\0\0\0\0\0\0\0\1' >> %t
1114 RUN: printf '\0\0\0\2\0\4\0\0' >> %t
1215 RUN: printf '\0\0\0\1\0\4\0\0' >> %t
16 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
17 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1319
1420 RUN: printf '\0\0\0\3' >> %t
1521 RUN: printf '\0\0\0\2' >> %t
1622 RUN: printf '\0\0\0\0\0\0\0\02' >> %t
1723 RUN: printf '\0\0\0\2\0\4\0\03' >> %t
1824 RUN: printf '\0\0\0\1\0\4\0\10' >> %t
25 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
26 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
27 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1928
2029 RUN: printf '\0\0\0\0\0\0\0\023' >> %t
2130 RUN: printf '\0\0\0\0\0\0\0\067' >> %t
2231 RUN: printf '\0\0\0\0\0\0\0\101' >> %t
23 RUN: printf 'foobar' >> %t
32 RUN: printf 'foobar\0\0' >> %t
2433
2534 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
2635
0 RUN: printf '\201rforpl\377' > %t
1 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
1 RUN: printf '\2\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
44 RUN: printf '\6\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
7 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
8 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
9 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
710
811 RUN: printf '\3\0\0\0' >> %t
912 RUN: printf '\1\0\0\0' >> %t
1013 RUN: printf '\1\0\0\0\0\0\0\0' >> %t
1114 RUN: printf '\0\0\4\0\2\0\0\0' >> %t
1215 RUN: printf '\0\0\4\0\1\0\0\0' >> %t
16 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
17 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
18 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1319
1420 RUN: printf '\03\0\0\0' >> %t
1521 RUN: printf '\02\0\0\0' >> %t
1622 RUN: printf '\02\0\0\0\0\0\0\0' >> %t
1723 RUN: printf '\03\0\4\0\2\0\0\0' >> %t
1824 RUN: printf '\10\0\4\0\1\0\0\0' >> %t
25 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
26 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
27 RUN: printf '\0\0\0\0\0\0\0\0' >> %t
1928
2029 RUN: printf '\023\0\0\0\0\0\0\0' >> %t
2130 RUN: printf '\067\0\0\0\0\0\0\0' >> %t
2231 RUN: printf '\101\0\0\0\0\0\0\0' >> %t
23 RUN: printf 'foobar' >> %t
32 RUN: printf 'foobar\0\0' >> %t
2433
2534 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s
2635
0 RUN: printf '\201rforpl\377' > %t-foo.profraw
1 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw
1 RUN: printf '\2\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
44 RUN: printf '\3\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
7 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
8 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
9 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
710
811 RUN: printf '\3\0\0\0' >> %t-foo.profraw
912 RUN: printf '\1\0\0\0' >> %t-foo.profraw
1013 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-foo.profraw
1114 RUN: printf '\0\0\4\0\2\0\0\0' >> %t-foo.profraw
1215 RUN: printf '\0\0\4\0\1\0\0\0' >> %t-foo.profraw
16 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-foo.profraw
17 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
1319
1420 RUN: printf '\023\0\0\0\0\0\0\0' >> %t-foo.profraw
15 RUN: printf 'foo' >> %t-foo.profraw
21 RUN: printf 'foo\0\0\0\0\0' >> %t-foo.profraw
1622
1723 RUN: printf '\201rforpl\377' > %t-bar.profraw
18 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-bar.profraw
24 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw
1925 RUN: printf '\1\0\0\0\0\0\0\0' >> %t-bar.profraw
2026 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw
2127 RUN: printf '\3\0\0\0\0\0\0\0' >> %t-bar.profraw
2228 RUN: printf '\0\0\6\0\1\0\0\0' >> %t-bar.profraw
2329 RUN: printf '\0\0\6\0\2\0\0\0' >> %t-bar.profraw
30 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
31 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
32 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
2433
2534 RUN: printf '\3\0\0\0' >> %t-bar.profraw
2635 RUN: printf '\2\0\0\0' >> %t-bar.profraw
2736 RUN: printf '\2\0\0\0\0\0\0\0' >> %t-bar.profraw
2837 RUN: printf '\0\0\6\0\2\0\0\0' >> %t-bar.profraw
2938 RUN: printf '\0\0\6\0\1\0\0\0' >> %t-bar.profraw
39 RUN: printf '\0\0\0\0\0\0\0\0' >> %t-bar.profraw
40 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
3042
3143 RUN: printf '\067\0\0\0\0\0\0\0' >> %t-bar.profraw
3244 RUN: printf '\101\0\0\0\0\0\0\0' >> %t-bar.profraw
33 RUN: printf 'bar' >> %t-bar.profraw
45 RUN: printf 'bar\0\0\0\0\0' >> %t-bar.profraw
3446
35 Versions of the profiles that are padded to eight byte alignment.
36 RUN: cat %t-foo.profraw > %t-foo-padded.profraw
37 RUN: printf '\0\0\0\0\0' >> %t-foo-padded.profraw
38 RUN: cat %t-bar.profraw > %t-bar-padded.profraw
39 RUN: printf '\0\0\0\0\0' >> %t-bar-padded.profraw
40
41 RUN: cat %t-foo-padded.profraw %t-bar.profraw > %t-pad-between.profraw
42 RUN: cat %t-foo-padded.profraw %t-bar-padded.profraw > %t-pad.profraw
43
44 RUN: llvm-profdata show %t-pad-between.profraw -all-functions -counts | FileCheck %s
47 RUN: cat %t-foo.profraw %t-bar.profraw > %t-pad.profraw
4548 RUN: llvm-profdata show %t-pad.profraw -all-functions -counts | FileCheck %s
4649
4750 CHECK: Counters: