Skip to content

Commit 19543ee

Browse files
committed
Add not null assert when de-referencing access paths and fix some depreciated warnings
1 parent f1992d7 commit 19543ee

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6280,6 +6280,7 @@ struct AAPointerInfo : public AbstractAttribute {
62806280

62816281
// Merge two access paths into one.
62826282
void mergeAccessPaths(const AccessPathSetTy *AccessPathsNew) const {
6283+
assert(AccessPathsNew != nullptr && "Expected Access Paths to be non null!");
62836284
for (auto *Path : *AccessPathsNew)
62846285
if (!existsChain(Path))
62856286
AccessPaths->insert(Path);
@@ -6290,7 +6291,8 @@ struct AAPointerInfo : public AbstractAttribute {
62906291
bool IsSame = true;
62916292
if (AccessPaths->size() != AccessPathsR->size())
62926293
return false;
6293-
6294+
6295+
assert(AccessPathsR != nullptr && "Expected Access Paths to be non null!");
62946296
for (auto *Path : *AccessPathsR) {
62956297
if (!existsChain(Path))
62966298
IsSame = false;
@@ -6300,8 +6302,9 @@ struct AAPointerInfo : public AbstractAttribute {
63006302

63016303
// Check if the chain exists in the AccessPathsSet.
63026304
bool existsChain(const AccessPathTy *NewPath) const {
6305+
assert(NewPath != nullptr && AccessPaths != nullptr && "Expected Access Paths to be non null!");
63036306
for (auto *OldPath : *AccessPaths)
6304-
if (*OldPath == *NewPath)
6307+
if (OldPath && *OldPath == *NewPath)
63056308
return true;
63066309

63076310
return false;
@@ -6310,6 +6313,7 @@ struct AAPointerInfo : public AbstractAttribute {
63106313
void dumpAccessPaths(raw_ostream &O) const {
63116314
O << "Print all access paths found:"
63126315
<< "\n";
6316+
assert(AccessPaths != nullptr && "Expected Access Paths to be non null!");
63136317
for (auto *It : *AccessPaths) {
63146318
O << "Backtrack a unique access path:\n";
63156319
for (Value *Ins : *It) {

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13870,11 +13870,11 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1387013870
int64_t ShiftValue = OffsetNew - OffsetOld;
1387113871
Value *IndexList[1] = {ConstantInt::get(Int64TyInteger, ShiftValue)};
1387213872
Value *GepToNewAddress = GetElementPtrInst::Create(
13873-
PointeeTy, PointerOperand, IndexList, "NewGep", OldLoadInst);
13873+
PointeeTy, PointerOperand, IndexList, "NewGep", OldLoadInst->getIterator());
1387413874

1387513875
LoadInst *NewLoadInst = new LoadInst(
1387613876
OldLoadInst->getType(), GepToNewAddress, OldLoadInst->getName(),
13877-
false, OldLoadInst->getAlign(), OldLoadInst);
13877+
false, OldLoadInst->getAlign(), OldLoadInst->getIterator());
1387813878

1387913879
Changed |=
1388013880
A.changeAfterManifest(IRPosition::inst(*OldLoadInst), *NewLoadInst);
@@ -13893,11 +13893,11 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1389313893
Type *PointeeTy = OldStoreInst->getPointerOperandType();
1389413894
Value *IndexList[1] = {ConstantInt::get(Int64TyInteger, ShiftValue)};
1389513895
Value *GepToNewAddress = GetElementPtrInst::Create(
13896-
PointeeTy, PointerOperand, IndexList, "NewGep", OldStoreInst);
13896+
PointeeTy, PointerOperand, IndexList, "NewGep", OldStoreInst->getIterator());
1389713897

1389813898
StoreInst *NewStoreInst =
1389913899
new StoreInst(OldStoreInst->getValueOperand(), GepToNewAddress,
13900-
false, OldStoreInst->getAlign(), OldStoreInst);
13900+
false, OldStoreInst->getAlign(), OldStoreInst->getIterator());
1390113901

1390213902
Changed |= A.changeAfterManifest(IRPosition::inst(*OldStoreInst),
1390313903
*NewStoreInst);
@@ -13911,7 +13911,7 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1391113911
Value *IndexList[1] = {ConstantInt::get(Int64TyInteger, OffsetNew)};
1391213912
Value *OldPointerOperand = OldGEP->getPointerOperand();
1391313913
Value *GepToNewAddress = GetElementPtrInst::Create(
13914-
NewAllocationType, OldPointerOperand, IndexList, "NewGep", OldGEP);
13914+
NewAllocationType, OldPointerOperand, IndexList, "NewGep", OldGEP->getIterator());
1391513915

1391613916
Changed |=
1391713917
A.changeAfterManifest(IRPosition::inst(*OldGEP), *GepToNewAddress);

0 commit comments

Comments
 (0)