aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp3
-rw-r--r--llvm/unittests/Support/CMakeLists.txt1
-rw-r--r--llvm/unittests/Support/DebugLogTest.cpp78
-rw-r--r--llvm/unittests/Transforms/Vectorize/VPlanTest.cpp2
-rw-r--r--llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp2
5 files changed, 82 insertions, 4 deletions
diff --git a/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp b/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
index 36504f5..e72b4e4 100644
--- a/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
+++ b/llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
@@ -39,8 +39,7 @@ createTargetMachine(std::string TargetStr, StringRef CPU, StringRef FS) {
return nullptr;
TargetOptions Options;
return std::unique_ptr<TargetMachine>(
- static_cast<TargetMachine *>(T->createTargetMachine(
- TT, CPU, FS, Options, std::nullopt, std::nullopt)));
+ T->createTargetMachine(TT, CPU, FS, Options, std::nullopt, std::nullopt));
}
std::unique_ptr<Module> parseMIR(const TargetMachine &TM, StringRef MIRCode,
diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt
index d048e87..868c40b 100644
--- a/llvm/unittests/Support/CMakeLists.txt
+++ b/llvm/unittests/Support/CMakeLists.txt
@@ -31,6 +31,7 @@ add_llvm_unittest(SupportTests
DataExtractorTest.cpp
DebugCounterTest.cpp
DebugTest.cpp
+ DebugLogTest.cpp
DivisionByConstantTest.cpp
DJBTest.cpp
EndianStreamTest.cpp
diff --git a/llvm/unittests/Support/DebugLogTest.cpp b/llvm/unittests/Support/DebugLogTest.cpp
new file mode 100644
index 0000000..b26fa40
--- /dev/null
+++ b/llvm/unittests/Support/DebugLogTest.cpp
@@ -0,0 +1,78 @@
+//===- llvm/unittest/Support/DebugLogTest.cpp -----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/DebugLog.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include <string>
+using namespace llvm;
+using testing::Eq;
+using testing::HasSubstr;
+
+#ifndef NDEBUG
+TEST(DebugLogTest, Basic) {
+ llvm::DebugFlag = true;
+ static const char *DT[] = {"A", "B"};
+
+ // Clear debug types.
+ setCurrentDebugTypes(DT, 0);
+ {
+ std::string str;
+ raw_string_ostream os(str);
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, nullptr) << "NoType";
+ EXPECT_FALSE(StringRef(os.str()).starts_with('['));
+ EXPECT_TRUE(StringRef(os.str()).ends_with("NoType\n"));
+ }
+
+ setCurrentDebugTypes(DT, 2);
+ {
+ std::string str;
+ raw_string_ostream os(str);
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "A") << "A";
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "B") << "B";
+ EXPECT_TRUE(StringRef(os.str()).starts_with('['));
+ EXPECT_THAT(os.str(), AllOf(HasSubstr("A\n"), HasSubstr("B\n")));
+ }
+
+ setCurrentDebugType("A");
+ {
+ std::string str;
+ raw_string_ostream os(str);
+ // Just check that the macro doesn't result in dangling else.
+ if (true)
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "A") << "A";
+ else
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "A") << "B";
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "B") << "B";
+ EXPECT_THAT(os.str(), AllOf(HasSubstr("A\n"), Not(HasSubstr("B\n"))));
+
+ int count = 0;
+ auto inc = [&]() { return ++count; };
+ EXPECT_THAT(count, Eq(0));
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "A") << inc();
+ EXPECT_THAT(count, Eq(1));
+ DEBUGLOG_WITH_STREAM_AND_TYPE(os, "B") << inc();
+ EXPECT_THAT(count, Eq(1));
+ }
+}
+#else
+TEST(DebugLogTest, Basic) {
+ // LDBG should be compiled out in NDEBUG, so just check it compiles and has
+ // no effect.
+ llvm::DebugFlag = true;
+ static const char *DT[] = {"A"};
+ setCurrentDebugTypes(DT, 0);
+ int count = 0;
+ auto inc = [&]() { return ++count; };
+ EXPECT_THAT(count, Eq(0));
+ LDBG() << inc();
+ EXPECT_THAT(count, Eq(0));
+}
+#endif
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 8012d9e..94b74d2 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -1075,7 +1075,7 @@ TEST_F(VPRecipeTest, CastVPBlendRecipeToVPUser) {
Args.push_back(I1);
Args.push_back(I2);
Args.push_back(M2);
- VPBlendRecipe Recipe(Phi, Args);
+ VPBlendRecipe Recipe(Phi, Args, {});
EXPECT_TRUE(isa<VPUser>(&Recipe));
VPRecipeBase *BaseR = &Recipe;
EXPECT_TRUE(isa<VPUser>(BaseR));
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
index 5394472..6214ea3 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
@@ -103,7 +103,7 @@ TEST_F(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
auto *CanIV = new VPCanonicalIVPHIRecipe(Zero, {});
VPInstruction *BranchOnCond =
new VPInstruction(VPInstruction::BranchOnCond, {CanIV});
- auto *Blend = new VPBlendRecipe(Phi, {DefI});
+ auto *Blend = new VPBlendRecipe(Phi, {DefI}, {});
VPBasicBlock *VPBB1 = Plan.getEntry();
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");