@@ -61,7 +61,7 @@ enum : uint32_t {
61
61
};
62
62
63
63
static cl::opt<std::string> DefaultGCOVVersion (" default-gcov-version" ,
64
- cl::init (" 408* " ), cl::Hidden,
64
+ cl::init (" 0000 " ), cl::Hidden,
65
65
cl::ValueRequired);
66
66
67
67
static cl::opt<bool > AtomicCounter (" gcov-atomic-counter" , cl::Hidden,
@@ -154,6 +154,7 @@ class GCOVProfiler {
154
154
GCOVOptions Options;
155
155
llvm::endianness Endian;
156
156
raw_ostream *os;
157
+ int Version = 0 ;
157
158
158
159
// Checksum, produced by hash of EdgeDestinations
159
160
SmallVector<uint32_t , 4 > FileChecksums;
@@ -334,12 +335,9 @@ namespace {
334
335
: GCOVRecord(P), SP(SP), EndLine(EndLine), Ident(Ident),
335
336
Version (Version), EntryBlock(P, 0 ), ReturnBlock(P, 1 ) {
336
337
LLVM_DEBUG (dbgs () << " Function: " << getFunctionName (SP) << " \n " );
337
- bool ExitBlockBeforeBody = Version >= 48 ;
338
- uint32_t i = ExitBlockBeforeBody ? 2 : 1 ;
338
+ uint32_t i = 2 ;
339
339
for (BasicBlock &BB : *F)
340
340
Blocks.insert (std::make_pair (&BB, GCOVBlock (P, i++)));
341
- if (!ExitBlockBeforeBody)
342
- ReturnBlock.Number = i;
343
341
344
342
std::string FunctionNameAndLine;
345
343
raw_string_ostream FNLOS (FunctionNameAndLine);
@@ -363,44 +361,28 @@ namespace {
363
361
void writeOut (uint32_t CfgChecksum) {
364
362
write (GCOV_TAG_FUNCTION);
365
363
SmallString<128 > Filename = getFilename (SP);
366
- uint32_t BlockLen =
367
- 2 + (Version >= 47 ) + wordsOfString (getFunctionName (SP));
368
- if (Version < 80 )
369
- BlockLen += wordsOfString (Filename) + 1 ;
370
- else
371
- BlockLen += 1 + wordsOfString (Filename) + 3 + (Version >= 90 );
364
+ uint32_t BlockLen = 3 + wordsOfString (getFunctionName (SP));
365
+ BlockLen += 1 + wordsOfString (Filename) + 4 ;
372
366
373
367
write (BlockLen);
374
368
write (Ident);
375
369
write (FuncChecksum);
376
- if (Version >= 47 )
377
- write (CfgChecksum);
370
+ write (CfgChecksum);
378
371
writeString (getFunctionName (SP));
379
- if (Version < 80 ) {
380
- writeString (Filename);
381
- write (SP->getLine ());
382
- } else {
383
- write (SP->isArtificial ()); // artificial
384
- writeString (Filename);
385
- write (SP->getLine ()); // start_line
386
- write (0 ); // start_column
387
- // EndLine is the last line with !dbg. It is not the } line as in GCC,
388
- // but good enough.
389
- write (EndLine);
390
- if (Version >= 90 )
391
- write (0 ); // end_column
392
- }
372
+
373
+ write (SP->isArtificial ()); // artificial
374
+ writeString (Filename);
375
+ write (SP->getLine ()); // start_line
376
+ write (0 ); // start_column
377
+ // EndLine is the last line with !dbg. It is not the } line as in GCC,
378
+ // but good enough.
379
+ write (EndLine);
380
+ write (0 ); // end_column
393
381
394
382
// Emit count of blocks.
395
383
write (GCOV_TAG_BLOCKS);
396
- if (Version < 80 ) {
397
- write (Blocks.size () + 2 );
398
- for (int i = Blocks.size () + 2 ; i; --i)
399
- write (0 );
400
- } else {
401
- write (1 );
402
- write (Blocks.size () + 2 );
403
- }
384
+ write (1 );
385
+ write (Blocks.size () + 2 );
404
386
LLVM_DEBUG (dbgs () << (Blocks.size () + 1 ) << " blocks\n " );
405
387
406
388
// Emit edges between blocks.
@@ -767,14 +749,18 @@ bool GCOVProfiler::emitProfileNotes(
767
749
function_ref<BlockFrequencyInfo *(Function &F)> GetBFI,
768
750
function_ref<BranchProbabilityInfo *(Function &F)> GetBPI,
769
751
function_ref<const TargetLibraryInfo &(Function &F)> GetTLI) {
770
- int Version;
771
752
{
772
753
uint8_t c3 = Options.Version [0 ];
773
754
uint8_t c2 = Options.Version [1 ];
774
755
uint8_t c1 = Options.Version [2 ];
775
756
Version = c3 >= ' A' ? (c3 - ' A' ) * 100 + (c2 - ' 0' ) * 10 + c1 - ' 0'
776
757
: (c3 - ' 0' ) * 10 + c1 - ' 0' ;
777
758
}
759
+ // Emit .gcno files that are compatible with GCC 11.1.
760
+ if (Version < 111 ) {
761
+ Version = 111 ;
762
+ memcpy (Options.Version , " B11*" , 4 );
763
+ }
778
764
779
765
bool EmitGCDA = Options.EmitData ;
780
766
for (unsigned i = 0 , e = CUNode->getNumOperands (); i != e; ++i) {
@@ -973,10 +959,8 @@ bool GCOVProfiler::emitProfileNotes(
973
959
out.write (Tmp, 4 );
974
960
}
975
961
write (Stamp);
976
- if (Version >= 90 )
977
- writeString (" " ); // unuseful current_working_directory
978
- if (Version >= 80 )
979
- write (0 ); // unuseful has_unexecuted_blocks
962
+ writeString (" ." ); // unuseful current_working_directory
963
+ write (0 ); // unuseful has_unexecuted_blocks
980
964
981
965
for (auto &Func : Funcs)
982
966
Func->writeOut (Stamp);
0 commit comments