Skip to content

Commit 0ec30ae

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

File tree

89 files changed

+4094
-835
lines changed

Some content is hidden

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

89 files changed

+4094
-835
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp

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

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

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

710703
if (Callee->isIntrinsic())
711-
return true;
704+
return Callee->getIntrinsicID() != Intrinsic::amdgcn_addrspacecast_nonnull;
712705

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

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

llvm/test/CodeGen/AMDGPU/GlobalISel/atomicrmw_udec_wrap.ll

Lines changed: 340 additions & 28 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)