Skip to content

[IndirectCallPromotion] Migrate to a new version of getValueProfDataFromInst #97357

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:transforms labels Jul 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2024

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (+8-9)
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index 6a5aeeb8b52cc..0d1f506986379 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -547,18 +547,17 @@ Instruction *IndirectCallPromoter::computeVTableInfos(
   for (size_t I = 0; I < Candidates.size(); I++)
     CalleeIndexMap[Candidates[I].TargetFunction] = I;
 
-  uint32_t ActualNumValueData = 0;
   uint64_t TotalVTableCount = 0;
-  auto VTableValueDataArray = getValueProfDataFromInst(
-      *VirtualCallInfo.VPtr, IPVK_VTableTarget, MaxNumVTableAnnotations,
-      ActualNumValueData, TotalVTableCount);
-  if (VTableValueDataArray.get() == nullptr)
+  auto VTableValueDataArray =
+      getValueProfDataFromInst(*VirtualCallInfo.VPtr, IPVK_VTableTarget,
+                               MaxNumVTableAnnotations, TotalVTableCount);
+  if (VTableValueDataArray.empty())
     return VPtr;
 
   // Compute the functions and counts from by each vtable.
-  for (size_t j = 0; j < ActualNumValueData; j++) {
-    uint64_t VTableVal = VTableValueDataArray[j].Value;
-    GUIDCountsMap[VTableVal] = VTableValueDataArray[j].Count;
+  for (const auto &V : VTableValueDataArray) {
+    uint64_t VTableVal = V.Value;
+    GUIDCountsMap[VTableVal] = V.Count;
     GlobalVariable *VTableVar = Symtab->getGlobalVariable(VTableVal);
     if (!VTableVar) {
       LLVM_DEBUG(dbgs() << "  Cannot find vtable definition for " << VTableVal
@@ -586,7 +585,7 @@ Instruction *IndirectCallPromoter::computeVTableInfos(
     // There shouldn't be duplicate GUIDs in one !prof metadata (except
     // duplicated zeros), so assign counters directly won't cause overwrite or
     // counter loss.
-    Candidate.VTableGUIDAndCounts[VTableVal] = VTableValueDataArray[j].Count;
+    Candidate.VTableGUIDAndCounts[VTableVal] = V.Count;
     Candidate.AddressPoints.push_back(
         getOrCreateVTableAddressPointVar(VTableVar, AddressPointOffset));
   }

@kazutakahirata kazutakahirata merged commit a07909f into llvm:main Jul 2, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_ProfileData_getValueProfDataFromInst_IndirectCallPromotion branch July 2, 2024 02:01
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 2, 2024

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building llvm at step 6 "test".

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

Here is the relevant piece of the build log for the reference:

Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: commands/expression/test/TestExprs.py (207 of 2626)
PASS: lldb-api :: functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py (208 of 2626)
PASS: lldb-api :: lang/c/step_over_no_deadlock/TestStepOverDoesntBlock.py (209 of 2626)
PASS: lldb-api :: functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py (210 of 2626)
PASS: lldb-api :: lang/c/fpeval/TestFPEval.py (211 of 2626)
PASS: lldb-api :: lang/c/step-target/TestStepTarget.py (212 of 2626)
PASS: lldb-api :: lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py (213 of 2626)
PASS: lldb-api :: functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py (214 of 2626)
PASS: lldb-api :: lldbutil-tests/failed-to-hit-breakpoint/TestLLDBUtilFailedToHitBreakpoint.py (215 of 2626)
UNRESOLVED: lldb-api :: python_api/global_module_cache/TestGlobalModuleCache.py (216 of 2626)
******************** TEST 'lldb-api :: python_api/global_module_cache/TestGlobalModuleCache.py' FAILED ********************
Script:
--
/usr/bin/python3 /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/bin/ar --env OBJCOPY=/usr/bin/objcopy --env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 --build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex --lldb-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --llvm-tools-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./lib -t /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/python_api/global_module_cache -p TestGlobalModuleCache.py
--
Exit Code: -6

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision a07909ff11327baa72a4644dca7c6951ac6be902)
  clang revision a07909ff11327baa72a4644dca7c6951ac6be902
  llvm revision a07909ff11327baa72a4644dca7c6951ac6be902

--
Command Output (stderr):
--
Change dir to: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/python_api/global_module_cache
UNSUPPORTED: LLDB (/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: test_OneTargetOneDebugger_dsym (TestGlobalModuleCache.GlobalModuleCacheTestCase.test_OneTargetOneDebugger_dsym) (test case does not fall in any category of interest for this run) 
runCmd: settings clear -all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

runCmd: settings set target.auto-apply-fixits false

lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
kbluck pushed a commit to kbluck/llvm-project that referenced this pull request Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:transforms PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants