Skip to content
Closed
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
13 changes: 2 additions & 11 deletions llvm/unittests/Analysis/InlineAdvisorPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
# The advisor plugin expects to not link against the Analysis, Support and Core
# libraries, but expects them to exist in the process loading the plugin. This
# The advisor plugin expects to not link against the Analysis, Support and Core
# libraries, but expects them to exist in the process loading the plugin. This
# doesn't work with DLLs on Windows (where a shared library can't have undefined
# references), so just skip this testcase on Windows.
if ((NOT WIN32 AND NOT CYGWIN) OR LLVM_BUILD_LLVM_DYLIB)
unset(LLVM_LINK_COMPONENTS)
add_llvm_library(InlineAdvisorPlugin MODULE BUILDTREE_ONLY
InlineAdvisorPlugin.cpp
)
# Put PLUGIN next to the unit test executable.
set_output_directory(InlineAdvisorPlugin
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
)
set_target_properties(InlineAdvisorPlugin PROPERTIES FOLDER "LLVM/Tests")

# The plugin depends on some of the output files of intrinsics_gen, so make sure
# it is built before the plugin.
add_dependencies(InlineAdvisorPlugin intrinsics_gen)
add_dependencies(AnalysisTests InlineAdvisorPlugin)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "llvm/Pass.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"

#include "llvm/Analysis/InlineAdvisor.h"

Expand Down
13 changes: 2 additions & 11 deletions llvm/unittests/Analysis/InlineOrderPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
# The order plugin expects to not link against the Analysis, Support and Core
# libraries, but expects them to exist in the process loading the plugin. This
# The order plugin expects to not link against the Analysis, Support and Core
# libraries, but expects them to exist in the process loading the plugin. This
# doesn't work with DLLs on Windows (where a shared library can't have undefined
# references), so just skip this testcase on Windows.
if ((NOT WIN32 AND NOT CYGWIN) OR LLVM_BUILD_LLVM_DYLIB)
unset(LLVM_LINK_COMPONENTS)
add_llvm_library(InlineOrderPlugin MODULE BUILDTREE_ONLY
InlineOrderPlugin.cpp
)
# Put PLUGIN next to the unit test executable.
set_output_directory(InlineOrderPlugin
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
)
set_target_properties(InlineOrderPlugin PROPERTIES FOLDER "Tests")

# The plugin depends on some of the output files of intrinsics_gen, so make sure
# it is built before the plugin.
add_dependencies(InlineOrderPlugin intrinsics_gen)
add_dependencies(AnalysisTests InlineOrderPlugin)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "llvm/Pass.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"

#include "llvm/Analysis/InlineOrder.h"

Expand Down
18 changes: 1 addition & 17 deletions llvm/unittests/Analysis/PluginInlineAdvisorAnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,13 @@
#include "llvm/IR/Module.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"

