[cfe-commits] [patch] Add codegen for the __noop intrinsic

Nico Weber thakis at chromium.org
Tue Sep 25 23:36:17 PDT 2012


On Wed, Sep 26, 2012 at 3:06 PM, Nico Weber <thakis at chromium.org> wrote:
> On Wed, Sep 26, 2012 at 2:49 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>> On Tue, Sep 25, 2012 at 10:05 PM, Nico Weber <thakis at chromium.org> wrote:
>>> Hi,
>>>
>>> similar to the __debugbreak patch, this adds codegen support for __noop.
>>
>> You don't actually have to call llvm.donothing... like the name says,
>> it doesn't do anything. :)  "return RValue::get(0);" should be
>> sufficient.
>
> My patch has nicer -S -emit-llvm output :-) But sure, I'll change it.
>
>>
>> Do we actually perform semantic analysis correctly for __noop?
>
> Not completely.
>
>> In MSVC, are the arguments unevaluated in the semantic analysis sense?
>
> cl seems to do sema for __noop, __noop(3 + someclassinstanc) results
> in a syntax error. So does wrapping a statement in __noop.
>
>> Do we do the right thing for expressions with non-POD type?
>> Expressions with cleanups?
>
> It looks like cl runs cleanups, __noop(MyClass()) runs destructors
> with cl (but not with clang). Do you want me to fix this before
> landing this patch?

Err, this is actually not true.

C:\src\chrome\src>type test.cc
#include <stdio.h>

class A {
 public:
  A() {printf("constr\n");}
  A(int) {printf("constr int\n");}
  ~A() {printf("cleanup\n");}
};

void g() {
  printf("g\n");
}

int h() {
  printf("h\n");
  return 0;
}

int j(const A& a) {
  printf("j\n");
  return 0;
}

int main() {
  //A a;
  //__noop(5 + a);  // errors in both msvc and clang
  __noop(A());
  __noop(g());
  __noop(A(h()));
  __noop(j(A()));
  __noop(A(4));
}

C:\src\chrome\src>cl test.cc
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cc
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj

C:\src\chrome\src>test
rem no output

>
>>
>> -Eli



More information about the cfe-commits mailing list