[PATCH] D30233: Fix an obvious bug in SampleProfileReaderGCC.
Dehao Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 16:38:26 PST 2017
danielcdh updated this revision to Diff 89301.
danielcdh added a comment.
add unittest
https://reviews.llvm.org/D30233
Files:
lib/ProfileData/SampleProfReader.cpp
test/Transforms/SampleProfile/Inputs/indirect-call.afdo
test/Transforms/SampleProfile/indirect-call.ll
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}
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);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30233.89301.patch
Type: text/x-patch
Size: 2063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/4aad2e24/attachment.bin>
More information about the llvm-commits
mailing list