Community
cancel
Showing results for 
Search instead for 
Did you mean: 
kfsone
New Contributor I
113 Views

Question about warning C4740

[bash] warning C4740: flow in or out of inline asm code suppresses global optimization[/bash]
This error is a little ambiguous: What is the scope of the suppression? I'm assuming it just means "cannot include this function in global optimization", but on the other hand, the builds are so fast when this error pops up that I get the impression they were suppressed for the entire link.
(Which is annoying, since the debug version of this library is compiled with global optimization enabled too, forcing the link to start over with /LTCG only to then appear not to actually do global optimization)
0 Kudos
2 Replies
Yang_W_Intel
Employee
113 Views

Here is the explaination for C4740:
http://msdn.microsoft.com/en-us/library/s93ckwz6(VS.80).aspx

Compiler Warning (Level 4) C4740

Error Message

flow in or out of inline asm code suppresses global optimization

When there is a jump in to or out of an asm block, global optimizations are disabled for that function.

The following sample generates C4740:

// C4740.cpp

// compile with: /O2 /W4

// processor: x86

int main() {

__asm jmp tester

tester:;

Brandon_H_Intel
Employee
113 Views

I can really only speak to the Intel compiler here, so I'm not sure what Microsoft's compiler is exactly disabling, but most "global" optimizations (for example mod/ref aliasing analysis)are unable to work with such a structure, and since any such optimization requires a global scope to work (hence why it's a global optimization), the existence of such a construct precludes it from occuring where flow information is necessary.

And in fact, this kind of construct also hinders some globaloptimizations that just occur across basic blocks, so it's not justinterprocedural globaloptimizations that are going to be affected. The basic takeawayis that if you have such a construct and can re-code it so that the code doesn't use them, better performance is quite possible.

Reply