blob: da8b44d273fb32c398a343db76e56c96af3f90a0 [file] [log] [blame]
David Blaikiec662b502017-06-06 20:51:15 +00001//===--- GlobalsModRefTest.cpp - Mixed TBAA unit tests --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/Analysis/GlobalsModRef.h"
11#include "llvm/AsmParser/Parser.h"
12#include "llvm/Support/SourceMgr.h"
13#include "gtest/gtest.h"
14
15using namespace llvm;
16
17TEST(GlobalsModRef, OptNone) {
18 StringRef Assembly = R"(
19 define void @f() optnone {
20 ret void
21 }
22 )";
23
24 LLVMContext Context;
25 SMDiagnostic Error;
26 auto M = parseAssemblyString(Assembly, Error, Context);
27 ASSERT_TRUE(M) << "Bad assembly?";
28
29 const auto &funcs = M->functions();
30 ASSERT_NE(funcs.begin(), funcs.end());
31 EXPECT_EQ(std::next(funcs.begin()), funcs.end());
32 const Function &F = *funcs.begin();
33
34 Triple Trip(M->getTargetTriple());
35 TargetLibraryInfoImpl TLII(Trip);
36 TargetLibraryInfo TLI(TLII);
37 llvm::CallGraph CG(*M);
38
39 auto AAR = GlobalsAAResult::analyzeModule(*M, TLI, CG);
40 EXPECT_EQ(FMRB_UnknownModRefBehavior, AAR.getModRefBehavior(&F));
41}