Skip to content

TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor #145826

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion llvm/include/llvm/Analysis/TargetLibraryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion llvm/include/llvm/LinkAllPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
#include "llvm/Transforms/Vectorize/LoadStoreVectorizer.h"
#include <cstdlib>

namespace llvm {
class Triple;
}

namespace {
struct ForcePassLinking {
ForcePassLinking() {
Expand Down Expand Up @@ -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()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
llvm::TargetLibraryInfoImpl TLII((llvm::Triple()));
llvm::TargetLibraryInfoImpl TLII(llvm::Triple());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
LinkAllPasses.h:154:38: note: add a pair of parentheses to declare a variable
error: no matching constructor for initialization of 'llvm::TargetLibraryInfo'

llvm::TargetLibraryInfo TLI(TLII);
llvm::AliasAnalysis AA(TLI);
llvm::BatchAAResults BAA(AA);
Expand Down
8 changes: 1 addition & 7 deletions llvm/lib/Analysis/TargetLibraryInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)) {}
Expand Down
3 changes: 2 additions & 1 deletion llvm/unittests/Analysis/AliasAnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/DDGTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/IVDescriptorsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/LoadsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/LoopInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/LoopNestTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion llvm/unittests/Analysis/MemorySSATest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion llvm/unittests/Analysis/ScalarEvolutionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/UnrollAnalyzerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/SandboxIR/UtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -255,7 +255,7 @@ declare void @sink_alt() cold

LoopInfo LI(DT);

TargetLibraryInfoImpl TLII;
TargetLibraryInfoImpl TLII(M->getTargetTriple());
TargetLibraryInfo TLI(TLII);

AAResults AA(TLI);
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
};

Expand Down
Loading