Vladislav Dzhidzhoev 82ba3f5d31
[clang][DebugInfo] Clear retained nodes list of vararg trunk's DISubprogram (#167758)
This fixes the issue reported in
https://github.com/llvm/llvm-project/pull/166855#issuecomment-3518604073
that had been revealed after
https://github.com/llvm/llvm-project/pull/166855 was merged.

`CodeGenFunction::GenerateVarArgsThunk` creates thunks for vararg
functions by cloning and modifying them. It is different from
`CodeGenFunction::generateThunk`, which is used for Itanium ABI.

According to https://reviews.llvm.org/D39396,
`CodeGenFunction::GenerateVarArgsThunk` may be called before metadata
nodes are resolved. So, it tries to avoid remapping DISubprogram and all
metadata nodes it references inside `CloneFunction()` by manually
cloning DISubprogram.

If optimization level is not OptNone, DILocalVariables for a function
are saved in DISubprogram's retainedNodes field. When
`CodeGenFunction::GenerateVarArgsThunk` clones such DISubprogram without
remapping, it produces a subprogram with incorrectly-scoped retained
nodes. It triggers Verifier checks added in
https://github.com/llvm/llvm-project/pull/166855.

To solve that, retained nodes list of a cloned DISubprogram is cleared.
2025-11-17 13:10:54 +01:00
..
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-06-23 22:45:17 -07:00
2023-08-28 12:13:42 -04:00
2023-01-08 10:35:26 +01:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00