Skip to content

[llvm-profdata] Enabled functionality to write split-layout profile #101795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

huangjd
Copy link
Contributor

@huangjd huangjd commented Aug 3, 2024

Using the flag -split_layout in llvm-profdata merge, the output profile can write profiles with and without inlined function into two different extbinary sections (and their FuncOffsetTable too). The section without inlined functions are marked with SecFlagFlat and is skipped by ThinLTO because it provides no useful info.

The split layout feature was already implemented in SampleProfWriter but previously there is no way to use it from llvm-profdata.

@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:binary-utilities labels Aug 3, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 3, 2024

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-pgo

Author: William Junda Huang (huangjd)

Changes

Using the flag -split_layout in llvm-profdata merge, the output profile can write profiles with and without inlined function into two different extbinary sections (and their FuncOffsetTable too). The section without inlined functions are marked with SecFlagFlat and is skipped by ThinLTO because it provides no useful info.

The split layout feature was already implemented in SampleProfWriter but previously there is no way to use it from llvm-profdata.


Full diff: https://github.com/llvm/llvm-project/pull/101795.diff

4 Files Affected:

  • (modified) llvm/docs/CommandGuide/llvm-profdata.rst (+6)
  • (added) llvm/test/tools/llvm-profdata/Inputs/split-layout.profdata ()
  • (added) llvm/test/tools/llvm-profdata/sample-split-layout.test (+2)
  • (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+12)
diff --git a/llvm/docs/CommandGuide/llvm-profdata.rst b/llvm/docs/CommandGuide/llvm-profdata.rst
index acf016a6dbcd7..166f694a2a611 100644
--- a/llvm/docs/CommandGuide/llvm-profdata.rst
+++ b/llvm/docs/CommandGuide/llvm-profdata.rst
@@ -162,6 +162,12 @@ OPTIONS
  coverage for the optimized target. This option can only be used with
  sample-based profile in extbinary format.
 
+.. option:: --split_layout=[true|false]
+
+ Split the profile data section to two with one containing sample profiles with
+ inlined functions and the other not. This option can only be used with
+ sample-based profile in extbinary format.
+
 .. option:: --convert-sample-profile-layout=[nest|flat]
 
  Convert the merged profile into a profile with a new layout. Supported
diff --git a/llvm/test/tools/llvm-profdata/Inputs/split-layout.profdata b/llvm/test/tools/llvm-profdata/Inputs/split-layout.profdata
new file mode 100644
index 0000000000000..bc473ae76558f
Binary files /dev/null and b/llvm/test/tools/llvm-profdata/Inputs/split-layout.profdata differ
diff --git a/llvm/test/tools/llvm-profdata/sample-split-layout.test b/llvm/test/tools/llvm-profdata/sample-split-layout.test
new file mode 100644
index 0000000000000..60a194e108362
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/sample-split-layout.test
@@ -0,0 +1,2 @@
+RUN: llvm-profdata merge --sample --extbinary --split_layout %p/Inputs/sample-profile.proftext -o %t-output
+RUN: diff %t-output %p/Inputs/split-layout.profdata
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 1f6c4c604d57b..1f6efa788b1b8 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -207,6 +207,12 @@ cl::opt<bool> GenPartialProfile(
     "gen-partial-profile", cl::init(false), cl::Hidden,
     cl::sub(MergeSubcommand),
     cl::desc("Generate a partial profile (only meaningful for -extbinary)"));
