//===- DDGTest.cpp - DDGAnalysis unit tests -------------------------------===// // // 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/Analysis/DDG.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/AsmParser/Parser.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Module.h" #include "llvm/Support/SourceMgr.h" #include "gtest/gtest.h" usingnamespacellvm; /// Build the DDG analysis for a loop and run the given test \p Test. static void runTest(Module &M, StringRef FuncName, function_ref<void(Function &F, LoopInfo &LI, DependenceInfo &DI, ScalarEvolution &SE)> Test) { … } static std::unique_ptr<Module> makeLLVMModule(LLVMContext &Context, const char *ModuleStr) { … } TEST(DDGTest, getDependencies) { … } /// Test to make sure that when pi-blocks are formed, multiple edges of the same /// kind and direction are collapsed into a single edge. /// In the test below, %loadASubI belongs to an outside node, which has input /// dependency with multiple load instructions in the pi-block containing /// %loadBSubI. We expect a single memory dependence edge from the outside node /// to this pi-block. The pi-block also contains %add and %add7 both of which /// feed a phi in an outside node. We expect a single def-use edge from the /// pi-block to the node containing that phi. TEST(DDGTest, avoidDuplicateEdgesToFromPiBlocks) { … }