================
@@ -683,6 +698,65 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
return !A.checkForAllCallLikeInstructions(DoesNotRetrieve, *this,
UsedAssumedInformation);
}
+
+ // Returns true if FlatScratchInit is needed, i.e., no-flat-scratch-init is
+ // not to be set.
+ bool needFlatScratchInit(Attributor &A) {
+ assert(isAssumed(FLAT_SCRATCH_INIT)); // only called if the bit is still
set
+
+ // Check all AddrSpaceCast instructions. FlatScratchInit is needed if
+ // there is a cast from PRIVATE_ADDRESS.
+ auto AddrSpaceCastNotFromPrivate = [](Instruction &I) {
+ return cast<AddrSpaceCastInst>(I).getSrcAddressSpace() !=
+ AMDGPUAS::PRIVATE_ADDRESS;
+ };
+
+ bool UsedAssumedInformation = false;
+ if (!A.checkForAllInstructions(AddrSpaceCastNotFromPrivate, *this,
+ {Instruction::AddrSpaceCast},
+ UsedAssumedInformation))
+ return true;
+
+ // Check for addrSpaceCast from PRIVATE_ADDRESS in constant expressions
+ auto &InfoCache = static_cast<AMDGPUInformationCache &>(A.getInfoCache());
+
+ Function *F = getAssociatedFunction();
----------------
shiltian wrote:
Is it possible to merge this into `AddrSpaceCastNotFromPrivate`?
https://github.com/llvm/llvm-project/pull/94647
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits