[PATCH] D30233: Fix an obvious bug in SampleProfileReaderGCC.
Dehao Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 22 09:19:20 PST 2017
danielcdh updated this revision to Diff 89372.
danielcdh added a comment.
The gcc reader does not work on certain architectures. Move the tests to a separate file and added XFAIL for those architectures.
https://reviews.llvm.org/D30233
Files:
lib/ProfileData/SampleProfReader.cpp
test/Transforms/SampleProfile/Inputs/indirect-call.afdo
test/Transforms/SampleProfile/indirect-call-gcc.ll
Index: test/Transforms/SampleProfile/indirect-call-gcc.ll
===================================================================
--- /dev/null
+++ test/Transforms/SampleProfile/indirect-call-gcc.ll
@@ -0,0 +1,26 @@
+; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call.afdo -S | FileCheck %s
+
+; Checks if indirect call targets are read correctly when reading from gcc
+; format profile.
+; It is expected to fail on certain architectures as gcc profile reader does
+; not work.
+; XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
+
+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]+]]
+ call void %3(), !dbg !4
+ ret void
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
+!1 = !DIFile(filename: "test.cc", directory: "/")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, unit: !0)
+!4 = !DILocation(line: 5, scope: !3)
+; CHECK: ![[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.89372.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/90f94cb1/attachment.bin>
More information about the llvm-commits
mailing list