1 //===--- GlobalsModRefTest.cpp - Mixed TBAA unit tests --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Analysis/GlobalsModRef.h"
11 #include "llvm/AsmParser/Parser.h"
12 #include "llvm/Support/SourceMgr.h"
13 #include "gtest/gtest.h"
17 TEST(GlobalsModRef
, OptNone
) {
18 StringRef Assembly
= R
"(
19 define void @f1() optnone {
22 define void @f2() optnone readnone {
25 define void @f3() optnone readonly {
32 auto M
= parseAssemblyString(Assembly
, Error
, Context
);
33 ASSERT_TRUE(M
) << "Bad assembly?";
35 const auto &funcs
= M
->functions();
36 auto I
= funcs
.begin();
37 ASSERT_NE(I
, funcs
.end());
38 const Function
&F1
= *I
;
39 ASSERT_NE(++I
, funcs
.end());
40 const Function
&F2
= *I
;
41 ASSERT_NE(++I
, funcs
.end());
42 const Function
&F3
= *I
;
43 EXPECT_EQ(++I
, funcs
.end());
45 Triple
Trip(M
->getTargetTriple());
46 TargetLibraryInfoImpl
TLII(Trip
);
47 TargetLibraryInfo
TLI(TLII
);
48 llvm::CallGraph
CG(*M
);
50 auto AAR
= GlobalsAAResult::analyzeModule(*M
, TLI
, CG
);
52 EXPECT_EQ(FMRB_UnknownModRefBehavior
, AAR
.getModRefBehavior(&F1
));
53 EXPECT_EQ(FMRB_DoesNotAccessMemory
, AAR
.getModRefBehavior(&F2
));
54 EXPECT_EQ(FMRB_OnlyReadsMemory
, AAR
.getModRefBehavior(&F3
));