Arthur Eubanks | 7c2f276 | 2020-07-17 17:49:46 -0700 | [diff] [blame] | 1 | ; RUN: opt < %s -asan -asan-detect-invalid-pointer-cmp -S -enable-new-pm=0 \ |
Pierre Gousseau | a833c2b | 2019-03-28 10:51:24 +0000 | [diff] [blame] | 2 | ; RUN: | FileCheck %s --check-prefixes=CMP,NOSUB,ALL |
Arthur Eubanks | 7c2f276 | 2020-07-17 17:49:46 -0700 | [diff] [blame] | 3 | ; RUN: opt < %s -passes='asan-function-pipeline' -asan-detect-invalid-pointer-cmp -S \ |
| 4 | ; RUN: | FileCheck %s --check-prefixes=CMP,NOSUB,ALL |
| 5 | ; RUN: opt < %s -asan -asan-detect-invalid-pointer-sub -S -enable-new-pm=0 \ |
Pierre Gousseau | a833c2b | 2019-03-28 10:51:24 +0000 | [diff] [blame] | 6 | ; RUN: | FileCheck %s --check-prefixes=SUB,NOCMP,ALL |
Arthur Eubanks | 7c2f276 | 2020-07-17 17:49:46 -0700 | [diff] [blame] | 7 | ; RUN: opt < %s -passes='asan-function-pipeline' -asan-detect-invalid-pointer-sub -S \ |
| 8 | ; RUN: | FileCheck %s --check-prefixes=SUB,NOCMP,ALL |
| 9 | ; RUN: opt < %s -asan -asan-detect-invalid-pointer-pair -S -enable-new-pm=0 \ |
| 10 | ; RUN: | FileCheck %s --check-prefixes=CMP,SUB,ALL |
| 11 | ; RUN: opt < %s -passes='asan-function-pipeline' -asan-detect-invalid-pointer-pair -S \ |
Pierre Gousseau | a833c2b | 2019-03-28 10:51:24 +0000 | [diff] [blame] | 12 | ; RUN: | FileCheck %s --check-prefixes=CMP,SUB,ALL |
| 13 | ; Support instrumentation of invalid pointer pair detection. |
| 14 | |
| 15 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 16 | |
| 17 | define i32 @mycmp(i8* %p, i8* %q) sanitize_address { |
| 18 | ; ALL-LABEL: @mycmp |
| 19 | ; NOCMP-NOT: call void @__sanitizer_ptr_cmp |
| 20 | ; CMP: [[P:%[0-9A-Za-z]+]] = ptrtoint i8* %p to i64 |
| 21 | ; CMP: [[Q:%[0-9A-Za-z]+]] = ptrtoint i8* %q to i64 |
| 22 | %x = icmp ule i8* %p, %q |
| 23 | ; CMP: call void @__sanitizer_ptr_cmp(i64 [[P]], i64 [[Q]]) |
| 24 | %y = zext i1 %x to i32 |
| 25 | ret i32 %y |
| 26 | } |
| 27 | |
| 28 | define i32 @mysub(i8* %p, i8* %q) sanitize_address { |
| 29 | ; ALL-LABEL: @mysub |
| 30 | ; NOSUB-NOT: call void @__sanitizer_ptr_sub |
| 31 | ; SUB: [[P:%[0-9A-Za-z]+]] = ptrtoint i8* %p to i64 |
| 32 | ; SUB: [[Q:%[0-9A-Za-z]+]] = ptrtoint i8* %q to i64 |
| 33 | %x = ptrtoint i8* %p to i64 |
| 34 | %y = ptrtoint i8* %q to i64 |
| 35 | %z = sub i64 %x, %y |
| 36 | ; SUB: call void @__sanitizer_ptr_sub(i64 [[P]], i64 [[Q]]) |
| 37 | %w = trunc i64 %z to i32 |
| 38 | ret i32 %w |
| 39 | } |