Skip to content

Commit a902024

Browse files
committed
Merging r169084: into 3.2 release branch.
SROA: Avoid struct and array types early to avoid creating an overly large integer type. Fixes PR14465. Differential Revision: http://llvm-reviews.chandlerc.com/D148 git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@169290 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 24d616e commit a902024

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Transforms/Scalar/SROA.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,9 @@ static bool isIntegerWideningViable(const DataLayout &TD,
21602160
AllocaPartitioning::const_use_iterator I,
21612161
AllocaPartitioning::const_use_iterator E) {
21622162
uint64_t SizeInBits = TD.getTypeSizeInBits(AllocaTy);
2163+
// Don't create integer types larger than the maximum bitwidth.
2164+
if (SizeInBits > IntegerType::MAX_INT_BITS)
2165+
return false;
21632166

21642167
// Don't try to handle allocas with bit-padding.
21652168
if (SizeInBits != TD.getTypeStoreSizeInBits(AllocaTy))

test/Transforms/SROA/basictest.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,3 +1134,16 @@ entry:
11341134
ret void
11351135
; CHECK: ret
11361136
}
1137+
1138+
define void @PR14465() {
1139+
; Ensure that we don't crash when analyzing a alloca larger than the maximum
1140+
; integer type width (MAX_INT_BITS) supported by llvm (1048576*32 > (1<<23)-1).
1141+
; CHECK: @PR14465
1142+
1143+
%stack = alloca [1048576 x i32], align 16
1144+
; CHECK: alloca [1048576 x i32]
1145+
%cast = bitcast [1048576 x i32]* %stack to i8*
1146+
call void @llvm.memset.p0i8.i64(i8* %cast, i8 -2, i64 4194304, i32 16, i1 false)
1147+
ret void
1148+
; CHECK: ret
1149+
}

0 commit comments

Comments
 (0)