LLVM DebugInfoBuilder

Hi list,
hi Talin,

I'm working on a frontend to generate IR using the IRBuilder from LLVM.

Now I want to add source-level-debuginfo and for that I would like to use the DebugInfoBuilder as it is taking some of the burderns. Unfortunately it does not take all of them, yet.

As of today, even in SVN, it only can add a part of information needed. Of course I also need stoppoint, declare, function.start and region.start - all the stuff for inside a basicblock.

I'm relatively new to LLVM's Builder-idea, but I'm learning fast ;).

So, let me ask, before adding anything to this class myself, is it

a) the correct way to add the basic-block-stuff to this class?

b) has someone already done something in that direction which is can be shared? :slight_smile:

best regards,
Patrick.

Instead of DebugInfoBuilder, I'd strongly recommend taking a look at include/llvm/Analysis/DebugInfo.h. This is the interface that llvm-gcc and clang both use to produce debug info. If it's ok with Talin, I'd like to eventually remove DebugInfoBuilder. Analysis/DebugInfo.h provides a nice and efficient API for both creating and reading debug info, and abstracts the clients from the actual form (e.g. serialized into GlobalVariables) that the debug info takes.

-Chris

Fine by me :slight_smile:

Fine by me :slight_smile:

Is it ok to remove DebugInfoBuilder now? I don’t think that anything in the tree is using it, what do you think Talin?

-Chris

Sure. My own compiler doesn’t even use it at the moment (I had to rewrite the code generator, and the new version doesn’t yet support debug info.)

Looking at DebugInfo.h, there are a couple of minor features that DebugInfoBuilder that I would miss:

  1. The ability to pass in an LLVM type and have it figure out the size, alignment, etc. without having to explicitly pass those values in as parameters to the builder call.

  2. The ability for the size & alignment to be specified as Constants rather than as int64 so that the “gep trick” can be used to generate target-agnostic debug info. (I don’t know if there are other aspects of the debug info which would prevent it from being target-agnostic.)

– Talin

DebugInfo.h is very light weight interface that allows one to manipulate llvm values that holds debugging information directly.

Looking at DebugInfo.h, there are a couple of minor features that DebugInfoBuilder that I would miss:

  1. The ability to pass in an LLVM type and have it figure out the size, alignment, etc. without having to explicitly pass those values in as parameters to the builder call.

This can be added. But note, LLVM type lose lots info that can be expressed in a debugging information format like DWARF.

Devang Patel wrote:

DebugInfo.h is very light weight interface that allows one to manipulate llvm values that holds debugging information directly.

Looking at DebugInfo.h, there are a couple of minor features that DebugInfoBuilder that I would miss:

1) The ability to pass in an LLVM type and have it figure out the size, alignment, etc. without having to explicitly pass those values in as parameters to the builder call.

This can be added. But note, LLVM type lose lots info that can be expressed in a debugging information format like DWARF.

I understand - which is why the DebugInfoBuilder class took additional parameters to supply the missing information. In other words, instead of 8 parameters to describe a type, it accepted an LLVM type + 4 additional parameters. That also allowed the DebugInfoBuilder to measure the size of the type using a constant GEP rather than having the application programmer supply a hard-coded size.