[all-commits] [llvm/llvm-project] 58d978: [PGO][ICP] Prevent indirect call promotion to func...

Han Shen via All-commits all-commits at lists.llvm.org
Mon May 4 22:03:31 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 58d9781e8433878444d7b7873e75f7e2c2fd8f50
      https://github.com/llvm/llvm-project/commit/58d9781e8433878444d7b7873e75f7e2c2fd8f50
  Author: Han Shen <shenhan at google.com>
  Date:   2026-05-04 (Mon, 04 May 2026)

  Changed paths:
    M llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
    A llvm/test/Transforms/SampleProfile/icp_target_feature.ll

  Log Message:
  -----------
  [PGO][ICP] Prevent indirect call promotion to functions with incompatible target features (#192142)

Profile-driven indirect call promotion was promoting indirect calls to
functions requiring advanced CPU features (e.g., AVX512) even when the
caller function did not support those features. When these promoted
calls were subsequently inlined, it could lead to invalid IR and
backend crashes during instruction selection because the target CPU
could not handle the advanced instructions.

This patch addresses the issue by adding a target feature
compatibility check to `llvm::isLegalToPromote` in
`CallPromotionUtils.cpp`. If the callee requires target features
(prefixed with `+`) that are not present in the caller's target
features, the promotion is skipped.  By centralizing this check in
`isLegalToPromote`, we protect all passes relying on this utility
(such as `SampleProfileLoader` and `IndirectCallPromotion`) from
promoting to incompatible targets. This also prevents incorrect
inlining of `always_inline` functions that would otherwise be promoted
via indirect calls and then inlined.

Fixes #192126

Pull Request: https://github.com/llvm/llvm-project/pull/192142



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list