[PATCH] DW_TAG_typedef and DW_TAG_structure_type not emitted when typedef is used

jyoti allur jyoti.yalamanchili at gmail.com
Tue Sep 16 07:46:07 PDT 2014


Hi David,

>>! In D2498#9, @dblaikie wrote:
>>>! In D2498#4, @jyoti.yalamanchili wrote:
>> This bug appears only when typedef is used.
> 
> Doesn't look like it.
This was my previous analysis which was incorrect. This issue occurs whenever explicit casting occurs. The type to which we are explicitly casting is not emitted in debug info.
> 
> Changing the code to cast to (S*) instead of (T) still demonstrates the bug and is still present even with this patch applied.
> 
As you mentioned, I verified this for the following code snippet where i am replacing T with struct S* and the result was that DW_TAG_structure_type & DW_TAG_member were emitted but not DW_TAG_typedef because T was not used. I thought this is expected behaviour. Please correct me if i am wrong.

typedef struct S {
  int i;
} *T;
#define M(p) (**(struct S*)**(p))

void foo(void *p) { M(p)->i++; }


> The problem is more general than typedefs and casts - arguably we should get this (C++11) case too:
> 
>   struct S { int i; };
>   void func(S);
>   void func() {
>     func(S{42});
>   }
> 
> but GCC doesn't get this either, so I'm less concerned.
> 
> GCC does get the cast case - with or without a typedef. So perhaps we can just deal with casts for now... 
> 
Okay. 

> The only other thing I can think of is far more invasive/more work - to get this all right, what we really need is a tree of "completeness" - keeping track of any time a type is required to be complete (not just a single bit that says "this has been required to be complete") & then emitting any type for which it was requried to be complete during a function we codegen'd.
> 
Sorry, could you please explain this with an example ?
I could mention this in the testcase as a TODO note if you want so we don't loose track of this improvement scope.

> This infrastructure would also allow us to do a better job minimizing debug info for the limited debug info optimization where we currently fail:
> 
>   struct foo { ... };
>   inline void unused() { foo f; } // 'f' is required to be complete here, but the function is never called
>   foo *f; // but that required completeness is never relied upon for this TU - a declaration would've sufficed
> 
> This hurts us in, for example, Clang's own Sema.h - the giant Sema class has a single non-member inline function right after it that has dereferences a Sema pointer, thus requiring Sema to be complete. From then on, if anything else in the TU including Sema.h requires Sema (evern just a pointer to it it) the debug info for the entire class will be emitted.

If i understand this correctly, point of worry here is about the increase in debug info size, am i right? But, we certainly need the debug info of any referenced variables isn't ?

http://reviews.llvm.org/D2498






More information about the cfe-commits mailing list