diff options
| author | Julius Ikkala <julius.ikkala@gmail.com> | 2025-10-10 19:41:13 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-10 16:41:13 +0000 |
| commit | 48afbf9a1075fcf541b2c196c6313aeda57e9637 (patch) | |
| tree | 15f05ac8bb78d54a90f60b6b6fae8712db681186 /source/slang/slang-ir-lower-generic-type.cpp | |
| parent | 5c672cef1f6ac6b5cd6cd71bd47489b7b7331adb (diff) | |
Specialize interfaces in DebugFunction (#8617)
E.g. in
[generic-extension-2.slang](https://github.com/shader-slang/slang/blob/master/tests/language-feature/extensions/generic-extension-2.slang),
incorrect DebugFunctions are generated for `getFirstOuter`:
```
let %33 : Void = DebugFunction("getFirstOuter", 18 : UInt, 3 : UInt, %26, Func(Int, 0 : Int))
```
This happens because specialization passes are leaving a `%IFoo` in the
function type, instead of replacing with a concrete type:
```
let %34 : Void = DebugFunction("getFirstOuter", 18 : UInt, 3 : UInt, %26, Func(Int, %IFoo))
```
and later, `cleanUpInterfaceTypes()` just replaces all interfaces with
the literal zero. So now we have a parameter type which isn't actually a
type at all, but an IntLit instead.
I'm not sure if the approach I picked is good, though. Some other
options that crossed my mind were:
* Make `fixUpFuncType` also update related DebugFunctions
- But is there a reason why DebugFunctions separately carry a function
type in the first place?
* Make `cleanUpInterfaceTypes` less aggressive or at least replace types
with a type instead of a value
- But this will still make the debug info incorrect :(
Diffstat (limited to 'source/slang/slang-ir-lower-generic-type.cpp')
| -rw-r--r-- | source/slang/slang-ir-lower-generic-type.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/slang/slang-ir-lower-generic-type.cpp b/source/slang/slang-ir-lower-generic-type.cpp index 9579b0a2b..c4dcd92a9 100644 --- a/source/slang/slang-ir-lower-generic-type.cpp +++ b/source/slang/slang-ir-lower-generic-type.cpp @@ -50,6 +50,14 @@ struct GenericTypeLoweringContext structField->setOperand(1, loweredFieldType); } break; + case kIROp_DebugFunction: + { + auto oldFuncType = as<IRDebugFunction>(inst)->getDebugType(); + auto newFuncType = sharedContext->lowerType(builder, oldFuncType); + if (newFuncType != oldFuncType) + inst = builder->replaceOperand(inst->getOperandUse(4), newFuncType); + } + break; } return inst; } |
