diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-10-02 15:24:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-02 15:24:46 -0700 |
| commit | 0c778339d7e3c39f600af2cc049f13f661d3434b (patch) | |
| tree | c7927a86fb2ae6e8df2fa781583179d59346e342 /source/slang/slang-ir.cpp | |
| parent | bffac95febd7a29cfac0becfcb019cd057b53765 (diff) | |
Relax the inst definition order rule (#8588)
Close #8572.
The root cause of the issue is that in `_replaceInstUsesWith` call,
if the use of the inst is a generic parameter, and the inst is the data
type of that generic parameter, we could end up of moving the data type
before the generic parameter. This will break the layout of generic
parameters, where all the generic parameters should be laid consecutively
at the beginning of the first block of the generic.
Therefore, we don't make that relocation for such case.
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 92543c952..e54238a9c 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -8164,7 +8164,12 @@ static void _maybeHoistOperand(IRUse* use) continue; // If the operand is defined after user, move it to before user. - if (_isInstDefinedAfter(operand, user)) + // There is exception that the use of an inst can be defined before the inst, + // e.g. generic parameter can be defined before its data type in some cases. + // And moving the datatype of a generic parameter before the parameter will result + // in incorrect IR layout, because we require that generic parameters are laid + // consecutively at first block of a generic. + if (_isInstDefinedAfter(operand, user) && !canRelaxInstOrderRule(operand, user)) { operand->insertBefore(user); for (UInt i = 0; i < operand->getOperandCount(); i++) |
