Search code examples
cmultithreadingconcurrencycompiler-constructionlock-free

What does an opaque function call mean in compiler optimization?


What does an opaque function call mean in the compiler optimization?I'v found it in Why do global variables cause trouble for compiler optimizations in function calls?, and 'opaque function call' really confuses me. It seems that an opaque function call is the function call that the compiler has no information about it. But what does it mean?


Solution

  • As you mention in the question, an opaque function call is a call to a function that the compiler has no prior information about. This implies that the compiler can make no assumptions about the side effects of this call except what is guaranteed by the language definition. For example, since the compiler has no other information it must assume that the function call can modify any global variable and must ensure that any local changes are stored before the call, it must also reload global variables used after the call. Further, the compiler can never skip making a call to this function even when calling it looks useless since there is no way for the compiler to know this for certain.