Skip to content

Commit e8232c3

Browse files
authored
[ADT] In FoldingSet calulation for APInt add bit width to avoid crash (#88635)
Multiple ranges attributes with the same lower and upper limit but different bit width caused a crash.
1 parent 1693009 commit e8232c3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

llvm/include/llvm/ADT/FoldingSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ class FoldingSetNodeID {
356356
AddInteger(unsigned(I >> 32));
357357
}
358358
void AddInteger(const APInt &Int) {
359+
AddInteger(Int.getBitWidth());
359360
const auto *Parts = Int.getRawData();
360361
for (int i = 0, N = Int.getNumWords(); i < N; ++i) {
361362
AddInteger(Parts[i]);

llvm/test/Bitcode/attributes.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ define range(i32 -1, 42) i32 @range_attribute(<4 x i32> range(i32 -1, 42) %a) {
531531
ret i32 0
532532
}
533533

534+
; CHECK: define range(i32 0, 42) i32 @range_attribute_same_range_other_bitwidth(i8 range(i8 0, 42) %a)
535+
define range(i32 0, 42) i32 @range_attribute_same_range_other_bitwidth(i8 range(i8 0, 42) %a) {
536+
ret i32 0
537+
}
538+
534539
; CHECK: define void @wide_range_attribute(i128 range(i128 618970019642690137449562111, 618970019642690137449562114) %a)
535540
define void @wide_range_attribute(i128 range(i128 618970019642690137449562111, 618970019642690137449562114) %a) {
536541
ret void

0 commit comments

Comments
 (0)