namespace llvm {

namespace {

void anchor() {}

static std::string libPath(const std::string Name = "InlineAdvisorPlugin") {
const auto &Argvs = testing::internal::GetArgvs();
const char *Argv0 =
Argvs.size() > 0 ? Argvs[0].c_str() : "PluginInlineAdvisorAnalysisTest";
void *Ptr = (void *)(intptr_t)anchor;
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
sys::path::append(Buf, (Name + LLVM_PLUGIN_EXT).c_str());
return std::string(Buf.str());
}

// Example of a custom InlineAdvisor that only inlines calls to functions called
// "foo".
class FooOnlyInlineAdvisor : public InlineAdvisor {
Expand Down Expand Up @@ -61,8 +46,7 @@ struct CompilerInstance {

// connect the plugin to our compiler instance
void setupPlugin() {
auto PluginPath = libPath();
ASSERT_NE("", PluginPath);
auto PluginPath{std::string{"InlineAdvisorPlugin"} + LLVM_PLUGIN_EXT};
Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath);
ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath;
Plugin->registerPassBuilderCallbacks(PB);
Expand Down
20 changes: 1 addition & 19 deletions llvm/unittests/Analysis/PluginInlineOrderAnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,13 @@
#include "llvm/IR/Module.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"

#include "llvm/Analysis/InlineOrder.h"

namespace llvm {

namespace {

void anchor() {}

std::string libPath(const std::string Name = "InlineOrderPlugin") {
const auto &Argvs = testing::internal::GetArgvs();
const char *Argv0 =
Argvs.size() > 0 ? Argvs[0].c_str() : "PluginInlineOrderAnalysisTest";
void *Ptr = (void *)(intptr_t)anchor;
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
sys::path::append(Buf, (Name + LLVM_PLUGIN_EXT).c_str());
return std::string(Buf.str());
}

struct CompilerInstance {
LLVMContext Ctx;
ModulePassManager MPM;
Expand All @@ -43,8 +26,7 @@ struct CompilerInstance {

// Connect the plugin to our compiler instance.
void setupPlugin() {
auto PluginPath = libPath();
ASSERT_NE("", PluginPath);
auto PluginPath{std::string{"InlineOrderPlugin"} + LLVM_PLUGIN_EXT};
Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath);
ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath;
Plugin->registerPassBuilderCallbacks(PB);
Expand Down
14 changes: 2 additions & 12 deletions llvm/unittests/Passes/Plugins/DoublerPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
add_llvm_library(DoublerPlugin MODULE BUILDTREE_ONLY
DoublerPlugin.cpp
)

# Put PLUGIN next to the unit test executable.
set_output_directory(DoublerPlugin
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
)
DoublerPlugin.cpp
)
set_target_properties(DoublerPlugin PROPERTIES FOLDER "Tests")

# The plugin depends on some of the output files of intrinsics_gen, so make sure
# it is built before the plugin.
add_dependencies(DoublerPlugin intrinsics_gen)
add_dependencies(PluginsTests DoublerPlugin)
22 changes: 3 additions & 19 deletions llvm/unittests/Passes/Plugins/PluginsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,13 @@

using namespace llvm;

void anchor() {}

static std::string LibPath(const std::string Name = "TestPlugin") {
const auto &Argvs = testing::internal::GetArgvs();
const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "PluginsTests";
void *Ptr = (void *)(intptr_t)anchor;
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
sys::path::append(Buf, (Name + LLVM_PLUGIN_EXT).c_str());
return std::string(Buf.str());
}

TEST(PluginsTests, LoadPlugin) {
#if !defined(LLVM_ENABLE_PLUGINS)
// Skip the test if plugins are disabled.
GTEST_SKIP();
#endif

auto PluginPath = LibPath();
ASSERT_NE("", PluginPath);

auto PluginPath{std::string{"TestPlugin"} + LLVM_PLUGIN_EXT};
Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath);
ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath;

Expand All @@ -71,10 +57,8 @@ TEST(PluginsTests, LoadMultiplePlugins) {
GTEST_SKIP();
#endif

auto DoublerPluginPath = LibPath("DoublerPlugin");
auto TestPluginPath = LibPath("TestPlugin");
ASSERT_NE("", DoublerPluginPath);
ASSERT_NE("", TestPluginPath);
auto DoublerPluginPath{std::string{"DoublerPlugin"} + LLVM_PLUGIN_EXT};
auto TestPluginPath{std::string{"TestPlugin"} + LLVM_PLUGIN_EXT};

Expected<PassPlugin> DoublerPlugin1 = PassPlugin::Load(DoublerPluginPath);
ASSERT_TRUE(!!DoublerPlugin1)
Expand Down
13 changes: 2 additions & 11 deletions llvm/unittests/Passes/Plugins/TestPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
add_llvm_library(TestPlugin MODULE BUILDTREE_ONLY
TestPlugin.cpp
)

# Put PLUGIN next to the unit test executable.
set_output_directory(TestPlugin
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/../
)
TestPlugin.cpp
)
set_target_properties(TestPlugin PROPERTIES FOLDER "Tests")

# The plugin depends on some of the output files of intrinsics_gen, so make sure
# it is built before the plugin.
add_dependencies(TestPlugin intrinsics_gen)
add_dependencies(PluginsTests TestPlugin)
9 changes: 2 additions & 7 deletions llvm/unittests/Support/DynamicLibrary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,16 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
endif()

function(dynlib_add_module NAME)
add_library(${NAME} MODULE
add_llvm_library(${NAME} MODULE BUILDTREE_ONLY
PipSqueak.cpp
)
)
set_target_properties(${NAME} PROPERTIES FOLDER "LLVM/Tests/Support")

set_output_directory(${NAME}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
)

set_target_properties(${NAME}
PROPERTIES PREFIX ""
SUFFIX ${LLVM_PLUGIN_EXT}
)

add_dependencies(DynamicLibraryTests ${NAME})

if(LLVM_INTEGRATED_CRT_ALLOC)
Expand Down
Loading