From 8e061e9a599b0bab2a8f7b9464ad6849548b653c Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Fri, 17 Jan 2025 18:10:48 +0000 Subject: [PATCH 1/2] [FMV][GlobalOpt] Do not statically resolver non-FMV callers. 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. --- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 10 +++++++++- llvm/test/Transforms/GlobalOpt/resolve-fmv-ifunc.ll | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index bf0cacc6224be..4e9cef97b670d 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 4b6a19d3f05cf..fa817a8cbf417 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() From 8a3d433df290f1e63f9994a69604cdbff2b20fa9 Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Fri, 17 Jan 2025 18:27:36 +0000 Subject: [PATCH 2/2] Update GlobalOpt.cpp clang format --- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 4e9cef97b670d..eb97d8b4a74f3 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -2785,7 +2785,7 @@ 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 @@ -2794,7 +2794,7 @@ static bool OptimizeNonTrivialIFuncs( // 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; + continue; } auto &Calls = CallSites[Caller]; for (CallBase *CS : Calls)