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