Index: lib/ProfileData/SampleProfReader.cpp =================================================================== --- lib/ProfileData/SampleProfReader.cpp +++ lib/ProfileData/SampleProfReader.cpp @@ -681,11 +681,9 @@ if (!GcovBuffer.readInt64(TargetCount)) return sampleprof_error::truncated; - if (Update) { - FunctionSamples &TargetProfile = Profiles[TargetName]; - TargetProfile.addCalledTargetSamples(LineOffset, Discriminator, - TargetName, TargetCount); - } + if (Update) + FProfile->addCalledTargetSamples(LineOffset, Discriminator, + TargetName, TargetCount); } } Index: test/Transforms/SampleProfile/indirect-call.ll =================================================================== --- test/Transforms/SampleProfile/indirect-call.ll +++ test/Transforms/SampleProfile/indirect-call.ll @@ -1,16 +1,20 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call.prof -S | FileCheck %s +; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call.afdo -S | FileCheck --check-prefix=GCC %s ; CHECK-LABEL: @test +; GCC-LABEL: @test define void @test(void ()*) !dbg !3 { %2 = alloca void ()* store void ()* %0, void ()** %2 %3 = load void ()*, void ()** %2 ; CHECK: call {{.*}}, !prof ![[PROF:[0-9]+]] + ; GCC: call {{.*}}, !prof ![[PROF:[0-9]+]] call void %3(), !dbg !4 ret void } ; CHECK-LABEL: @test_inline +; GCC-LABEL: @test_inline ; If the indirect call is promoted and inlined in profile, we should promote and inline it. define void @test_inline(i64* (i32*)*, i32* %x) !dbg !3 { %2 = alloca i64* (i32*)* @@ -72,3 +76,4 @@ !4 = !DILocation(line: 5, scope: !3) !5 = !DILocation(line: 6, scope: !3) ; CHECK: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398} +; GCC: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}