Skip to content

Revert "[PGO][ICP] Prevent indirect call promotion to functions with incompatible target features" - #208079

Merged
boomanaiden154 merged 1 commit into
mainfrom
revert-192142-fix-pgo-target-feature-clash
Jul 7, 2026
Merged

boomanaiden154 merged 1 commit into
mainfrom
revert-192142-fix-pgo-target-feature-clash

Conversation

@boomanaiden154

Copy link
Copy Markdown
Contributor

Reverts #192142

Now that #205113 has landed, we will not inline functions with incompatible target features, even if the callee is marked alwaysinline, so we can promote calls to such functions while also removing the extra complexity from ICP.

@llvmorg-github-actions llvmorg-github-actions Bot added PGO Profile Guided Optimizations llvm:transforms labels Jul 7, 2026
@llvmorg-github-actions

llvmorg-github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-transforms

Author: Aiden Grossman (boomanaiden154)

Changes

Reverts llvm/llvm-project#192142

Now that #205113 has landed, we will not inline functions with incompatible target features, even if the callee is marked alwaysinline, so we can promote calls to such functions while also removing the extra complexity from ICP.


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

2 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/CallPromotionUtils.cpp (-21)
  • (removed) llvm/test/Transforms/SampleProfile/icp_target_feature.ll (-61)
diff --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
index 1bfeea3b711f9..f0f9add09bf82 100644
--- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
+++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
@@ -477,27 +477,6 @@ bool llvm::isLegalToPromote(const CallBase &CB, Function *Callee,
     }
   }
 
-  // Check target feature compatibility. This is also needed to avoid incorrect
-  // inlining if the callee has the always_inline attribute. An always_inline
-  // function can be incorrectly inlined via two paths: either it is directly
-  // called and inlined, or it is indirectly called, promoted, and then inlined.
-  // The check here only prevents the latter case.
-  auto CalleeFeatures =
-      Callee->getFnAttribute("target-features").getValueAsString();
-  auto CallerFeatures =
-      CB.getCaller()->getFnAttribute("target-features").getValueAsString();
-  SmallVector<StringRef, 8> CalleeFeats;
-  CalleeFeatures.split(CalleeFeats, ',');
-  for (auto Feat : CalleeFeats) {
-    if (Feat.starts_with("+")) {
-      if (!CallerFeatures.contains(Feat)) {
-        if (FailureReason)
-          *FailureReason = "Incompatible target features";
-        return false;
-      }
-    }
-  }
-
   return true;
 }
 
