diff --git a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp index 5555899c4f6b74..5e9a39932a94e9 100644 --- a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp +++ b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp @@ -1,4 +1,4 @@ -// REQUIRES: lld-available +// REQUIRES: lld, lld-available // Building the instrumented binary will fail because lld doesn't support // big-endian ELF for PPC (aka ABI 1). @@ -142,12 +142,12 @@ // RUN: | FileCheck %s --check-prefixes=REMARK,IR --implicit-check-not="!VP" // For the indirect call site `ptr->func` -// REMARK: instrprof-vtable-value-prof.cpp:214:19: Promote indirect call to _ZN12_GLOBAL__N_18Derived24funcEii with count 150 out of 200, sink 1 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E} -// REMARK: instrprof-vtable-value-prof.cpp:214:19: Promote indirect call to _ZN8Derived14funcEii with count 50 out of 50, sink 1 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1} +// REMARK: instrprof-vtable-value-prof.cpp:221:19: Promote indirect call to _ZN12_GLOBAL__N_18Derived24funcEii with count 150 out of 200, sink 1 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E} +// REMARK: instrprof-vtable-value-prof.cpp:221:19: Promote indirect call to _ZN8Derived14funcEii with count 50 out of 50, sink 1 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1} // // For the indirect call site `delete ptr` -// REMARK: instrprof-vtable-value-prof.cpp:216:5: Promote indirect call to _ZN12_GLOBAL__N_18Derived2D0Ev with count 750 out of 1000, sink 2 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E} -// REMARK: instrprof-vtable-value-prof.cpp:216:5: Promote indirect call to _ZN8Derived1D0Ev with count 250 out of 250, sink 2 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1} +// REMARK: instrprof-vtable-value-prof.cpp:223:5: Promote indirect call to _ZN12_GLOBAL__N_18Derived2D0Ev with count 750 out of 1000, sink 2 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E} +// REMARK: instrprof-vtable-value-prof.cpp:223:5: Promote indirect call to _ZN8Derived1D0Ev with count 250 out of 250, sink 2 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1} // The IR matchers for indirect callsite `ptr->func`. // IR-LABEL: @main diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index be6f4c7464dc23..2baca05988808d 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -1760,11 +1760,11 @@ void PGOUseFunc::annotateValueSites(uint32_t Kind) { unsigned NumValueSites = ProfileRecord.getNumValueSites(Kind); // FuncPGOInstrumentation ctor finds value sites for each kind. It runs on the // common path of pgo-instr-gen and pgo-instr-use, and vtable kind path - // is gated by `-enable-vtable-value-profiling`. Give pgo-instr-use pass a - // second chance to find out vtable value sites when vtable profiles are - // present and `-enable-vtable-profile-use` is not explicitly off. + // is gated by `-enable-vtable-value-profiling`. If vtable profiles are + // present, not explicitly discarded and vtable sites remain empty, try to + // find the sites again. if (NumValueSites > 0 && Kind == IPVK_VTableTarget && - NumValueSites != FuncInfo.ValueSites[IPVK_VTableTarget].size() && + FuncInfo.ValueSites[Kind].empty() && !(EnableVTableProfileUse.getNumOccurrences() && EnableVTableProfileUse == false)) FuncInfo.ValueSites[IPVK_VTableTarget] = VPC.get(IPVK_VTableTarget);