aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/ADT/SmallVectorTest.cpp16
-rw-r--r--llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp14
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp27
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/SimpleExecutorMemoryManagerTest.cpp20
-rw-r--r--llvm/unittests/Frontend/OpenMPDecompositionTest.cpp16
-rw-r--r--llvm/unittests/IR/RuntimeLibcallsTest.cpp12
-rw-r--r--llvm/unittests/Support/SourceMgrTest.cpp11
7 files changed, 66 insertions, 50 deletions
diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp
index 137dd43..e2e778f 100644
--- a/llvm/unittests/ADT/SmallVectorTest.cpp
+++ b/llvm/unittests/ADT/SmallVectorTest.cpp
@@ -127,24 +127,24 @@ public:
return c0.getValue() == c1.getValue();
}
- friend bool LLVM_ATTRIBUTE_UNUSED operator!=(const Constructable &c0,
- const Constructable &c1) {
+ [[maybe_unused]] friend bool operator!=(const Constructable &c0,
+ const Constructable &c1) {
return c0.getValue() != c1.getValue();
}
friend bool operator<(const Constructable &c0, const Constructable &c1) {
return c0.getValue() < c1.getValue();
}
- friend bool LLVM_ATTRIBUTE_UNUSED operator<=(const Constructable &c0,
- const Constructable &c1) {
+ [[maybe_unused]] friend bool operator<=(const Constructable &c0,
+ const Constructable &c1) {
return c0.getValue() <= c1.getValue();
}
- friend bool LLVM_ATTRIBUTE_UNUSED operator>(const Constructable &c0,
- const Constructable &c1) {
+ [[maybe_unused]] friend bool operator>(const Constructable &c0,
+ const Constructable &c1) {
return c0.getValue() > c1.getValue();
}
- friend bool LLVM_ATTRIBUTE_UNUSED operator>=(const Constructable &c0,
- const Constructable &c1) {
+ [[maybe_unused]] friend bool operator>=(const Constructable &c0,
+ const Constructable &c1) {
return c0.getValue() >= c1.getValue();
}
};
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
index 7340f56..04cd66c 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
@@ -420,12 +420,14 @@ TEST(LegalizerInfoTest, RuleSets) {
// Raw type form
LI.getActionDefinitionsBuilder(G_ADD)
- .fewerElementsIf(typeIs(0, v4s32), changeElementCountTo(0, v2s32))
- .fewerElementsIf(typeIs(0, v8s32), changeElementCountTo(0, s32))
- .fewerElementsIf(typeIs(0, LLT::scalable_vector(4, 16)),
- changeElementCountTo(0, LLT::scalable_vector(2, 16)))
- .fewerElementsIf(typeIs(0, LLT::scalable_vector(8, 16)),
- changeElementCountTo(0, s16));
+ .fewerElementsIf(typeIs(0, v4s32),
+ changeElementCountTo(0, ElementCount::getFixed(2)))
+ .fewerElementsIf(typeIs(0, v8s32),
+ changeElementCountTo(0, ElementCount::getFixed(1)))
+ .fewerElementsIf(typeIs(0, LLT::scalable_vector(4, s16)),
+ changeElementCountTo(0, ElementCount::getScalable(2)))
+ .fewerElementsIf(typeIs(0, LLT::scalable_vector(8, s16)),
+ changeElementCountTo(0, ElementCount::getFixed(1)));
LegacyInfo.computeTables();
diff --git a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
index d4b45ea..2c6650d 100644
--- a/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManagerTest.cpp
@@ -39,8 +39,11 @@ public:
return ExecutorAddr::fromPtr(MB.base());
}
- Error finalize(tpctypes::FinalizeRequest FR) {
+ Expected<ExecutorAddr> initialize(tpctypes::FinalizeRequest FR) {
+ assert(!FR.Segments.empty());
+ ExecutorAddr Base = FR.Segments[0].Addr;
for (auto &Seg : FR.Segments) {
+ Base = std::min(Base, Seg.Addr);
char *Mem = Seg.Addr.toPtr<char *>();
memcpy(Mem, Seg.Content.data(), Seg.Content.size());
memset(Mem + Seg.Content.size(), 0, Seg.Size - Seg.Content.size());
@@ -52,10 +55,10 @@ public:
if ((Seg.RAG.Prot & MemProt::Exec) != MemProt::Exec)
sys::Memory::InvalidateInstructionCache(Mem, Seg.Size);
}
- return Error::success();
+ return Base;
}
- Error deallocate(std::vector<ExecutorAddr> &Bases) {
+ Error release(std::vector<ExecutorAddr> &Bases) {
Error Err = Error::success();
for (auto &Base : Bases) {
auto I = Blocks.find(Base.toPtr<void *>());
@@ -86,18 +89,18 @@ CWrapperFunctionResult testReserve(const char *ArgData, size_t ArgSize) {
.release();
}
-CWrapperFunctionResult testFinalize(const char *ArgData, size_t ArgSize) {
- return WrapperFunction<rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>::
+CWrapperFunctionResult testInitialize(const char *ArgData, size_t ArgSize) {
+ return WrapperFunction<
+ rt::SPSSimpleExecutorMemoryManagerInitializeSignature>::
handle(ArgData, ArgSize,
- makeMethodWrapperHandler(&SimpleAllocator::finalize))
+ makeMethodWrapperHandler(&SimpleAllocator::initialize))
.release();
}
-CWrapperFunctionResult testDeallocate(const char *ArgData, size_t ArgSize) {
- return WrapperFunction<
- rt::SPSSimpleExecutorMemoryManagerDeallocateSignature>::
+CWrapperFunctionResult testRelease(const char *ArgData, size_t ArgSize) {
+ return WrapperFunction<rt::SPSSimpleExecutorMemoryManagerReleaseSignature>::
handle(ArgData, ArgSize,
- makeMethodWrapperHandler(&SimpleAllocator::deallocate))
+ makeMethodWrapperHandler(&SimpleAllocator::release))
.release();
}
@@ -108,8 +111,8 @@ TEST(EPCGenericJITLinkMemoryManagerTest, AllocFinalizeFree) {
EPCGenericJITLinkMemoryManager::SymbolAddrs SAs;
SAs.Allocator = ExecutorAddr::fromPtr(&SA);
SAs.Reserve = ExecutorAddr::fromPtr(&testReserve);
- SAs.Finalize = ExecutorAddr::fromPtr(&testFinalize);
- SAs.Deallocate = ExecutorAddr::fromPtr(&testDeallocate);
+ SAs.Initialize = ExecutorAddr::fromPtr(&testInitialize);
+ SAs.Release = ExecutorAddr::fromPtr(&testRelease);
auto MemMgr = std::make_unique<EPCGenericJITLinkMemoryManager>(*SelfEPC, SAs);
StringRef Hello = "hello";
diff --git a/llvm/unittests/ExecutionEngine/Orc/SimpleExecutorMemoryManagerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/SimpleExecutorMemoryManagerTest.cpp
index 6e9b0b2..9c6f19c 100644
--- a/llvm/unittests/ExecutionEngine/Orc/SimpleExecutorMemoryManagerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/SimpleExecutorMemoryManagerTest.cpp
@@ -34,12 +34,12 @@ TEST(SimpleExecutorMemoryManagerTest, AllocFinalizeFree) {
SimpleExecutorMemoryManager MemMgr;
constexpr unsigned AllocSize = 16384;
- auto Mem = MemMgr.allocate(AllocSize);
+ auto Mem = MemMgr.reserve(AllocSize);
EXPECT_THAT_ERROR(Mem.takeError(), Succeeded());
std::string HW = "Hello, world!";
- int FinalizeCounter = 0;
+ int InitializeCounter = 0;
int DeallocateCounter = 0;
tpctypes::FinalizeRequest FR;
@@ -52,27 +52,27 @@ TEST(SimpleExecutorMemoryManagerTest, AllocFinalizeFree) {
{/* Finalize: */
cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
ExecutorAddr::fromPtr(incrementWrapper),
- ExecutorAddr::fromPtr(&FinalizeCounter))),
+ ExecutorAddr::fromPtr(&InitializeCounter))),
/* Deallocate: */
cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
ExecutorAddr::fromPtr(incrementWrapper),
ExecutorAddr::fromPtr(&DeallocateCounter)))});
- EXPECT_EQ(FinalizeCounter, 0);
+ EXPECT_EQ(InitializeCounter, 0);
EXPECT_EQ(DeallocateCounter, 0);
- auto FinalizeErr = MemMgr.finalize(FR);
- EXPECT_THAT_ERROR(std::move(FinalizeErr), Succeeded());
+ auto InitializeErr = MemMgr.initialize(FR);
+ EXPECT_THAT_EXPECTED(std::move(InitializeErr), Succeeded());
- EXPECT_EQ(FinalizeCounter, 1);
+ EXPECT_EQ(InitializeCounter, 1);
EXPECT_EQ(DeallocateCounter, 0);
EXPECT_EQ(HW, std::string(Mem->toPtr<const char *>()));
- auto DeallocateErr = MemMgr.deallocate({*Mem});
- EXPECT_THAT_ERROR(std::move(DeallocateErr), Succeeded());
+ auto ReleaseErr = MemMgr.release({*Mem});
+ EXPECT_THAT_ERROR(std::move(ReleaseErr), Succeeded());
- EXPECT_EQ(FinalizeCounter, 1);
+ EXPECT_EQ(InitializeCounter, 1);
EXPECT_EQ(DeallocateCounter, 1);
}
diff --git a/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp b/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp
index 95c26b1..a8706ce 100644
--- a/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp
@@ -431,8 +431,8 @@ TEST_F(OpenMPDecompositionTest, Firstprivate3) {
std::string Dir0 = stringify(Dec.output[0]);
std::string Dir1 = stringify(Dec.output[1]);
std::string Dir2 = stringify(Dec.output[2]);
- ASSERT_EQ(Dir0, "target map(2, , , , , (x))"); // (12), (27)
- ASSERT_EQ(Dir1, "teams shared(x)"); // (6), (17)
+ ASSERT_EQ(Dir0, "target map(2, , , , , , (x))"); // (12), (27)
+ ASSERT_EQ(Dir1, "teams shared(x)"); // (6), (17)
ASSERT_EQ(Dir2, "distribute firstprivate(x) lastprivate(, (x))"); // (5), (21)
}
@@ -574,9 +574,9 @@ TEST_F(OpenMPDecompositionTest, Lastprivate3) {
std::string Dir0 = stringify(Dec.output[0]);
std::string Dir1 = stringify(Dec.output[1]);
std::string Dir2 = stringify(Dec.output[2]);
- ASSERT_EQ(Dir0, "target map(2, , , , , (x))"); // (21), (27)
- ASSERT_EQ(Dir1, "parallel shared(x)"); // (22)
- ASSERT_EQ(Dir2, "do lastprivate(, (x))"); // (21)
+ ASSERT_EQ(Dir0, "target map(2, , , , , , (x))"); // (21), (27)
+ ASSERT_EQ(Dir1, "parallel shared(x)"); // (22)
+ ASSERT_EQ(Dir2, "do lastprivate(, (x))"); // (21)
}
// SHARED
@@ -984,9 +984,9 @@ TEST_F(OpenMPDecompositionTest, Reduction7) {
std::string Dir0 = stringify(Dec.output[0]);
std::string Dir1 = stringify(Dec.output[1]);
std::string Dir2 = stringify(Dec.output[2]);
- ASSERT_EQ(Dir0, "target map(2, , , , , (x))"); // (36), (10)
- ASSERT_EQ(Dir1, "parallel shared(x)"); // (36), (1), (4)
- ASSERT_EQ(Dir2, "do reduction(, (3), (x))"); // (36)
+ ASSERT_EQ(Dir0, "target map(2, , , , , , (x))"); // (36), (10)
+ ASSERT_EQ(Dir1, "parallel shared(x)"); // (36), (1), (4)
+ ASSERT_EQ(Dir2, "do reduction(, (3), (x))"); // (36)
}
// IF
diff --git a/llvm/unittests/IR/RuntimeLibcallsTest.cpp b/llvm/unittests/IR/RuntimeLibcallsTest.cpp
index 26cb7e3..8925d2b 100644
--- a/llvm/unittests/IR/RuntimeLibcallsTest.cpp
+++ b/llvm/unittests/IR/RuntimeLibcallsTest.cpp
@@ -44,9 +44,9 @@ TEST(RuntimeLibcallsTest, LibcallImplByName) {
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName("sqrtl");
ASSERT_EQ(size(SquirtleSquad), 3);
auto I = SquirtleSquad.begin();
- EXPECT_EQ(*I++, RTLIB::impl_sqrt_f128);
- EXPECT_EQ(*I++, RTLIB::impl_sqrt_f80);
- EXPECT_EQ(*I++, RTLIB::impl_sqrt_ppcf128);
+ EXPECT_EQ(*I++, RTLIB::impl_sqrtl_f128);
+ EXPECT_EQ(*I++, RTLIB::impl_sqrtl_f80);
+ EXPECT_EQ(*I++, RTLIB::impl_sqrtl_ppcf128);
}
// Last libcall
@@ -54,9 +54,9 @@ TEST(RuntimeLibcallsTest, LibcallImplByName) {
auto Truncs = RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName("truncl");
ASSERT_EQ(size(Truncs), 3);
auto I = Truncs.begin();
- EXPECT_EQ(*I++, RTLIB::impl_trunc_f128);
- EXPECT_EQ(*I++, RTLIB::impl_trunc_f80);
- EXPECT_EQ(*I++, RTLIB::impl_trunc_ppcf128);
+ EXPECT_EQ(*I++, RTLIB::impl_truncl_f128);
+ EXPECT_EQ(*I++, RTLIB::impl_truncl_f80);
+ EXPECT_EQ(*I++, RTLIB::impl_truncl_ppcf128);
}
}
diff --git a/llvm/unittests/Support/SourceMgrTest.cpp b/llvm/unittests/Support/SourceMgrTest.cpp
index 301b64f..c65f001 100644
--- a/llvm/unittests/Support/SourceMgrTest.cpp
+++ b/llvm/unittests/Support/SourceMgrTest.cpp
@@ -8,6 +8,7 @@
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
@@ -506,3 +507,13 @@ TEST_F(SourceMgrTest, PrintWithoutLoc) {
Diag.print(nullptr, OS, false, false, false);
EXPECT_EQ("message\n", Output);
}
+
+TEST_F(SourceMgrTest, IncludeDirs) {
+ auto VFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
+ VFS->addFile("include/file", 0, MemoryBuffer::getMemBuffer("contents"));
+ SM.setVirtualFileSystem(std::move(VFS));
+ SM.setIncludeDirs({"include"});
+ std::string ResolvedPath;
+ unsigned NumBuffers = SM.AddIncludeFile("file", SMLoc(), ResolvedPath);
+ EXPECT_EQ(NumBuffers, 1u);
+}