You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[irgen] Convert emitIRGenBuiltin to use a covered switch.
This should make it easier to add new builtins by "following the warnings" and
prevent us from not handling a builtin in IRGen.
When I did this, I discovered that if I did this naively, we would have
AddressOf show up twice in the switch. This turned out to be because:
1. AddressOf is a SIL builtin that semantically is expected to only result in
SIL being emitted instead of having a builtin "addressof" be emitted.
2. For what ever reason, we actually had code in IRGen to emit an AddressOf
BuiltinInst if we saw it (which we never should have)... but also later code
asserted that we would never see it b/c it is a "SIL only builtin".
3. When I converted the if statements to be case statements, helpfully the
compiler told me I had a duplicate case. After investigation, I found the above
meaning that I was able to just delete the IRGen handling.
So now we properly handle AddressOf by asserting. As an additional tactic to
make "SIL only builtins" even more explicit, I added code to the SIL verifier
that validates we never see a builtin inst that is a "SIL only builtin" and
added some comments to Builtins.def that elaborate on this.
0 commit comments