| ▲ | im3w1l 9 hours ago | |||||||||||||||||||||||||||||||||||||||||||
> No, that’s not why the /EHa option results in less efficient code. The possibility that any memory access or arithmetic operation could trigger an exception significantly impairs optimization opportunities. It means that all variables must be stable at the point memory accesses occur. This is a good insight but I feel like stopping the analysis here is a little bit too early. We should also think about what they actually wanted to achieve. Did they actually need all variables to be stable at the point of any memory access? Maybe they want 90% of the benefits at 10% of the cost somehow? | ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | nwallin 5 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
> Did they actually need all variables to be stable at the point of any memory access? One of the most important optimizations that a compiler can do is keeping a variable in a register and never even bother letting it hit memory in the first place. If every variable must get its own RAM address and the value at that RAM address must be faithful to a variable's "true" value at any given instruction, we should expect our software to slow down by an order of magnitude or two. | ||||||||||||||||||||||||||||||||||||||||||||
| ▲ | StilesCrisis 9 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
I don’t think there is a version of UB that gives you a predictable 90%, though. Either your program is exception-safe or it’s not. There’s no such thing as 90% safe. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||