Skip to content

A copy of https://github.com/llvm/llvm-project/pull/66825. Actually this is a superset (a copy plus the thinlto-import change) #80761

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

Closed
wants to merge 35 commits into from

Conversation

mingmingl-llvm
Copy link
Contributor

No description provided.

Created using spr 1.3.4
Copy link

github-actions bot commented Feb 5, 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 300425cea51ef566a4d38e57afd9a7ae8024a682 c46056846be395ca47a76726089bf541b34ecc5f -- compiler-rt/include/profile/InstrProfData.inc compiler-rt/lib/profile/InstrProfiling.h compiler-rt/lib/profile/InstrProfilingBuffer.c compiler-rt/lib/profile/InstrProfilingFile.c compiler-rt/lib/profile/InstrProfilingInternal.h compiler-rt/lib/profile/InstrProfilingMerge.c compiler-rt/lib/profile/InstrProfilingPlatformAIX.c compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c compiler-rt/lib/profile/InstrProfilingPlatformLinux.c compiler-rt/lib/profile/InstrProfilingPlatformOther.c compiler-rt/lib/profile/InstrProfilingPlatformWindows.c compiler-rt/lib/profile/InstrProfilingWriter.c compiler-rt/test/profile/instrprof-write-buffer-internal.c llvm/include/llvm/Analysis/IndirectCallVisitor.h llvm/include/llvm/ProfileData/InstrProf.h llvm/include/llvm/ProfileData/InstrProfData.inc llvm/include/llvm/ProfileData/InstrProfReader.h llvm/include/llvm/ProfileData/InstrProfWriter.h llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp llvm/lib/Analysis/ModuleSummaryAnalysis.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/ProfileData/InstrProf.cpp llvm/lib/ProfileData/InstrProfReader.cpp llvm/lib/ProfileData/InstrProfWriter.cpp llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp llvm/lib/Transforms/Instrumentation/ValueProfilePlugins.inc llvm/tools/llvm-profdata/llvm-profdata.cpp llvm/unittests/ProfileData/InstrProfTest.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index b6e70e467e..e5f7240d7c 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -610,21 +610,21 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
 
   uint64_t VTableNamesSectionStart = OS.tell();
 
-    std::string CompressedVTableNames;
+  std::string CompressedVTableNames;
 
-    std::vector<std::string> VTableNameStrs;
-    for (const auto &VTableName : VTableNames.keys()) {
-      VTableNameStrs.push_back(VTableName.str());
-    }
+  std::vector<std::string> VTableNameStrs;
+  for (const auto &VTableName : VTableNames.keys()) {
+    VTableNameStrs.push_back(VTableName.str());
+  }
 
-    if (!VTableNameStrs.empty()) {
-      if (Error E = collectGlobalObjectNameStrings(
-              VTableNameStrs, compression::zlib::isAvailable(),
-              CompressedVTableNames))
-        return E;
-    }
+  if (!VTableNameStrs.empty()) {
+    if (Error E = collectGlobalObjectNameStrings(
+            VTableNameStrs, compression::zlib::isAvailable(),
+            CompressedVTableNames))
+      return E;
+  }
 
-    uint64_t CompressedStringLen = CompressedVTableNames.length();
+  uint64_t CompressedStringLen = CompressedVTableNames.length();
 
   // Record the length of compressed string.
   OS.write(CompressedStringLen);

