1 ; RUN: opt < %s -asan -asan-detect-invalid-pointer-cmp -S \
2 ; RUN: | FileCheck %s --check-prefixes=CMP,NOSUB,ALL
3 ; RUN: opt < %s -asan -asan-detect-invalid-pointer-sub -S \
4 ; RUN: | FileCheck %s --check-prefixes=SUB,NOCMP,ALL
5 ; RUN: opt < %s -asan -asan-detect-invalid-pointer-pair -S \
6 ; RUN: | FileCheck %s --check-prefixes=CMP,SUB,ALL
7 ; Support instrumentation of invalid pointer pair detection.
9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11 define i32 @mycmp(i8* %p, i8* %q) sanitize_address {
13 ; NOCMP-NOT: call void @__sanitizer_ptr_cmp
14 ; CMP: [[P:%[0-9A-Za-z]+]] = ptrtoint i8* %p to i64
15 ; CMP: [[Q:%[0-9A-Za-z]+]] = ptrtoint i8* %q to i64
16 %x = icmp ule i8* %p, %q
17 ; CMP: call void @__sanitizer_ptr_cmp(i64 [[P]], i64 [[Q]])
18 %y = zext i1 %x to i32
22 define i32 @mysub(i8* %p, i8* %q) sanitize_address {
24 ; NOSUB-NOT: call void @__sanitizer_ptr_sub
25 ; SUB: [[P:%[0-9A-Za-z]+]] = ptrtoint i8* %p to i64
26 ; SUB: [[Q:%[0-9A-Za-z]+]] = ptrtoint i8* %q to i64
27 %x = ptrtoint i8* %p to i64
28 %y = ptrtoint i8* %q to i64
30 ; SUB: call void @__sanitizer_ptr_sub(i64 [[P]], i64 [[Q]])
31 %w = trunc i64 %z to i32