Commit 031d998
authored
[SPIRV] Error in backend for vararg functions (#169111)
SPIR-V doesn't support variadic functions, though we make an exception
for `printf`.
If we don't error, we generate invalid SPIR-V because the backend has no
idea how to codegen vararg functions as it is not described in the spec.
We get asm like this:
```
%27 = OpFunction %6 None %7
%28 = OpFunctionParameter %4
; -- End function
```
The above asm is totally invalid, there's no `OpFunctionEnd` and it
causes crashes in downstream tools like `spirv-as` and `spirv-link`.
We already have many `printf` tests locking down that this doesn't break
`printf`, it was already handled elsewhere at the time the error check
runs.
Note the SPIR-V Translator does the same thing, see
[here](KhronosGroup/SPIRV-LLVM-Translator#2703).
---------
Signed-off-by: Nick Sarnie <[email protected]>1 parent b3b83ac commit 031d998
File tree
3 files changed
+23
-4
lines changed- llvm
- lib/Target/SPIRV
- test/CodeGen/SPIRV/function
3 files changed
+23
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
970 | 971 | | |
971 | 972 | | |
972 | 973 | | |
973 | | - | |
| 974 | + | |
| 975 | + | |
974 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
975 | 983 | | |
976 | 984 | | |
977 | 985 | | |
| |||
988 | 996 | | |
989 | 997 | | |
990 | 998 | | |
991 | | - | |
| 999 | + | |
| 1000 | + | |
992 | 1001 | | |
993 | 1002 | | |
994 | 1003 | | |
| |||
1097 | 1106 | | |
1098 | 1107 | | |
1099 | 1108 | | |
1100 | | - | |
| 1109 | + | |
1101 | 1110 | | |
1102 | 1111 | | |
1103 | 1112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments