[llvm] TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor (PR #145826)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 18:46:55 PDT 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/145826
>From 6a5b928021b717cd2c28761092ccf16b3eb03d84 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 17 May 2024 13:37:35 +0200
Subject: [PATCH 1/3] TargetLibraryInfo: Delete default TargetLibraryInfoImpl
constructor
It should not be possible to construct one without a triple. It would
also be nice to delete TargetLibraryInfoWrapperPass, but that is more
difficult.
---
llvm/include/llvm/Analysis/TargetLibraryInfo.h | 8 +++++++-
llvm/include/llvm/LinkAllPasses.h | 6 +++++-
llvm/lib/Analysis/TargetLibraryInfo.cpp | 8 +-------
llvm/unittests/Analysis/AliasAnalysisTest.cpp | 3 ++-
.../unittests/Analysis/BasicAliasAnalysisTest.cpp | 3 ++-
llvm/unittests/Analysis/DDGTest.cpp | 2 +-
llvm/unittests/Analysis/IVDescriptorsTest.cpp | 2 +-
llvm/unittests/Analysis/LoadsTest.cpp | 2 +-
llvm/unittests/Analysis/LoopInfoTest.cpp | 2 +-
llvm/unittests/Analysis/LoopNestTest.cpp | 2 +-
llvm/unittests/Analysis/MemorySSATest.cpp | 3 ++-
llvm/unittests/Analysis/ScalarEvolutionTest.cpp | 3 ++-
llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | 2 +-
llvm/unittests/Analysis/UnrollAnalyzerTest.cpp | 2 +-
llvm/unittests/SandboxIR/UtilsTest.cpp | 2 +-
.../Transforms/Instrumentation/MemProfUseTest.cpp | 8 ++++----
.../Transforms/Utils/BasicBlockUtilsTest.cpp | 4 ++--
.../Transforms/Utils/CodeMoverUtilsTest.cpp | 8 ++++----
.../Transforms/Utils/LoopRotationUtilsTest.cpp | 4 ++--
llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp | 2 +-
.../Utils/ScalarEvolutionExpanderTest.cpp | 3 ++-
.../unittests/Transforms/Utils/UnrollLoopTest.cpp | 2 +-
.../SandboxVectorizer/DependencyGraphTest.cpp | 15 ++++++++++-----
.../Vectorize/SandboxVectorizer/LegalityTest.cpp | 9 ++++++---
.../Vectorize/SandboxVectorizer/SchedulerTest.cpp | 15 ++++++++++-----
.../SandboxVectorizer/SeedCollectorTest.cpp | 14 +++++++-------
.../Vectorize/SandboxVectorizer/VecUtilsTest.cpp | 10 +++++++---
.../Transforms/Vectorize/VPlanSlpTest.cpp | 14 ++++++--------
.../Transforms/Vectorize/VPlanTestBase.h | 11 ++++++-----
29 files changed, 97 insertions(+), 72 deletions(-)
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index 0596ff86b473e..58ffac0a6e207 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -136,7 +136,7 @@ class TargetLibraryInfoImpl {
AMDLIBM // AMD Math Vector library.
};
- LLVM_ABI TargetLibraryInfoImpl();
+ LLVM_ABI TargetLibraryInfoImpl() = delete;
LLVM_ABI explicit TargetLibraryInfoImpl(const Triple &T);
// Provide value semantics.
@@ -294,6 +294,8 @@ class TargetLibraryInfo {
std::bitset<NumLibFuncs> OverrideAsUnavailable;
public:
+ TargetLibraryInfo() = delete;
+
explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl,
std::optional<const Function *> F = std::nullopt)
: Impl(&Impl) {
@@ -649,7 +651,11 @@ class LLVM_ABI TargetLibraryInfoWrapperPass : public ImmutablePass {
public:
static char ID;
+
+ /// The default constructor should not be used and is only for pass manager
+ /// initialization purposes.
TargetLibraryInfoWrapperPass();
+
explicit TargetLibraryInfoWrapperPass(const Triple &T);
explicit TargetLibraryInfoWrapperPass(const TargetLibraryInfoImpl &TLI);
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 5965be676ea69..bae7f0da7022c 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -47,6 +47,10 @@
#include "llvm/Transforms/Vectorize/LoadStoreVectorizer.h"
#include <cstdlib>
+namespace llvm {
+class Triple;
+}
+
namespace {
struct ForcePassLinking {
ForcePassLinking() {
@@ -147,7 +151,7 @@ struct ForcePassLinking {
llvm::Function::Create(nullptr, llvm::GlobalValue::ExternalLinkage)
->viewCFGOnly();
llvm::RGPassManager RGM;
- llvm::TargetLibraryInfoImpl TLII;
+ llvm::TargetLibraryInfoImpl TLII((llvm::Triple()));
llvm::TargetLibraryInfo TLI(TLII);
llvm::AliasAnalysis AA(TLI);
llvm::BatchAAResults BAA(AA);
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 28a5cdb5561dd..973c9b1d30ca1 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -929,12 +929,6 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
initializeLibCalls(TLI, T, StandardNames);
}
-TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
- // Default to nothing being available.
- memset(AvailableArray, 0, sizeof(AvailableArray));
- initializeBase(*this, Triple());
-}
-
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
// Default to everything being available.
memset(AvailableArray, -1, sizeof(AvailableArray));
@@ -1499,7 +1493,7 @@ unsigned TargetLibraryInfoImpl::getSizeTSize(const Module &M) const {
}
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
- : ImmutablePass(ID), TLA(TargetLibraryInfoImpl()) {}
+ : ImmutablePass(ID), TLA(TargetLibraryInfoImpl(Triple())) {}
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
: ImmutablePass(ID), TLA(TargetLibraryInfoImpl(T)) {}
diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
index 5d990521d4839..06066b1b92c51 100644
--- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -147,7 +147,8 @@ class AliasAnalysisTest : public testing::Test {
std::unique_ptr<BasicAAResult> BAR;
std::unique_ptr<AAResults> AAR;
- AliasAnalysisTest() : M("AliasAnalysisTest", C), TLI(TLII) {}
+ AliasAnalysisTest()
+ : M("AliasAnalysisTest", C), TLII(M.getTargetTriple()), TLI(TLII) {}
AAResults &getAAResults(Function &F) {
// Reset the Function AA results first to clear out any references.
diff --git a/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp b/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
index f5c73ff63934e..bae1f1c508af3 100644
--- a/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
@@ -66,7 +66,8 @@ class BasicAATest : public testing::Test {
public:
BasicAATest()
- : M("BasicAATest", C), B(C), DL(DLString), TLI(TLII), F(nullptr) {}
+ : M("BasicAATest", C), B(C), DL(DLString), TLII(M.getTargetTriple()),
+ TLI(TLII), F(nullptr) {}
};
// Check that a function arg can't trivially alias a global when we're accessing
diff --git a/llvm/unittests/Analysis/DDGTest.cpp b/llvm/unittests/Analysis/DDGTest.cpp
index da6f53fb0141c..7fcdfdb62da43 100644
--- a/llvm/unittests/Analysis/DDGTest.cpp
+++ b/llvm/unittests/Analysis/DDGTest.cpp
@@ -29,7 +29,7 @@ static void runTest(Module &M, StringRef FuncName,
auto *F = M.getFunction(FuncName);
ASSERT_NE(F, nullptr) << "Could not find " << FuncName;
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
DominatorTree DT(*F);
diff --git a/llvm/unittests/Analysis/IVDescriptorsTest.cpp b/llvm/unittests/Analysis/IVDescriptorsTest.cpp
index ce9383d15f461..453800abf9cab 100644
--- a/llvm/unittests/Analysis/IVDescriptorsTest.cpp
+++ b/llvm/unittests/Analysis/IVDescriptorsTest.cpp
@@ -26,7 +26,7 @@ static void runWithLoopInfoAndSE(
auto *F = M.getFunction(FuncName);
ASSERT_NE(F, nullptr) << "Could not find " << FuncName;
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
DominatorTree DT(*F);
diff --git a/llvm/unittests/Analysis/LoadsTest.cpp b/llvm/unittests/Analysis/LoadsTest.cpp
index 13377a8082096..c4f5b22318e34 100644
--- a/llvm/unittests/Analysis/LoadsTest.cpp
+++ b/llvm/unittests/Analysis/LoadsTest.cpp
@@ -180,7 +180,7 @@ loop.end:
auto *F2 = dyn_cast<Function>(GV2);
ASSERT_TRUE(F1 && F2);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
auto IsDerefReadOnlyLoop = [&TLI](Function *F) -> bool {
diff --git a/llvm/unittests/Analysis/LoopInfoTest.cpp b/llvm/unittests/Analysis/LoopInfoTest.cpp
index 5e9edce049718..627e59d121c51 100644
--- a/llvm/unittests/Analysis/LoopInfoTest.cpp
+++ b/llvm/unittests/Analysis/LoopInfoTest.cpp
@@ -38,7 +38,7 @@ static void runWithLoopInfoPlus(
auto *F = M.getFunction(FuncName);
ASSERT_NE(F, nullptr) << "Could not find " << FuncName;
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
DominatorTree DT(*F);
diff --git a/llvm/unittests/Analysis/LoopNestTest.cpp b/llvm/unittests/Analysis/LoopNestTest.cpp
index 366be2e872118..107ce85299f8f 100644
--- a/llvm/unittests/Analysis/LoopNestTest.cpp
+++ b/llvm/unittests/Analysis/LoopNestTest.cpp
@@ -25,7 +25,7 @@ static void runTest(
auto *F = M.getFunction(FuncName);
ASSERT_NE(F, nullptr) << "Could not find " << FuncName;
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
DominatorTree DT(*F);
diff --git a/llvm/unittests/Analysis/MemorySSATest.cpp b/llvm/unittests/Analysis/MemorySSATest.cpp
index fda3a713b5761..a6f002b63dff1 100644
--- a/llvm/unittests/Analysis/MemorySSATest.cpp
+++ b/llvm/unittests/Analysis/MemorySSATest.cpp
@@ -70,7 +70,8 @@ class MemorySSATest : public testing::Test {
public:
MemorySSATest()
- : M("MemorySSATest", C), B(C), DL(DLString), TLI(TLII), F(nullptr) {}
+ : M("MemorySSATest", C), B(C), DL(DLString), TLII(M.getTargetTriple()),
+ TLI(TLII), F(nullptr) {}
};
TEST_F(MemorySSATest, CreateALoad) {
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
index 95a4affdd7789..9b88e423e802b 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -39,7 +39,8 @@ class ScalarEvolutionsTest : public testing::Test {
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<LoopInfo> LI;
- ScalarEvolutionsTest() : M("", Context), TLII(), TLI(TLII) {}
+ ScalarEvolutionsTest()
+ : M("", Context), TLII(M.getTargetTriple()), TLI(TLII) {}
ScalarEvolution buildSE(Function &F) {
AC.reset(new AssumptionCache(F));
diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
index 2f1bcbae4fc50..b33419545efa8 100644
--- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -26,7 +26,7 @@ class TargetLibraryInfoTest : public testing::Test {
std::unique_ptr<Module> M;
- TargetLibraryInfoTest() : TLI(TLII) {}
+ TargetLibraryInfoTest() : TLII(Triple()), TLI(TLII) {}
void parseAssembly(const char *Assembly) {
SMDiagnostic Error;
diff --git a/llvm/unittests/Analysis/UnrollAnalyzerTest.cpp b/llvm/unittests/Analysis/UnrollAnalyzerTest.cpp
index 0ff08d19957ef..d5ba1757ce35c 100644
--- a/llvm/unittests/Analysis/UnrollAnalyzerTest.cpp
+++ b/llvm/unittests/Analysis/UnrollAnalyzerTest.cpp
@@ -27,7 +27,7 @@ runUnrollAnalyzer(Module &M, StringRef FuncName,
auto *F = M.getFunction(FuncName);
ASSERT_NE(F, nullptr) << "Could not find " << FuncName;
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
DominatorTree DT(*F);
diff --git a/llvm/unittests/SandboxIR/UtilsTest.cpp b/llvm/unittests/SandboxIR/UtilsTest.cpp
index a30fc253a1a74..2bef48616beb7 100644
--- a/llvm/unittests/SandboxIR/UtilsTest.cpp
+++ b/llvm/unittests/SandboxIR/UtilsTest.cpp
@@ -89,7 +89,7 @@ define void @foo(ptr %ptr) {
)IR");
llvm::Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
AssumptionCache AC(LLVMF);
diff --git a/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp b/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
index 0dd819a10e0b1..220dfedbee14a 100644
--- a/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
+++ b/llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
@@ -91,7 +91,7 @@ declare !dbg !19 void @_Z2f3v()
auto *F = M->getFunction("_Z3foov");
ASSERT_NE(F, nullptr);
- TargetLibraryInfoWrapperPass WrapperPass;
+ TargetLibraryInfoWrapperPass WrapperPass(M->getTargetTriple());
auto &TLI = WrapperPass.getTLI(*F);
auto Calls = extractCallsFromIR(*M, TLI);
@@ -191,7 +191,7 @@ declare !dbg !25 void @_Z2g2v() local_unnamed_addr
auto *F = M->getFunction("_Z3foov");
ASSERT_NE(F, nullptr);
- TargetLibraryInfoWrapperPass WrapperPass;
+ TargetLibraryInfoWrapperPass WrapperPass(M->getTargetTriple());
auto &TLI = WrapperPass.getTLI(*F);
auto Calls = extractCallsFromIR(*M, TLI);
@@ -282,7 +282,7 @@ attributes #2 = { builtin allocsize(0) }
auto *F = M->getFunction("_Z3foov");
ASSERT_NE(F, nullptr);
- TargetLibraryInfoWrapperPass WrapperPass;
+ TargetLibraryInfoWrapperPass WrapperPass(M->getTargetTriple());
auto &TLI = WrapperPass.getTLI(*F);
auto Calls = extractCallsFromIR(*M, TLI);
@@ -398,7 +398,7 @@ attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "t
auto *F = M->getFunction("_Z3foov");
ASSERT_NE(F, nullptr);
- TargetLibraryInfoWrapperPass WrapperPass;
+ TargetLibraryInfoWrapperPass WrapperPass(M->getTargetTriple());
auto &TLI = WrapperPass.getTLI(*F);
auto Calls = extractCallsFromIR(*M, TLI);
diff --git a/llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp b/llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
index e58daed887855..40a8c1d8d3da1 100644
--- a/llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
@@ -180,7 +180,7 @@ define i32 @foo(i32 %n) {
LoopInfo LI(DT);
DataLayout DL("e-i64:64-f80:128-n8:16:32:64-S128");
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
AAResults AA(TLI);
@@ -255,7 +255,7 @@ declare void @sink_alt() cold
LoopInfo LI(DT);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
AAResults AA(TLI);
diff --git a/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp b/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
index 9200fab436866..9466977d00649 100644
--- a/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
@@ -38,7 +38,7 @@ static void run(Module &M, StringRef FuncName,
auto *F = M.getFunction(FuncName);
DominatorTree DT(*F);
PostDominatorTree PDT(*F);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
AliasAnalysis AA(TLI);
@@ -227,7 +227,7 @@ TEST(CodeMoverUtils, IsControlFlowEquivalentCondNestTest) {
// i = 2;
// }
std::unique_ptr<Module> M =
- parseIR(C, R"(define void @foo(i32* %i, i1 %cond1, i1 %cond2) {
+ parseIR(C, R"(define void @foo(i32* %i, i1 %cond1, i1 %cond2) {
entry:
br i1 %cond1, label %if.outer.first, label %if.first.end
if.outer.first:
@@ -282,8 +282,8 @@ TEST(CodeMoverUtils, IsControlFlowEquivalentImbalanceTest) {
// if (cond1)
// i = 4;
// }
- std::unique_ptr<Module> M = parseIR(
- C, R"(define void @foo(i32* %i, i1 %cond1, i1 %cond2, i1 %cond3) {
+ std::unique_ptr<Module> M =
+ parseIR(C, R"(define void @foo(i32* %i, i1 %cond1, i1 %cond2, i1 %cond3) {
entry:
br i1 %cond1, label %if.outer.first, label %if.first.end
if.outer.first:
diff --git a/llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp b/llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
index c276f2ea62fed..70cdf0aba356c 100644
--- a/llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
@@ -79,7 +79,7 @@ deopt.exit:
LoopInfo LI(DT);
AssumptionCache AC(*F);
TargetTransformInfo TTI(M->getDataLayout());
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
ScalarEvolution SE(*F, TLI, AC, DT, LI);
SimplifyQuery SQ(M->getDataLayout());
@@ -150,7 +150,7 @@ deopt.exit:
LoopInfo LI(DT);
AssumptionCache AC(*F);
TargetTransformInfo TTI(M->getDataLayout());
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
ScalarEvolution SE(*F, TLI, AC, DT, LI);
SimplifyQuery SQ(M->getDataLayout());
diff --git a/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp b/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
index cd4717181d2ca..c22a3582bee86 100644
--- a/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
@@ -33,7 +33,7 @@ static void run(Module &M, StringRef FuncName,
Test) {
Function *F = M.getFunction(FuncName);
DominatorTree DT(*F);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M.getTargetTriple());
TargetLibraryInfo TLI(TLII);
AssumptionCache AC(*F);
LoopInfo LI(DT);
diff --git a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
index 6aff8406790d3..55eae64fe0f6d 100644
--- a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -42,7 +42,8 @@ class ScalarEvolutionExpanderTest : public testing::Test {
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<LoopInfo> LI;
- ScalarEvolutionExpanderTest() : M("", Context), TLII(), TLI(TLII) {}
+ ScalarEvolutionExpanderTest()
+ : M("", Context), TLII(M.getTargetTriple()), TLI(TLII) {}
ScalarEvolution buildSE(Function &F) {
AC.reset(new AssumptionCache(F));
diff --git a/llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp b/llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
index fb02c89c77a10..eec10110e6af4 100644
--- a/llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
+++ b/llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
@@ -63,7 +63,7 @@ while.end: ; preds = %while.cond
DominatorTree DT(*F);
LoopInfo LI(DT);
AssumptionCache AC(*F);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
ScalarEvolution SE(*F, TLI, AC, DT, LI);
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/DependencyGraphTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/DependencyGraphTest.cpp
index 9a7ee8214d10a..721eda16c7e11 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/DependencyGraphTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/DependencyGraphTest.cpp
@@ -30,21 +30,26 @@ struct DependencyGraphTest : public testing::Test {
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<BasicAAResult> BAA;
std::unique_ptr<AAResults> AA;
+ std::unique_ptr<TargetLibraryInfoImpl> TLII;
+ std::unique_ptr<TargetLibraryInfo> TLI;
void parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
M = parseAssemblyString(IR, Err, C);
- if (!M)
+ if (!M) {
Err.print("DependencyGraphTest", errs());
+ return;
+ }
+
+ TLII = std::make_unique<TargetLibraryInfoImpl>(M->getTargetTriple());
+ TLI = std::make_unique<TargetLibraryInfo>(*TLII);
}
AAResults &getAA(llvm::Function &LLVMF) {
- TargetLibraryInfoImpl TLII;
- TargetLibraryInfo TLI(TLII);
- AA = std::make_unique<AAResults>(TLI);
+ AA = std::make_unique<AAResults>(*TLI);
AC = std::make_unique<AssumptionCache>(LLVMF);
DT = std::make_unique<DominatorTree>(LLVMF);
- BAA = std::make_unique<BasicAAResult>(M->getDataLayout(), LLVMF, TLI, *AC,
+ BAA = std::make_unique<BasicAAResult>(M->getDataLayout(), LLVMF, *TLI, *AC,
DT.get());
AA->addAAResult(*BAA);
return *AA;
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp
index 99519d17d0e8e..586f846caf267 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/LegalityTest.cpp
@@ -38,8 +38,6 @@ struct LegalityTest : public testing::Test {
void getAnalyses(llvm::Function &LLVMF) {
DT = std::make_unique<DominatorTree>(LLVMF);
- TLII = std::make_unique<TargetLibraryInfoImpl>();
- TLI = std::make_unique<TargetLibraryInfo>(*TLII);
AC = std::make_unique<AssumptionCache>(LLVMF);
LI = std::make_unique<LoopInfo>(*DT);
SE = std::make_unique<ScalarEvolution>(LLVMF, *TLI, *AC, *DT, *LI);
@@ -52,8 +50,13 @@ struct LegalityTest : public testing::Test {
void parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
M = parseAssemblyString(IR, Err, C);
- if (!M)
+ if (!M) {
Err.print("LegalityTest", errs());
+ return;
+ }
+
+ TLII = std::make_unique<TargetLibraryInfoImpl>(M->getTargetTriple());
+ TLI = std::make_unique<TargetLibraryInfo>(*TLII);
}
};
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SchedulerTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SchedulerTest.cpp
index 6f6e8a089bacd..4c38fa069ba66 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SchedulerTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SchedulerTest.cpp
@@ -30,21 +30,26 @@ struct SchedulerTest : public testing::Test {
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<BasicAAResult> BAA;
std::unique_ptr<AAResults> AA;
+ std::unique_ptr<TargetLibraryInfoImpl> TLII;
+ std::unique_ptr<TargetLibraryInfo> TLI;
void parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
M = parseAssemblyString(IR, Err, C);
- if (!M)
+ if (!M) {
Err.print("SchedulerTest", errs());
+ return;
+ }
+
+ TLII = std::make_unique<TargetLibraryInfoImpl>(M->getTargetTriple());
+ TLI = std::make_unique<TargetLibraryInfo>(*TLII);
}
AAResults &getAA(llvm::Function &LLVMF) {
- TargetLibraryInfoImpl TLII;
- TargetLibraryInfo TLI(TLII);
- AA = std::make_unique<AAResults>(TLI);
+ AA = std::make_unique<AAResults>(*TLI);
AC = std::make_unique<AssumptionCache>(LLVMF);
DT = std::make_unique<DominatorTree>(LLVMF);
- BAA = std::make_unique<BasicAAResult>(M->getDataLayout(), LLVMF, TLI, *AC,
+ BAA = std::make_unique<BasicAAResult>(M->getDataLayout(), LLVMF, *TLI, *AC,
DT.get());
AA->addAAResult(*BAA);
return *AA;
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
index 99a13801c7c33..3c66f985fe6e1 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/SeedCollectorTest.cpp
@@ -185,7 +185,7 @@ define void @foo(ptr %ptrA, float %val, ptr %ptr) {
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
@@ -240,7 +240,7 @@ define void @foo(ptr %ptrA, float %val, ptr %ptrB) {
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
@@ -305,7 +305,7 @@ define void @foo(ptr noalias %ptr, float %val) {
)IR");
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
@@ -349,7 +349,7 @@ define void @foo(ptr noalias %ptr, float %val) {
)IR");
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
@@ -409,7 +409,7 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0, i64 %val1) {
)IR");
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
@@ -450,7 +450,7 @@ define void @foo(ptr noalias %ptr, float %v, <2 x float> %val) {
)IR");
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
@@ -493,7 +493,7 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0) {
)IR");
Function &LLVMF = *M->getFunction("foo");
DominatorTree DT(LLVMF);
- TargetLibraryInfoImpl TLII;
+ TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);
DataLayout DL(M->getDataLayout());
LoopInfo LI(DT);
diff --git a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp
index 1751701967e6a..2bfea6908305c 100644
--- a/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp
@@ -37,12 +37,16 @@ struct VecUtilsTest : public testing::Test {
void parseIR(const char *IR) {
SMDiagnostic Err;
M = parseAssemblyString(IR, Err, C);
- if (!M)
+ if (!M) {
Err.print("VecUtilsTest", errs());
+ return;
+ }
+
+ TLII = std::make_unique<TargetLibraryInfoImpl>(M->getTargetTriple());
+ TLI = std::make_unique<TargetLibraryInfo>(*TLII);
}
+
ScalarEvolution &getSE(llvm::Function &LLVMF) {
- TLII = std::make_unique<TargetLibraryInfoImpl>();
- TLI = std::make_unique<TargetLibraryInfo>(*TLII);
AC = std::make_unique<AssumptionCache>(LLVMF);
DT = std::make_unique<DominatorTree>(LLVMF);
LI = std::make_unique<LoopInfo>(*DT);
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
index 3f43a2ef690c6..8677ded42215b 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
@@ -18,8 +18,6 @@ namespace {
class VPlanSlpTest : public VPlanTestIRBase {
protected:
- TargetLibraryInfoImpl TLII;
- TargetLibraryInfo TLI;
DataLayout DL;
std::unique_ptr<AssumptionCache> AC;
@@ -31,20 +29,20 @@ class VPlanSlpTest : public VPlanTestIRBase {
std::unique_ptr<InterleavedAccessInfo> IAI;
VPlanSlpTest()
- : TLII(), TLI(TLII),
- DL("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-"
+ : DL("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-"
"f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:"
"16:32:64-S128") {}
VPInterleavedAccessInfo getInterleavedAccessInfo(Function &F, Loop *L,
VPlan &Plan) {
AC.reset(new AssumptionCache(F));
- SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
- BasicAA.reset(new BasicAAResult(DL, F, TLI, *AC, &*DT));
- AARes.reset(new AAResults(TLI));
+ SE.reset(new ScalarEvolution(F, *TLI, *AC, *DT, *LI));
+ BasicAA.reset(new BasicAAResult(DL, F, *TLI, *AC, &*DT));
+ AARes.reset(new AAResults(*TLI));
AARes->addAAResult(*BasicAA);
PSE.reset(new PredicatedScalarEvolution(*SE, *L));
- LAI.reset(new LoopAccessInfo(L, &*SE, nullptr, &TLI, &*AARes, &*DT, &*LI));
+ LAI.reset(
+ new LoopAccessInfo(L, &*SE, nullptr, TLI.get(), &*AARes, &*DT, &*LI));
IAI.reset(new InterleavedAccessInfo(*PSE, L, &*DT, &*LI, &*LAI));
IAI->analyzeInterleaving(false);
return {Plan, *IAI};
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h b/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
index e2ad65b93e3dd..7dfd11a48b595 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
@@ -31,8 +31,6 @@ namespace llvm {
/// given loop entry block.
class VPlanTestIRBase : public testing::Test {
protected:
- TargetLibraryInfoImpl TLII;
- TargetLibraryInfo TLI;
DataLayout DL;
std::unique_ptr<LLVMContext> Ctx;
@@ -41,10 +39,11 @@ class VPlanTestIRBase : public testing::Test {
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<AssumptionCache> AC;
std::unique_ptr<ScalarEvolution> SE;
+ std::unique_ptr<TargetLibraryInfoImpl> TLII;
+ std::unique_ptr<TargetLibraryInfo> TLI;
VPlanTestIRBase()
- : TLII(), TLI(TLII),
- DL("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-"
+ : DL("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-"
"f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:"
"16:32:64-S128"),
Ctx(new LLVMContext) {}
@@ -53,6 +52,8 @@ class VPlanTestIRBase : public testing::Test {
SMDiagnostic Err;
M = parseAssemblyString(ModuleString, Err, *Ctx);
EXPECT_TRUE(M);
+ TLII = std::make_unique<TargetLibraryInfoImpl>(M->getTargetTriple());
+ TLI = std::make_unique<TargetLibraryInfo>(*TLII);
return *M;
}
@@ -60,7 +61,7 @@ class VPlanTestIRBase : public testing::Test {
DT.reset(new DominatorTree(F));
LI.reset(new LoopInfo(*DT));
AC.reset(new AssumptionCache(F));
- SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
+ SE.reset(new ScalarEvolution(F, *TLI, *AC, *DT, *LI));
}
/// Build the VPlan for the loop starting from \p LoopHeader.
>From 979636a6f2b6ed249073f106133f6c96155e11ff Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 26 Jun 2025 10:43:11 +0900
Subject: [PATCH 2/3] Update
llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
---
llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
index 8677ded42215b..81a75c4d200a6 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
@@ -42,7 +42,7 @@ class VPlanSlpTest : public VPlanTestIRBase {
AARes->addAAResult(*BasicAA);
PSE.reset(new PredicatedScalarEvolution(*SE, *L));
LAI.reset(
- new LoopAccessInfo(L, &*SE, nullptr, TLI.get(), &*AARes, &*DT, &*LI));
+ new LoopAccessInfo(L, &*SE, nullptr, &*TLI, &*AARes, &*DT, &*LI));
IAI.reset(new InterleavedAccessInfo(*PSE, L, &*DT, &*LI, &*LAI));
IAI->analyzeInterleaving(false);
return {Plan, *IAI};
>From 0de156c9567afec40c67ffa76f248e2119875b5f Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 26 Jun 2025 10:46:47 +0900
Subject: [PATCH 3/3] fix clang-format
---
llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
index 81a75c4d200a6..118bf67320a3b 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
@@ -41,8 +41,7 @@ class VPlanSlpTest : public VPlanTestIRBase {
AARes.reset(new AAResults(*TLI));
AARes->addAAResult(*BasicAA);
PSE.reset(new PredicatedScalarEvolution(*SE, *L));
- LAI.reset(
- new LoopAccessInfo(L, &*SE, nullptr, &*TLI, &*AARes, &*DT, &*LI));
+ LAI.reset(new LoopAccessInfo(L, &*SE, nullptr, &*TLI, &*AARes, &*DT, &*LI));
IAI.reset(new InterleavedAccessInfo(*PSE, L, &*DT, &*LI, &*LAI));
IAI->analyzeInterleaving(false);
return {Plan, *IAI};
More information about the llvm-commits
mailing list