LCOV - code coverage report
Current view: top level - include/llvm/Analysis - CFLAliasAnalysisUtils.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 3 12 25.0 %
Date: 2018-10-20 13:21:21 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //=- CFLAliasAnalysisUtils.h - Utilities for CFL Alias Analysis ----*- 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             : // These are the utilities/helpers used by the CFL Alias Analyses available in
      11             : // tree, i.e. Steensgaard's and Andersens'.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_ANALYSIS_CFLALIASANALYSISUTILS_H
      16             : #define LLVM_ANALYSIS_CFLALIASANALYSISUTILS_H
      17             : 
      18             : #include "llvm/IR/Function.h"
      19             : #include "llvm/IR/ValueHandle.h"
      20             : 
      21             : namespace llvm {
      22             : namespace cflaa {
      23             : 
      24           0 : template <typename AAResult> struct FunctionHandle final : public CallbackVH {
      25           0 :   FunctionHandle(Function *Fn, AAResult *Result)
      26           0 :       : CallbackVH(Fn), Result(Result) {
      27             :     assert(Fn != nullptr);
      28             :     assert(Result != nullptr);
      29             :   }
      30             : 
      31           0 :   void deleted() override { removeSelfFromCache(); }
      32           0 :   void allUsesReplacedWith(Value *) override { removeSelfFromCache(); }
      33             : 
      34             : private:
      35             :   AAResult *Result;
      36             : 
      37           0 :   void removeSelfFromCache() {
      38             :     assert(Result != nullptr);
      39           0 :     auto *Val = getValPtr();
      40           0 :     Result->evict(cast<Function>(Val));
      41             :     setValPtr(nullptr);
      42           0 :   }
      43             : };
      44             : 
      45             : static inline const Function *parentFunctionOfValue(const Value *Val) {
      46             :   if (auto *Inst = dyn_cast<Instruction>(Val)) {
      47        2421 :     auto *Bb = Inst->getParent();
      48        2421 :     return Bb->getParent();
      49             :   }
      50             : 
      51             :   if (auto *Arg = dyn_cast<Argument>(Val))
      52        3784 :     return Arg->getParent();
      53             :   return nullptr;
      54             : } // namespace cflaa
      55             : } // namespace llvm
      56             : }
      57             : 
      58             : #endif // LLVM_ANALYSIS_CFLALIASANALYSISUTILS_H

Generated by: LCOV version 1.13