This is a large rewrite of how Dwarf info for inlined functions is handled.
authorBill Wendling <isanbard@gmail.com>
Sun, 10 May 2009 23:14:38 +0000 (23:14 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 10 May 2009 23:14:38 +0000 (23:14 +0000)
commita5c8a4e4e6b2478675bf55007a3adc34dceb74ea
treef4e681ed8337794c027dd12d3854d8d4730d6e52
parentcb33799b9f4e152e3460faa83e59b53ff604c87d
This is a large rewrite of how Dwarf info for inlined functions is handled.

The DwarfWriter expects DbgScopes and DIEs to behave themselves according to
DwarfWriter's rules. However, inlined functions violate these rules. There are
two different types of DIEs associated with an inlined function: an abstract
instance, which has information about the original source code for the function
being inlined; and concrete instances, which are created for each place the
function was inlined and point back to the abstract instance.

This patch tries to stay true to this schema. It bypasses how regular DbgScopes
and DIEs are created and used when necessary. It provides special handling for
DIEs of abstract and concrete instances.

This doesn't take care of all of the problems with debug info for inlined
functions, but it's a step in the right direction. For one thing, llvm-gcc
generates wrong IR (it's missing some llvm.dbg intrinsics at the point where the
function's inlined) for this example:

#include <stdio.h>
static __inline__ __attribute__((always_inline))  int bar(int x) { return 4; }
void foo() {
  long long b = 1;
  int Y = bar(4);
  printf("%d\n", Y);
}

while clang generates correct IR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71410 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/AsmPrinter/DwarfWriter.cpp