Commit 01b4490
Avoid calling ambiguous intrinsics from emulation builtins
If GenISA intrinsics are declared in OpenCL C as follows:
```c
extern double GenISA_fma_rtz(double, double, double);
```
Clang produces the following LLVM function declaration:
```llvm
declare dso_local double @GenISA_fma_rtz(double, double, double)
```
The issue is that the declaration is not mangled, so the same function
name will be produced for double and float types. If a kernel needs multiple
emulation builtins to be imported and some of them need `float` version of
`GenISA_fma_rtz` and some of them need `double` version of `GenISA_fma_rtz`,
then LLVM treats them both as the same function, hence it inserts a `bitcast`
instruction for one of them (depending on which one was imported first):
```llvm
float bitcast (double (double, double, double)* @GenISA_fma_rtz to float (float, float, float)*)(float %div, float 0xBE98000000000000, float %div)
```
It is incorrect, because we call `double` version of the intrinsic, even
though the intention was to call the `float` version.
The solution for this issue is to add manual mangling to GenISA externs:
```c
extern double GenISA_fma_rtz_f64(double, double, double);
```
(cherry picked from commit aecdc4c)1 parent 78191e6 commit 01b4490
File tree
10 files changed
+4507
-3485
lines changed- IGC
- Compiler
- Builtins
- Optimizer
- tests/PreCompiledFuncImport
- common
10 files changed
+4507
-3485
lines changedLarge diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
| 638 | + | |
644 | 639 | | |
645 | 640 | | |
| 641 | + | |
646 | 642 | | |
647 | 643 | | |
648 | 644 | | |
| |||
756 | 752 | | |
757 | 753 | | |
758 | 754 | | |
759 | | - | |
| 755 | + | |
760 | 756 | | |
761 | 757 | | |
762 | 758 | | |
763 | | - | |
| 759 | + | |
764 | 760 | | |
765 | 761 | | |
766 | 762 | | |
767 | | - | |
| 763 | + | |
768 | 764 | | |
769 | 765 | | |
770 | 766 | | |
| |||
794 | 790 | | |
795 | 791 | | |
796 | 792 | | |
797 | | - | |
| 793 | + | |
798 | 794 | | |
799 | 795 | | |
800 | 796 | | |
801 | | - | |
| 797 | + | |
802 | 798 | | |
803 | 799 | | |
804 | 800 | | |
805 | | - | |
| 801 | + | |
806 | 802 | | |
807 | 803 | | |
808 | 804 | | |
| |||
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| |||
0 commit comments