File tree Expand file tree Collapse file tree 2 files changed +24
-18
lines changed Expand file tree Collapse file tree 2 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -590,19 +590,20 @@ void Lint::visitIndirectBrInst(IndirectBrInst &I) {
590
590
591
591
void Lint::visitExtractElementInst (ExtractElementInst &I) {
592
592
if (ConstantInt *CI = dyn_cast<ConstantInt>(findValue (I.getIndexOperand (),
593
- /* OffsetOk=*/ false )))
594
- Check (
595
- CI->getValue ().ult (
596
- cast<FixedVectorType>(I. getVectorOperandType ())-> getNumElements ()),
597
- " Undefined result: extractelement index out of range " , &I);
593
+ /* OffsetOk=*/ false ))) {
594
+ ElementCount EC = I. getVectorOperandType ()-> getElementCount ();
595
+ Check (EC. isScalable () || CI->getValue ().ult (EC. getFixedValue ()),
596
+ " Undefined result: extractelement index out of range " , &I);
597
+ }
598
598
}
599
599
600
600
void Lint::visitInsertElementInst (InsertElementInst &I) {
601
601
if (ConstantInt *CI = dyn_cast<ConstantInt>(findValue (I.getOperand (2 ),
602
- /* OffsetOk=*/ false )))
603
- Check (CI-> getValue (). ult (
604
- cast<FixedVectorType>(I. getType ())-> getNumElements ()),
602
+ /* OffsetOk=*/ false ))) {
603
+ ElementCount EC = I. getType ()-> getElementCount ();
604
+ Check (EC. isScalable () || CI-> getValue (). ult (EC. getFixedValue ()),
605
605
" Undefined result: insertelement index out of range" , &I);
606
+ }
606
607
}
607
608
608
609
void Lint::visitUnreachableInst (UnreachableInst &I) {
Original file line number Diff line number Diff line change 1
- ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2
- ; RUN: opt -S -passes=lint < %s | FileCheck %s
1
+ ; RUN: opt -S -passes=lint -disable-output < %s 2>&1 | FileCheck %s --allow-empty
3
2
4
- ; Make sure we don't crash.
5
-
6
- define <vscale x 8 x i8 > @test () {
7
- ; CHECK-LABEL: define <vscale x 8 x i8> @test() {
8
- ; CHECK-NEXT: [[A:%.*]] = alloca <vscale x 8 x i8>, align 8
9
- ; CHECK-NEXT: [[V:%.*]] = load <vscale x 8 x i8>, ptr [[A]], align 8
10
- ; CHECK-NEXT: ret <vscale x 8 x i8> [[V]]
11
- ;
3
+ ; CHECK-NOT: Buffer overflow
4
+ define <vscale x 8 x i8 > @alloca_access () {
12
5
%a = alloca <vscale x 8 x i8 >
13
6
%v = load <vscale x 8 x i8 >, ptr %a
14
7
ret <vscale x 8 x i8 > %v
15
8
}
9
+
10
+ ; CHECK-NOT: insertelement index out of range
11
+ define <vscale x 8 x half > @insertelement () {
12
+ %insert = insertelement <vscale x 8 x half > poison, half 0xH0000, i64 100
13
+ ret <vscale x 8 x half > %insert
14
+ }
15
+
16
+ ; CHECK-NOT: extract index out of range
17
+ define half @extractelement (<vscale x 8 x half > %v ) {
18
+ %insert = extractelement <vscale x 8 x half > %v , i64 100
19
+ ret half %insert
20
+ }
You can’t perform that action at this time.
0 commit comments