//===- BasicAliasAnalysisTest.cpp - Unit tests for BasicAA ----------------===// // // 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 // //===----------------------------------------------------------------------===// // // Targeted tests that are hard/convoluted to make happen with just `opt`. // #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/AsmParser/Parser.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Support/SourceMgr.h" #include "gtest/gtest.h" usingnamespacellvm; // FIXME: This is duplicated between this file and MemorySSATest. Refactor. const static char DLString[] = …; /// There's a lot of common setup between these tests. This fixture helps reduce /// that. Tests should mock up a function, store it in F, and then call /// setupAnalyses(). class BasicAATest : public testing::Test { … }; // Check that a function arg can't trivially alias a global when we're accessing // >sizeof(global) bytes through that arg, unless the access size is just an // upper-bound. TEST_F(BasicAATest, AliasInstWithObjectOfImpreciseSize) { … } // Check that we fall back to MayAlias if we see an access of an entire object // that's just an upper-bound. TEST_F(BasicAATest, AliasInstWithFullObjectOfImpreciseSize) { … } TEST_F(BasicAATest, PartialAliasOffsetPhi) { … } TEST_F(BasicAATest, PartialAliasOffsetSelect) { … }