aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/Analysis
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-12-01 14:51:49 -0800
committerStephen Hines <srhines@google.com>2014-12-02 16:08:10 -0800
commit37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch)
tree8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /unittests/Analysis
parentd2327b22152ced7bc46dc629fc908959e8a52d03 (diff)
downloadexternal_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'unittests/Analysis')
-rw-r--r--unittests/Analysis/CFGTest.cpp10
-rw-r--r--unittests/Analysis/CMakeLists.txt2
-rw-r--r--unittests/Analysis/CallGraphTest.cpp59
-rw-r--r--unittests/Analysis/LazyCallGraphTest.cpp40
-rw-r--r--unittests/Analysis/Makefile2
-rw-r--r--unittests/Analysis/MixedTBAATest.cpp2
6 files changed, 86 insertions, 29 deletions
diff --git a/unittests/Analysis/CFGTest.cpp b/unittests/Analysis/CFGTest.cpp
index ac5e710..dba9d49 100644
--- a/unittests/Analysis/CFGTest.cpp
+++ b/unittests/Analysis/CFGTest.cpp
@@ -30,20 +30,16 @@ namespace {
class IsPotentiallyReachableTest : public testing::Test {
protected:
void ParseAssembly(const char *Assembly) {
- M.reset(new Module("Module", getGlobalContext()));
-
SMDiagnostic Error;
- bool Parsed = ParseAssemblyString(Assembly, M.get(),
- Error, M->getContext()) == M.get();
+ M = parseAssemblyString(Assembly, Error, getGlobalContext());
std::string errMsg;
raw_string_ostream os(errMsg);
Error.print("", os);
- if (!Parsed) {
- // A failure here means that the test itself is buggy.
+ // A failure here means that the test itself is buggy.
+ if (!M)
report_fatal_error(os.str().c_str());
- }
Function *F = M->getFunction("test");
if (F == nullptr)
diff --git a/unittests/Analysis/CMakeLists.txt b/unittests/Analysis/CMakeLists.txt
index 8454860..baf0c28 100644
--- a/unittests/Analysis/CMakeLists.txt
+++ b/unittests/Analysis/CMakeLists.txt
@@ -1,4 +1,5 @@
set(LLVM_LINK_COMPONENTS
+ IPA
Analysis
AsmParser
Core
@@ -6,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
)
add_llvm_unittest(AnalysisTests
+ CallGraphTest.cpp
CFGTest.cpp
LazyCallGraphTest.cpp
ScalarEvolutionTest.cpp
diff --git a/unittests/Analysis/CallGraphTest.cpp b/unittests/Analysis/CallGraphTest.cpp
new file mode 100644
index 0000000..777907a
--- /dev/null
+++ b/unittests/Analysis/CallGraphTest.cpp
@@ -0,0 +1,59 @@
+//=======- CallGraphTest.cpp - Unit tests for the CG analysis -------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/CallGraph.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+template <typename Ty> void canSpecializeGraphTraitsIterators(Ty *G) {
+ typedef typename GraphTraits<Ty *>::NodeType NodeTy;
+
+ auto I = GraphTraits<Ty *>::nodes_begin(G);
+ auto E = GraphTraits<Ty *>::nodes_end(G);
+ auto X = ++I;
+
+ // Should be able to iterate over all nodes of the graph.
+ static_assert(std::is_same<decltype(*I), NodeTy &>::value,
+ "Node type does not match");
+ static_assert(std::is_same<decltype(*X), NodeTy &>::value,
+ "Node type does not match");
+ static_assert(std::is_same<decltype(*E), NodeTy &>::value,
+ "Node type does not match");
+
+ NodeTy *N = GraphTraits<Ty *>::getEntryNode(G);
+
+ auto S = GraphTraits<NodeTy *>::child_begin(N);
+ auto F = GraphTraits<NodeTy *>::child_end(N);
+
+ // Should be able to iterate over immediate successors of a node.
+ static_assert(std::is_same<decltype(*S), NodeTy *>::value,
+ "Node type does not match");
+ static_assert(std::is_same<decltype(*F), NodeTy *>::value,
+ "Node type does not match");
+}
+
+TEST(CallGraphTest, GraphTraitsSpecialization) {
+ Module M("", getGlobalContext());
+ CallGraph CG(M);
+
+ canSpecializeGraphTraitsIterators(&CG);
+}
+
+TEST(CallGraphTest, GraphTraitsConstSpecialization) {
+ Module M("", getGlobalContext());
+ CallGraph CG(M);
+
+ canSpecializeGraphTraitsIterators(const_cast<const CallGraph *>(&CG));
+}
+}
diff --git a/unittests/Analysis/LazyCallGraphTest.cpp b/unittests/Analysis/LazyCallGraphTest.cpp
index d7c7045..6caccb8 100644
--- a/unittests/Analysis/LazyCallGraphTest.cpp
+++ b/unittests/Analysis/LazyCallGraphTest.cpp
@@ -22,38 +22,38 @@ using namespace llvm;
namespace {
std::unique_ptr<Module> parseAssembly(const char *Assembly) {
- auto M = make_unique<Module>("Module", getGlobalContext());
-
SMDiagnostic Error;
- bool Parsed =
- ParseAssemblyString(Assembly, M.get(), Error, M->getContext()) == M.get();
+ std::unique_ptr<Module> M =
+ parseAssemblyString(Assembly, Error, getGlobalContext());
std::string ErrMsg;
raw_string_ostream OS(ErrMsg);
Error.print("", OS);
// A failure here means that the test itself is buggy.
- if (!Parsed)
+ if (!M)
report_fatal_error(OS.str().c_str());
return M;
}
-// IR forming a call graph with a diamond of triangle-shaped SCCs:
-//
-// d1
-// / \
-// d3--d2
-// / \
-// b1 c1
-// / \ / \
-// b3--b2 c3--c2
-// \ /
-// a1
-// / \
-// a3--a2
-//
-// All call edges go up between SCCs, and clockwise around the SCC.
+/*
+ IR forming a call graph with a diamond of triangle-shaped SCCs:
+
+ d1
+ / \
+ d3--d2
+ / \
+ b1 c1
+ / \ / \
+ b3--b2 c3--c2
+ \ /
+ a1
+ / \
+ a3--a2
+
+ All call edges go up between SCCs, and clockwise around the SCC.
+ */
static const char DiamondOfTriangles[] =
"define void @a1() {\n"
"entry:\n"
diff --git a/unittests/Analysis/Makefile b/unittests/Analysis/Makefile
index 527f452..52296e7 100644
--- a/unittests/Analysis/Makefile
+++ b/unittests/Analysis/Makefile
@@ -9,7 +9,7 @@
LEVEL = ../..
TESTNAME = Analysis
-LINK_COMPONENTS := analysis asmparser
+LINK_COMPONENTS := ipa analysis asmparser
include $(LEVEL)/Makefile.config
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
diff --git a/unittests/Analysis/MixedTBAATest.cpp b/unittests/Analysis/MixedTBAATest.cpp
index 142e047..d7935e3 100644
--- a/unittests/Analysis/MixedTBAATest.cpp
+++ b/unittests/Analysis/MixedTBAATest.cpp
@@ -65,7 +65,7 @@ TEST_F(MixedTBAATest, MixedTBAA) {
// Run the TBAA eval pass on a mixture of path-aware and non-path-aware TBAA.
// The order of the metadata (path-aware vs non-path-aware) is important,
// because the AA eval pass only runs one test per store-pair.
- const char* args[] = { "MixedTBAATest", "-evaluate-tbaa" };
+ const char* args[] = { "MixedTBAATest", "-evaluate-aa-metadata" };
cl::ParseCommandLineOptions(sizeof(args) / sizeof(const char*), args);
PM.add(createTypeBasedAliasAnalysisPass());
PM.add(createAAEvalPass());