diff --git a/llvm/test/tools/llvm-profgen/cs-preinline.test b/llvm/test/tools/llvm-profgen/cs-preinline.test --- a/llvm/test/tools/llvm-profgen/cs-preinline.test +++ b/llvm/test/tools/llvm-profgen/cs-preinline.test @@ -10,7 +10,7 @@ ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --csspgo-preinliner=1 -sample-profile-cold-inline-threshold=0 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-NO-PREINL -; CHECK-DEFAULT: [main:1 @ foo]:309:0 +; CHECK-DEFAULT: [main:1 @ foo]:225:0 ; CHECK-DEFAULT-NEXT: 2.1: 14 ; CHECK-DEFAULT-NEXT: 3: 15 ; CHECK-DEFAULT-NEXT: 3.1: 14 bar:14 @@ -20,7 +20,7 @@ ; CHECK-DEFAULT-NEXT: 1: 14 ; CHECK-DEFAULT-NEXT: !Attributes: 1 -; CHECK-PREINL: [foo]:309:0 +; CHECK-PREINL: [foo]:225:0 ; CHECK-PREINL-NEXT: 2.1: 14 ; CHECK-PREINL-NEXT: 3: 15 ; CHECK-PREINL-NEXT: 3.1: 14 bar:14 @@ -30,7 +30,7 @@ ; CHECK-PREINL-NEXT: 1: 14 ; CHECK-PREINL-NEXT: !Attributes: 3 -; CHECK-NO-PREINL: [foo]:309:0 +; CHECK-NO-PREINL: [foo]:225:0 ; CHECK-NO-PREINL-NEXT: 2.1: 14 ; CHECK-NO-PREINL-NEXT: 3: 15 ; CHECK-NO-PREINL-NEXT: 3.1: 14 bar:14 diff --git a/llvm/test/tools/llvm-profgen/duplication-factor.test b/llvm/test/tools/llvm-profgen/duplication-factor.test --- a/llvm/test/tools/llvm-profgen/duplication-factor.test +++ b/llvm/test/tools/llvm-profgen/duplication-factor.test @@ -5,24 +5,24 @@ ; Test when the duplication factor is 10 -; CHECK:[main:1 @ foo]:1716:0 +; CHECK:[main:1 @ foo]:1576:0 ; CHECK: 2.1: 150 ; CHECK: 2.2: 160 ; CHECK: 2.3: 176 bar:16 -; CHECK:[main:1 @ foo:2.3 @ bar]:192:0 +; CHECK:[main:1 @ foo:2.3 @ bar]:176:0 ; CHECK: 1: 16 -; CHECK-STRIP-CTX: main:1892:0 +; CHECK-STRIP-CTX: main:1736:0 ; CHECK-STRIP-CTX: 0: 0 ; CHECK-STRIP-CTX: 2: 0 -; CHECK-STRIP-CTX: 1: foo:1892 +; CHECK-STRIP-CTX: 1: foo:1736 ; CHECK-STRIP-CTX: 2.1: 150 ; CHECK-STRIP-CTX: 2.2: 160 ; CHECK-STRIP-CTX: 2.3: 160 ; CHECK-STRIP-CTX: 2.4: 0 ; CHECK-STRIP-CTX: 3: 0 -; CHECK-STRIP-CTX: 2.3: bar:192 +; CHECK-STRIP-CTX: 2.3: bar:176 ; CHECK-STRIP-CTX: 1: 16 ; Here we manually generate the duplication-factor in discriminator for the test. diff --git a/llvm/test/tools/llvm-profgen/fname-canonicalization.test b/llvm/test/tools/llvm-profgen/fname-canonicalization.test --- a/llvm/test/tools/llvm-profgen/fname-canonicalization.test +++ b/llvm/test/tools/llvm-profgen/fname-canonicalization.test @@ -2,7 +2,7 @@ ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/unique-linkage-name-dwarf.perfscript --binary=%S/Inputs/unique-linkage-name-dwarf.perfbin --output=%t --profile-summary-cold-count=0 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-DWARF-FNAME -; CHECK-DWARF-FNAME:[main:1 @ foo]:309:0 +; CHECK-DWARF-FNAME:[main:1 @ foo]:225:0 ; CHECK-DWARF-FNAME: 2: 14 ; CHECK-DWARF-FNAME: 3: 29 bar.__uniq.26267048767521081047744692097241227776:14 ; CHECK-DWARF-FNAME:[main:1 @ foo:3 @ bar.__uniq.26267048767521081047744692097241227776]:84:0 diff --git a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test --- a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test +++ b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test @@ -5,7 +5,7 @@ ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --profile-summary-cold-count=0 --strip-context ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-STRIP-CTX -; CHECK:[main:1 @ foo]:309:0 +; CHECK:[main:1 @ foo]:225:0 ; CHECK: 2.1: 14 ; CHECK: 3: 15 ; CHECK: 3.1: 14 bar:14 @@ -13,10 +13,10 @@ ; CHECK:[main:1 @ foo:3.1 @ bar]:84:0 ; CHECK: 1: 14 -; CHECK-STRIP-CTX: main:379:0 +; CHECK-STRIP-CTX: main:295:0 ; CHECK-STRIP-CTX: 0: 0 ; CHECK-STRIP-CTX: 2: 0 -; CHECK-STRIP-CTX: 1: foo:379 +; CHECK-STRIP-CTX: 1: foo:295 ; CHECK-STRIP-CTX: 2.1: 14 ; CHECK-STRIP-CTX: 3: 15 ; CHECK-STRIP-CTX: 3.2: 1 diff --git a/llvm/test/tools/llvm-profgen/inline-noprobe.test b/llvm/test/tools/llvm-profgen/inline-noprobe.test --- a/llvm/test/tools/llvm-profgen/inline-noprobe.test +++ b/llvm/test/tools/llvm-profgen/inline-noprobe.test @@ -3,15 +3,15 @@ ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe.perfscript --binary=%S/Inputs/inline-noprobe.perfbin --output=%t ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK -CHECK: main:836:0 +CHECK: main:669:0 CHECK: 0: 0 CHECK: 2: 0 -CHECK: 1: foo:836 +CHECK: 1: foo:669 CHECK: 2.1: 42 CHECK: 3: 62 CHECK: 3.2: 21 CHECK: 4: 0 -CHECK: 3.1: bar:252 +CHECK: 3.1: bar:210 CHECK: 1: 42 CHECK: 3.2: bar:63 CHECK: 1: 21 diff --git a/llvm/test/tools/llvm-profgen/multi-load-segs.test b/llvm/test/tools/llvm-profgen/multi-load-segs.test --- a/llvm/test/tools/llvm-profgen/multi-load-segs.test +++ b/llvm/test/tools/llvm-profgen/multi-load-segs.test @@ -1,7 +1,7 @@ ; RUN: llvm-profgen --perfscript=%S/Inputs/multi-load-segs.perfscript --binary=%S/Inputs/multi-load-segs.perfbin --output=%t --format=text ; RUN: FileCheck %s --input-file %t -;; %S/Inputs/multi-load-segs.perfbin is an ELF image with two executable load segments. +;; %S/Inputs/multi-load-segs.perfbin is an ELF image with two executable load segments. ; running llvm-readelf -l %S/Inputs/multi-load-segs.perfbin gives: ;; LOAD 0x000000 0x0000000000200000 0x0000000000200000 0x00075c 0x00075c R 0x1000 ;; LOAD 0x000760 0x0000000000201760 0x0000000000201760 0x0004c0 0x0004c0 R E 0x1000 @@ -9,7 +9,7 @@ ;; LOAD 0x000e10 0x0000000000203e10 0x0000000000203e10 0x000040 0x000058 RW 0x1000 ;; LOAD 0x200000 0x0000000000400000 0x0000000000400000 0x0005e8 0x0005e8 R E 0x200000 -; CHECK: [main:2 @ _Z10sort_arrayv:6 @ _Z11bubble_sortPii]:465:0 +; CHECK: [main:2 @ _Z10sort_arrayv:6 @ _Z11bubble_sortPii]:434:0 ; CHECK-NEXT: 4: 31 ; CHECK-NEXT: 5: 31 ; CHECK-NEXT: 7: 31 diff --git a/llvm/test/tools/llvm-profgen/recursion-compression-noprobe.test b/llvm/test/tools/llvm-profgen/recursion-compression-noprobe.test --- a/llvm/test/tools/llvm-profgen/recursion-compression-noprobe.test +++ b/llvm/test/tools/llvm-profgen/recursion-compression-noprobe.test @@ -6,26 +6,24 @@ ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/recursion-compression-noprobe.perfscript --binary=%S/Inputs/recursion-compression-noprobe.perfbin --output=%t --compress-recursion=0 --profile-summary-cold-count=0 --csprof-max-context-depth=2 ; RUN: FileCheck %s --input-file %t -check-prefix=CHECK-MAX-CTX-DEPTH -; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa:2 @ fb]:48:0 +; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa:2 @ fb]:37:0 ; CHECK-UNCOMPRESS: 1: 11 ; CHECK-UNCOMPRESS: 2: 1 fa:1 -; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa]:24:0 +; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa]:21:0 ; CHECK-UNCOMPRESS: 1: 1 ; CHECK-UNCOMPRESS: 2: 13 fb:11 ; CHECK-UNCOMPRESS:[main:1 @ foo]:7:0 ; CHECK-UNCOMPRESS: 2: 1 ; CHECK-UNCOMPRESS: 3: 2 fa:1 -; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa:2 @ fb:2 @ fa]:7:0 +; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa:2 @ fb:2 @ fa]:6:0 ; CHECK-UNCOMPRESS: 1: 1 -; CHECK-UNCOMPRESS: 2: 2 fb:1 -; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa:2 @ fb:2 @ fa:2 @ fb]:2:0 -; CHECK-UNCOMPRESS: 2: 1 fa:1 +; CHECK-UNCOMPRESS: 2: 1 ; CHECK-UNCOMPRESS:[main:1 @ foo:3 @ fa:2 @ fb:2 @ fa:2 @ fb:2 @ fa]:2:0 ; CHECK-UNCOMPRESS: 4: 1 -; CHECK-MAX-CTX-DEPTH:[foo:3 @ fa:2 @ fb]:47:0 +; CHECK-MAX-CTX-DEPTH:[foo:3 @ fa:2 @ fb]:36:0 ; CHECK-MAX-CTX-DEPTH: 1: 11 -; CHECK-MAX-CTX-DEPTH:[main:1 @ foo:3 @ fa]:13:0 +; CHECK-MAX-CTX-DEPTH:[main:1 @ foo:3 @ fa]:10:0 ; CHECK-MAX-CTX-DEPTH: 1: 1 ; CHECK-MAX-CTX-DEPTH: 2: 2 ; CHECK-MAX-CTX-DEPTH:[fa:2 @ fb:2 @ fa]:8:0 @@ -35,24 +33,21 @@ ; CHECK-MAX-CTX-DEPTH:[main:1 @ foo]:7:0 ; CHECK-MAX-CTX-DEPTH: 2: 1 ; CHECK-MAX-CTX-DEPTH: 3: 2 fa:1 -; CHECK-MAX-CTX-DEPTH:[fb:2 @ fa:2 @ fb]:1:0 -; CHECK: [main:1 @ foo:3 @ fa:2 @ fb]:48:0 +; CHECK: [main:1 @ foo:3 @ fa:2 @ fb]:37:0 ; CHECK: 1: 11 ; CHECK: 2: 1 fa:1 -; CHECK: [main:1 @ foo:3 @ fa]:24:0 +; CHECK: [main:1 @ foo:3 @ fa]:21:0 ; CHECK: 1: 1 ; CHECK: 2: 13 fb:11 -; CHECK: [main:1 @ foo:3 @ fa:2 @ fb:2 @ fa]:9:0 +; CHECK: [main:1 @ foo:3 @ fa:2 @ fb:2 @ fa]:8:0 ; CHECK: 1: 1 -; CHECK: 2: 2 fb:1 +; CHECK: 2: 1 ; CHECK: 4: 1 ; CHECK: [main:1 @ foo]:7:0 ; CHECK: 2: 1 ; CHECK: 3: 2 fa:1 -; CHECK: [main:1 @ foo:3 @ fa:2 @ fb:2 @ fa:2 @ fb]:1:0 - ; original code: ; clang -O3 -g test.c -o a.out diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp --- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp +++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp @@ -431,9 +431,6 @@ void ProfileGenerator::updateBodySamplesforFunctionProfile( FunctionSamples &FunctionProfile, const SampleContextFrame &LeafLoc, uint64_t Count) { - // Filter out invalid negative(int type) lineOffset - if (LeafLoc.Callsite.LineOffset & 0x80000000) - return; // Use the maximum count of samples with same line location uint32_t Discriminator = getDiscriminator(LeafLoc.Callsite.Discriminator); ErrorOr R = diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp --- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp +++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp @@ -538,6 +538,10 @@ LineOffset = PseudoProbeDwarfDiscriminator::extractProbeIndex(Discriminator); Discriminator = 0; + } else { + // Filter out invalid negative(int type) lineOffset + if (LineOffset & 0x80000000) + return SampleContextFrameVector(); } LineLocation Line(LineOffset, Discriminator);