Skip to content

[NFC][Attributor] Use unsigned integer for address space tracking #108447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading