Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp
- This file was copied to llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp.
#include "llvm/Analysis/CallGraph.h" | #include "llvm/Analysis/CallGraph.h" | ||||
#include "llvm/AsmParser/Parser.h" | #include "llvm/AsmParser/Parser.h" | ||||
#include "llvm/Config/config.h" | #include "llvm/Config/config.h" | ||||
#include "llvm/Passes/PassBuilder.h" | #include "llvm/Passes/PassBuilder.h" | ||||
#include "llvm/Passes/PassPlugin.h" | #include "llvm/Passes/PassPlugin.h" | ||||
#include "llvm/Support/CommandLine.h" | #include "llvm/Support/CommandLine.h" | ||||
#include "llvm/Support/raw_ostream.h" | #include "llvm/Support/raw_ostream.h" | ||||
#include "llvm/Testing/Support/Error.h" | #include "llvm/Testing/Support/Error.h" | ||||
#include "gtest/gtest.h" | #include "gtest/gtest.h" | ||||
namespace llvm { | namespace llvm { | ||||
namespace { | |||||
void anchor() {} | void anchor() {} | ||||
static std::string libPath(const std::string Name = "InlineAdvisorPlugin") { | static std::string libPath(const std::string Name = "InlineAdvisorPlugin") { | ||||
const auto &Argvs = testing::internal::GetArgvs(); | const auto &Argvs = testing::internal::GetArgvs(); | ||||
const char *Argv0 = | const char *Argv0 = | ||||
Argvs.size() > 0 ? Argvs[0].c_str() : "PluginInlineAdvisorAnalysisTest"; | Argvs.size() > 0 ? Argvs[0].c_str() : "PluginInlineAdvisorAnalysisTest"; | ||||
void *Ptr = (void *)(intptr_t)anchor; | void *Ptr = (void *)(intptr_t)anchor; | ||||
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr); | std::string Path = sys::fs::getMainExecutable(Argv0, Ptr); | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | CompilerInstance() { | ||||
PB.registerFunctionAnalyses(FAM); | PB.registerFunctionAnalyses(FAM); | ||||
PB.registerLoopAnalyses(LAM); | PB.registerLoopAnalyses(LAM); | ||||
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); | PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); | ||||
MPM.addPass(ModuleInlinerPass(IP, InliningAdvisorMode::Default, | MPM.addPass(ModuleInlinerPass(IP, InliningAdvisorMode::Default, | ||||
ThinOrFullLTOPhase::None)); | ThinOrFullLTOPhase::None)); | ||||
} | } | ||||
std::string output; | std::string output; | ||||
std::unique_ptr<Module> outputM; | std::unique_ptr<Module> outputM; | ||||
kazu: Could you capitalize the first letter of the sentence and put a period at the end. Easier to… | |||||
// run with the default inliner | // run with the default inliner | ||||
auto run_default(StringRef IR) { | auto run_default(StringRef IR) { | ||||
PluginInlineAdvisorAnalysis::HasBeenRegistered = false; | PluginInlineAdvisorAnalysis::HasBeenRegistered = false; | ||||
outputM = parseAssemblyString(IR, Error, Ctx); | outputM = parseAssemblyString(IR, Error, Ctx); | ||||
MPM.run(*outputM, MAM); | MPM.run(*outputM, MAM); | ||||
ASSERT_TRUE(outputM); | ASSERT_TRUE(outputM); | ||||
output.clear(); | output.clear(); | ||||
raw_string_ostream o_stream{output}; | raw_string_ostream o_stream{output}; | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | if_end: | ||||
store i32 %add, i32* %i | store i32 %add, i32* %i | ||||
br label %loop_cond | br label %loop_cond | ||||
loop_end: | loop_end: | ||||
%correct_val = load i32, i32* %correct | %correct_val = load i32, i32* %correct | ||||
ret i32 %correct_val | ret i32 %correct_val | ||||
} | } | ||||
)"}; | )"}; | ||||
} // namespace | |||||
// check that loading a plugin works | // check that loading a plugin works | ||||
// the plugin being loaded acts identically to the default inliner | // the plugin being loaded acts identically to the default inliner | ||||
TEST(PluginInlineAdvisorTest, PluginLoad) { | TEST(PluginInlineAdvisorTest, PluginLoad) { | ||||
#if !defined(LLVM_ENABLE_PLUGINS) | #if !defined(LLVM_ENABLE_PLUGINS) | ||||
// Disable the test if plugins are disabled. | // Disable the test if plugins are disabled. | ||||
return; | return; | ||||
#endif | #endif | ||||
CompilerInstance CI{}; | CompilerInstance CI{}; | ||||
Show All 32 Lines |
Could you capitalize the first letter of the sentence and put a period at the end. Easier to parse that way.