Specifically, I have some Swift 3.0 logging functions that wrap all of their statements in an if
that only executes when an operation on two static const
values bridged in from ObjC has a nonzero result.
func logStuff(_ message: @autoclosure () -> String) {
if a & b != 0 {
// log stuff here...
}
}
Variables a
and b
are declared in my bridging header like this:
static const NSUInteger a = <some literal>;
static const NSUInteger b = <some literal>;
Will the compiler elide the entire call to logStuff()
when the result of a & b
is zero and whole module optimization is enabled?
A specific answer to this question would be appreciated, but a way to easily see what optimizations are actually applied by LLVM in any situation would be ideal.