[LLVMdev] More DIFactory questions
Devang Patel
dpatel at apple.com
Tue Aug 31 10:28:33 PDT 2010
On Aug 31, 2010, at 9:03 AM, Talin wrote:
> (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?)
$ cat foo.h
int bar() { return 42; }
$ cat foo.c
#include "foo.h"
void foo() { bar(); }
$ cat foo2.c
void foo2() { bar(); }
$ clang -c -g foo.c
Here one compile unit is created for foo.c. This compile unit will have to DIFile nodes, one for foo.c and one for foo.h
$ clang -c -g foo2.c
Here one compile unit is created for foo2.c with one DIFile node for foo2.c.
However, if you do
$ clang -c -g foo.c -o foo.o
$ clang -c -g foo2.c -o foo2.o
$ llvm-ld foo.o foo2.o
then generated bitcode file, treated as one module by the optimizer, will have two compile_units and three DIFile nodes.
I hope this helps.
-
Devang
More information about the llvm-dev
mailing list