@@ -41,17 +41,6 @@ static cl::opt<bool>
41
41
" and produce context-insensitive profile." ));
42
42
cl::opt<bool > ShowDetailedWarning (" show-detailed-warning" ,
43
43
cl::desc (" Show detailed warning message." ));
44
- cl::opt<bool >
45
- LeadingIPOnly (" leading-ip-only" ,
46
- cl::desc (" Form a profile based only on sample IPs" ));
47
-
48
- static cl::list<std::string> PerfEventFilter (
49
- " perf-event" ,
50
- cl::desc (" Ignore samples not matching the given event names" ));
51
- static cl::alias
52
- PerfEventFilterPlural (" perf-events" , cl::CommaSeparated,
53
- cl::desc (" Comma-delimited version of -perf-event" ),
54
- cl::aliasopt(PerfEventFilter));
55
44
56
45
extern cl::opt<std::string> PerfTraceFilename;
57
46
extern cl::opt<bool > ShowDisassemblyOnly;
@@ -415,18 +404,13 @@ PerfScriptReader::convertPerfDataToTrace(ProfiledBinary *Binary, bool SkipPID,
415
404
}
416
405
}
417
406
418
- // If filtering by events was requested, additionally request the "event"
419
- // field.
420
- const std::string FieldList =
421
- PerfEventFilter.empty () ? " ip,brstack" : " event,ip,brstack" ;
422
-
423
407
// Run perf script again to retrieve events for PIDs collected above
424
408
SmallVector<StringRef, 8 > ScriptSampleArgs;
425
409
ScriptSampleArgs.push_back (PerfPath);
426
410
ScriptSampleArgs.push_back (" script" );
427
411
ScriptSampleArgs.push_back (" --show-mmap-events" );
428
412
ScriptSampleArgs.push_back (" -F" );
429
- ScriptSampleArgs.push_back (FieldList );
413
+ ScriptSampleArgs.push_back (" ip,brstack " );
430
414
ScriptSampleArgs.push_back (" -i" );
431
415
ScriptSampleArgs.push_back (PerfData);
432
416
if (!PIDs.empty ()) {
@@ -591,54 +575,14 @@ bool PerfScriptReader::extractLBRStack(TraceStream &TraceIt,
591
575
592
576
// Skip the leading instruction pointer.
593
577
size_t Index = 0 ;
594
-
595
- StringRef EventName;
596
- // Skip a perf event name. This may or may not exist.
597
- if (Records.size () > Index && Records[Index].ends_with (" :" )) {
598
- EventName = Records[Index].ltrim ().rtrim (' :' );
599
- Index++;
600
-
601
- if (PerfEventFilter.empty ()) {
602
- WithColor::warning () << " No --perf-event filter was specified, but an "
603
- " \" event\" field was found in line "
604
- << TraceIt.getLineNumber () << " : "
605
- << TraceIt.getCurrentLine () << " \n " ;
606
- } else if (std::find (PerfEventFilter.begin (), PerfEventFilter.end (),
607
- EventName) == PerfEventFilter.end ()) {
608
- TraceIt.advance ();
609
- return false ;
610
- }
611
-
612
- } else if (!PerfEventFilter.empty ()) {
613
- WithColor::warning () << " A --perf-event filter was specified, but no "
614
- " \" event\" field found in line "
615
- << TraceIt.getLineNumber () << " : "
616
- << TraceIt.getCurrentLine () << " \n " ;
617
- }
618
-
619
578
uint64_t LeadingAddr;
620
- if (Records.size () > Index && !Records[Index ].contains (' /' )) {
621
- if (Records[Index ].getAsInteger (16 , LeadingAddr)) {
579
+ if (! Records.empty () && !Records[0 ].contains (' /' )) {
580
+ if (Records[0 ].getAsInteger (16 , LeadingAddr)) {
622
581
WarnInvalidLBR (TraceIt);
623
582
TraceIt.advance ();
624
583
return false ;
625
584
}
626
- Index++;
627
- }
628
-
629
- // We assume that if we saw an event name we also saw a leading addr.
630
- // In other words, LeadingAddr is set if Index is 1 or 2.
631
- if (LeadingIPOnly && Index > 0 ) {
632
- // Form a profile only from the sample IP. Do not assume an LBR stack
633
- // follows, and ignore it if it does.
634
- uint64_t SampleIP = Binary->canonicalizeVirtualAddress (LeadingAddr);
635
- bool SampleIPIsInternal = Binary->addressIsCode (SampleIP);
636
- if (SampleIPIsInternal) {
637
- // Form a half LBR entry where the sample IP is the destination.
638
- LBRStack.emplace_back (LBREntry (SampleIP, SampleIP));
639
- }
640
- TraceIt.advance ();
641
- return !LBRStack.empty ();
585
+ Index = 1 ;
642
586
}
643
587
644
588
// Now extract LBR samples - note that we do not reverse the
@@ -958,20 +902,6 @@ void PerfScriptReader::computeCounterFromLBR(const PerfSample *Sample,
958
902
uint64_t Repeat) {
959
903
SampleCounter &Counter = SampleCounters.begin ()->second ;
960
904
uint64_t EndAddress = 0 ;
961
-
962
- if (LeadingIPOnly) {
963
- assert (Sample->LBRStack .size () == 1 &&
964
- " Expected only half LBR entries for ip-only mode" );
965
- const LBREntry &LBR = *(Sample->LBRStack .begin ());
966
- uint64_t SourceAddress = LBR.Source ;
967
- uint64_t TargetAddress = LBR.Target ;
968
- if (SourceAddress == TargetAddress &&
969
- Binary->addressIsCode (TargetAddress)) {
970
- Counter.recordRangeCount (SourceAddress, TargetAddress, Repeat);
971
- }
972
- return ;
973
- }
974
-
975
905
for (const LBREntry &LBR : Sample->LBRStack ) {
976
906
uint64_t SourceAddress = LBR.Source ;
977
907
uint64_t TargetAddress = LBR.Target ;
@@ -1132,18 +1062,6 @@ bool PerfScriptReader::isLBRSample(StringRef Line) {
1132
1062
Line.trim ().split (Records, " " , 2 , false );
1133
1063
if (Records.size () < 2 )
1134
1064
return false ;
1135
- // Check if there is an event name before the leading IP.
1136
- // If there is, it will be in Records[0]. To skip it, we'll re-split on
1137
- // Records[1], which should contain the rest of the line.
1138
- if (Records[0 ].contains (" :" )) {
1139
- // If so, consume the event name and continue processing the rest of the
1140
- // line.
1141
- StringRef IPAndLBR = Records[1 ].ltrim ();
1142
- Records.clear ();
1143
- IPAndLBR.split (Records, " " , 2 , false );
1144
- if (Records.size () < 2 )
1145
- return false ;
1146
- }
1147
1065
if (Records[1 ].starts_with (" 0x" ) && Records[1 ].contains (' /' ))
1148
1066
return true ;
1149
1067
return false ;
@@ -1234,18 +1152,6 @@ void PerfScriptReader::warnInvalidRange() {
1234
1152
const PerfSample *Sample = Item.first .getPtr ();
1235
1153
uint64_t Count = Item.second ;
1236
1154
uint64_t EndAddress = 0 ;
1237
-
1238
- if (LeadingIPOnly) {
1239
- assert (Sample->LBRStack .size () == 1 &&
1240
- " Expected only half LBR entries for ip-only mode" );
1241
- const LBREntry &LBR = *(Sample->LBRStack .begin ());
1242
- if (LBR.Source == LBR.Target && LBR.Source != ExternalAddr) {
1243
- // This is an leading-addr-only profile.
1244
- Ranges[{LBR.Source , LBR.Source }] += Count;
1245
- }
1246
- continue ;
1247
- }
1248
-
1249
1155
for (const LBREntry &LBR : Sample->LBRStack ) {
1250
1156
uint64_t SourceAddress = LBR.Source ;
1251
1157
uint64_t StartAddress = LBR.Target ;
@@ -1293,15 +1199,11 @@ void PerfScriptReader::warnInvalidRange() {
1293
1199
!Binary->addressIsCode (EndAddress))
1294
1200
continue ;
1295
1201
1296
- // IP samples can indicate activity on individual instructions rather than
1297
- // basic blocks/edges. In this mode, don't warn if sampled IPs aren't
1298
- // branches.
1299
- if (!LeadingIPOnly)
1300
- if (!Binary->addressIsCode (StartAddress) ||
1301
- !Binary->addressIsTransfer (EndAddress)) {
1302
- InstNotBoundary += I.second ;
1303
- WarnInvalidRange (StartAddress, EndAddress, EndNotBoundaryMsg);
1304
- }
1202
+ if (!Binary->addressIsCode (StartAddress) ||
1203
+ !Binary->addressIsTransfer (EndAddress)) {
1204
+ InstNotBoundary += I.second ;
1205
+ WarnInvalidRange (StartAddress, EndAddress, EndNotBoundaryMsg);
1206
+ }
1305
1207
1306
1208
auto *FRange = Binary->findFuncRange (StartAddress);
1307
1209
if (!FRange) {
0 commit comments