@mingmingl-llvm mingmingl-llvm changed the base branch from main to users/minglotus-6/typeprofrawformat February 14, 2024 23:41
@mingmingl-llvm mingmingl-llvm changed the title [Placeholder] A copy of https://github.com/llvm/llvm-project/pull/66825. Actually this is a superset (a copy plus the thinlto-import change) Feb 15, 2024
Base automatically changed from users/minglotus-6/typeprofrawformat to main February 22, 2024 04:59
mingmingl-llvm added a commit that referenced this pull request Feb 22, 2024
…r type profiling. (#81691)

* Raw profile format
- Header: records the byte size of compressed vtable names, and the
number of profiled vtable entries (call it `VTableProfData`). Header
also records padded bytes of each section.
- Payload: adds a section for compressed vtable names, and a section to
store `VTableProfData`. Both sections are padded so the size is a
multiple of 8.
* Indexed profile format
  - Header: records the byte offset of compressed vtable names.
- Payload: adds a section to store compressed vtable names. This section
is used by `llvm-profdata` to show the list of vtables profiled for an
instrumented site.
  
[The originally reviewed
patch](#66825) will have
profile reader/write change and llvm-profdata change.
- To ensure this PR has all the necessary profile format change along
with profile version bump, created a copy of the originally reviewed
patch in #80761. The copy
doesn't have profile format change, but it has the set of tests which
covers type profile generation, profile read and profile merge. Tests
pass there.
  
rfc in
https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600

---------

Co-authored-by: modiking <modiking213@gmail.com>
@mingmingl-llvm mingmingl-llvm changed the base branch from main to users/minglotus-6/typeprofrawformat February 26, 2024 06:22
@mingmingl-llvm mingmingl-llvm changed the base branch from users/minglotus-6/typeprofrawformat to main February 26, 2024 09:48
@mingmingl-llvm mingmingl-llvm changed the base branch from main to users/minglotus-6/typeprofrawformat February 26, 2024 20:23
Base automatically changed from users/minglotus-6/typeprofrawformat to main February 27, 2024 19:07
mingmingl-llvm added a commit that referenced this pull request Feb 27, 2024
…hange for type profiling." (#82711)

New change on top of [reviewed
patch](#81691) are [in commits
after this
one](d0757f4).
Previous commits are restored from the remote branch with timestamps.

1. Fix build breakage for non-ELF platforms, by defining the missing
functions {`__llvm_profile_begin_vtables`, `__llvm_profile_end_vtables`,
`__llvm_profile_begin_vtabnames `, `__llvm_profile_end_vtabnames`}
everywhere.
* Tested on mac laptop (for darwins) and Windows. Specifically,
functions in `InstrProfilingPlatformWindows.c` returns `NULL` to make it
more explicit that type prof isn't supported; see comments for the
reason.
* For the rest (AIX, other), mostly follow existing examples (like this
[one](f95b2f1))
   
2. Rename `__llvm_prf_vtabnames` -> `__llvm_prf_vns` for shorter section
name, and make returned pointers
[const](a825d2a#diff-4de780ce726d76b7abc9d3353aef95013e7b21e7bda01be8940cc6574fb0b5ffR120-R121)

**Original Description**

* Raw profile format
- Header: records the byte size of compressed vtable names, and the
number of profiled vtable entries (call it `VTableProfData`). Header
also records padded bytes of each section.
- Payload: adds a section for compressed vtable names, and a section to
store `VTableProfData`. Both sections are padded so the size is a
multiple of 8.
* Indexed profile format
  - Header: records the byte offset of compressed vtable names.
- Payload: adds a section to store compressed vtable names. This section
is used by `llvm-profdata` to show the list of vtables profiled for an
instrumented site.
  
[The originally reviewed
patch](#66825) will have
profile reader/write change and llvm-profdata change.
- To ensure this PR has all the necessary profile format change along
with profile version bump, created a copy of the originally reviewed
patch in #80761. The copy
doesn't have profile format change, but it has the set of tests which
covers type profile generation, profile read and profile merge. Tests
pass there.
  
rfc in
https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600

---------

Co-authored-by: modiking <modiking213@gmail.com>
@mingmingl-llvm
Copy link
Contributor Author

Closing this and delete the branch. It's used to assist stack reviews. Formal code are already in review.

@mingmingl-llvm mingmingl-llvm deleted the users/minglotus-6/spr/placeholder branch February 28, 2024 21:50
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.

1 participant