[LLVMdev] More DIFactory questions

Talin viridia at gmail.com
Tue Aug 31 09:03:31 PDT 2010


Here are some issues that I am unclear about. What would be great is if the
answers could be incorporated into the comments and documentation for
DIFactory and DebugInfo.h:

1) What types of DIScope are valid arguments for DebugLoc::get()? The method
takes an MDNode* argument, so looking at the function signature is no help.

For example, DIFile is a subtype of DIScope, however looking
at DwarfDebug::recordSourceLine, I see that DIFile scopes are not valid for
source lines.

2) What is the proper DIScope for executable code that is not part of a
source-level function? For example, suppose I have code that is used to
generate the initialization expression for a static variable. A similar
example would be a default constructor, or any of the various implicit
casting functions used when dealing with dynamic types. Now, although that
code is in an LLVM function, that function was synthesized by the compiler
and was never defined in any source file, so even if I were to create a
DISubprogram scope for it, there's no valid source location information for
it.

If DIFile were allowed as a scope, then the issue would be straightforward,
I would just declare the scope to be the source file.

3) Similarly, suppose I have synthesized code that is taken from a different
module. An example is a static variable contained within a template defined
in a different source file. Again, if DIFile were allowed as a scope, then
I'd simply use the file which originally defined the template. I don't think
I can use DICompileUnit, since (I'm guessing) only one of those are allowed
per module.

(Side note: I've never understood the relationship between DICompileUnit and
DIFile. I'm guessing, however, that DICompileUnit acts like a container for
all of the DIDescriptors within a module - that is, even if the DIDescriptor
is referring to an external symbol, the compile unit for that descriptor is
the module *containing* the reference, not the module of the *target* of the
reference. DIFile, on the other hand, is I think the target. If this is not
the case, then why have both?)

If my assumptions are correct, then, you can't have more than one
DICompileUnit per module, and the only way for code that was inlined from
another module to indicate where it came from is to have a scope which is a
DISubprogram, where that subprogram's DIFile is the file from where the code
was defined. However, if the code didn't come from a function but was
synthesized by the compiler, then I'm not sure how to generate a valid
DISubprogram.

4) What is the meaning of the "inlinedAt" argument for DebugLoc::get()? Does
it mean the location where the inlined code was defined, or the location
where it was expanded?

-- 
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100831/e0f2a367/attachment.html>


More information about the llvm-dev mailing list