2014-03-20 19:16:34 +08:00
|
|
|
; RUN: opt < %s -basicaa -gvn -asan -asan-module -S | FileCheck %s
|
2012-09-27 18:14:43 +08:00
|
|
|
; ASAN conflicts with load widening iff the widened load accesses data out of bounds
|
2012-02-07 06:48:56 +08:00
|
|
|
; (while the original unwidened loads do not).
|
2017-11-14 07:47:58 +08:00
|
|
|
; https://github.com/google/sanitizers/issues/20#issuecomment-136381262
|
2012-02-07 06:48:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
; 32-bit little endian target.
|
|
|
|
target 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"
|
|
|
|
|
|
|
|
%struct_of_7_bytes_4_aligned = type { i32, i8, i8, i8}
|
|
|
|
|
2013-10-16 22:06:14 +08:00
|
|
|
@f = external global %struct_of_7_bytes_4_aligned , align 4
|
2012-02-07 06:48:56 +08:00
|
|
|
|
2013-02-26 14:58:09 +08:00
|
|
|
; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_address is set.
|
2012-02-07 06:48:56 +08:00
|
|
|
|
2013-02-26 14:58:09 +08:00
|
|
|
define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_address {
|
2012-02-07 06:48:56 +08:00
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%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
|
2012-02-07 06:48:56 +08:00
|
|
|
%conv = zext i8 %tmp to i32
|
2015-03-14 02:20:45 +08:00
|
|
|
%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
|
2012-02-07 06:48:56 +08:00
|
|
|
%conv2 = zext i8 %tmp1 to i32
|
|
|
|
%add = add nsw i32 %conv, %conv2
|
|
|
|
ret i32 %add
|
|
|
|
; CHECK: @test_widening_bad
|
|
|
|
; CHECK: __asan_report_load1
|
|
|
|
; CHECK: __asan_report_load1
|
2012-02-14 08:02:35 +08:00
|
|
|
; CHECK-NOT: __asan_report
|
|
|
|
; We can not use check for "ret" here because __asan_report_load1 calls live after ret.
|
|
|
|
; CHECK: end_test_widening_bad
|
2012-02-07 06:48:56 +08:00
|
|
|
}
|
|
|
|
|
2012-02-14 08:02:35 +08:00
|
|
|
define void @end_test_widening_bad() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
Do not widen load for different variable in GVN.
Summary:
Widening load in GVN is too early because it will block other optimizations like PRE, LICM.
https://llvm.org/bugs/show_bug.cgi?id=29110
The SPECCPU2006 benchmark impact of this patch:
Reference: o2_nopatch
(1): o2_patched
Benchmark Base:Reference (1)
-------------------------------------------------------
spec/2006/fp/C++/444.namd 25.2 -0.08%
spec/2006/fp/C++/447.dealII 45.92 +1.05%
spec/2006/fp/C++/450.soplex 41.7 -0.26%
spec/2006/fp/C++/453.povray 35.65 +1.68%
spec/2006/fp/C/433.milc 23.79 +0.42%
spec/2006/fp/C/470.lbm 41.88 -1.12%
spec/2006/fp/C/482.sphinx3 47.94 +1.67%
spec/2006/int/C++/471.omnetpp 22.46 -0.36%
spec/2006/int/C++/473.astar 21.19 +0.24%
spec/2006/int/C++/483.xalancbmk 36.09 -0.11%
spec/2006/int/C/400.perlbench 33.28 +1.35%
spec/2006/int/C/401.bzip2 22.76 -0.04%
spec/2006/int/C/403.gcc 32.36 +0.12%
spec/2006/int/C/429.mcf 41.04 -0.41%
spec/2006/int/C/445.gobmk 26.94 +0.04%
spec/2006/int/C/456.hmmer 24.5 -0.20%
spec/2006/int/C/458.sjeng 28 -0.46%
spec/2006/int/C/462.libquantum 55.25 +0.27%
spec/2006/int/C/464.h264ref 45.87 +0.72%
geometric mean +0.23%
For most benchmarks, it's a wash, but we do see stable improvements on some benchmarks, e.g. 447,453,482,400.
Reviewers: davidxl, hfinkel, dberlin, sanjoy, reames
Subscribers: gberry, junbuml
Differential Revision: https://reviews.llvm.org/D24096
llvm-svn: 281074
2016-09-10 02:42:35 +08:00
|
|
|
;; Accessing bytes 4 and 5. No widen to i16.
|
2012-02-07 06:48:56 +08:00
|
|
|
|
2013-02-26 14:58:09 +08:00
|
|
|
define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone sanitize_address {
|
2012-02-07 06:48:56 +08:00
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%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
|
2012-02-07 06:48:56 +08:00
|
|
|
%conv = zext i8 %tmp to i32
|
2015-03-14 02:20:45 +08:00
|
|
|
%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
|
2012-02-07 06:48:56 +08:00
|
|
|
%conv2 = zext i8 %tmp1 to i32
|
|
|
|
%add = add nsw i32 %conv, %conv2
|
|
|
|
ret i32 %add
|
|
|
|
; CHECK: @test_widening_ok
|
Do not widen load for different variable in GVN.
Summary:
Widening load in GVN is too early because it will block other optimizations like PRE, LICM.
https://llvm.org/bugs/show_bug.cgi?id=29110
The SPECCPU2006 benchmark impact of this patch:
Reference: o2_nopatch
(1): o2_patched
Benchmark Base:Reference (1)
-------------------------------------------------------
spec/2006/fp/C++/444.namd 25.2 -0.08%
spec/2006/fp/C++/447.dealII 45.92 +1.05%
spec/2006/fp/C++/450.soplex 41.7 -0.26%
spec/2006/fp/C++/453.povray 35.65 +1.68%
spec/2006/fp/C/433.milc 23.79 +0.42%
spec/2006/fp/C/470.lbm 41.88 -1.12%
spec/2006/fp/C/482.sphinx3 47.94 +1.67%
spec/2006/int/C++/471.omnetpp 22.46 -0.36%
spec/2006/int/C++/473.astar 21.19 +0.24%
spec/2006/int/C++/483.xalancbmk 36.09 -0.11%
spec/2006/int/C/400.perlbench 33.28 +1.35%
spec/2006/int/C/401.bzip2 22.76 -0.04%
spec/2006/int/C/403.gcc 32.36 +0.12%
spec/2006/int/C/429.mcf 41.04 -0.41%
spec/2006/int/C/445.gobmk 26.94 +0.04%
spec/2006/int/C/456.hmmer 24.5 -0.20%
spec/2006/int/C/458.sjeng 28 -0.46%
spec/2006/int/C/462.libquantum 55.25 +0.27%
spec/2006/int/C/464.h264ref 45.87 +0.72%
geometric mean +0.23%
For most benchmarks, it's a wash, but we do see stable improvements on some benchmarks, e.g. 447,453,482,400.
Reviewers: davidxl, hfinkel, dberlin, sanjoy, reames
Subscribers: gberry, junbuml
Differential Revision: https://reviews.llvm.org/D24096
llvm-svn: 281074
2016-09-10 02:42:35 +08:00
|
|
|
; CHECK: __asan_report_load1
|
|
|
|
; CHECK: __asan_report_load1
|
2012-02-14 08:02:35 +08:00
|
|
|
; CHECK-NOT: __asan_report
|
|
|
|
; CHECK: end_test_widening_ok
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @end_test_widening_ok() {
|
|
|
|
entry:
|
|
|
|
ret void
|
2012-02-07 06:48:56 +08:00
|
|
|
}
|