diff --git a/llvm/test/Transforms/SampleProfile/icp_target_feature.ll b/llvm/test/Transforms/SampleProfile/icp_target_feature.ll
deleted file mode 100644
index 1210a97e98b09..0000000000000
--- a/llvm/test/Transforms/SampleProfile/icp_target_feature.ll
+++ /dev/null
@@ -1,61 +0,0 @@
-; This test verifies that indirect call promotion (ICP) under sample profiling
-; correctly checks target feature compatibility. Specifically, a callee with
-; target features incompatible with the caller's features (e.g., "_Z3moov" requiring
-; "+avx512f" while caller "_Z3goov" does not support it) should not be promoted,
-; while a compatible callee (e.g., "_Z3hoov") should be promoted successfully.
-; Note that under Sample PGO, the promotion candidates (e.g., _Z3hoov and _Z3moov)
-; are retrieved directly from the sample profile file (Inputs/norepeated-icp-2.prof)
-; at the corresponding line offset (1) rather than using value profile !prof metadata.
-; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/norepeated-icp-2.prof -S | FileCheck %s
-
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-@p = dso_local global ptr null, align 8
-
-; Function Attrs: uwtable mustprogress
-define dso_local void @_Z3moov() #0 !dbg !7 {
-entry:
-  ret void
-}
-
-; Function Attrs: uwtable mustprogress
-define dso_local void @_Z3hoov() #1 !dbg !11 {
-entry:
-  store ptr @_Z3moov, ptr @p, align 8
-  ret void
-}
-
-; Function Attrs: uwtable mustprogress
-define dso_local void @_Z3goov() #1 !dbg !24 {
-entry:
-  %t0 = load ptr, ptr @p, align 8
-  ; Here, _Z3moov requires "+avx512f" (attributes #0) which the caller lacks (attributes #1).
-  ; Therefore, _Z3moov is not promoted.
-  ; CHECK-NOT: icmp eq ptr %t0, @_Z3moov
-  ; On the other hand, _Z3hoov has compatible target features and is promoted successfully.
-  ; CHECK: icmp eq ptr %t0, @_Z3hoov
-  ; CHECK-NOT: icmp eq ptr %t0, @_Z3moov
-  call void %t0(), !dbg !26
-  ret void
-}
-
-attributes #0 = { uwtable mustprogress "use-sample-profile" "target-features"="+avx512f" }
-attributes #1 = { uwtable mustprogress "use-sample-profile" }
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5}
-!llvm.ident = !{!6}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
-!1 = !DIFile(filename: "1.cc", directory: "")
-!2 = !{}
-!3 = !{i32 7, !"Dwarf Version", i32 4}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = !{i32 1, !"wchar_size", i32 4}
-!6 = !{!"clang"}
-!7 = distinct !DISubprogram(name: "moo", linkageName: "_Z3moov", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
-!8 = !DISubroutineType(types: !2)
-!11 = distinct !DISubprogram(name: "hoo", linkageName: "_Z3hoov", scope: !1, file: !1, line: 9, type: !8, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
-!24 = distinct !DISubprogram(name: "goo", linkageName: "_Z3goov", scope: !1, file: !1, line: 15, type: !8, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
-!26 = !DILocation(line: 16, column: 3, scope: !24)

@teresajohnson teresajohnson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@boomanaiden154
boomanaiden154 enabled auto-merge (squash) July 7, 2026 19:48
@boomanaiden154
boomanaiden154 merged commit 9ff1d7a into main Jul 7, 2026
14 checks passed
@boomanaiden154
boomanaiden154 deleted the revert-192142-fix-pgo-target-feature-clash branch July 7, 2026 20:19
@llvm-ci

llvm-ci commented Jul 7, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder mlir-nvidia running on mlir-nvidia while building llvm at step 2 "checkout".

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

Here is the relevant piece of the build log for the reference
Step 2 (checkout) failure: update (failure)
git version 2.34.1
error: RPC failed; HTTP 429 curl 22 The requested URL returned error: 429
fatal: error reading section header 'acknowledgments'
error: RPC failed; HTTP 429 curl 22 The requested URL returned error: 429
fatal: error reading section header 'acknowledgments'

@llvm-ci

llvm-ci commented Jul 7, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder clangd-ubuntu-tsan running on clangd-ubuntu-clang while building llvm at step 2 "checkout".

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

Here is the relevant piece of the build log for the reference
Step 2 (checkout) failure: update (failure)
git version 2.17.1
remote: This request was rate-limited due to too many requests. Reduce the frequency of your requests or try again later.
remote: For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service).
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': The requested URL returned error: 429
remote: This request was rate-limited due to too many requests. Reduce the frequency of your requests or try again later.
remote: For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service).
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': The requested URL returned error: 429

1 similar comment
@llvm-ci

llvm-ci commented Jul 7, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder clangd-ubuntu-tsan running on clangd-ubuntu-clang while building llvm at step 2 "checkout".

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

Here is the relevant piece of the build log for the reference
Step 2 (checkout) failure: update (failure)
git version 2.17.1
remote: This request was rate-limited due to too many requests. Reduce the frequency of your requests or try again later.
remote: For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service).
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': The requested URL returned error: 429
remote: This request was rate-limited due to too many requests. Reduce the frequency of your requests or try again later.
remote: For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service).
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': The requested URL returned error: 429

gandhi56 pushed a commit that referenced this pull request Jul 9, 2026
…incompatible target features" (#208079)

Reverts #192142

Now that #205113 has landed, we
will not inline functions with incompatible target features, even if the
callee is marked `alwaysinline`, so we can promote calls to such
functions while also removing the extra complexity from ICP.
boomanaiden154 added a commit that referenced this pull request Jul 10, 2026
… incompatible target features" (#208774)

Reverts #208079

We're still seeing build failures without this, so reapply for now.
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 10, 2026
…ctions with incompatible target features" (#208774)

Reverts llvm/llvm-project#208079

We're still seeing build failures without this, so reapply for now.
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jul 10, 2026
…ctions with incompatible target features" (#208774)

Reverts llvm/llvm-project#208079

We're still seeing build failures without this, so reapply for now.
llvm-upstream-sync Bot pushed a commit to sriyalamar/cpullvm-toolchain that referenced this pull request Jul 10, 2026
…ctions with incompatible target features" (#208774)

Reverts llvm/llvm-project#208079

We're still seeing build failures without this, so reapply for now.
pedroMVicente pushed a commit to pedroMVicente/llvm-project that referenced this pull request Jul 15, 2026
… incompatible target features" (llvm#208774)

Reverts llvm#208079

We're still seeing build failures without this, so reapply for now.
nekoshirro pushed a commit to nekoshirro/Alchemist-LLVM that referenced this pull request Jul 30, 2026
… incompatible target features" (#208774)

Reverts llvm/llvm-project#208079

We're still seeing build failures without this, so reapply for now.
Signed-off-by: Hafidz Muzakky <[email protected]>
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.

3 participants