summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-18 22:32:43 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-18 22:32:43 +0000
commitcb1c81afa0f319de56afddd1b13f6b1ce3cdec1a (patch)
treed64bb90425ac4cb60f6b4b363f1255cef37efc9a /llvm/test
parent2f6bec6ee9f289b2c042d32f781130e053d2f116 (diff)
downloadbcm5719-llvm-cb1c81afa0f319de56afddd1b13f6b1ce3cdec1a.tar.gz
bcm5719-llvm-cb1c81afa0f319de56afddd1b13f6b1ce3cdec1a.zip
Fix use_iterator crash in ObjCArc from r203364
The use_iterator redesign in r203364 introduced an increment past the end of a range in -objc-arc-contract. Added an explicit check for the end of the range. <rdar://problem/16333235> llvm-svn: 204195
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/ObjCARC/contract-end-of-use-list.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ObjCARC/contract-end-of-use-list.ll b/llvm/test/Transforms/ObjCARC/contract-end-of-use-list.ll
new file mode 100644
index 00000000000..a38cd8a1da1
--- /dev/null
+++ b/llvm/test/Transforms/ObjCARC/contract-end-of-use-list.ll
@@ -0,0 +1,30 @@
+; RUN: opt -S < %s -objc-arc-expand -objc-arc-contract | FileCheck %s
+; Don't crash. Reproducer for a use_iterator bug from r203364.
+; rdar://problem/16333235
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-darwin13.2.0"
+
+%struct = type { i8*, i8* }
+
+; CHECK-LABEL: @foo() {
+define internal i8* @foo() {
+entry:
+ %call = call i8* @bar()
+; CHECK: %retained1 = call i8* @objc_retainAutoreleasedReturnValue(i8* %call)
+ %retained1 = call i8* @objc_retain(i8* %call)
+ %isnull = icmp eq i8* %retained1, null
+ br i1 %isnull, label %cleanup, label %if.end
+
+if.end:
+; CHECK: %retained2 = call i8* @objc_retain(i8* %retained1)
+ %retained2 = call i8* @objc_retain(i8* %retained1)
+ br label %cleanup
+
+cleanup:
+ %retval = phi i8* [ %retained2, %if.end ], [ null, %entry ]
+ ret i8* %retval
+}
+
+declare i8* @bar()
+
+declare extern_weak i8* @objc_retain(i8*)
OpenPOWER on IntegriCloud