mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 22:30:13 +00:00
[PM] Sink the module parsing from the fixture to the test as subsequent
tests will want different IR. Wanted this when writing tests for the proposed CG update stuff, and this is an easily separable piece. llvm-svn: 273973
This commit is contained in:
parent
7de0cf3cf7
commit
6c138ce31c
@ -208,53 +208,48 @@ struct TestFunctionPass {
|
|||||||
int &RunCount;
|
int &RunCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
|
std::unique_ptr<Module> parseIR(const char *IR) {
|
||||||
|
// We just use a static context here. This is never called from multiple
|
||||||
|
// threads so it is harmless no matter how it is implemented. We just need
|
||||||
|
// the context to outlive the module which it does.
|
||||||
|
static LLVMContext C;
|
||||||
SMDiagnostic Err;
|
SMDiagnostic Err;
|
||||||
return parseAssemblyString(IR, Err, C);
|
return parseAssemblyString(IR, Err, C);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CGSCCPassManagerTest : public ::testing::Test {
|
TEST(CGSCCPassManagerTest, Basic) {
|
||||||
protected:
|
auto M = parseIR("define void @f() {\n"
|
||||||
LLVMContext Context;
|
"entry:\n"
|
||||||
std::unique_ptr<Module> M;
|
" call void @g()\n"
|
||||||
|
" call void @h1()\n"
|
||||||
public:
|
" ret void\n"
|
||||||
CGSCCPassManagerTest()
|
"}\n"
|
||||||
: M(parseIR(Context, "define void @f() {\n"
|
"define void @g() {\n"
|
||||||
"entry:\n"
|
"entry:\n"
|
||||||
" call void @g()\n"
|
" call void @g()\n"
|
||||||
" call void @h1()\n"
|
" call void @x()\n"
|
||||||
" ret void\n"
|
" ret void\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"define void @g() {\n"
|
"define void @h1() {\n"
|
||||||
"entry:\n"
|
"entry:\n"
|
||||||
" call void @g()\n"
|
" call void @h2()\n"
|
||||||
" call void @x()\n"
|
" ret void\n"
|
||||||
" ret void\n"
|
"}\n"
|
||||||
"}\n"
|
"define void @h2() {\n"
|
||||||
"define void @h1() {\n"
|
"entry:\n"
|
||||||
"entry:\n"
|
" call void @h3()\n"
|
||||||
" call void @h2()\n"
|
" call void @x()\n"
|
||||||
" ret void\n"
|
" ret void\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"define void @h2() {\n"
|
"define void @h3() {\n"
|
||||||
"entry:\n"
|
"entry:\n"
|
||||||
" call void @h3()\n"
|
" call void @h1()\n"
|
||||||
" call void @x()\n"
|
" ret void\n"
|
||||||
" ret void\n"
|
"}\n"
|
||||||
"}\n"
|
"define void @x() {\n"
|
||||||
"define void @h3() {\n"
|
"entry:\n"
|
||||||
"entry:\n"
|
" ret void\n"
|
||||||
" call void @h1()\n"
|
"}\n");
|
||||||
" ret void\n"
|
|
||||||
"}\n"
|
|
||||||
"define void @x() {\n"
|
|
||||||
"entry:\n"
|
|
||||||
" ret void\n"
|
|
||||||
"}\n")) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(CGSCCPassManagerTest, Basic) {
|
|
||||||
FunctionAnalysisManager FAM(/*DebugLogging*/ true);
|
FunctionAnalysisManager FAM(/*DebugLogging*/ true);
|
||||||
int FunctionAnalysisRuns = 0;
|
int FunctionAnalysisRuns = 0;
|
||||||
FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
|
FAM.registerPass([&] { return TestFunctionAnalysis(FunctionAnalysisRuns); });
|
||||||
|
Loading…
Reference in New Issue
Block a user