LCOV - code coverage report
Current view: top level - lib/Target/AMDGPU - AMDGPUMachineFunction.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 25 25 100.0 %
Date: 2018-10-20 13:21:21 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=//
       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             : #include "AMDGPUMachineFunction.h"
      11             : #include "AMDGPUSubtarget.h"
      12             : #include "AMDGPUPerfHintAnalysis.h"
      13             : #include "llvm/CodeGen/MachineModuleInfo.h"
      14             : 
      15             : using namespace llvm;
      16             : 
      17       22968 : AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
      18             :   MachineFunctionInfo(),
      19             :   LocalMemoryObjects(),
      20             :   ExplicitKernArgSize(0),
      21             :   MaxKernArgAlign(0),
      22             :   LDSSize(0),
      23       45936 :   IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
      24       22968 :   NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
      25             :   MemoryBound(false),
      26       22968 :   WaveLimiter(false) {
      27       22968 :   const AMDGPUSubtarget &ST = AMDGPUSubtarget::get(MF);
      28             : 
      29             :   // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
      30             :   // except reserved size is not correctly aligned.
      31       22968 :   const Function &F = MF.getFunction();
      32             : 
      33       22968 :   if (auto *Resolver = MF.getMMI().getResolver()) {
      34       22949 :     if (AMDGPUPerfHintAnalysis *PHA = static_cast<AMDGPUPerfHintAnalysis*>(
      35       22949 :           Resolver->getAnalysisIfAvailable(&AMDGPUPerfHintAnalysisID, true))) {
      36       21813 :       MemoryBound = PHA->isMemoryBound(&F);
      37       21813 :       WaveLimiter = PHA->needsWaveLimiter(&F);
      38             :     }
      39             :   }
      40             : 
      41             :   CallingConv::ID CC = F.getCallingConv();
      42       22968 :   if (CC == CallingConv::AMDGPU_KERNEL || CC == CallingConv::SPIR_KERNEL)
      43       18616 :     ExplicitKernArgSize = ST.getExplicitKernArgSize(F, MaxKernArgAlign);
      44       22968 : }
      45             : 
      46         447 : unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,
      47             :                                                   const GlobalValue &GV) {
      48         447 :   auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
      49         447 :   if (!Entry.second)
      50           7 :     return Entry.first->second;
      51             : 
      52         440 :   unsigned Align = GV.getAlignment();
      53         440 :   if (Align == 0)
      54          73 :     Align = DL.getABITypeAlignment(GV.getValueType());
      55             : 
      56             :   /// TODO: We should sort these to minimize wasted space due to alignment
      57             :   /// padding. Currently the padding is decided by the first encountered use
      58             :   /// during lowering.
      59         440 :   unsigned Offset = LDSSize = alignTo(LDSSize, Align);
      60             : 
      61         440 :   Entry.first->second = Offset;
      62         440 :   LDSSize += DL.getTypeAllocSize(GV.getValueType());
      63             : 
      64         440 :   return Offset;
      65             : }

Generated by: LCOV version 1.13