summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-07-11 20:22:55 +0000
committerReid Kleckner <reid@kleckner.net>2014-07-11 20:22:55 +0000
commited5d4adb36bf07481f16bfe46d055396eebb9d0c (patch)
tree007c89d0ca651dfd1f7feb1e919e23c4503ef3ce
parent10cd0f457a0b6d9b9fba0cd0286ee2b7c5065c45 (diff)
downloadbcm5719-llvm-ed5d4adb36bf07481f16bfe46d055396eebb9d0c.tar.gz
bcm5719-llvm-ed5d4adb36bf07481f16bfe46d055396eebb9d0c.zip
MS extension: Make __noop be the integer zero, not void
We still don't accept '__noop;', and we don't consider __noop to be the integer literal zero. More work is needed. llvm-svn: 212839
-rw-r--r--clang/include/clang/Basic/Builtins.def2
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp3
-rw-r--r--clang/test/CodeGen/builtin-ms-noop.cpp6
3 files changed, 6 insertions, 5 deletions
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index a7a7f428d4b..e705382e11c 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -679,7 +679,7 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
// Microsoft builtins. These are only active with -fms-extensions.
LANGBUILTIN(_alloca, "v*z", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__assume, "vb", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(__noop, "v.", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__noop, "i.", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__debugbreak, "v", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__va_start, "vc**.", "nt", ALL_MS_LANGUAGES)
LANGBUILTIN(_InterlockedCompareExchange, "LiLiD*LiLi", "n", ALL_MS_LANGUAGES)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ded75c192ae..9d1ad673c20 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1515,7 +1515,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
return EmitBuiltinNewDeleteCall(FD->getType()->castAs<FunctionProtoType>(),
E->getArg(0), true);
case Builtin::BI__noop:
- return RValue::get(nullptr);
+ // __noop always evaluates to an integer literal zero.
+ return RValue::get(ConstantInt::get(IntTy, 0));
case Builtin::BI_InterlockedExchange:
case Builtin::BI_InterlockedExchangePointer:
return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E);
diff --git a/clang/test/CodeGen/builtin-ms-noop.cpp b/clang/test/CodeGen/builtin-ms-noop.cpp
index b579e2d08ce..f5064fbf3c0 100644
--- a/clang/test/CodeGen/builtin-ms-noop.cpp
+++ b/clang/test/CodeGen/builtin-ms-noop.cpp
@@ -5,9 +5,9 @@ class A {
~A() {}
};
-void f() {
+int f() {
// CHECK: @_Z1fv
// CHECK-NOT: call void @_ZN1AD1Ev
-// CHECK: ret void
- __noop(A());
+// CHECK: ret i32 0
+ return __noop(A());
};
OpenPOWER on IntegriCloud