-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm] Fix ObjectSizeOffsetVisitor behavior in exact mode upon negati… (
#116955) …ve offset In Exact mode, the approximation of returning (0,0) is invalid. It only holds in min/max mode.
- Loading branch information
1 parent
68f7b07
commit 19ddafa
Showing
2 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; Check that negative oob gep do not generate invalid check. | ||
; RUN: opt < %s -passes=bounds-checking -S | FileCheck %s | ||
target datalayout = "e-p:64:64:64-p1:16:16:16-p2:64:64:64:48-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" | ||
|
||
|
||
@str = global [100 x i8] zeroinitializer, align 1 | ||
|
||
define i16 @main() { | ||
; CHECK-LABEL: @main( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: br label [[FOR_COND:%.*]] | ||
; CHECK: for.cond: | ||
; CHECK-NEXT: [[I_0:%.*]] = phi i8 [ 65, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[TMP4:%.*]] ] | ||
; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i8 [[I_0]], 76 | ||
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END:%.*]], label [[TMP4]] | ||
; CHECK: for.inc: | ||
; CHECK-NEXT: [[I_0_C:%.*]] = sext i8 [[I_0]] to i64 | ||
; CHECK-NEXT: [[TMP0:%.*]] = add i64 -65, [[I_0_C]] | ||
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr getelementptr (i8, ptr @str, i8 -65), i8 [[I_0]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = sub i64 100, [[TMP0]] | ||
; CHECK-NEXT: store i8 [[I_0]], ptr [[GEP]], align 1 | ||
; CHECK-NEXT: [[INC]] = add nuw nsw i8 [[I_0]], 1 | ||
; CHECK-NEXT: br label [[FOR_COND]] | ||
; CHECK: for.end: | ||
; CHECK-NEXT: ret i16 0 | ||
; | ||
entry: | ||
br label %for.cond | ||
|
||
for.cond: | ||
%i.0 = phi i8 [ 65, %entry ], [ %inc, %for.inc ] | ||
%exitcond.not = icmp eq i8 %i.0, 76 | ||
br i1 %exitcond.not, label %for.end, label %for.inc | ||
|
||
for.inc: ; preds = %for.cond | ||
%gep = getelementptr i8, ptr getelementptr (i8, ptr @str, i8 -65), i8 %i.0 | ||
store i8 %i.0, ptr %gep, align 1 | ||
%inc = add nuw nsw i8 %i.0, 1 | ||
br label %for.cond | ||
|
||
for.end: | ||
ret i16 0 | ||
} | ||
|