how to use sampling profiler outputs with opt

Hi,
I’m trying to get some information using sampling profile data to extract the program behavior. I’m using llvm 5.0.0.

I followed clang’s documentation. I’m compiling my sources with -g, using perf record to collect the profiling info. I also used autofdo and converted the profiling data to LLVM’s format.

I fed the profiling data to clang and compiled it into .ll file using -g -fprofile-sample=… I can see the profile summary. So I assume that I managed to collect the sample profiling data correctly. I somewhat figured out what the detailed summary means when I compared it against llvm-profdata’s output.

!4 = !{i32 1, !“ProfileSummary”, !5}
!5 = !{!6, !7, !8, !9, !10, !11, !12, !13}
!6 = !{!“ProfileFormat”, !“SampleProfile”}
!7 = !{!“TotalCount”, i64 269054785}
!8 = !{!“MaxCount”, i64 406635}
!9 = !{!“MaxInternalCount”, i64 0}
!10 = !{!“MaxFunctionCount”, i64 435366}
!11 = !{!“NumCounts”, i64 1538}
!12 = !{!“NumFunctions”, i64 13}
!13 = !{!“DetailedSummary”, !14}
!14 = !{!15, !16, !17, !18, !19, !20, !20, !21, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30}
!15 = !{i32 10000, i64 406635, i32 17}
!16 = !{i32 100000, i64 406632, i32 92}
!17 = !{i32 200000, i64 384936, i32 135}
!18 = !{i32 300000, i64 365763, i32 223}
!19 = !{i32 400000, i64 365762, i32 282}
!20 = !{i32 500000, i64 365759, i32 359}
!21 = !{i32 600000, i64 250328, i32 451}
!22 = !{i32 700000, i64 216434, i32 569}
!23 = !{i32 800000, i64 213161, i32 697}
!24 = !{i32 900000, i64 196084, i32 822}
!25 = !{i32 950000, i64 95056, i32 892}
!26 = !{i32 990000, i64 86169, i32 1011}
!27 = !{i32 999000, i64 3734, i32 1074}
!28 = !{i32 999900, i64 494, i32 1271}
!29 = !{i32 999990, i64 125, i32 1358}
!30 = !{i32 999999, i64 12, i32 1390}
!31 = !{!“clang version 3.9.0 (tags/RELEASE_390/final 289411)”}
!32 = distinct !DISubprogram(name: “main”, scope: !1, file: !1, line: 92, type: !33, isLocal: false, isDefinition: true, scopeLine: 93, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
!33 = !DISubroutineType(types: !2)
!34 = !{!“function_entry_count”, i64 0}

My purpose is to see how the sample profile I collected using perf affects branch probability and block frequency info. So I used the sampling profile data with the .ll file that I compiled WITHOUT -fprofile-sample=…

I invoked opt like this:

opt -analyze -sample-profile-file=“…/bt.A.x_out” -block-freq bt.ll

opt -analyze -sample-profile-file=“…/bt.A.x_out” -branch-prob bt.ll

I see no difference in the outputs between when I use the sample profiling data and when I do the same analysis without the sample profiling data.

bt is from NPB suite (Serial, class A).

I’m kind of confused. I appreciate if somebody can comment on:
Am I doing something wrong or should I change my benchmark since this is not representative enough?

Thanks!