Skip to content

Reland "[ThinLTO][Bitcode] Generate import type in bitcode" #97253

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 29 commits into from
Jul 9, 2024

Conversation

mingmingl-llvm
Copy link
Contributor

@mingmingl-llvm mingmingl-llvm commented Jul 1, 2024

#87600 was reverted in order to revert 6262763. Now #95482 is fix forward for 6262763. This patch is a reland for #87600

Changes on top of original patch
In llvm/include/llvm/IR/ModuleSummaryIndex.h, make the type of GVSummaryPtrSet an unordered_set which is more memory efficient when the number of elements is smaller than 128 [1]

Original commit message

For distributed ThinLTO, the LTO indexing step generates combined summary for each module, and postlink pipeline reads the combined summary which stores the information for link-time optimization.

This patch populates the 'import type' of a summary in bitcode, and updates bitcode reader to parse the bit correctly.

[1]

Grow(CurArraySize < 64 ? 128 : CurArraySize * 2);

…eSummary::GVFlags

- This change doesn't set the bit in the summaries, just make the code changes.
Update this one accordingly
1. Set 'import-instr-evolution-factor' to 1.0 (default 0.7) to make sure
  import limit remains 7 (otherwise import limit decays through each
  edge)
2. Updated bar* function names
3. Explain why aliasee is null for bar* functions
Copy link

github-actions bot commented Jul 1, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@mingmingl-llvm mingmingl-llvm marked this pull request as ready for review July 8, 2024 18:43
@@ -1277,7 +1278,7 @@ using ModulePathStringTableTy = StringMap<ModuleHash>;
using GVSummaryMapTy = DenseMap<GlobalValue::GUID, GlobalValueSummary *>;

/// A set of global value summary pointers.
using GVSummaryPtrSet = SmallPtrSet<GlobalValueSummary *, 4>;
using GVSummaryPtrSet = std::unordered_set<GlobalValueSummary *>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah nice -- interesting that SmallPtrSet also has a big jump when growing at small sizes! (

Grow(CurArraySize < 64 ? 128 : CurArraySize * 2);
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I corrected the patch description with this link. thanks!

@@ -453,11 +458,16 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
/// Constructs a IndexBitcodeWriter object for the given combined index,
/// writing to the provided \p Buffer. When writing a subset of the index
/// for a distributed backend, provide a \p ModuleToSummariesForIndex map.
/// If provided, \p ModuleToDecSummaries specifies the set of summaries for
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: DecSummaries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@mingmingl-llvm
Copy link
Contributor Author

The pre-commit buildbot failure is irrelevant

 cat github-pull-requests_build_79148_linux-linux-x64.log | grep -B 10 -A 10  "Failed Tests "
[0.70s,0.80s) :: [                                        ] :: [  3/442]
[0.60s,0.70s) :: [                                        ] :: [  2/442]
[0.50s,0.60s) :: [                                        ] :: [ 10/442]
[0.40s,0.50s) :: [                                        ] :: [  9/442]
[0.30s,0.40s) :: [*                                       ] :: [ 22/442]
[0.20s,0.30s) :: [*************                           ] :: [151/442]
[0.10s,0.20s) :: [****************                        ] :: [183/442]
[0.00s,0.10s) :: [*****                                   ] :: [ 61/442]
--------------------------------------------------------------------------
********************
Failed Tests (1):
  BOLT :: X86/reader-stale-yaml-std.test


Testing Time: 2.55s

Total Discovered Tests: 454
  Skipped          :   7 (1.54%)
  Unsupported      :  13 (2.86%)
  Passed           : 431 (94.93%)
  Expectedly Failed:   2 (0.44%)

@mingmingl-llvm mingmingl-llvm merged commit 50fea99 into main Jul 9, 2024
5 of 7 checks passed
@mingmingl-llvm mingmingl-llvm deleted the users/minglotus-6/spr/summary1 branch July 9, 2024 05:20
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
llvm#87600 was reverted in order to
revert
llvm@6262763.
Now llvm#95482 is fix forward for
llvm@6262763.
This patch is a reland for
llvm#87600

**Changes on top of original patch**
In `llvm/include/llvm/IR/ModuleSummaryIndex.h`, make the type of
`GVSummaryPtrSet` an `unordered_set` which is more memory efficient when
the number of elements is smaller than 128 [1]

**Original commit message**

For distributed ThinLTO, the LTO indexing step generates combined
summary for each module, and postlink pipeline reads the combined
summary which stores the information for link-time optimization.

This patch populates the 'import type' of a summary in bitcode, and
updates bitcode reader to parse the bit correctly.

[1]
https://github.com/llvm/llvm-project/blob/393eff4e02e7ab3d234d246a8d6912c8e745e6f9/llvm/lib/Support/SmallPtrSet.cpp#L43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants