brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · a98df8b Raw
31 lines · plain
1; RUN: opt < %s -passes=asan -asan-detect-invalid-pointer-cmp -S | FileCheck %s --check-prefixes=CMP,NOSUB,ALL2; RUN: opt < %s -passes=asan -asan-detect-invalid-pointer-sub -S | FileCheck %s --check-prefixes=SUB,NOCMP,ALL3; RUN: opt < %s -passes=asan -asan-detect-invalid-pointer-pair -S | FileCheck %s --check-prefixes=CMP,SUB,ALL4; Support instrumentation of invalid pointer pair detection.5 6target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"7 8define i32 @mycmp(ptr %p, ptr %q) sanitize_address {9; ALL-LABEL: @mycmp10; NOCMP-NOT: call void @__sanitizer_ptr_cmp11; CMP: [[P:%[0-9A-Za-z]+]] = ptrtoint ptr %p to i6412; CMP: [[Q:%[0-9A-Za-z]+]] = ptrtoint ptr %q to i6413  %x = icmp ule ptr %p, %q14; CMP: call void @__sanitizer_ptr_cmp(i64 [[P]], i64 [[Q]])15  %y = zext i1 %x to i3216  ret i32 %y17}18 19define i32 @mysub(ptr %p, ptr %q) sanitize_address {20; ALL-LABEL: @mysub21; NOSUB-NOT: call void @__sanitizer_ptr_sub22; SUB: [[P:%[0-9A-Za-z]+]] = ptrtoint ptr %p to i6423; SUB: [[Q:%[0-9A-Za-z]+]] = ptrtoint ptr %q to i6424  %x = ptrtoint ptr %p to i6425  %y = ptrtoint ptr %q to i6426  %z = sub i64 %x, %y27; SUB: call void @__sanitizer_ptr_sub(i64 [[P]], i64 [[Q]])28  %w = trunc i64 %z to i3229  ret i32 %w30}31