Commit c760671
authored
[AMDGPU] Update base addr of dyn alloca considering GrowingUp stack (#119822)
Currently, compiler calculates the base address of
dynamic sized stack object (alloca) as follows:
1. `NewSP = Align(CurrSP + Size)`
_where_ `Size = # of elements * wave size * alloca type`
2. `BaseAddr = NewSP`
3. The alignment is computed as: `AlignedAddr = Addr & ~(Alignment - 1)`
4. Return the `BaseAddr`
This makes sense when stack is grows downwards.
AMDGPU stack grows upwards, the base address
needs to be aligned first and SP bump by required size later:
1. `BaseAddr = Align(CurrSP)`
2. `NewSP = BaseAddr + Size`
3. `AlignedAddr = (Addr + (Alignment - 1)) & ~(Alignment - 1)`
4. and returns the `BaseAddr`.1 parent a73ca29 commit c760671
File tree
7 files changed
+312
-215
lines changed- llvm
- lib/Target/AMDGPU
- test/CodeGen/AMDGPU
- GlobalISel
7 files changed
+312
-215
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
1207 | | - | |
| 1207 | + | |
1208 | 1208 | | |
1209 | | - | |
1210 | | - | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1211 | 1213 | | |
1212 | 1214 | | |
1213 | | - | |
| 1215 | + | |
1214 | 1216 | | |
1215 | | - | |
| 1217 | + | |
| 1218 | + | |
1216 | 1219 | | |
1217 | 1220 | | |
1218 | 1221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4016 | 4016 | | |
4017 | 4017 | | |
4018 | 4018 | | |
4019 | | - | |
4020 | | - | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
4021 | 4022 | | |
4022 | 4023 | | |
4023 | 4024 | | |
| |||
4037 | 4038 | | |
4038 | 4039 | | |
4039 | 4040 | | |
4040 | | - | |
4041 | | - | |
4042 | | - | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
4043 | 4044 | | |
4044 | 4045 | | |
4045 | 4046 | | |
4046 | 4047 | | |
| 4048 | + | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
4047 | 4060 | | |
4048 | 4061 | | |
4049 | 4062 | | |
4050 | 4063 | | |
4051 | | - | |
4052 | | - | |
4053 | | - | |
4054 | | - | |
4055 | | - | |
4056 | | - | |
4057 | | - | |
4058 | | - | |
4059 | | - | |
| 4064 | + | |
4060 | 4065 | | |
4061 | | - | |
| 4066 | + | |
4062 | 4067 | | |
4063 | 4068 | | |
4064 | | - | |
| 4069 | + | |
4065 | 4070 | | |
4066 | 4071 | | |
4067 | 4072 | | |
| |||
0 commit comments