LCOV - code coverage report
Current view: top level - lib/IR - Statepoint.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 30 33 90.9 %
Date: 2017-09-14 15:23:50 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- IR/Statepoint.cpp -- gc.statepoint utilities ---  -----------------===//
       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             : //
      10             : // This file contains some utility functions to help recognize gc.statepoint
      11             : // intrinsics.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/IR/Statepoint.h"
      16             : 
      17             : #include "llvm/IR/Function.h"
      18             : 
      19             : using namespace llvm;
      20             : 
      21             : static const Function *getCalledFunction(ImmutableCallSite CS) {
      22      652232 :   if (!CS.getInstruction())
      23             :     return nullptr;
      24             :   return CS.getCalledFunction();
      25             : }
      26             : 
      27      652232 : bool llvm::isStatepoint(ImmutableCallSite CS) {
      28      633107 :   if (auto *F = getCalledFunction(CS))
      29      633107 :     return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint;
      30             :   return false;
      31             : }
      32             : 
      33     3628543 : bool llvm::isStatepoint(const Value *V) {
      34     7257086 :   if (auto CS = ImmutableCallSite(V))
      35      652042 :     return isStatepoint(CS);
      36             :   return false;
      37             : }
      38             : 
      39     1958012 : bool llvm::isStatepoint(const Value &V) {
      40     1958012 :   return isStatepoint(&V);
      41             : }
      42             : 
      43        1626 : bool llvm::isGCRelocate(ImmutableCallSite CS) {
      44        4878 :   return CS.getInstruction() && isa<GCRelocateInst>(CS.getInstruction());
      45             : }
      46             : 
      47        1584 : bool llvm::isGCRelocate(const Value *V) {
      48        3168 :   if (auto CS = ImmutableCallSite(V))
      49        1584 :     return isGCRelocate(CS);
      50             :   return false;
      51             : }
      52             : 
      53          42 : bool llvm::isGCResult(ImmutableCallSite CS) {
      54         126 :   return CS.getInstruction() && isa<GCResultInst>(CS.getInstruction());
      55             : }
      56             : 
      57           0 : bool llvm::isGCResult(const Value *V) {
      58           0 :   if (auto CS = ImmutableCallSite(V))
      59           0 :     return isGCResult(CS);
      60             :   return false;
      61             : }
      62             : 
      63           5 : bool llvm::isStatepointDirectiveAttr(Attribute Attr) {
      64          14 :   return Attr.hasAttribute("statepoint-id") ||
      65          14 :          Attr.hasAttribute("statepoint-num-patch-bytes");
      66             : }
      67             : 
      68             : StatepointDirectives
      69         149 : llvm::parseStatepointDirectivesFromAttrs(AttributeList AS) {
      70         149 :   StatepointDirectives Result;
      71             : 
      72             :   Attribute AttrID =
      73         149 :       AS.getAttribute(AttributeList::FunctionIndex, "statepoint-id");
      74             :   uint64_t StatepointID;
      75         149 :   if (AttrID.isStringAttribute())
      76           2 :     if (!AttrID.getValueAsString().getAsInteger(10, StatepointID))
      77           1 :       Result.StatepointID = StatepointID;
      78             : 
      79             :   uint32_t NumPatchBytes;
      80             :   Attribute AttrNumPatchBytes = AS.getAttribute(AttributeList::FunctionIndex,
      81         149 :                                                 "statepoint-num-patch-bytes");
      82         149 :   if (AttrNumPatchBytes.isStringAttribute())
      83           2 :     if (!AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes))
      84           1 :       Result.NumPatchBytes = NumPatchBytes;
      85             : 
      86         149 :   return Result;
      87             : }

Generated by: LCOV version 1.13