llvm-project/lld/test/COFF/pgo-warn-mismatch.ll
Yolanda Chen 8fa16cc628 [LTO][lld] Add lto-pgo-warn-mismatch option
When enable CSPGO for ThinLTO, there are profile cfg mismatch warnings that will cause lld-link errors (with /WX)
due to source changes (e.g. `#if` code runs for profile generation but not for profile use)
To disable it we have to use an internal "/mllvm:-no-pgo-warn-mismatch" option.
In contrast clang uses option ”-Wno-backend-plugin“ to avoid such warnings and gcc has an explicit "-Wno-coverage-mismatch" option.

Add "lto-pgo-warn-mismatch" option to lld COFF/ELF to help turn on/off the profile mismatch warnings explicitly when build with ThinLTO and CSPGO.

Differential Revision: https://reviews.llvm.org/D104431
2021-08-11 09:45:55 -07:00

71 lines
2.2 KiB
LLVM

; REQUIRES: x86
; RUN: rm -rf %t && split-file %s %t
; RUN: opt -module-summary %t/a.ll -o %t/a.bc
; RUN: llvm-profdata merge %t/cs.proftext -o %t/cs.profdata
; Ensure lld generates warnings for profile cfg mismatch.
; RUN: lld-link /dll /noentry /export:f /lto-cs-profile-file:%t/cs.profdata /lto-pgo-warn-mismatch /opt:lldlto=2 %t/a.bc /out:%t/a.dll 2>&1 | FileCheck %s
; Ensure lld will not generate warnings for profile cfg mismatch.
; RUN: lld-link /dll /noentry /export:f /lto-cs-profile-file:%t/cs.profdata /lto-pgo-warn-mismatch:no /opt:lldlto=2 %t/a.bc /out:%t/a.dll 2>&1 | count 0
; CHECK: warning: {{.*}} function control flow change detected (hash mismatch) f Hash = [[#]]
;--- a.ll
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
define i32 @f(i32 returned %a) #0 {
entry:
ret i32 %a
}
attributes #0 = { "target-cpu"="x86-64" }
!llvm.module.flags = !{!0, !1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, !"ProfileSummary", !2}
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10, !11, !12}
!3 = !{!"ProfileFormat", !"InstrProf"}
!4 = !{!"TotalCount", i64 2}
!5 = !{!"MaxCount", i64 1}
!6 = !{!"MaxInternalCount", i64 0}
!7 = !{!"MaxFunctionCount", i64 1}
!8 = !{!"NumCounts", i64 3}
!9 = !{!"NumFunctions", i64 2}
!10 = !{!"IsPartialProfile", i64 0}
!11 = !{!"PartialProfileRatio", double 0.000000e+00}
!12 = !{!"DetailedSummary", !13}
!13 = !{!14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29}
!14 = !{i32 10000, i64 0, i32 0}
!15 = !{i32 100000, i64 0, i32 0}
!16 = !{i32 200000, i64 0, i32 0}
!17 = !{i32 300000, i64 0, i32 0}
!18 = !{i32 400000, i64 0, i32 0}
!19 = !{i32 500000, i64 1, i32 2}
!20 = !{i32 600000, i64 1, i32 2}
!21 = !{i32 700000, i64 1, i32 2}
!22 = !{i32 800000, i64 1, i32 2}
!23 = !{i32 900000, i64 1, i32 2}
!24 = !{i32 950000, i64 1, i32 2}
!25 = !{i32 990000, i64 1, i32 2}
!26 = !{i32 999000, i64 1, i32 2}
!27 = !{i32 999900, i64 1, i32 2}
!28 = !{i32 999990, i64 1, i32 2}
!29 = !{i32 999999, i64 1, i32 2}
;--- cs.proftext
# CSIR level Instrumentation Flag
:csir
f
# Func Hash:
1535914979662757887
# Num Counters:
2
# Counter Values:
1
0