Commit 281187d
[triton][beta] Backport '[Triton] Fix LLVMDILocalVariable pass crash with LLVM_EXTRACT_DI_LOCAL_VARIABLES (#10042)' (#1390)
Summary:
This is a backport of an upstream PR: triton-lang/triton#10042
Upstream commit message:
```
> [Triton] Fix LLVMDILocalVariable pass crash with LLVM_EXTRACT_DI_LOCAL_VARIABLES (#10042)
> Summary:
> Fix multiple bugs in the LLVMDILocalVariable pass that caused crashes
> when running with LLVM_EXTRACT_DI_LOCAL_VARIABLES=1.
> Root cause: The MLIR DIRecursiveTypeAttrInterface uses isRecSelf=true as
> a placeholder and isRecSelf=false as its resolver. During MLIR-to-LLVM
> IR translation, the resolver recursiveNodeMap entry is temporary (popped
> after translation). Any isRecSelf=true references encountered outside
> the resolver translation scope trigger an assertion.
> The add_di_scope pass creates a DISubprogramAttr with isRecSelf=true and
> embeds it in function locations and DILexicalBlockFileAttr scopes in
> operation locations. The LLVMDILocalVariable pass was supposed to
> resolve these but had several issues.
> Fixes:
> 1. Added null/scope guard for diSubprogramAttr to skip module-level ops
> that appear before or between functions in the walk.
> 2. Fixed getDISubprogramAttr(Operation op) to take Operation *op.
> 3. Restructured fuseFuncArgVariables to create two sets of
> DILocalVariableAttr: one with isRecSelf=true scope for retainedNodes
> (correct recursive pattern), and separate ones with the resolved
> isRecSelf=false scope for DbgValueOps (avoids unresolvable refs).
> 4. Added fixLexicalBlockScopes to walk operations and replace
> DILexicalBlockFileAttr scopes that reference the old isRecSelf=true
> subprogram with the resolved version.
> 5. Value-initialized diSubprogramAttr to avoid undefined behavior.
> Test Plan:
> TRITON_ALWAYS_COMPILE=1 LLVM_EXTRACT_DI_LOCAL_VARIABLES=1 \
> python3 python/tutorials/02-fused-softmax.py
> <!---
> The core Triton is a small number of people, and we receive many PRs
> (thank
> you!). To help us review your code more quickly, **if you are a new
> contributor (less than 3 PRs merged) we ask that you complete the
> following
> tasks and include the filled-out checklist in your PR description.**
> Complete the following tasks before sending your PR, and replace `[ ]`
> with
> `[x]` to indicate you have done them.
> -->
> # New contributor declaration
> - [x] I am not making a trivial change, such as fixing a typo in a
> comment.
> - [x] I have written a PR description following these
> [rules](https://cbea.ms/git-commit/#why-not-how).
> - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`.
> - Select one of the following.
> - [X] I have added tests.
> - `/test` for `lit` tests
> - `/unittest` for C++ tests
> - `/python/test` for end-to-end tests
> - [ ] This PR does not need a test because `FILL THIS IN`.
> - Select one of the following.
> - [ ] I have not added any `lit` tests.
> - [x] The `lit` tests I have added follow these [best
> practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices),
> including the "tests should be minimal" section. (Usually running Python
> code
> and using the instructions it generates is not minimal.)
> Co-authored-by: Bill Yoshimi <byoshimi@fb.com>
> Co-authored-by: Corbin Robeck <robeck@meta.com>
```
***Do not remove the following line from this commit***
Reactor Backport Revision: 5b3965b27eb331094854963b751709bcb148c3d4
---
This diff was generated by running:
```
buck run fbcode//triton/tools/reactor:reactor -- backport --pr 10042
```
Differential Revision: D1028596871 parent aac961f commit 281187d
2 files changed
Lines changed: 165 additions & 20 deletions
File tree
- lib/Target/LLVMIR
- test/LLVMIR
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
| |||
201 | 207 | | |
202 | 208 | | |
203 | 209 | | |
204 | | - | |
| 210 | + | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
| |||
213 | 219 | | |
214 | 220 | | |
215 | 221 | | |
216 | | - | |
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
220 | 225 | | |
221 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
222 | 229 | | |
223 | 230 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
228 | 234 | | |
229 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
230 | 247 | | |
231 | 248 | | |
232 | 249 | | |
| |||
236 | 253 | | |
237 | 254 | | |
238 | 255 | | |
239 | | - | |
240 | | - | |
241 | 256 | | |
| 257 | + | |
242 | 258 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 259 | + | |
| 260 | + | |
250 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
251 | 265 | | |
252 | 266 | | |
| 267 | + | |
253 | 268 | | |
254 | 269 | | |
255 | 270 | | |
| |||
262 | 277 | | |
263 | 278 | | |
264 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
265 | 294 | | |
266 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
267 | 303 | | |
268 | 304 | | |
269 | 305 | | |
270 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
271 | 365 | | |
272 | | - | |
| 366 | + | |
273 | 367 | | |
274 | 368 | | |
275 | 369 | | |
276 | 370 | | |
277 | 371 | | |
278 | 372 | | |
279 | 373 | | |
280 | | - | |
281 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
282 | 386 | | |
283 | 387 | | |
284 | 388 | | |
| |||
| 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 | + | |
| 41 | + | |
0 commit comments