4 ms·
That particular behavior (and some other examples of pathological optimizer behavior) is probably an emergent property of how several optimizations combine as o
by aw1621107 7y ago
That particular behavior (and some other examples of pathological optimizer behavior) is probably an emergent property of how several optimizations combine as opposed to being a specifically targeted optimization. I can imagine something the optimizer doing something like:
1. Determine possible function call targets
2. Eliminate invalid targets from call set
3. If only one target remains, replace indirect call with direct call
That might be useful for something like devirtualization, but also could lead to the behavior exhibited in that blog post.
Indeed, the second blog post [0] shows that if there are two possible call targets, LLVM could generate an indirect call like what you may expect.
[0]: https://kristerw.blogspot.com/2017/09/follow-up-on-why-undefined-behavior-may.html https://kristerw.blogspot.com/2017/09/follow-up-on-why-undef...