Commit d8f3be7
authored
[mlir][dialect-conversion] Fix OOB crash in convertFuncOpTypes for funcs with extra block args (llvm#185060)
Some function ops (e.g., gpu.func with workgroup memory arguments) have
more entry block arguments than their FunctionType has inputs. The
workgroup memory arguments are not part of the public function signature
but are present as additional block arguments.
`convertFuncOpTypes` previously created a `SignatureConversion` sized
only for `type.getNumInputs()`, then called `applySignatureConversion`
on the entry block. When the block had more arguments (e.g., workgroup
args), the loop in `applySignatureConversion` would call
`getInputMapping(i)` with out-of-bounds indices, causing an assertion
failure in `SmallVector::operator[]`.
Fix this by:
1. Sizing the `SignatureConversion` for all entry block arguments.
2. Adding identity mappings for extra block args beyond the function
type inputs.
3. Using only the converted function-type-input types when updating the
FunctionType (so extra block arg types are not included in the
signature).
Fixes llvm#184744
Assisted-by: Claude Code1 parent b78ceef commit d8f3be7
2 files changed
Lines changed: 47 additions & 8 deletions
File tree
- mlir
- lib/Transforms/Utils
- test/Transforms
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3843 | 3843 | | |
3844 | 3844 | | |
3845 | 3845 | | |
3846 | | - | |
3847 | | - | |
| 3846 | + | |
| 3847 | + | |
3848 | 3848 | | |
3849 | | - | |
| 3849 | + | |
| 3850 | + | |
3850 | 3851 | | |
3851 | 3852 | | |
3852 | | - | |
3853 | | - | |
| 3853 | + | |
| 3854 | + | |
| 3855 | + | |
| 3856 | + | |
| 3857 | + | |
| 3858 | + | |
| 3859 | + | |
| 3860 | + | |
| 3861 | + | |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
| 3868 | + | |
| 3869 | + | |
| 3870 | + | |
| 3871 | + | |
| 3872 | + | |
| 3873 | + | |
3854 | 3874 | | |
| 3875 | + | |
3855 | 3876 | | |
3856 | | - | |
3857 | | - | |
3858 | | - | |
| 3877 | + | |
| 3878 | + | |
3859 | 3879 | | |
3860 | 3880 | | |
3861 | 3881 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
0 commit comments