[CloneFunction][DebugInfo] Avoid cloning DILexicalBlocks of inlined subprograms
authorKristina Bessonova <kbessonova@accesssoftek.com>
Mon, 18 Jul 2022 11:09:29 +0000 (13:09 +0200)
committerKristina Bessonova <kbessonova@accesssoftek.com>
Mon, 18 Jul 2022 11:14:52 +0000 (13:14 +0200)
commit44736c1d497f2c269f6ef86ef7bf0e47f4869a4d
treebf9fc1a23570ff397f34829a8e2cab501225e35a
parent04e978ccba1e6c8b600b2fbad1a82b4b64ffc34b
[CloneFunction][DebugInfo] Avoid cloning DILexicalBlocks of inlined subprograms

If DISubpogram was not cloned (e.g. we are cloning a function that has other
functions inlined into it, and subprograms of the inlined functions are
not supposed to be cloned), it doesn't make sense to clone its DILexicalBlocks
as well. Otherwise we'll get duplicated DILexicalBlocks that may confuse
debug info emission in AsmPrinter.

I believe it also makes no sense cloning any DILocalVariables or maybe
other local entities, if their parent subprogram was not cloned, cause
they will be dangling and will not participate in futher emission.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D127102
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll
llvm/unittests/Transforms/Utils/CloningTest.cpp