Commit 3beec2f
authored
[flang] do not rely on existing fir.convert in TargetRewrite (llvm#157413)
TargetRewrite is doing a shallow rewrite of function signatures. It is
only rewriting function definitions (FuncOp), calls (CallOp) and
AddressOfOp. It is not trying to visit each operations that may have an
operand with a function type.
It therefore needs function signature casts around the operations it is
rewriting.
Currently, these casts were not inserted after AddressOfOp rewrites
because lowering tends to always insert function cast after generating
AddressOfOp to the void type so the pass relied on implicitly updating
this cast operand type to get the required cast. This is brittle because
there is no guarantee such convert must be here and canonicalization and
passes may remove them.
Insert a cast after on the result of rewritten operations. If it is
redundant, it will be canonicalized away later.1 parent b45f1fb commit 3beec2f
File tree
2 files changed
+25
-5
lines changed- flang
- lib/Optimizer/CodeGen
- test/Fir
2 files changed
+25
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1336 | 1336 | | |
1337 | 1337 | | |
1338 | 1338 | | |
1339 | | - | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
1340 | 1348 | | |
1341 | 1349 | | |
1342 | 1350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
65 | | - | |
66 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
67 | 78 | | |
68 | 79 | | |
69 | 80 | | |
| |||
95 | 106 | | |
96 | 107 | | |
97 | 108 | | |
98 | | - | |
99 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| |||
0 commit comments