58 lines · plain
1; RUN: opt < %s "-passes=function(require<basic-aa>,gvn),asan" -S | FileCheck %s2; ASAN conflicts with load widening iff the widened load accesses data out of bounds3; (while the original unwidened loads do not).4; https://github.com/google/sanitizers/issues/20#issuecomment-1363812625 6 7; 32-bit little endian target.8target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"9 10%struct_of_7_bytes_4_aligned = type { i32, i8, i8, i8}11 12@f = external global %struct_of_7_bytes_4_aligned , align 413 14; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_address is set.15 16define i32 @test_widening_bad(ptr %P) nounwind ssp noredzone sanitize_address {17entry:18 %tmp = load i8, ptr getelementptr inbounds (%struct_of_7_bytes_4_aligned, ptr @f, i64 0, i32 1), align 419 %conv = zext i8 %tmp to i3220 %tmp1 = load i8, ptr getelementptr inbounds (%struct_of_7_bytes_4_aligned, ptr @f, i64 0, i32 3), align 121 %conv2 = zext i8 %tmp1 to i3222 %add = add nsw i32 %conv, %conv223 ret i32 %add24; CHECK: @test_widening_bad25; CHECK: __asan_report_load126; CHECK: __asan_report_load127; CHECK-NOT: __asan_report28; We can not use check for "ret" here because __asan_report_load1 calls live after ret.29; CHECK: end_test_widening_bad30}31 32define void @end_test_widening_bad() {33 entry:34 ret void35}36 37;; Accessing bytes 4 and 5. No widen to i16.38 39define i32 @test_widening_ok(ptr %P) nounwind ssp noredzone sanitize_address {40entry:41 %tmp = load i8, ptr getelementptr inbounds (%struct_of_7_bytes_4_aligned, ptr @f, i64 0, i32 1), align 442 %conv = zext i8 %tmp to i3243 %tmp1 = load i8, ptr getelementptr inbounds (%struct_of_7_bytes_4_aligned, ptr @f, i64 0, i32 2), align 144 %conv2 = zext i8 %tmp1 to i3245 %add = add nsw i32 %conv, %conv246 ret i32 %add47; CHECK: @test_widening_ok48; CHECK: __asan_report_load149; CHECK: __asan_report_load150; CHECK-NOT: __asan_report51; CHECK: end_test_widening_ok52}53 54define void @end_test_widening_ok() {55 entry:56 ret void57}58