mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
All SILArgument types are "block arguments". There are three kinds: 1. Function arguments 2. Phis 3. Terminator results In every situation where the source of the block argument matters, we need to distinguish between these three. Accidentally failing to handle one of the cases is an perpetual source of compiler bugs. Attempting to handle both phis and terminator results uniformly is *always* a bug, especially once OSSA has phi flags. Even when all cases are handled correctly, the code that deals with data flow across blocks is incomprehensible without giving each case a type. This continues to be a massive waste of time literally every time I review code that involves cross-block control flow. Unfortunately, we don't have these C++ types yet (nothing big is blocking that, it just wasn't done). That's manageable because we can use wrapper types on the Swift side for now. Wrapper types don't create any more complexity than protocols, but they do sacrifice some usability in switch cases. There is no reason for a BlockArgument type. First, a function argument is a block argument just as much as any other. BlockArgument provides no useful information beyond Argument. And it is nearly always a mistake to care about whether a value is a function argument and not care whether it is a phi or terminator result.
13 KiB
13 KiB