[llvm] e36b22f - Revert "[PGO] Preserve analysis results when nothing was instrumented (#93421)"
Howard Roark via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 00:52:41 PDT 2024
Author: Howard Roark
Date: 2024-10-16T10:50:48+03:00
New Revision: e36b22f3bf45a23d31b569e53d22b98714cf00e3
URL: https://github.com/llvm/llvm-project/commit/e36b22f3bf45a23d31b569e53d22b98714cf00e3
DIFF: https://github.com/llvm/llvm-project/commit/e36b22f3bf45a23d31b569e53d22b98714cf00e3.diff
LOG: Revert "[PGO] Preserve analysis results when nothing was instrumented (#93421)"
This reverts commit 23c64beeccc03c6a8329314ecd75864e09bb6d97.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index dbe908bb5e72f3..e6e474ed376069 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1916,7 +1916,6 @@ static bool InstrumentAllFunctions(
std::unordered_multimap<Comdat *, GlobalValue *> ComdatMembers;
collectComdatMembers(M, ComdatMembers);
- bool AnythingInstrumented = false;
for (auto &F : M) {
if (skipPGOGen(F))
continue;
@@ -1926,9 +1925,8 @@ static bool InstrumentAllFunctions(
FunctionInstrumenter FI(M, F, TLI, ComdatMembers, BPI, BFI,
InstrumentationType);
FI.instrument();
- AnythingInstrumented = true;
}
- return AnythingInstrumented;
+ return true;
}
PreservedAnalyses
diff --git a/llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp b/llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp
index a4c076a8752fc3..9ccb13934cbd38 100644
--- a/llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp
+++ b/llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp
@@ -103,13 +103,9 @@ class MockModuleAnalysisHandle
ModuleAnalysisManager::Invalidator &));
};
-template <typename ParamType> struct PGOTestName {
- std::string operator()(const TestParamInfo<ParamType> &Info) const {
- return std::get<1>(Info.param).str();
- }
-};
-
-struct PGOInstrumentationGenTest : public Test {
+struct PGOInstrumentationGenTest
+ : public Test,
+ WithParamInterface<std::tuple<StringRef, StringRef>> {
ModulePassManager MPM;
PassBuilder PB;
MockModuleAnalysisHandle MMAHandle;
@@ -145,47 +141,12 @@ struct PGOInstrumentationGenTest : public Test {
}
};
-struct PGOInstrumentationGenInstrumentTest
- : PGOInstrumentationGenTest,
- WithParamInterface<std::tuple<StringRef, StringRef>> {};
-
static constexpr StringRef CodeWithFuncDefs = R"(
define i32 @f(i32 %n) {
entry:
ret i32 0
})";
-INSTANTIATE_TEST_SUITE_P(
- PGOInstrumetationGenTestSuite, PGOInstrumentationGenInstrumentTest,
- Values(std::make_tuple(CodeWithFuncDefs, "instrument_function_defs")),
- PGOTestName<PGOInstrumentationGenInstrumentTest::ParamType>());
-
-TEST_P(PGOInstrumentationGenInstrumentTest, Instrumented) {
- const StringRef Code = std::get<0>(GetParam());
- parseAssembly(Code);
-
- ASSERT_THAT(M, NotNull());
-
- Sequence PassSequence;
- EXPECT_CALL(MMAHandle, run(Ref(*M), _))
- .InSequence(PassSequence)
- .WillOnce(DoDefault());
- EXPECT_CALL(MMAHandle, invalidate(Ref(*M), _, _))
- .InSequence(PassSequence)
- .WillOnce(DoDefault());
-
- MPM.run(*M, MAM);
-
- const auto *IRInstrVar =
- M->getNamedGlobal(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
- ASSERT_THAT(IRInstrVar, NotNull());
- EXPECT_FALSE(IRInstrVar->isDeclaration());
-}
-
-struct PGOInstrumentationGenIgnoreTest
- : PGOInstrumentationGenTest,
- WithParamInterface<std::tuple<StringRef, StringRef>> {};
-
static constexpr StringRef CodeWithFuncDecls = R"(
declare i32 @f(i32);
)";
@@ -196,26 +157,33 @@ static constexpr StringRef CodeWithGlobals = R"(
)";
INSTANTIATE_TEST_SUITE_P(
- PGOInstrumetationGenIgnoreTestSuite, PGOInstrumentationGenIgnoreTest,
- Values(std::make_tuple(CodeWithFuncDecls, "instrument_function_decls"),
+ PGOInstrumetationGenTestSuite, PGOInstrumentationGenTest,
+ Values(std::make_tuple(CodeWithFuncDefs, "instrument_function_defs"),
+ std::make_tuple(CodeWithFuncDecls, "instrument_function_decls"),
std::make_tuple(CodeWithGlobals, "instrument_globals")),
- PGOTestName<PGOInstrumentationGenIgnoreTest::ParamType>());
+ [](const TestParamInfo<PGOInstrumentationGenTest::ParamType> &Info) {
+ return std::get<1>(Info.param).str();
+ });
-TEST_P(PGOInstrumentationGenIgnoreTest, NotInstrumented) {
+TEST_P(PGOInstrumentationGenTest, Instrumented) {
const StringRef Code = std::get<0>(GetParam());
-
parseAssembly(Code);
ASSERT_THAT(M, NotNull());
- EXPECT_CALL(MMAHandle, run(Ref(*M), _)).WillOnce(DoDefault());
- EXPECT_CALL(MMAHandle, invalidate(Ref(*M), _, _)).Times(0);
+ Sequence PassSequence;
+ EXPECT_CALL(MMAHandle, run(Ref(*M), _))
+ .InSequence(PassSequence)
+ .WillOnce(DoDefault());
+ EXPECT_CALL(MMAHandle, invalidate(Ref(*M), _, _))
+ .InSequence(PassSequence)
+ .WillOnce(DoDefault());
MPM.run(*M, MAM);
const auto *IRInstrVar =
M->getNamedGlobal(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
- ASSERT_THAT(IRInstrVar, NotNull());
+ EXPECT_THAT(IRInstrVar, NotNull());
EXPECT_FALSE(IRInstrVar->isDeclaration());
}
More information about the llvm-commits
mailing list