Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7724,7 +7724,7 @@ bool AMDGPULegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
case Intrinsic::amdgcn_make_buffer_rsrc:
return legalizePointerAsRsrcIntrin(MI, MRI, B);
case Intrinsic::amdgcn_kernarg_segment_ptr:
if (!AMDGPU::isKernel(B.getMF().getFunction().getCallingConv())) {
if (!AMDGPU::isKernel(B.getMF().getFunction())) {
// This only makes sense to call in a kernel, so just lower to null.
B.buildConstant(MI.getOperand(0).getReg(), 0);
MI.eraseFromParent();
Expand Down
28 changes: 14 additions & 14 deletions llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class AMDGPULowerModuleLDS {
return KernelSet;

for (Function &Func : M.functions()) {
if (Func.isDeclaration() || !isKernelLDS(&Func))
if (Func.isDeclaration() || !isKernel(Func))
continue;
for (GlobalVariable *GV : LDSUsesInfo.indirect_access[&Func]) {
if (VariableSet.contains(GV)) {
Expand Down Expand Up @@ -555,7 +555,7 @@ class AMDGPULowerModuleLDS {
for (Function &Func : M->functions()) {
if (Func.isDeclaration())
continue;
if (!isKernelLDS(&Func))
if (!isKernel(Func))
continue;

if (KernelsThatAllocateTableLDS.contains(&Func) ||
Expand Down Expand Up @@ -703,15 +703,15 @@ class AMDGPULowerModuleLDS {
return false;
}
Function *F = I->getFunction();
return !isKernelLDS(F);
return !isKernel(*F);
});

// Replace uses of module scope variable from kernel functions that
// allocate the module scope variable, otherwise leave them unchanged
// Record on each kernel whether the module scope global is used by it

for (Function &Func : M.functions()) {
if (Func.isDeclaration() || !isKernelLDS(&Func))
if (Func.isDeclaration() || !isKernel(Func))
continue;

if (KernelsThatAllocateModuleLDS.contains(&Func)) {
Expand Down Expand Up @@ -743,7 +743,7 @@ class AMDGPULowerModuleLDS {

DenseMap<Function *, LDSVariableReplacement> KernelToReplacement;
for (Function &Func : M.functions()) {
if (Func.isDeclaration() || !isKernelLDS(&Func))
if (Func.isDeclaration() || !isKernel(Func))
continue;

DenseSet<GlobalVariable *> KernelUsedVariables;
Expand Down Expand Up @@ -828,7 +828,7 @@ class AMDGPULowerModuleLDS {
// semantics. Setting the alignment here allows this IR pass to accurately
// predict the exact constant at which it will be allocated.

assert(isKernelLDS(func));
assert(isKernel(*func));

LLVMContext &Ctx = M.getContext();
const DataLayout &DL = M.getDataLayout();
Expand Down Expand Up @@ -878,7 +878,7 @@ class AMDGPULowerModuleLDS {
for (auto &func : OrderedKernels) {

if (KernelsThatIndirectlyAllocateDynamicLDS.contains(func)) {
assert(isKernelLDS(func));
assert(isKernel(*func));
if (!func->hasName()) {
reportFatalUsageError("anonymous kernels cannot use LDS variables");
}
Expand Down Expand Up @@ -912,7 +912,7 @@ class AMDGPULowerModuleLDS {
auto *I = dyn_cast<Instruction>(U.getUser());
if (!I)
continue;
if (isKernelLDS(I->getFunction()))
if (isKernel(*I->getFunction()))
continue;

replaceUseWithTableLookup(M, Builder, table, GV, U, nullptr);
Expand All @@ -928,7 +928,7 @@ class AMDGPULowerModuleLDS {
for (Use &U : GV->uses()) {
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
Function *F = I->getFunction();
if (isKernelLDS(F) && F != KF) {
if (isKernel(*F) && F != KF) {
NeedsReplacement = true;
break;
}
Expand All @@ -945,7 +945,7 @@ class AMDGPULowerModuleLDS {
for (Use &U : make_early_inc_range(GV->uses())) {
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
Function *F = I->getFunction();
if (!isKernelLDS(F) || F == KF) {
if (!isKernel(*F) || F == KF) {
U.getUser()->replaceUsesOfWith(GV, NewGV);
}
}
Expand Down Expand Up @@ -997,7 +997,7 @@ class AMDGPULowerModuleLDS {
std::vector<Function *> OrderedKernels;
for (auto &K : LDSUsesInfo.direct_access) {
Function *F = K.first;
assert(isKernelLDS(F));
assert(isKernel(*F));
OrderedKernels.push_back(F);
}
OrderedKernels = sortByName(std::move(OrderedKernels));
Expand Down Expand Up @@ -1033,7 +1033,7 @@ class AMDGPULowerModuleLDS {
}
// Also erase those special LDS variables from indirect_access.
for (auto &K : LDSUsesInfo.indirect_access) {
assert(isKernelLDS(K.first));
assert(isKernel(*K.first));
for (GlobalVariable *GV : K.second) {
if (isNamedBarrier(*GV))
K.second.erase(GV);
Expand All @@ -1058,7 +1058,7 @@ class AMDGPULowerModuleLDS {
VariableFunctionMap LDSToKernelsThatNeedToAccessItIndirectly;
for (auto &K : LDSUsesInfo.indirect_access) {
Function *F = K.first;
assert(isKernelLDS(F));
assert(isKernel(*F));
for (GlobalVariable *GV : K.second) {
LDSToKernelsThatNeedToAccessItIndirectly[GV].insert(F);
}
Expand Down Expand Up @@ -1157,7 +1157,7 @@ class AMDGPULowerModuleLDS {
const DataLayout &DL = M.getDataLayout();

for (Function &Func : M.functions()) {
if (Func.isDeclaration() || !isKernelLDS(&Func))
if (Func.isDeclaration() || !isKernel(Func))
continue;

// All three of these are optional. The first variable is allocated at
Expand Down
16 changes: 6 additions & 10 deletions llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
for (User *V : GV.users()) {
if (auto *I = dyn_cast<Instruction>(V)) {
Function *F = I->getFunction();
if (isKernelLDS(F))
if (isKernel(*F))
kernels[F].insert(&GV);
else
Functions[F].insert(&GV);
Expand All @@ -135,10 +135,6 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
}
}

bool isKernelLDS(const Function *F) {
return AMDGPU::isKernel(F->getCallingConv());
}

LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {

FunctionVariableMap DirectMapKernel;
Expand All @@ -148,7 +144,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
// Collect functions whose address has escaped
DenseSet<Function *> AddressTakenFuncs;
for (Function &F : M.functions()) {
if (!isKernelLDS(&F))
if (!isKernel(F))
if (F.hasAddressTaken(nullptr,
/* IgnoreCallbackUses */ false,
/* IgnoreAssumeLikeCalls */ false,
Expand Down Expand Up @@ -180,7 +176,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
// access all variables accessed by functions whose address escaped
for (Function &F : M.functions()) {
if (!F.isDeclaration() && FunctionMakesUnknownCall(&F)) {
if (!isKernelLDS(&F)) {
if (!isKernel(F)) {
set_union(TransitiveMapFunction[&F],
VariablesReachableThroughFunctionPointer);
}
Expand All @@ -190,7 +186,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
// Direct implementation of collecting all variables reachable from each
// function
for (Function &Func : M.functions()) {
if (Func.isDeclaration() || isKernelLDS(&Func))
if (Func.isDeclaration() || isKernel(Func))
continue;

DenseSet<Function *> seen; // catches cycles
Expand Down Expand Up @@ -227,7 +223,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
FunctionVariableMap IndirectMapKernel;

for (Function &Func : M.functions()) {
if (Func.isDeclaration() || !isKernelLDS(&Func))
if (Func.isDeclaration() || !isKernel(Func))
continue;

for (const CallGraphNode::CallRecord &R : *CG[&Func]) {
Expand Down Expand Up @@ -335,7 +331,7 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
Function *PotentialCallee =
ExternalCallRecord.second->getFunction();
assert(PotentialCallee);
if (!isKernelLDS(PotentialCallee)) {
if (!isKernel(*PotentialCallee)) {
for (StringRef Attr : FnAttrs)
PotentialCallee->removeFnAttr(Attr);
}
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
FunctionVariableMap &kernels,
FunctionVariableMap &functions);

bool isKernelLDS(const Function *F);

LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M);

/// Strip FnAttr attribute from any functions where we may have
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ bool AMDGPUSubtarget::makeLIDRangeMetadata(Instruction *I) const {
}

unsigned AMDGPUSubtarget::getImplicitArgNumBytes(const Function &F) const {
assert(AMDGPU::isKernel(F.getCallingConv()));
assert(AMDGPU::isKernel(F));

// We don't allocate the segment if we know the implicit arguments weren't
// used, even if the ABI implies we need them.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void AMDGPUSwLowerLDS::getNonKernelsWithLDSArguments(const CallGraph &CG) {
Function *CalledFunc = CallerCGN->getFunction();
if (!CalledFunc || CalledFunc->isDeclaration())
continue;
if (AMDGPU::isKernelLDS(CalledFunc))
if (AMDGPU::isKernel(*CalledFunc))
continue;
for (auto AI = CalledFunc->arg_begin(), E = CalledFunc->arg_end();
AI != E; ++AI) {
Expand All @@ -297,7 +297,7 @@ void AMDGPUSwLowerLDS::getUsesOfLDSByNonKernels() {
for (User *V : GV->users()) {
if (auto *I = dyn_cast<Instruction>(V)) {
Function *F = I->getFunction();
if (!isKernelLDS(F) && !F->isDeclaration())
if (!isKernel(*F) && !F->isDeclaration())
FuncLDSAccessInfo.NonKernelToLDSAccessMap[F].insert(GV);
}
}
Expand Down Expand Up @@ -1169,7 +1169,7 @@ bool AMDGPUSwLowerLDS::run() {
if (!F || K.second.empty())
continue;

assert(isKernelLDS(F));
assert(isKernel(*F));

// Only inserts if key isn't already in the map.
FuncLDSAccessInfo.KernelToLDSParametersMap.insert(
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9737,7 +9737,7 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
AMDGPUFunctionArgInfo::IMPLICIT_ARG_PTR);
}
case Intrinsic::amdgcn_kernarg_segment_ptr: {
if (!AMDGPU::isKernel(MF.getFunction().getCallingConv())) {
if (!AMDGPU::isKernel(MF.getFunction())) {
// This only makes sense to call in a kernel, so just lower to null.
return DAG.getConstant(0, DL, VT);
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,8 @@ constexpr inline bool isKernel(CallingConv::ID CC) {
}
}

inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }

LLVM_READNONE
constexpr bool canGuaranteeTCO(CallingConv::ID CC) {
return CC == CallingConv::Fast;
Expand Down