Skip to content

Commit

Permalink
[NFC][Attributor] Use unsigned integer for address space tracking (ll…
Browse files Browse the repository at this point in the history
  • Loading branch information
shiltian authored Sep 12, 2024
1 parent 71cb781 commit 4808842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/Transforms/IPO/Attributor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6249,7 +6249,7 @@ struct AAAddressSpace : public StateWrapper<BooleanState, AbstractAttribute> {
/// Return the address space of the associated value. \p NoAddressSpace is
/// returned if the associated value is dead. This functions is not supposed
/// to be called if the AA is invalid.
virtual int32_t getAddressSpace() const = 0;
virtual uint32_t getAddressSpace() const = 0;

/// Create an abstract attribute view for the position \p IRP.
static AAAddressSpace &createForPosition(const IRPosition &IRP,
Expand All @@ -6268,7 +6268,7 @@ struct AAAddressSpace : public StateWrapper<BooleanState, AbstractAttribute> {
}

// No address space which indicates the associated value is dead.
static const int32_t NoAddressSpace = -1;
static const uint32_t NoAddressSpace = ~0U;

/// Unique ID (due to the unique address)
static const char ID;
Expand Down
17 changes: 7 additions & 10 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12562,7 +12562,7 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
AAAddressSpaceImpl(const IRPosition &IRP, Attributor &A)
: AAAddressSpace(IRP, A) {}

int32_t getAddressSpace() const override {
uint32_t getAddressSpace() const override {
assert(isValidState() && "the AA is invalid");
return AssumedAddressSpace;
}
Expand All @@ -12576,7 +12576,7 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
}

ChangeStatus updateImpl(Attributor &A) override {
int32_t OldAddressSpace = AssumedAddressSpace;
uint32_t OldAddressSpace = AssumedAddressSpace;
auto *AUO = A.getOrCreateAAFor<AAUnderlyingObjects>(getIRPosition(), this,
DepClassTy::REQUIRED);
auto Pred = [&](Value &Obj) {
Expand All @@ -12597,16 +12597,13 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
Value *AssociatedValue = &getAssociatedValue();
Value *OriginalValue = peelAddrspacecast(AssociatedValue);
if (getAddressSpace() == NoAddressSpace ||
static_cast<uint32_t>(getAddressSpace()) ==
getAssociatedType()->getPointerAddressSpace())
getAddressSpace() == getAssociatedType()->getPointerAddressSpace())
return ChangeStatus::UNCHANGED;

PointerType *NewPtrTy =
PointerType::get(getAssociatedType()->getContext(),
static_cast<uint32_t>(getAddressSpace()));
PointerType::get(getAssociatedType()->getContext(), getAddressSpace());
bool UseOriginalValue =
OriginalValue->getType()->getPointerAddressSpace() ==
static_cast<uint32_t>(getAddressSpace());
OriginalValue->getType()->getPointerAddressSpace() == getAddressSpace();

bool Changed = false;

Expand Down Expand Up @@ -12656,9 +12653,9 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
}

private:
int32_t AssumedAddressSpace = NoAddressSpace;
uint32_t AssumedAddressSpace = NoAddressSpace;

bool takeAddressSpace(int32_t AS) {
bool takeAddressSpace(uint32_t AS) {
if (AssumedAddressSpace == NoAddressSpace) {
AssumedAddressSpace = AS;
return true;
Expand Down

0 comments on commit 4808842

Please sign in to comment.