Question

I have several debugging functions throughout my code, and when the build flag -release is specified the calls are all replaced with NULL (for performance); for example:

self.condition ? NULL : NULL;

where the first and second NULLs were function calls that got replaced in preprocessing.

My question is what does this compile to, if anything? I'm using Apple's LLVM 5.1; obviously to us it's a no-op so does that mean it generates no instructions from this line? I would hope it's that way, since there's no good reason to actually execute anything.

Was it helpful?

Solution

I would guess that it would depend on context.

Since self.condition is an alias for [self condition] that call can only be omitted if the compiler can positively assert that [self condition] has no side effects. If the compiler cannot establish there are no side effects, then the entire statement can be optimized to [self condition]; yielding a slight optimization.

_condition ? NULL : NULL; should be safely dead stripped since there is no associated method call with possible side effects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top