Skip to content

InlineCostAnnotationPrinter: Fix constructing random TargetTransformInfo #133637

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

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Mar 30, 2025

Query the correct TTI for the current target instead of constructing
some random default one. Also query the pass manager for ProfileSummaryInfo.
This should only change the printing, not the actual result.

Query the correct TTI for the current target instead of constructing
some random default one. Also query the pass manager for ProfileSummaryInfo.
Copy link
Contributor Author

arsenm commented Mar 30, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review March 30, 2025 14:15
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Mar 30, 2025
Copy link
Contributor Author

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

@llvmbot
Copy link
Member

llvmbot commented Mar 30, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Matt Arsenault (arsenm)

Changes

Query the correct TTI for the current target instead of constructing
some random default one. Also query the pass manager for ProfileSummaryInfo.


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

1 Files Affected:

  • (modified) llvm/lib/Analysis/InlineCost.cpp (+7-4)
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index e42b2bd82cf2e..9f193b610328b 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -3295,9 +3295,12 @@ InlineCostAnnotationPrinterPass::run(Function &F,
       [&](Function &F) -> AssumptionCache & {
     return FAM.getResult<AssumptionAnalysis>(F);
   };
-  Module *M = F.getParent();
-  ProfileSummaryInfo PSI(*M);
-  TargetTransformInfo TTI(M->getDataLayout());
+
+  auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
+  ProfileSummaryInfo *PSI =
+      MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
+  const TargetTransformInfo &TTI = FAM.getResult<TargetIRAnalysis>(F);
+
   // FIXME: Redesign the usage of InlineParams to expand the scope of this pass.
   // In the current implementation, the type of InlineParams doesn't matter as
   // the pass serves only for verification of inliner's decisions.
@@ -3312,7 +3315,7 @@ InlineCostAnnotationPrinterPass::run(Function &F,
           continue;
         OptimizationRemarkEmitter ORE(CalledFunction);
         InlineCostCallAnalyzer ICCA(*CalledFunction, *CB, Params, TTI,
-                                    GetAssumptionCache, nullptr, nullptr, &PSI,
+                                    GetAssumptionCache, nullptr, nullptr, PSI,
                                     &ORE);
         ICCA.analyze();
         OS << "      Analyzing call of " << CalledFunction->getName()

Copy link
Member

@mtrofin mtrofin left a comment

Choose a reason for hiding this comment

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

Lgtm, but can the commit message say this is about the printer pass - i.e. this should have no effect on inlining cost itself?

@arsenm arsenm changed the title InlineCost: Fix constructing random TargetTransformInfo InlineCostAnnotationPrinter: Fix constructing random TargetTransformInfo Mar 30, 2025
@arsenm arsenm merged commit 9a913a3 into main Mar 30, 2025
15 checks passed
@arsenm arsenm deleted the users/arsenm/inline-cost/fix-constructing-tti-for-no-reason branch March 30, 2025 15:05
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 30, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve2-vla running on linaro-g4-01 while building llvm at step 7 "ninja check 1".

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

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
...
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/bin/ld64.lld
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/bin/wasm-ld
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/bin/ld.lld
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/bin/lld-link
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/bin/ld64.lld
llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla/stage1/bin/wasm-ld
-- Testing: 96440 tests, 48 workers --
UNRESOLVED: Flang :: Driver/slp-vectorize.ll (1 of 96440)
******************** TEST 'Flang :: Driver/slp-vectorize.ll' FAILED ********************
Test has no 'RUN:' line
********************
PASS: SanitizerCommon-msan-aarch64-Linux :: Linux/signal_segv_handler.cpp (2 of 96440)
PASS: libFuzzer-aarch64-default-Linux :: sigint.test (3 of 96440)
PASS: Clang :: Driver/x86-target-features.c (4 of 96440)
PASS: libFuzzer-aarch64-default-Linux :: sigusr.test (5 of 96440)
PASS: UBSan-ThreadSanitizer-aarch64 :: TestCases/ImplicitConversion/unsigned-integer-truncation-ignorelist.c (6 of 96440)
PASS: UBSan-ThreadSanitizer-aarch64 :: TestCases/ImplicitConversion/signed-integer-truncation-ignorelist.c (7 of 96440)
PASS: Clang :: OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp (8 of 96440)
PASS: Clang :: Driver/linux-ld.c (9 of 96440)
PASS: Clang :: Driver/clang_f_opts.c (10 of 96440)
PASS: libFuzzer-aarch64-default-Linux :: msan.test (11 of 96440)
PASS: Clang :: Analysis/runtime-regression.c (12 of 96440)
PASS: libFuzzer-aarch64-default-Linux :: merge-sigusr.test (13 of 96440)
PASS: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir (14 of 96440)
PASS: ScudoStandalone-Unit-GwpAsanTorture :: ./ScudoUnitTest-aarch64-Test/53/71 (15 of 96440)
PASS: MemorySanitizer-AARCH64 :: release_origin.c (16 of 96440)
PASS: ScudoStandalone-Unit :: ./ScudoUnitTest-aarch64-Test/53/71 (17 of 96440)
PASS: LLVM :: CodeGen/Hexagon/isel/isel-tfrrp.ll (18 of 96440)
PASS: Clang :: Preprocessor/predefined-arch-macros.c (19 of 96440)
PASS: HWAddressSanitizer-aarch64 :: TestCases/Linux/create-thread-stress.cpp (20 of 96440)
PASS: ThreadSanitizer-aarch64 :: deadlock_detector_stress_test.cpp (21 of 96440)
PASS: Clang :: CodeGen/AArch64/sve-intrinsics/acle_sve_reinterpret-bfloat.c (22 of 96440)
PASS: Clang :: Preprocessor/aarch64-target-features.c (23 of 96440)
PASS: Clang :: Preprocessor/arm-target-features.c (24 of 96440)
PASS: Clang :: Analysis/a_flaky_crash.cpp (25 of 96440)
PASS: Clang :: Driver/arm-cortex-cpus-1.c (26 of 96440)
PASS: Clang :: Driver/arm-cortex-cpus-2.c (27 of 96440)
PASS: LLVM :: CodeGen/RISCV/attributes.ll (28 of 96440)
PASS: Profile-aarch64 :: Posix/instrprof-value-prof-shared.test (29 of 96440)
PASS: lld :: MachO/arm64-thunk-starvation.s (30 of 96440)
PASS: LLVM :: CodeGen/AMDGPU/memintrinsic-unroll.ll (31 of 96440)
PASS: Clang :: CodeGen/AArch64/sve-intrinsics/acle_sve_reinterpret.c (32 of 96440)
PASS: ThreadSanitizer-aarch64 :: signal_thread.cpp (33 of 96440)
PASS: libFuzzer-aarch64-default-Linux :: fuzzer-timeout.test (34 of 96440)
PASS: ThreadSanitizer-aarch64 :: force_background_thread.cpp (35 of 96440)
PASS: Clang :: OpenMP/target_defaultmap_codegen_01.cpp (36 of 96440)
PASS: MLIR :: Integration/Dialect/SparseTensor/CPU/sparse_conv_3d_ndhwc_dhwcf.mlir (37 of 96440)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 30, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-darwin running on doug-worker-3 while building llvm at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang-Unit :: DirectoryWatcher/./DirectoryWatcherTests/2/8' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/unittests/DirectoryWatcher/./DirectoryWatcherTests-Clang-Unit-41584-2-8.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=8 GTEST_SHARD_INDEX=2 /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/unittests/DirectoryWatcher/./DirectoryWatcherTests
--

Script:
--
/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/unittests/DirectoryWatcher/./DirectoryWatcherTests --gtest_filter=DirectoryWatcherTest.AddFiles
--
/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:259: Failure
Value of: WaitForExpectedStateResult.wait_for(EventualResultTimeout) == std::future_status::ready
  Actual: false
Expected: true
The expected result state wasn't reached before the time-out.

/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:262: Failure
Value of: TestConsumer.result().has_value()
  Actual: false
Expected: true

libc++abi: terminating due to uncaught exception of type std::__1::system_error: condition_variable wait failed: Invalid argument

/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:259
Value of: WaitForExpectedStateResult.wait_for(EventualResultTimeout) == std::future_status::ready
  Actual: false
Expected: true
The expected result state wasn't reached before the time-out.

/Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:262
Value of: TestConsumer.result().has_value()
  Actual: false
Expected: true



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


@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 30, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve2-vla-2stage running on linaro-g4-02 while building llvm at step 12 "ninja check 2".

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

Here is the relevant piece of the build log for the reference
Step 12 (ninja check 2) failure: stage 2 checked (failure)
...
PASS: Flang :: Driver/msvc-dependent-lib-flags.f90 (24739 of 96440)
PASS: Flang :: Driver/macro-def-undef.F90 (24740 of 96440)
PASS: Flang :: Driver/print-resource-dir.F90 (24741 of 96440)
PASS: Flang :: Driver/override-triple.ll (24742 of 96440)
PASS: Flang :: Driver/parse-fir-error.ll (24743 of 96440)
PASS: Flang :: Driver/parse-error.ll (24744 of 96440)
PASS: Flang :: Driver/mlir-pass-pipeline.f90 (24745 of 96440)
PASS: Flang :: Driver/phases.f90 (24746 of 96440)
PASS: Flang :: Driver/linker-flags.f90 (24747 of 96440)
UNRESOLVED: Flang :: Driver/slp-vectorize.ll (24748 of 96440)
******************** TEST 'Flang :: Driver/slp-vectorize.ll' FAILED ********************
Test has no 'RUN:' line
********************
PASS: Flang :: Driver/predefined-macros-compiler-version.F90 (24749 of 96440)
PASS: Flang :: Driver/parse-ir-error.f95 (24750 of 96440)
PASS: Flang :: Driver/missing-arg.f90 (24751 of 96440)
PASS: Flang :: Driver/print-pipeline-passes.f90 (24752 of 96440)
PASS: Flang :: Driver/pass-plugin-not-found.f90 (24753 of 96440)
PASS: Flang :: Driver/mlink-builtin-bc.f90 (24754 of 96440)
PASS: Flang :: Driver/lto-bc.f90 (24755 of 96440)
PASS: Flang :: Driver/scanning-error.f95 (24756 of 96440)
PASS: Flang :: Driver/pp-fixed-form.f90 (24757 of 96440)
PASS: Flang :: Driver/print-target-triple.f90 (24758 of 96440)
PASS: Flang :: Driver/supported-suffices/f03-suffix.f03 (24759 of 96440)
PASS: Flang :: Driver/std2018-wrong.f90 (24760 of 96440)
PASS: Flang :: Driver/pthread.f90 (24761 of 96440)
PASS: Flang :: Driver/supported-suffices/f08-suffix.f08 (24762 of 96440)
PASS: Flang :: Driver/tco-code-gen-llvm.fir (24763 of 96440)
PASS: Flang :: Driver/fsave-optimization-record.f90 (24764 of 96440)
PASS: Flang :: Driver/target-gpu-features.f90 (24765 of 96440)
PASS: Flang :: Driver/fixed-line-length.f90 (24766 of 96440)
PASS: Flang :: Driver/target.f90 (24767 of 96440)
PASS: Flang :: Driver/q-unused-arguments.f90 (24768 of 96440)
PASS: Flang :: Driver/multiple-input-files.f90 (24769 of 96440)
PASS: Flang :: Driver/mllvm.f90 (24770 of 96440)
PASS: Flang :: Driver/lto-flags.f90 (24771 of 96440)
PASS: Flang :: Driver/unsupported-vscale-max-min.f90 (24772 of 96440)
PASS: Flang :: Driver/no-duplicate-main.f90 (24773 of 96440)
PASS: Flang :: Driver/unparse-with-modules.f90 (24774 of 96440)
PASS: Flang :: Driver/prescanner-diag.f90 (24775 of 96440)
PASS: Flang :: Driver/input-from-stdin/input-from-stdin.f90 (24776 of 96440)
PASS: Flang :: Driver/unparse-use-analyzed.f95 (24777 of 96440)
PASS: Flang :: Driver/target-machine-error.f90 (24778 of 96440)
PASS: Flang :: Driver/std2018.f90 (24779 of 96440)
PASS: Flang :: Driver/save-temps.f90 (24780 of 96440)
PASS: Flang :: Driver/falias-analysis.f90 (24781 of 96440)
PASS: Flang :: Driver/optimization-remark-invalid.f90 (24782 of 96440)
PASS: Flang :: Driver/optimization-remark-backend.f90 (24783 of 96440)
PASS: Flang :: Driver/save-temps-use-module.f90 (24784 of 96440)

SchrodingerZhu pushed a commit to SchrodingerZhu/llvm-project that referenced this pull request Mar 31, 2025
…nfo (llvm#133637)

Query the correct TTI for the current target instead of constructing
some random default one. Also query the pass manager for
ProfileSummaryInfo.
This should only change the printing, not the actual result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:analysis Includes value tracking, cost tables and constant folding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants