Skip to content

Commit ffc131e

Browse files
committed
(1) Use getCalledFunction instead of getCalledOperand (2) other
minor code change based on reviews (3) fix test files.
1 parent 27f0629 commit ffc131e

File tree

92 files changed

+4107
-833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+4107
-833
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -434,17 +434,11 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
434434
return;
435435
}
436436

437-
bool HasAllocaOrASCast = false;
438-
for (BasicBlock &BB : *F) {
439-
for (Instruction &I : BB) {
440-
if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
441-
HasAllocaOrASCast = true;
442-
removeAssumedBits(FLAT_SCRATCH_INIT);
443-
break;
444-
}
437+
for (Instruction &I : instructions(F)) {
438+
if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
439+
removeAssumedBits(FLAT_SCRATCH_INIT);
440+
return;
445441
}
446-
if (HasAllocaOrASCast)
447-
break;
448442
}
449443
}
450444

@@ -701,13 +695,12 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
701695
// no-flat-scratch-init.
702696
auto CheckForNoFlatScratchInit = [&](Instruction &I) {
703697
const auto &CB = cast<CallBase>(I);
704-
const Value *CalleeOp = CB.getCalledOperand();
705-
const Function *Callee = dyn_cast<Function>(CalleeOp);
698+
const Function *Callee = CB.getCalledFunction();
706699
if (!Callee) // indirect call
707700
return CB.isInlineAsm();
708701

709702
if (Callee->isIntrinsic())
710-
return true;
703+
return Callee->getIntrinsicID() != Intrinsic::amdgcn_addrspacecast_nonnull;
711704

712705
const auto *CalleeInfo = A.getAAFor<AAAMDAttributes>(
713706
*this, IRPosition::function(*Callee), DepClassTy::REQUIRED);
@@ -716,7 +709,8 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
716709

717710
bool UsedAssumedInformation = false;
718711
// If any callee is false (i.e. need FlatScratchInit),
719-
// checkForAllCallLikeInstructions returns false
712+
// checkForAllCallLikeInstructions returns false, in which case this
713+
// function returns true.
720714
return !A.checkForAllCallLikeInstructions(CheckForNoFlatScratchInit, *this,
721715
UsedAssumedInformation);
722716
}

llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,6 @@ GCNUserSGPRUsageInfo::GCNUserSGPRUsageInfo(const Function &F,
10541054
const CallingConv::ID CC = F.getCallingConv();
10551055
const bool IsKernel =
10561056
CC == CallingConv::AMDGPU_KERNEL || CC == CallingConv::SPIR_KERNEL;
1057-
const bool NoFlatScratchInit =
1058-
F.hasFnAttribute("amdgpu-no-flat-scratch-init");
10591057

10601058
if (IsKernel && (!F.arg_empty() || ST.getImplicitArgNumBytes(F) != 0))
10611059
KernargSegmentPtr = true;
@@ -1078,6 +1076,8 @@ GCNUserSGPRUsageInfo::GCNUserSGPRUsageInfo(const Function &F,
10781076
DispatchID = true;
10791077
}
10801078

1079+
const bool NoFlatScratchInit =
1080+
F.hasFnAttribute("amdgpu-no-flat-scratch-init");
10811081
// TODO: This could be refined a lot. The attribute is a poor way of
10821082
// detecting calls or stack objects that may require it before argument
10831083
// lowering.

0 commit comments

Comments
 (0)