Skip to content
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

[FMV][GlobalOpt] Do not statically resolve non-FMV callers. #123383

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

labrinea
Copy link
Collaborator

@labrinea labrinea commented Jan 17, 2025

This fixes a runtime regression in the llvm testsuite:

https://lab.llvm.org/buildbot/#/builders/198/builds/1237

On clang-aarch64-sve2-vla:

predres
FAIL

A 'predres' version is unexpectedly trapping on GravitonG4. My explanation is that when the caller in not a versioned function, the compiler exclusively relies on the command line option, or target attribute to deduce whether a feature is available. However, there is no guarantee that in reality the host supports those implied features.

This is a quickfix. We may rather change the mcpu option in the llvm testsuite build instead.

This fixes a runtime regression in the llvm testsuite:

https://lab.llvm.org/buildbot/#/builders/198/builds/1237

On clang-aarch64-sve2-vla:

predres
        FAIL

A 'predres' version is unexpectedly trapping on GravitonG4.
My explanation is that when the caller in not a versioned
function, the compiler exclusively relies on the command line
option, or target attribute to deduce whether a feature is
available. However, there is no guarantee that in reality
the host supports those implied features.
@labrinea labrinea requested a review from davemgreen January 17, 2025 18:18
@labrinea labrinea changed the title [FMV][GlobalOpt] Do not statically resolver non-FMV callers. [FMV][GlobalOpt] Do not statically resolve non-FMV callers. Jan 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Alexandros Lamprineas (labrinea)

Changes

This fixes a runtime regression in the llvm testsuite:

https://lab.llvm.org/buildbot/#/builders/198/builds/1237

On clang-aarch64-sve2-vla:

predres
FAIL

A 'predres' version is unexpectedly trapping on GravitonG4. My explanation is that when the caller in not a versioned function, the compiler exclusively relies on the command line option, or target attribute to deduce whether a feature is available. However, there is no guarantee that in reality the host supports those implied features.


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

2 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/GlobalOpt.cpp (+9-1)
  • (modified) llvm/test/Transforms/GlobalOpt/resolve-fmv-ifunc.ll (+1-1)
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index bf0cacc6224be8..4e9cef97b670da 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2785,7 +2785,15 @@ static bool OptimizeNonTrivialIFuncs(
       } else {
         // We can't reason much about non-FMV callers. Just pick the highest
         // priority callee if it matches, otherwise bail.
-        if (I > 0 || !implies(CallerBits, CalleeBits))
+        //if (I > 0 || !implies(CallerBits, CalleeBits))
+        //
+        // FIXME: This is causing a regression in the llvm test suite,
+        // specifically a 'predres' version is unexpectedly trapping on
+        // GravitonG4. My explanation is that when the caller in not a
+        // versioned function, the compiler exclusively relies on the
+        // command line option, or target attribute to deduce whether a
+        // feature is available. However, there is no guarantee that in
+        // reality the host supports those implied features.
           continue;
       }
       auto &Calls = CallSites[Caller];
diff --git a/llvm/test/Transforms/GlobalOpt/resolve-fmv-ifunc.ll b/llvm/test/Transforms/GlobalOpt/resolve-fmv-ifunc.ll
index 4b6a19d3f05cf5..fa817a8cbf417f 100644
--- a/llvm/test/Transforms/GlobalOpt/resolve-fmv-ifunc.ll
+++ b/llvm/test/Transforms/GlobalOpt/resolve-fmv-ifunc.ll
@@ -221,7 +221,7 @@ resolver_entry:
 define i32 @caller4() #8 {
 ; CHECK-LABEL: define i32 @caller4(
 ; CHECK-SAME: ) local_unnamed_addr #[[ATTR7:[0-9]+]] {
-; CHECK:    [[CALL:%.*]] = tail call i32 @test_non_fmv_caller._Maes()
+; CHECK:    [[CALL:%.*]] = tail call i32 @test_non_fmv_caller()
 ;
 entry:
   %call = tail call i32 @test_non_fmv_caller()

Copy link

github-actions bot commented Jan 17, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

clang format
Copy link
Contributor

@jroelofs jroelofs left a comment

Choose a reason for hiding this comment

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

LGTM as a temporary fix

#87939 (comment)

@labrinea labrinea merged commit dce5d1f into llvm:main Jan 17, 2025
8 checks passed
@labrinea labrinea deleted the do-not-resolve-non-fmv-callers branch January 17, 2025 20:33
labrinea added a commit to labrinea/llvm-project that referenced this pull request Jan 21, 2025
Adds `optimize-non-fmv-callers` (disabled by default) as a short term
workaround to keep the llvm testsuite bots green, until we decide what
is the right solution for the problem which was previously addressed
with llvm#123383.
labrinea added a commit that referenced this pull request Jan 21, 2025
…rs. (#123757)

Adds `optimize-non-fmv-callers` (disabled by default) as a short term
workaround to keep the llvm testsuite bots green, until we decide what
is the right solution for the problem which was previously addressed
with #123383.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 21, 2025
…n-FMV callers. (#123757)

Adds `optimize-non-fmv-callers` (disabled by default) as a short term
workaround to keep the llvm testsuite bots green, until we decide what
is the right solution for the problem which was previously addressed
with llvm/llvm-project#123383.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants