Regarding anonymous types

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Regarding anonymous types

Pankaj Gode
Hi All,
 
While collecting type information for "anonymous types", I had below observation.
 
For the example with anonymous types, given below
struct test
{
  struct {
    union {
      Char a[4];
    };
  };
  struct {
    int b;
    char c;
  };
};
 
LLVM 2.6 defines the types as
%struct.anon1 = type { %union.anon0}
%struct.anon2 = type { i32, i8}
%struct.test = type { %struct.anon1, %struct.anon2}
%union.anon0 = type {[4 x i8]}
 
Whereas, LLVM 2.9 defines the types as
%0 = type { i32, i8}
%anonanonct. = type {%anonanonn.}
%anonanonn.  = type { [ 4x i8] }
%struct.test = type { %anonanonct., %0}
 
In case of LLVM2.9, "%0" is interesting case. 
When I try to extract types using "Module_Ptr->getTypeSymbolTable()".
for(TypeSymbolTable::const_iterator I = M->getTypeSymbolTable().begin(),
      E = M->getTypeSymbolTable().end(); I != E; ++I) {
   if( I->second->isStructTy() )
   {
     //code to collect type names
   }    
}
 
I don't get this type in TypeSymbolTable.  :(
 
Though
struct{
 union {
   char a[4];
 };
};
too is anonymous, but a name is given to it, i.e anonanonct.
 
I need this information as I want to collect all type-names.
 
 
Thanks & Regards,
Pankaj
 
 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Regarding anonymous types

Devang Patel
Pankaj,

I encourage you to read Chris's excellent blog entry on type system @ http://blog.llvm.org/2011/11/llvm-30-type-system-rewrite.html
-
Devang

On Dec 6, 2011, at 3:54 AM, Pankaj Gode wrote:

Hi All,
 
While collecting type information for "anonymous types", I had below observation.
 
For the example with anonymous types, given below
struct test
{
  struct {
    union {
      Char a[4];
    };
  };
  struct {
    int b;
    char c;
  };
};
 
LLVM 2.6 defines the types as
%struct.anon1 = type { %union.anon0}
%struct.anon2 = type { i32, i8}
%struct.test = type { %struct.anon1, %struct.anon2}
%union.anon0 = type {[4 x i8]}
 
Whereas, LLVM 2.9 defines the types as
%0 = type { i32, i8}
%anonanonct. = type {%anonanonn.}
%anonanonn.  = type { [ 4x i8] }
%struct.test = type { %anonanonct., %0}
 
In case of LLVM2.9, "%0" is interesting case. 
When I try to extract types using "Module_Ptr->getTypeSymbolTable()".
for(TypeSymbolTable::const_iterator I = M->getTypeSymbolTable().begin(),
      E = M->getTypeSymbolTable().end(); I != E; ++I) {
   if( I->second->isStructTy() )
   {
     //code to collect type names
   }    
}
 
I don't get this type in TypeSymbolTable.  :(
 
Though
struct{
 union {
   char a[4];
 };
};
too is anonymous, but a name is given to it, i.e anonanonct.
 
I need this information as I want to collect all type-names.
 
 
Thanks & Regards,
Pankaj
 
 
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Regarding anonymous types

Duncan Sands
In reply to this post by Pankaj Gode
Hi Pankaj, everything is different in the just release LLVM 3.0: the type system
was rewritten.  I think Chris wrote a blog post explaining the changes.  In
terms of LLVM-2.9 and earlier, please note that type names are meaningless and
are only produced by the front-end to make debugging LLVM IR easier.  You can't
expect to reliably discover which types correspond to types in the source using
type names for example, for that you need to use debug info.

Ciao, Duncan.

> While collecting type information for "anonymous types", I had below observation.
> For the example with anonymous types, given below
> struct test
> {
> struct {
> union {
> Char a[4];
> };
> };
> struct {
> int b;
> char c;
> };
> };
> LLVM 2.6 defines the types as
> %struct.anon1 = type { %union.anon0}
> %struct.anon2 = type { i32, i8}
> %struct.test = type { %struct.anon1, %struct.anon2}
> %union.anon0 = type {[4 x i8]}
> Whereas, LLVM 2.9 defines the types as
> %0 = type { i32, i8}
> %anonanonct. = type {%anonanonn.}
> %anonanonn.= type { [ 4x i8] }
> %struct.test = type { %anonanonct., %0}
> In case of LLVM2.9, "%0" is interesting case.
> When I try to extract types using " Module_Ptr->getTypeSymbolTable()".
> for(TypeSymbolTable::const_iterator I = M->getTypeSymbolTable().begin(),
> E = M->getTypeSymbolTable().end(); I != E; ++I) {
> if( I->second->isStructTy() )
> {
> //code to collect type names
> }
> }
> I don't get this type in TypeSymbolTable. :(
> Though
> struct{
> union {
> char a[4];
> };
> };
> too is anonymous, but a name is given to it, i.e anonanonct.
> I need this information as I want to collect all type-names.
> Thanks & Regards,
> Pankaj
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Regarding anonymous types

Pankaj Gode
In reply to this post by Devang Patel
Thanks for sharing the link.
I had a similar link by chris, but it was a small text document.
This link was helpful in understanding how the anonymous types, and specially the numbered types, are so represented.
 
Thanks & Regards,
Pankaj
 
 

From: Devang Patel <[hidden email]>
To: Pankaj Gode <[hidden email]>
Cc: llvm Developers <[hidden email]>
Sent: Wednesday, December 7, 2011 12:06 AM
Subject: Re: [LLVMdev] Regarding anonymous types

Pankaj,

I encourage you to read Chris's excellent blog entry on type system @ http://blog.llvm.org/2011/11/llvm-30-type-system-rewrite.html
-
Devang

On Dec 6, 2011, at 3:54 AM, Pankaj Gode wrote:

Hi All,
 
While collecting type information for "anonymous types", I had below observation.
 
For the example with anonymous types, given below
struct test
{
  struct {
    union {
      Char a[4];
    };
  };
  struct {
    int b;
    char c;
  };
};
 
LLVM 2.6 defines the types as
%struct.anon1 = type { %union.anon0}
%struct.anon2 = type { i32, i8}
%struct.test = type { %struct.anon1, %struct.anon2}
%union.anon0 = type {[4 x i8]}
 
Whereas, LLVM 2.9 defines the types as
%0 = type { i32, i8}
%anonanonct. = type {%anonanonn.}
%anonanonn.  = type { [ 4x i8] }
%struct.test = type { %anonanonct., %0}
 
In case of LLVM2.9, "%0" is interesting case. 
When I try to extract types using " Module_Ptr->getTypeSymbolTable()".
for(TypeSymbolTable::const_iterator I = M->getTypeSymbolTable().begin(),
      E = M->getTypeSymbolTable().end(); I != E; ++I) {
   if( I->second->isStructTy() )
   {
     //code to collect type names
   }     
}
 
I don't get this type in TypeSymbolTable.  :(
 
Though
struct{
 union {
   char a[4];
 };
};
too is anonymous, but a name is given to it, i.e anonanonct.
 
I need this information as I want to collect all type-names.
 
 
Thanks & Regards,
Pankaj
 
 
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev