PATCH: do ?: lowering to selects less wrong

Nick Lewycky nlewycky at
Tue Nov 5 16:54:28 PST 2013

When lowering "cond ? X : Y" we do some safety checks to see whether we can
instead emit both X and Y and use a llvm select instruction to choose
between them. This code is insufficiently safe, and introducing loads into
a program that didn't load is a bad idea. For example, it could be TLS. It
could be a non-volatile auto in another function that isn't the current
function (think lambdas).

Don't do this here. LLVM knows how to do this properly.

Patch attached, please review!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loads-arent-cheap-1.patch
Type: text/x-patch
Size: 2158 bytes
Desc: not available
URL: <>

More information about the cfe-commits mailing list