[llvm] Add DW_CC_nocall to function debug metadata when either return values or argum...
authorVenkata Ramanaiah Nalamothu <VenkataRamanaiah.Nalamothu@amd.com>
Mon, 6 Jun 2022 15:37:09 +0000 (21:07 +0530)
committerVenkata Ramanaiah Nalamothu <VenkataRamanaiah.Nalamothu@amd.com>
Tue, 14 Jun 2022 22:00:15 +0000 (03:30 +0530)
commit340b0ca90095d838f095271aaa1098fa1bd5ecbe
treee310e9b57b8de1ea4f42998d810b1d9dd5bdb461
parentd3b179684205ef8ba7bc5a388e013a813983fc8a
[llvm] Add DW_CC_nocall to function debug metadata when either return values or arguments are removed

Adding the `DW_CC_nocall` calling convention to the function debug metadata is needed when either the return values or the arguments of a function are removed as this helps in informing debugger that it may not be safe to call this function or try to interpret the return value.
This translates to setting `DW_AT_calling_convention` with `DW_CC_nocall` for appropriate DWARF DIEs.

The DWARF5 spec (section 3.3.1.1 Calling Convention Information) says:

If the `DW_AT_calling_convention` attribute is not present, or its value is the constant `DW_CC_normal`, then the subroutine may be safely called by obeying the `standard` calling conventions of the target architecture. If the value of the calling convention attribute is the constant `DW_CC_nocall`, the subroutine does not obey standard calling conventions, and it may not be safe for the debugger to call this subroutine.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D127134
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll