Skip to content

Commit f1992d7

Browse files
committed
rebase and fix build errors
1 parent cd05702 commit f1992d7

File tree

12 files changed

+207
-158
lines changed

12 files changed

+207
-158
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,13 +1140,14 @@ struct AAPointerInfoImpl
11401140
(isValidState() ? (std::string("#") +
11411141
std::to_string(OffsetBins.size()) + " bins")
11421142
: "<invalid>") +
1143-
(reachesReturn()
1144-
? (" (returned:" +
1145-
join(map_range(ReturnedOffsets,
1146-
[](int64_t O) { return std::to_string(O); }),
1147-
", ") +
1148-
")")
1149-
: "");
1143+
(reachesReturn() ? (" (returned:" +
1144+
join(map_range(ReturnedOffsets,
1145+
[](const AA::RangeTy &R) {
1146+
return std::to_string(R.Offset);
1147+
}),
1148+
", ") +
1149+
")")
1150+
: "");
11501151
}
11511152

11521153
/// See AbstractAttribute::manifest(...).
@@ -1164,14 +1165,14 @@ struct AAPointerInfoImpl
11641165
}
11651166
virtual void addReturnedOffsetsTo(OffsetInfo &OI) const override {
11661167
if (ReturnedOffsets.isUnknown()) {
1167-
OI.setUnknown();
1168+
OI.setUnknown(getAssociatedValue());
11681169
return;
11691170
}
11701171

11711172
OffsetInfo MergedOI;
1172-
for (auto Offset : ReturnedOffsets) {
1173+
for (const AA::RangeTy &OffsetRange : ReturnedOffsets) {
11731174
OffsetInfo TmpOI = OI;
1174-
TmpOI.addToAll(Offset);
1175+
TmpOI.addToAll(OffsetRange.Offset);
11751176
MergedOI.merge(TmpOI);
11761177
}
11771178
OI = std::move(MergedOI);
@@ -1181,11 +1182,15 @@ struct AAPointerInfoImpl
11811182
if (ReturnedOffsets.isUnknown())
11821183
return ChangeStatus::UNCHANGED;
11831184
if (ReachedReturnedOffsets.isUnknown()) {
1184-
ReturnedOffsets.setUnknown();
1185+
ReturnedOffsets.setUnknown(getAssociatedValue());
11851186
return ChangeStatus::CHANGED;
11861187
}
1187-
if (ReturnedOffsets.merge(ReachedReturnedOffsets))
1188+
1189+
auto OldReturned = ReturnedOffsets;
1190+
ReturnedOffsets.merge(ReachedReturnedOffsets);
1191+
if (ReturnedOffsets != OldReturned)
11881192
return ChangeStatus::CHANGED;
1193+
11891194
return ChangeStatus::UNCHANGED;
11901195
}
11911196

@@ -1539,8 +1544,9 @@ struct AAPointerInfoImpl
15391544
AccessKind AK = RAcc.getKind();
15401545
if (!IsMustAcc)
15411546
AK = AccessKind((AK & ~AK_MUST) | AK_MAY);
1542-
Changed |= addAccess(A, NewRanges, CB, RAcc.getContent(), AK,
1543-
RAcc.getType(), OffsetInfoMap, RAcc.getRemoteInst());
1547+
Changed |=
1548+
addAccess(A, NewRanges, CB, RAcc.getContent(), AK, RAcc.getType(),
1549+
OffsetInfoMap, RAcc.getRemoteInst());
15441550
}
15451551
}
15461552
}
@@ -13595,7 +13601,8 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1359513601

1359613602
// Set the new size of the allocation. The new size of the Allocation should
1359713603
// be the size of PrevBinEndOffset * 8 in bits.
13598-
auto NewAllocationSize = std::make_optional<TypeSize>(PrevBinEndOffset * 8, false);
13604+
auto NewAllocationSize =
13605+
std::make_optional<TypeSize>(PrevBinEndOffset * 8, false);
1359913606

1360013607
if (!changeAllocationSize(NewAllocationSize))
1360113608
return ChangeStatus::UNCHANGED;
@@ -13643,7 +13650,7 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1364313650
Instruction *LocalInst, const AA::RangeTy &OldRange,
1364413651
const AA::RangeTy &NewRange) {
1364513652
DenseMap<AA::RangeTy, AA::RangeTy> &NewBinsForInstruction =
13646-
Map.getOrInsertDefault(LocalInst);
13653+
Map.try_emplace(LocalInst).first->second;
1364713654

1364813655
NewBinsForInstruction.insert(std::make_pair(OldRange, NewRange));
1364913656
};
@@ -13975,7 +13982,8 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
1397513982
if (OldOffset == NewComputedOffset)
1397613983
return false;
1397713984

13978-
AA::RangeTy &NewRange = NewComputedOffsets.getOrInsertDefault(OldRange);
13985+
AA::RangeTy &NewRange =
13986+
NewComputedOffsets.try_emplace(OldRange).first->second;
1397913987
NewRange.Offset = NewComputedOffset;
1398013988
NewRange.Size = Size;
1398113989

llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ define internal i32 @caller(ptr %B) {
5252
;
5353
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
5454
; CGSCC-LABEL: define {{[^@]+}}@caller
55-
; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
55+
; CGSCC-SAME: (ptr noalias nofree noundef nonnull writeonly align 4 captures(none) dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
5656
; CGSCC-NEXT: [[A1:%.*]] = alloca [0 x i8], align 1
57-
; CGSCC-NEXT: [[C:%.*]] = call i32 @test(ptr noalias nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[B]]) #[[ATTR2:[0-9]+]]
57+
; CGSCC-NEXT: [[C:%.*]] = call i32 @test(ptr noalias nofree noundef nonnull writeonly align 4 captures(none) dereferenceable(4) [[B]]) #[[ATTR2:[0-9]+]]
5858
; CGSCC-NEXT: ret i32 0
5959
;
6060
%A = alloca i32

llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3434
define dso_local i32 @main() {
3535
; TUNIT-LABEL: define {{[^@]+}}@main() {
3636
; TUNIT-NEXT: entry:
37-
; TUNIT-NEXT: [[ALLOC11:%.*]] = alloca [0 x i8], align 1
38-
; TUNIT-NEXT: [[ALLOC22:%.*]] = alloca [0 x i8], align 1
37+
; TUNIT-NEXT: [[ALLOC1:%.*]] = alloca i8, align 8
38+
; TUNIT-NEXT: [[ALLOC2:%.*]] = alloca i8, align 8
3939
; TUNIT-NEXT: [[THREAD:%.*]] = alloca i64, align 8
4040
; TUNIT-NEXT: [[CALL:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef null, ptr noundef nonnull @foo, ptr nofree readnone undef)
4141
; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @pthread_create(ptr noundef nonnull align 8 dereferenceable(8) [[THREAD]], ptr noundef null, ptr noundef nonnull @bar, ptr noalias nofree nonnull readnone align 8 captures(none) dereferenceable(8) undef)

llvm/test/Transforms/Attributor/IPConstantProp/return-argument.ll

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44

55
;; This function returns its second argument on all return statements
66
define internal ptr @incdec(i1 %C, ptr %V) {
7-
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
7+
; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn
88
; TUNIT-LABEL: define {{[^@]+}}@incdec
9-
; TUNIT-SAME: (i1 noundef [[C:%.*]], ptr noalias nofree noundef nonnull returned writeonly align 4 dereferenceable(4) "no-capture-maybe-returned" [[V:%.*]]) #[[ATTR0:[0-9]+]] {
9+
; TUNIT-SAME: (i1 noundef [[C:%.*]], ptr nofree noundef nonnull returned align 4 dereferenceable(4) [[V:%.*]]) #[[ATTR0:[0-9]+]] {
10+
; TUNIT-NEXT: [[X:%.*]] = load i32, ptr [[V]], align 4
1011
; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1112
; TUNIT: T:
13+
; TUNIT-NEXT: [[X1:%.*]] = add i32 [[X]], 1
14+
; TUNIT-NEXT: store i32 [[X1]], ptr [[V]], align 4
1215
; TUNIT-NEXT: ret ptr [[V]]
1316
; TUNIT: F:
17+
; TUNIT-NEXT: [[X2:%.*]] = sub i32 [[X]], 1
18+
; TUNIT-NEXT: store i32 [[X2]], ptr [[V]], align 4
1419
; TUNIT-NEXT: ret ptr [[V]]
1520
;
1621
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
@@ -44,13 +49,13 @@ F: ; preds = %0
4449
;; This function returns its first argument as a part of a multiple return
4550
;; value
4651
define internal { i32, i32 } @foo(i32 %A, i32 %B) {
47-
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
48-
; CGSCC-LABEL: define {{[^@]+}}@foo
49-
; CGSCC-SAME: (i32 noundef [[A:%.*]], i32 noundef [[B:%.*]]) #[[ATTR1:[0-9]+]] {
50-
; CGSCC-NEXT: [[X:%.*]] = add i32 [[A]], [[B]]
51-
; CGSCC-NEXT: [[Y:%.*]] = insertvalue { i32, i32 } undef, i32 [[A]], 0
52-
; CGSCC-NEXT: [[Z:%.*]] = insertvalue { i32, i32 } [[Y]], i32 [[X]], 1
53-
; CGSCC-NEXT: ret { i32, i32 } [[Z]]
52+
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
53+
; CHECK-LABEL: define {{[^@]+}}@foo
54+
; CHECK-SAME: (i32 noundef [[A:%.*]], i32 noundef [[B:%.*]]) #[[ATTR1:[0-9]+]] {
55+
; CHECK-NEXT: [[X:%.*]] = add i32 [[A]], [[B]]
56+
; CHECK-NEXT: [[Y:%.*]] = insertvalue { i32, i32 } undef, i32 [[A]], 0
57+
; CHECK-NEXT: [[Z:%.*]] = insertvalue { i32, i32 } [[Y]], i32 [[X]], 1
58+
; CHECK-NEXT: ret { i32, i32 } [[Z]]
5459
;
5560
%X = add i32 %A, %B
5661
%Y = insertvalue { i32, i32 } undef, i32 %A, 0
@@ -59,13 +64,19 @@ define internal { i32, i32 } @foo(i32 %A, i32 %B) {
5964
}
6065

6166
define void @caller(i1 %C) personality ptr @__gxx_personality_v0 {
62-
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
67+
; TUNIT: Function Attrs: norecurse
6368
; TUNIT-LABEL: define {{[^@]+}}@caller
64-
; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR1:[0-9]+]] personality ptr @__gxx_personality_v0 {
69+
; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] personality ptr @__gxx_personality_v0 {
6570
; TUNIT-NEXT: [[Q:%.*]] = alloca i32, align 4
66-
; TUNIT-NEXT: [[W:%.*]] = call align 4 ptr @incdec(i1 noundef [[C]], ptr noalias nofree noundef nonnull writeonly align 4 dereferenceable(4) "no-capture-maybe-returned" [[Q]]) #[[ATTR2:[0-9]+]]
71+
; TUNIT-NEXT: [[W:%.*]] = call align 4 ptr @incdec(i1 noundef [[C]], ptr nofree noundef nonnull align 4 dereferenceable(4) [[Q]]) #[[ATTR3:[0-9]+]]
72+
; TUNIT-NEXT: [[S1:%.*]] = call { i32, i32 } @foo(i32 noundef 1, i32 noundef 2) #[[ATTR4:[0-9]+]]
73+
; TUNIT-NEXT: [[X1:%.*]] = extractvalue { i32, i32 } [[S1]], 0
74+
; TUNIT-NEXT: [[S2:%.*]] = call { i32, i32 } @foo(i32 noundef 3, i32 noundef 4) #[[ATTR4]]
6775
; TUNIT-NEXT: br label [[OK:%.*]]
6876
; TUNIT: OK:
77+
; TUNIT-NEXT: [[X2:%.*]] = extractvalue { i32, i32 } [[S2]], 0
78+
; TUNIT-NEXT: [[Z:%.*]] = add i32 [[X1]], [[X2]]
79+
; TUNIT-NEXT: store i32 [[Z]], ptr [[Q]], align 4
6980
; TUNIT-NEXT: br label [[RET:%.*]]
7081
; TUNIT: LPAD:
7182
; TUNIT-NEXT: unreachable
@@ -118,9 +129,11 @@ RET:
118129

119130
declare i32 @__gxx_personality_v0(...)
120131
;.
121-
; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
132+
; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nounwind willreturn }
122133
; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
123-
; TUNIT: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn memory(write) }
134+
; TUNIT: attributes #[[ATTR2]] = { norecurse }
135+
; TUNIT: attributes #[[ATTR3]] = { nofree nounwind willreturn }
136+
; TUNIT: attributes #[[ATTR4]] = { nounwind memory(none) }
124137
;.
125138
; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
126139
; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
@@ -129,5 +142,3 @@ declare i32 @__gxx_personality_v0(...)
129142
; CGSCC: attributes #[[ATTR4]] = { nofree nosync willreturn }
130143
; CGSCC: attributes #[[ATTR5]] = { nofree nosync nounwind willreturn memory(none) }
131144
;.
132-
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
133-
; CHECK: {{.*}}

0 commit comments

Comments
 (0)