1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -basicaa -gvn -asan -asan-module -S | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; ASAN conflicts with load widening iff the widened load accesses data out of bounds 3*9880d681SAndroid Build Coastguard Worker; (while the original unwidened loads do not). 4*9880d681SAndroid Build Coastguard Worker; http://code.google.com/p/address-sanitizer/issues/detail?id=20#c1 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker; 32-bit little endian target. 8*9880d681SAndroid Build Coastguard Workertarget 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*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker%struct_of_7_bytes_4_aligned = type { i32, i8, i8, i8} 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker@f = external global %struct_of_7_bytes_4_aligned , align 4 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_address is set. 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Workerdefine i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_address { 17*9880d681SAndroid Build Coastguard Workerentry: 18*9880d681SAndroid Build Coastguard Worker %tmp = load i8, i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned, %struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4 19*9880d681SAndroid Build Coastguard Worker %conv = zext i8 %tmp to i32 20*9880d681SAndroid Build Coastguard Worker %tmp1 = load i8, i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned, %struct_of_7_bytes_4_aligned* @f, i64 0, i32 3), align 1 21*9880d681SAndroid Build Coastguard Worker %conv2 = zext i8 %tmp1 to i32 22*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %conv, %conv2 23*9880d681SAndroid Build Coastguard Worker ret i32 %add 24*9880d681SAndroid Build Coastguard Worker; CHECK: @test_widening_bad 25*9880d681SAndroid Build Coastguard Worker; CHECK: __asan_report_load1 26*9880d681SAndroid Build Coastguard Worker; CHECK: __asan_report_load1 27*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: __asan_report 28*9880d681SAndroid Build Coastguard Worker; We can not use check for "ret" here because __asan_report_load1 calls live after ret. 29*9880d681SAndroid Build Coastguard Worker; CHECK: end_test_widening_bad 30*9880d681SAndroid Build Coastguard Worker} 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Workerdefine void @end_test_widening_bad() { 33*9880d681SAndroid Build Coastguard Worker entry: 34*9880d681SAndroid Build Coastguard Worker ret void 35*9880d681SAndroid Build Coastguard Worker} 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker;; Accessing bytes 4 and 5. Ok to widen to i16. 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerdefine i32 @test_widening_ok(i8* %P) nounwind ssp noredzone sanitize_address { 40*9880d681SAndroid Build Coastguard Workerentry: 41*9880d681SAndroid Build Coastguard Worker %tmp = load i8, i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned, %struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4 42*9880d681SAndroid Build Coastguard Worker %conv = zext i8 %tmp to i32 43*9880d681SAndroid Build Coastguard Worker %tmp1 = load i8, i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned, %struct_of_7_bytes_4_aligned* @f, i64 0, i32 2), align 1 44*9880d681SAndroid Build Coastguard Worker %conv2 = zext i8 %tmp1 to i32 45*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %conv, %conv2 46*9880d681SAndroid Build Coastguard Worker ret i32 %add 47*9880d681SAndroid Build Coastguard Worker; CHECK: @test_widening_ok 48*9880d681SAndroid Build Coastguard Worker; CHECK: __asan_report_load2 49*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: __asan_report 50*9880d681SAndroid Build Coastguard Worker; CHECK: end_test_widening_ok 51*9880d681SAndroid Build Coastguard Worker} 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Workerdefine void @end_test_widening_ok() { 54*9880d681SAndroid Build Coastguard Worker entry: 55*9880d681SAndroid Build Coastguard Worker ret void 56*9880d681SAndroid Build Coastguard Worker} 57