r212839 - MS extension: Make __noop be the integer zero, not void
Reid Kleckner
reid at kleckner.net
Fri Jul 11 13:22:56 PDT 2014
Author: rnk
Date: Fri Jul 11 15:22:55 2014
New Revision: 212839
URL: http://llvm.org/viewvc/llvm-project?rev=212839&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtin-ms-noop.cpp
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=212839&r1=212838&r2=212839&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jul 11 15:22:55 2014
@@ -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)
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=212839&r1=212838&r2=212839&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 11 15:22:55 2014
@@ -1515,7 +1515,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
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);
Modified: cfe/trunk/test/CodeGen/builtin-ms-noop.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-ms-noop.cpp?rev=212839&r1=212838&r2=212839&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtin-ms-noop.cpp (original)
+++ cfe/trunk/test/CodeGen/builtin-ms-noop.cpp Fri Jul 11 15:22:55 2014
@@ -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());
};
More information about the cfe-commits
mailing list