summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-07-16 22:44:54 +0000
committerHal Finkel <hfinkel@anl.gov>2014-07-16 22:44:54 +0000
commit3e49fda0d4f2de4c22a4cedfd9c2d2e5b0589f9c (patch)
tree5a2434360479f837d43a8c49da4eeffccaa0fe11
parentd3bbfa1cb6c10991637182a976f9d03a359d4859 (diff)
downloadbcm5719-llvm-3e49fda0d4f2de4c22a4cedfd9c2d2e5b0589f9c.tar.gz
bcm5719-llvm-3e49fda0d4f2de4c22a4cedfd9c2d2e5b0589f9c.zip
Add basic (noop) CodeGen support for __assume
Clang supports __assume, at least at the semantic level, when MS extensions are enabled. Unfortunately, trying to actually compile code using __assume would result in this error: error: cannot compile this builtin function yet __assume is an optimizer hint, and can be ignored at the IR level. Until LLVM supports assumptions at the IR level, a noop lowering is valid, and that is what is done here. llvm-svn: 213206
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp3
-rw-r--r--clang/test/CodeGen/builtin-assume.c8
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 37347168f3c..4bdc87e2d42 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1517,6 +1517,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__noop:
// __noop always evaluates to an integer literal zero.
return RValue::get(ConstantInt::get(IntTy, 0));
+ case Builtin::BI__assume:
+ // Until LLVM supports assumptions at the IR level, this becomes nothing.
+ return RValue::get(nullptr);
case Builtin::BI_InterlockedExchange:
case Builtin::BI_InterlockedExchangePointer:
return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E);
diff --git a/clang/test/CodeGen/builtin-assume.c b/clang/test/CodeGen/builtin-assume.c
new file mode 100644
index 00000000000..a381a4c1dfb
--- /dev/null
+++ b/clang/test/CodeGen/builtin-assume.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @test1
+int test1(int *a) {
+ __assume(a != 0);
+ return a[0];
+}
+
OpenPOWER on IntegriCloud