Fix code emission for conditional branches.
Patch by Collin Winter!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70898 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/CPP/2009-05-04-CondBr.ll b/test/CodeGen/CPP/2009-05-04-CondBr.ll
new file mode 100644
index 0000000..6c3f984
--- /dev/null
+++ b/test/CodeGen/CPP/2009-05-04-CondBr.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | llc -march=cpp -cppgen=program -f -o %t
+; RUN: grep "BranchInst::Create(label_if_then, label_if_end, int1_cmp, label_entry);" %t
+
+define i32 @some_func(i32 %a) nounwind {
+entry:
+ %retval = alloca i32 ; <i32*> [#uses=2]
+ %a.addr = alloca i32 ; <i32*> [#uses=8]
+ store i32 %a, i32* %a.addr
+ %tmp = load i32* %a.addr ; <i32> [#uses=1]
+ %inc = add i32 %tmp, 1 ; <i32> [#uses=1]
+ store i32 %inc, i32* %a.addr
+ %tmp1 = load i32* %a.addr ; <i32> [#uses=1]
+ %cmp = icmp slt i32 %tmp1, 3 ; <i1> [#uses=1]
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ store i32 7, i32* %a.addr
+ br label %if.end
+
+if.end: ; preds = %if.then, %entry
+ %tmp2 = load i32* %a.addr ; <i32> [#uses=1]
+ %inc3 = add i32 %tmp2, 1 ; <i32> [#uses=1]
+ store i32 %inc3, i32* %a.addr
+ %tmp4 = load i32* %a.addr ; <i32> [#uses=1]
+ store i32 %tmp4, i32* %retval
+ %0 = load i32* %retval ; <i32> [#uses=1]
+ ret i32 %0
+}
diff --git a/test/DebugInfo/2009-01-29-HeaderLocation.ll b/test/DebugInfo/2009-01-29-HeaderLocation.ll
index c59a1c7..a201bd5 100644
--- a/test/DebugInfo/2009-01-29-HeaderLocation.ll
+++ b/test/DebugInfo/2009-01-29-HeaderLocation.ll
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc | grep "m.h" | count 1
+; RUN: llvm-as < %s | llc | grep "\\"m.h\\"" | count 1
target triple = "i386-apple-darwin9.6"
%llvm.dbg.anchor.type = type { i32, i32 }
%llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 }
diff --git a/test/FrontendC++/2009-05-04-PureConstNounwind.cpp b/test/FrontendC++/2009-05-04-PureConstNounwind.cpp
new file mode 100644
index 0000000..a4b4653
--- /dev/null
+++ b/test/FrontendC++/2009-05-04-PureConstNounwind.cpp
@@ -0,0 +1,8 @@
+// RUN: %llvmgxx -S -emit-llvm %s -o - | grep nounwind | count 4
+int c(void) __attribute__((const));
+int p(void) __attribute__((pure));
+int t(void);
+
+int f(void) {
+ return c() + p() + t();
+}
diff --git a/test/FrontendC/2009-05-04-EnumInreg.c b/test/FrontendC/2009-05-04-EnumInreg.c
new file mode 100644
index 0000000..8a76f5f
--- /dev/null
+++ b/test/FrontendC/2009-05-04-EnumInreg.c
@@ -0,0 +1,17 @@
+// RUN: %llvmgcc -S -m32 -mregparm=3 %s -emit-llvm -o - | grep {inreg %action}
+// XTARGET: x86
+// PR3967
+
+enum kobject_action {
+ KOBJ_ADD,
+ KOBJ_REMOVE,
+ KOBJ_CHANGE,
+ KOBJ_MOVE,
+ KOBJ_ONLINE,
+ KOBJ_OFFLINE,
+ KOBJ_MAX
+};
+
+struct kobject;
+
+int kobject_uevent(struct kobject *kobj, enum kobject_action action) {}
diff --git a/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll b/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
index b874c82..aec134a 100644
--- a/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
+++ b/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
@@ -39,6 +39,16 @@
ret i1 %val
}
+declare void @throw_if_bit_set(i8*, i8) readonly
+define i1 @c6(i8* %q, i8 %bit) {
+ invoke void @throw_if_bit_set(i8* %q, i8 %bit)
+ to label %ret0 unwind label %ret1
+ret0:
+ ret i1 0
+ret1:
+ ret i1 1
+}
+
define i32 @nc1(i32* %q, i32* %p, i1 %b) {
e:
br label %l
@@ -63,14 +73,20 @@
ret void
}
-declare void @external(i8*) readonly
+declare void @external(i8*) readonly nounwind
define void @nc4(i8* %p) {
call void @external(i8* %p)
ret void
}
-define void @nc5(void (i8*)* %f, i8* %p) {
- call void %f(i8* %p) readonly
- call void %f(i8* nocapture %p)
+define void @nc5(void (i8*)* %p, i8* %r) {
+ call void %p(i8* %r)
+ call void %p(i8* nocapture %r)
+ ret void
+}
+
+declare i8* @external_identity(i8*) readonly nounwind
+define void @nc6(i8* %p) {
+ call i8* @external_identity(i8* %p)
ret void
}