Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
Line
Count
Source
1
//===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "AMDGPUMachineFunction.h"
10
#include "AMDGPUSubtarget.h"
11
#include "AMDGPUPerfHintAnalysis.h"
12
#include "llvm/CodeGen/MachineModuleInfo.h"
13
14
using namespace llvm;
15
16
AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
17
  MachineFunctionInfo(),
18
  LocalMemoryObjects(),
19
  ExplicitKernArgSize(0),
20
  MaxKernArgAlign(0),
21
  LDSSize(0),
22
  IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
23
  NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
24
  MemoryBound(false),
25
33.5k
  WaveLimiter(false) {
26
33.5k
  const AMDGPUSubtarget &ST = AMDGPUSubtarget::get(MF);
27
33.5k
28
33.5k
  // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
29
33.5k
  // except reserved size is not correctly aligned.
30
33.5k
  const Function &F = MF.getFunction();
31
33.5k
32
33.5k
  Attribute MemBoundAttr = F.getFnAttribute("amdgpu-memory-bound");
33
33.5k
  MemoryBound = MemBoundAttr.isStringAttribute() &&
34
33.5k
                
MemBoundAttr.getValueAsString() == "true"842
;
35
33.5k
36
33.5k
  Attribute WaveLimitAttr = F.getFnAttribute("amdgpu-wave-limiter");
37
33.5k
  WaveLimiter = WaveLimitAttr.isStringAttribute() &&
38
33.5k
                
WaveLimitAttr.getValueAsString() == "true"15.1k
;
39
33.5k
40
33.5k
  CallingConv::ID CC = F.getCallingConv();
41
33.5k
  if (CC == CallingConv::AMDGPU_KERNEL || 
CC == CallingConv::SPIR_KERNEL10.8k
)
42
22.7k
    ExplicitKernArgSize = ST.getExplicitKernArgSize(F, MaxKernArgAlign);
43
33.5k
}
44
45
unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,
46
236
                                                  const GlobalValue &GV) {
47
236
  auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
48
236
  if (!Entry.second)
49
6
    return Entry.first->second;
50
230
51
230
  unsigned Align = GV.getAlignment();
52
230
  if (Align == 0)
53
73
    Align = DL.getABITypeAlignment(GV.getValueType());
54
230
55
230
  /// TODO: We should sort these to minimize wasted space due to alignment
56
230
  /// padding. Currently the padding is decided by the first encountered use
57
230
  /// during lowering.
58
230
  unsigned Offset = LDSSize = alignTo(LDSSize, Align);
59
230
60
230
  Entry.first->second = Offset;
61
230
  LDSSize += DL.getTypeAllocSize(GV.getValueType());
62
230
63
230
  return Offset;
64
230
}