[llvm] r295852 - Fix an obvious bug in SampleProfileReaderGCC.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 09:27:22 PST 2017


Author: dehao
Date: Wed Feb 22 11:27:21 2017
New Revision: 295852

URL: http://llvm.org/viewvc/llvm-project?rev=295852&view=rev
Log:
Fix an obvious bug in SampleProfileReaderGCC.

Summary: The CallTargetProfile should be added to FProfile to be consistent with other profile readers.

Reviewers: dnovillo, davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D30233

Added:
    llvm/trunk/test/Transforms/SampleProfile/Inputs/indirect-call.afdo   (with props)
    llvm/trunk/test/Transforms/SampleProfile/indirect-call-gcc.ll
Modified:
    llvm/trunk/lib/ProfileData/SampleProfReader.cpp

Modified: llvm/trunk/lib/ProfileData/SampleProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfReader.cpp?rev=295852&r1=295851&r2=295852&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/SampleProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp Wed Feb 22 11:27:21 2017
@@ -681,11 +681,9 @@ std::error_code SampleProfileReaderGCC::
       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);
     }
   }
 

Added: llvm/trunk/test/Transforms/SampleProfile/Inputs/indirect-call.afdo
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/Inputs/indirect-call.afdo?rev=295852&view=auto
==============================================================================
Binary file - no diff available.

Propchange: llvm/trunk/test/Transforms/SampleProfile/Inputs/indirect-call.afdo
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm/trunk/test/Transforms/SampleProfile/indirect-call-gcc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/indirect-call-gcc.ll?rev=295852&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/indirect-call-gcc.ll (added)
+++ llvm/trunk/test/Transforms/SampleProfile/indirect-call-gcc.ll Wed Feb 22 11:27:21 2017
@@ -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}




More information about the llvm-commits mailing list