Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.

This makes use of the recently-added @llvm.assume intrinsic to implement a
__builtin_assume(bool) intrinsic (to provide additional information to the
optimizer). This hooks up __assume in MS-compatibility mode to mirror
__builtin_assume (the semantics have been intentionally kept compatible), and
implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM
now contains special logic to deal with assumptions of this form.

llvm-svn: 217349
diff --git a/clang/test/CodeGen/builtin-assume.c b/clang/test/CodeGen/builtin-assume.c
index a381a4c..041e9f4 100644
--- a/clang/test/CodeGen/builtin-assume.c
+++ b/clang/test/CodeGen/builtin-assume.c
@@ -1,8 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -emit-llvm -o - %s | FileCheck %s
 
 // CHECK-LABEL: @test1
-int test1(int *a) {
-  __assume(a != 0);
+int test1(int *a, int i) {
+// CHECK: %0 = load i32** %a.addr
+// CHECK: %cmp = icmp ne i32* %0, null
+// CHECK: call void @llvm.assume(i1 %cmp)
+#ifdef _MSC_VER
+  __assume(a != 0)
+#else
+  __builtin_assume(a != 0);
+#endif
+
+// Nothing is generated for an assume with side effects...
+// CHECK-NOT: load i32** %i.addr
+// CHECK-NOT: call void @llvm.assume
+#ifdef _MSC_VER
+  __assume(++i != 0)
+#else
+  __builtin_assume(++i != 0);
+#endif
+
   return a[0];
 }