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/Sema/builtin-assume.c b/clang/test/Sema/builtin-assume.c
index 1f6a3a0..512eeec 100644
--- a/clang/test/Sema/builtin-assume.c
+++ b/clang/test/Sema/builtin-assume.c
@@ -1,11 +1,18 @@
// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
int foo(int *a, int i) {
+#ifdef _MSC_VER
__assume(i != 4);
- __assume(++i > 2); //expected-warning {{the argument to __assume has side effects that will be discarded}}
+ __assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
+#else
+ __builtin_assume(i != 4);
+ __builtin_assume(++i > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
+ int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];});
+#endif
return a[i];
}