Skip to content

Commit 4808842

Browse files
authored
[NFC][Attributor] Use unsigned integer for address space tracking (#108447)
1 parent 71cb781 commit 4808842

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6249,7 +6249,7 @@ struct AAAddressSpace : public StateWrapper<BooleanState, AbstractAttribute> {
62496249
/// Return the address space of the associated value. \p NoAddressSpace is
62506250
/// returned if the associated value is dead. This functions is not supposed
62516251
/// to be called if the AA is invalid.
6252-
virtual int32_t getAddressSpace() const = 0;
6252+
virtual uint32_t getAddressSpace() const = 0;
62536253

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

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

62736273
/// Unique ID (due to the unique address)
62746274
static const char ID;

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12562,7 +12562,7 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
1256212562
AAAddressSpaceImpl(const IRPosition &IRP, Attributor &A)
1256312563
: AAAddressSpace(IRP, A) {}
1256412564

12565-
int32_t getAddressSpace() const override {
12565+
uint32_t getAddressSpace() const override {
1256612566
assert(isValidState() && "the AA is invalid");
1256712567
return AssumedAddressSpace;
1256812568
}
@@ -12576,7 +12576,7 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
1257612576
}
1257712577

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

1260412603
PointerType *NewPtrTy =
12605-
PointerType::get(getAssociatedType()->getContext(),
12606-
static_cast<uint32_t>(getAddressSpace()));
12604+
PointerType::get(getAssociatedType()->getContext(), getAddressSpace());
1260712605
bool UseOriginalValue =
12608-
OriginalValue->getType()->getPointerAddressSpace() ==
12609-
static_cast<uint32_t>(getAddressSpace());
12606+
OriginalValue->getType()->getPointerAddressSpace() == getAddressSpace();
1261012607

1261112608
bool Changed = false;
1261212609

@@ -12656,9 +12653,9 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
1265612653
}
1265712654

1265812655
private:
12659-
int32_t AssumedAddressSpace = NoAddressSpace;
12656+
uint32_t AssumedAddressSpace = NoAddressSpace;
1266012657

12661-
bool takeAddressSpace(int32_t AS) {
12658+
bool takeAddressSpace(uint32_t AS) {
1266212659
if (AssumedAddressSpace == NoAddressSpace) {
1266312660
AssumedAddressSpace = AS;
1266412661
return true;

0 commit comments

Comments
 (0)