+cl::opt<bool> SplitLayout(
+    "split_layout", cl::init(false), cl::Hidden,
+    cl::sub(MergeSubcommand),
+    cl::desc("Split the profile to two sections with one containing sample "
+             "profiles with inlined functions and the another not (only "
+             "meaningful for -extbinary)"));
 cl::opt<std::string> SupplInstrWithSample(
     "supplement-instr-with-sample", cl::init(""), cl::Hidden,
     cl::sub(MergeSubcommand),
@@ -1492,6 +1498,12 @@ static void handleExtBinaryWriter(sampleprof::SampleProfileWriter &Writer,
     else
       Writer.setPartialProfile();
   }
+  if (SplitLayout) {
+    if (OutputFormat != PF_Ext_Binary)
+      warn("-split-layout is ignored. Specify -extbinary to enable it");
+    else
+      Writer.resetSecLayout(SectionLayout::CtxSplitLayout);
+  }
 }
 
 static void mergeSampleProfile(const WeightedFileVector &Inputs,

@huangjd huangjd added llvm-tools All llvm tools that do not have corresponding tag and removed llvm:binary-utilities labels Aug 3, 2024
Copy link

github-actions bot commented Aug 3, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff a7ba73bf614f6d147bd1cdaddee156bd85e31703 a2c0b510e0cee06b9ef004eee4a3d12f7d9e6b99 --extensions h,cpp -- llvm/include/llvm/ProfileData/SampleProfReader.h llvm/include/llvm/ProfileData/SampleProfWriter.h llvm/lib/ProfileData/SampleProfReader.cpp llvm/lib/ProfileData/SampleProfWriter.cpp llvm/tools/llvm-profdata/llvm-profdata.cpp
View the diff from clang-format here.
diff --git a/llvm/include/llvm/ProfileData/SampleProfWriter.h b/llvm/include/llvm/ProfileData/SampleProfWriter.h
index 4b659eaf95..cbde6cb5ab 100644
--- a/llvm/include/llvm/ProfileData/SampleProfWriter.h
+++ b/llvm/include/llvm/ProfileData/SampleProfWriter.h
@@ -176,9 +176,7 @@ protected:
     return sampleprof_error::success;
   }
 
-  void setUseCtxSplitLayout() override {
-    MarkFlatProfiles = true;
-  }
+  void setUseCtxSplitLayout() override { MarkFlatProfiles = true; }
 
 private:
   /// Indent level to use when writing.
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 3b775de11e..a72f4dc060 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -208,8 +208,7 @@ cl::opt<bool> GenPartialProfile(
     cl::sub(MergeSubcommand),
     cl::desc("Generate a partial profile (only meaningful for -extbinary)"));
 cl::opt<bool> SplitLayout(
-    "split-layout", cl::init(false), cl::Hidden,
-    cl::sub(MergeSubcommand),
+    "split-layout", cl::init(false), cl::Hidden, cl::sub(MergeSubcommand),
     cl::desc("Split the profile to two sections with one containing sample "
              "profiles with inlined functions and the other without (only "
              "meaningful for -extbinary)"));

@@ -0,0 +1,2 @@
RUN: llvm-profdata merge --sample --extbinary --split_layout %p/Inputs/sample-profile.proftext -o %t-output
RUN: diff %t-output %p/Inputs/split-layout.profdata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test this without checking in the binary file split-layout.profdata?

If you must use a binary file, consider using printf to create the file so changes can be reviewed.

RUN: printf '\xffcgdata\x81' > %t_version.cgdata
RUN: printf '\x02\x00\x00\x00' >> %t_version.cgdata
RUN: printf '\x00\x00\x00\x00' >> %t_version.cgdata
RUN: printf '\x18\x00\x00\x00\x00\x00\x00\x00' >> %t_version.cgdata
RUN: not llvm-cgdata --show %t_version.cgdata 2>&1 | FileCheck %s --check-prefix=BAD_VERSION

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way to avoid checking in binary file is to convert it to text format (with llvm-profdata merge --text) as input, and convert it back to binary file with a RUN line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is no way to represent flat profile in text mode, I will have to implement that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there's no point to represent that in text mode, because the point of split layout is to allow sample profile reader to skip reading an entire section when used by ThinLTO since samples without inline callsites provide no info to advise inlining. In text mode the profile is read sequentially anyways so you can't skip anything

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is no way to represent flat profile in text mode, I will have to implement that

Maybe we can try --show-sec-info-only to check the section size. The size would change if others remove what you adds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking section info only sounds good to me.

@mingmingl-llvm
Copy link
Contributor

A drive-by comment, what's the use case to write split-layout profile?

@@ -0,0 +1,2 @@
RUN: llvm-profdata merge --sample --extbinary --split_layout %p/Inputs/sample-profile.proftext -o %t-output
RUN: diff %t-output %p/Inputs/split-layout.profdata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds good.

@huangjd
Copy link
Contributor Author

huangjd commented Aug 8, 2024

A drive-by comment, what's the use case to write split-layout profile?

ThinLTO uses samples with inlined functions to decide whether to perform inline or not, so samples without inlined functions are useless in this stage, we gather them in one section so that they can be skipped entirely without building a funcoffsettable for them

