LCOV - code coverage report
Current view: top level - lib/Target/AMDGPU - AMDGPUAliasAnalysis.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 14 14 100.0 %
Date: 2017-09-14 15:23:50 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- AMDGPUAliasAnalysis --------------------------------------*- C++ -*-===//
       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             : /// \file
      10             : /// This is the AMGPU address space based alias analysis pass.
      11             : //===----------------------------------------------------------------------===//
      12             : 
      13             : #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
      14             : #define LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
      15             : 
      16             : #include "AMDGPU.h"
      17             : #include "llvm/ADT/Triple.h"
      18             : #include "llvm/Analysis/AliasAnalysis.h"
      19             : #include "llvm/IR/Function.h"
      20             : #include "llvm/IR/Module.h"
      21             : #include "llvm/Pass.h"
      22             : #include <algorithm>
      23             : #include <memory>
      24             : 
      25             : namespace llvm {
      26             : 
      27             : class DataLayout;
      28             : class MDNode;
      29             : class MemoryLocation;
      30             : 
      31             : /// A simple AA result that uses TBAA metadata to answer queries.
      32             : class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {
      33             :   friend AAResultBase<AMDGPUAAResult>;
      34             : 
      35             :   const DataLayout &DL;
      36             :   AMDGPUAS AS;
      37             : 
      38             : public:
      39        1752 :   explicit AMDGPUAAResult(const DataLayout &DL, Triple T) : AAResultBase(),
      40        3504 :     DL(DL), AS(AMDGPU::getAMDGPUAS(T)), ASAliasRules(AS, T.getArch()) {}
      41             :   AMDGPUAAResult(AMDGPUAAResult &&Arg)
      42             :       : AAResultBase(std::move(Arg)), DL(Arg.DL), AS(Arg.AS),
      43             :         ASAliasRules(Arg.ASAliasRules){}
      44             : 
      45             :   /// Handle invalidation events from the new pass manager.
      46             :   ///
      47             :   /// By definition, this result is stateless and so remains valid.
      48             :   bool invalidate(Function &, const PreservedAnalyses &) { return false; }
      49             : 
      50             :   AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
      51             :   bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
      52             : 
      53             : private:
      54             :   bool Aliases(const MDNode *A, const MDNode *B) const;
      55             :   bool PathAliases(const MDNode *A, const MDNode *B) const;
      56             : 
      57             :   class ASAliasRulesTy {
      58             :   public:
      59             :     ASAliasRulesTy(AMDGPUAS AS_, Triple::ArchType Arch_);
      60             : 
      61             :     AliasResult getAliasResult(unsigned AS1, unsigned AS2) const;
      62             : 
      63             :   private:
      64             :     Triple::ArchType Arch;
      65             :     AMDGPUAS AS;
      66             :     const AliasResult (*ASAliasRules)[6][6];
      67             :   } ASAliasRules;
      68             : };
      69             : 
      70             : /// Analysis pass providing a never-invalidated alias analysis result.
      71             : class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
      72             :   friend AnalysisInfoMixin<AMDGPUAA>;
      73             : 
      74             :   static char PassID;
      75             : 
      76             : public:
      77             :   using Result = AMDGPUAAResult;
      78             : 
      79             :   AMDGPUAAResult run(Function &F, AnalysisManager<Function> &AM) {
      80             :     return AMDGPUAAResult(F.getParent()->getDataLayout(),
      81             :         Triple(F.getParent()->getTargetTriple()));
      82             :   }
      83             : };
      84             : 
      85             : /// Legacy wrapper pass to provide the AMDGPUAAResult object.
      86        5259 : class AMDGPUAAWrapperPass : public ImmutablePass {
      87             :   std::unique_ptr<AMDGPUAAResult> Result;
      88             : 
      89             : public:
      90             :   static char ID;
      91             : 
      92        5283 :   AMDGPUAAWrapperPass() : ImmutablePass(ID) {
      93        1761 :     initializeAMDGPUAAWrapperPassPass(*PassRegistry::getPassRegistry());
      94        1761 :   }
      95             : 
      96      179440 :   AMDGPUAAResult &getResult() { return *Result; }
      97             :   const AMDGPUAAResult &getResult() const { return *Result; }
      98             : 
      99        1752 :   bool doInitialization(Module &M) override {
     100        3504 :     Result.reset(new AMDGPUAAResult(M.getDataLayout(),
     101        5256 :         Triple(M.getTargetTriple())));
     102        1752 :     return false;
     103             :   }
     104             : 
     105        1744 :   bool doFinalization(Module &M) override {
     106        3488 :     Result.reset();
     107        1744 :     return false;
     108             :   }
     109             : 
     110             :   void getAnalysisUsage(AnalysisUsage &AU) const override;
     111             : };
     112             : 
     113             : } // end namespace llvm
     114             : 
     115             : #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H

Generated by: LCOV version 1.13