Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(903)

Unified Diff: test/Instrumentation/AddressSanitizer/OptKnownBounds/multi-obj-phi-select-invalid.ll

Issue 6643048: Add a known bounds optimization to ASan.
Patch Set: Match the DataLayout getIntPtrType change. Created 12 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/Instrumentation/AddressSanitizer/OptKnownBounds/multi-obj-phi-select-invalid.ll
diff --git a/test/Instrumentation/AddressSanitizer/OptKnownBounds/multi-obj-phi-select-invalid.ll b/test/Instrumentation/AddressSanitizer/OptKnownBounds/multi-obj-phi-select-invalid.ll
new file mode 100644
index 0000000000000000000000000000000000000000..23e772069ca3c19f28636d752dc56855ac5ef561
--- /dev/null
+++ b/test/Instrumentation/AddressSanitizer/OptKnownBounds/multi-obj-phi-select-invalid.ll
@@ -0,0 +1,48 @@
+; Possibly invalid access of a too small object through a select instruction and a phi node.
+
+; RUN: opt < %s -asan -S -asan-opt=1 -asan-opt-known-bounds=1 | FileCheck %s -check-prefix=OPT1
+; RUN: opt < %s -asan -S -asan-opt=0 | FileCheck %s -check-prefix=OPT0
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@g2 = global i32 0, align 4
+@g3 = global i32 0, align 4
+@array = global [3 x i8] zeroinitializer, align 1
+
+define i32* @_Z7examplei(i32 %first) address_safety nounwind uwtable {
+entry:
+ %cmp = icmp eq i32 %first, 1
+ br i1 %cmp, label %cond.end, label %cond.false
+
+cond.false: ; preds = %entry
+ %tobool = icmp ne i32 %first, 0
+ %cond = select i1 %tobool, i32* @g2, i32* @g3
+ br label %cond.end
+
+cond.end: ; preds = %entry, %cond.false
+ %cond1 = phi i32* [ %cond, %cond.false ], [ bitcast ([3 x i8]* @array to i32*), %entry ]
+ store i32 42, i32* %cond1, align 4
+ ret i32* bitcast ([3 x i8]* @array to i32*)
+}
+
+; OPT1: @_Z7examplei
+; OPT1: call void @__asan_report_
+; OPT1-NOT: call void @__asan_report_
+; OPT1: @asan.module_ctor
+
+; OPT0: @_Z7examplei
+; OPT0: call void @__asan_report_
+; OPT0-NOT: call void @__asan_report_
+; OPT0: @asan.module_ctor
+
+; C++-example: #include <stdlib.h>
+; C++-example:
+; C++-example: int g2, g3;
+; C++-example: char array[sizeof(int) - 1];
+; C++-example:
+; C++-example: int* example(int first) {
+; C++-example: int *ptr1 = (int*)&array[0];
+; C++-example: *(first == 1? ptr1: first? &g2: &g3) = 42; // BUG (if first == 1)
+; C++-example: return ptr1;
+; C++-example: }

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b