@huangjd
Copy link
Contributor Author

huangjd commented Aug 8, 2024

Added text mode representation for checking purpose .

// This metadata is only for manual inspection only. We already created a
// FunctionSamples and put it in the profile map, so there is no point
// to skip profiles even they have no use for ThinLTO.
if (Input == StringRef(" !Flat"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to make sure that profiles in different formats, originating from the same source, to be equivalent. This means that if we do a round-trip conversion—from a "text" profile to an "extbinary" profile and back to a "text" profile—the two text profiles before and after the conversion should be identical. However, it seems that here the "!flat" metadata would be lost because we treat "!Flat" as a no-op, and the extended binary format won't be set to split-layout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text and Extbinary mode was already not perfectly compatible. There are already various types of info that will be lost when converting Extbinary to Text, for example Profile Symbol List, flags such as PartialProfile, ProfileIsFS etc. Furthermore, the sample profile writer splits flat profiles from non-flat profiles at runtime, and the reader ignores the flag if used by llvm-profdata (instead of used by thinLTO), so the flag is a no-op in this sense, and the round trip output will be identical, unless the user intentionally marked a non-flat function as flat, which doesn't make sense anyways (profile reader could emit a warning in this case but it is also pointless, because 1. in llvm-profdata the writer will correct this, 2. in thinLTO the flat section is skipped intentionally so we don't even know there's non-flat function inside 3. in other compilation mode we read all functions with matching names regardless they are flat or not.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does losing !flat change the semantics of the profile? If not, they are still equivalent? On other hand, instead of using meta data, would a comment line be sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the clarification. I thought for other incompatible cases( Profile Symbol List, PartialProfile, ProfileIsFS, etc), mostly because they don't support text format, but here as the text format is added, so maybe it's not hard to support the compatibility.

@WenleiHe
Copy link
Member

Update change summary: split_layout -> split-layout

but previously there is no way to use it from llvm-profdata.

How was it previously used?

Copy link
Contributor

@david-xl david-xl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG with Wenlei's last comment addressed.

@huangjd
Copy link
Contributor Author

huangjd commented Aug 28, 2024

Update change summary: split_layout -> split-layout

but previously there is no way to use it from llvm-profdata.

How was it previously used?

There is a function in SampleProfileWriter resetSecLayout which can be called with the value CtxSplitLayout to change it into split layout. It is not used anywhere in LLVM so there is no user access to it. However in our internal tools we do call this function to create such profile. This patch make this option available to the user.

Using the flag `-split_layout` in llvm-profdata merge, the output
profile can write profiles with and without inlined function into two
different extbinary sections (and their FuncOffsetTable too). The
section without inlined functions are marked with `SecFlagFlat` and is
skipped by ThinLTO because it provides no useful info.

The split layout feature was already implemented in SampleProfWriter but previously
there is no way from the tool to use it.
Fixed wordings refering to this flag, Previously it is described as
"samples with/out context", which confuses with CSSPGO. Now they are
called "samples/functions with/out inlined functions"
@huangjd huangjd force-pushed the llvmprofdataFlatProfile branch from 44c28cf to a2c0b51 Compare August 29, 2024 00:05
@huangjd huangjd merged commit 75e9d19 into llvm:main Aug 29, 2024
5 of 8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 29, 2024

LLVM Buildbot has detected a new failure on builder clang-solaris11-sparcv9 running on solaris11-sparcv9 while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/13/builds/1865

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: Transforms/SampleProfile/inline-replay.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/opt < /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/inline-replay.ll -passes=sample-profile -sample-profile-file=/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/Inputs/inline-topdown.prof -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output 2>&1 | /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/FileCheck -check-prefix=DEFAULT /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/inline-replay.ll
+ /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/opt -passes=sample-profile -sample-profile-file=/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/Inputs/inline-topdown.prof -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline --disable-output
+ /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/FileCheck -check-prefix=DEFAULT /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/inline-replay.ll
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/inline-replay.ll:67:12: error: DEFAULT: expected string not found in input
; DEFAULT: '_Z3sumii' inlined into 'main' to match profiling context with (cost={{[-0-9]+}}
           ^
<stdin>:1:1: note: scanning from here
remark: calls.cc:4:0: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost=-5, threshold=3000) at callsite _Z3sumii:1:0;
^
<stdin>:1:23: note: possible intended match here
remark: calls.cc:4:0: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost=-5, threshold=3000) at callsite _Z3sumii:1:0;
                      ^

Input file: <stdin>
Check file: /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/test/Transforms/SampleProfile/inline-replay.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: remark: calls.cc:4:0: '_Z3subii' inlined into '_Z3sumii' to match profiling context with (cost=-5, threshold=3000) at callsite _Z3sumii:1:0; 
check:67'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:67'1                           ?                                                                                                                       possible intended match
>>>>>>

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 29, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux running on sanitizer-buildbot1 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/3190

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
[378/384] Generating FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o
[379/384] Generating FuzzerUtils-x86_64-Test
[380/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[381/384] Generating Msan-x86_64-with-call-Test
[382/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[383/384] Generating Msan-x86_64-Test
[383/384] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 4592 of 10298 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60
FAIL: SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp (3027 of 4592)
******************** TEST 'SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -gline-tables-only -fsanitize=leak  -m32 -funwind-tables  -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=leak -m32 -funwind-tables -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
RUN: at line 5: env LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1      /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -check-prefix=CHECK_MAY_RETURN_1
+ env LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -check-prefix=CHECK_MAY_RETURN_1
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp:68:24: error: CHECK_MAY_RETURN_1: expected string not found in input
// CHECK_MAY_RETURN_1: allocating 512 times
                       ^
<stdin>:52:44: note: scanning from here
Some of the malloc calls returned non-null: 252
                                           ^
<stdin>:52:45: note: possible intended match here
Some of the malloc calls returned non-null: 252
                                            ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           47:  [256] 
           48:  [320] 
           49:  [384] 
           50:  [448] 
           51: Some of the malloc calls returned null: 260 
           52: Some of the malloc calls returned non-null: 252 
check:68'0                                                X~~~~ error: no match found
check:68'1                                                 ?    possible intended match
Step 11 (test compiler-rt debug) failure: test compiler-rt debug (failure)
...
[378/384] Generating FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o
[379/384] Generating FuzzerUtils-x86_64-Test
[380/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[381/384] Generating Msan-x86_64-with-call-Test
[382/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[383/384] Generating Msan-x86_64-Test
[383/384] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 4592 of 10298 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60
FAIL: SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp (3027 of 4592)
******************** TEST 'SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -gline-tables-only -fsanitize=leak  -m32 -funwind-tables  -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=leak -m32 -funwind-tables -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
RUN: at line 5: env LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1      /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -check-prefix=CHECK_MAY_RETURN_1
+ env LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -check-prefix=CHECK_MAY_RETURN_1
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp:68:24: error: CHECK_MAY_RETURN_1: expected string not found in input
// CHECK_MAY_RETURN_1: allocating 512 times
                       ^
<stdin>:52:44: note: scanning from here
Some of the malloc calls returned non-null: 252
                                           ^
<stdin>:52:45: note: possible intended match here
Some of the malloc calls returned non-null: 252
                                            ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           47:  [256] 
           48:  [320] 
           49:  [384] 
           50:  [448] 
           51: Some of the malloc calls returned null: 260 
           52: Some of the malloc calls returned non-null: 252 
check:68'0                                                X~~~~ error: no match found
check:68'1                                                 ?    possible intended match

@huangjd
Copy link
Contributor Author

huangjd commented Aug 29, 2024

I could not reproduce the error on sparcv9 because I don't have the hardware. Those test cases were fine on Linux and I could not reason how would this patch affect them. Could someone also take a look?

@rorth
Copy link
Collaborator

rorth commented Aug 29, 2024

You do, actually: the GCC Compile Farm contains a Solaris/sparcv9 system perfectly equipped to build and test LLVM.

That said, I've done some investigation myself: even in exactly the same configuration as the buildbot (clang-17 as host compiler, both 1-stage and 2-stage builds) I couldn't reproduce the failures. I have to conclude that it's somehow related to the fact that the bot is doing incremental builds most of the time, while my builds were always from scratch.

I've now switched the bot to use clang-19 (19.1.0-rc3) as host compiler and after a fresh build with that one, the failure is gone. Very strange.

@huangjd huangjd deleted the llvmprofdataFlatProfile branch September 3, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:binary-utilities llvm-tools All llvm tools that do not have corresponding tag PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants