[llvm] Attributor: Add noalias.addrspace attribute for store and load (PR #136553)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 21 08:58:28 PDT 2025
================
@@ -6336,6 +6336,46 @@ struct AAAddressSpace : public StateWrapper<BooleanState, AbstractAttribute> {
static const uint32_t InvalidAddressSpace = ~0U;
};
+/// An abstract interface for potential address space information.
+struct AANoAliasAddrSpace
+ : public StateWrapper<BitIntegerState<uint32_t>, AbstractAttribute> {
+ using Base = StateWrapper<BitIntegerState<uint32_t>, AbstractAttribute>;
+ AANoAliasAddrSpace(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
+
+ /// See AbstractAttribute::isValidIRPositionForInit
+ static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
+ if (!IRP.getAssociatedType()->isPtrOrPtrVectorTy())
+ return false;
+ return AbstractAttribute::isValidIRPositionForInit(A, IRP);
+ }
+
+ /// See AbstractAttribute::requiresCallersForArgOrFunction
+ static bool requiresCallersForArgOrFunction() { return true; }
+
+ /// Create an abstract attribute view for the position \p IRP.
+ static AANoAliasAddrSpace &createForPosition(const IRPosition &IRP,
+ Attributor &A);
+ /// See AbstractAttribute::getName()
+ const std::string getName() const override { return "AANoAliasAddrSpace"; }
+
+ /// See AbstractAttribute::getIdAddr()
+ const char *getIdAddr() const override { return &ID; }
+
+ /// This function should return true if the type of the \p AA is
+ /// AAAssumptionInfo
+ static bool classof(const AbstractAttribute *AA) {
+ return (AA->getIdAddr() == &ID);
+ }
+
+ void setMask(uint32_t mask) {
+ removeKnownBits(~mask);
+ removeAssumedBits(~mask);
+ }
----------------
shiltian wrote:
```suggestion
void setMask(uint32_t Mask) {
removeKnownBits(~Mask);
removeAssumedBits(~Mask);
}
```
https://github.com/llvm/llvm-project/pull/136553
More information about the llvm-commits
mailing list