[LLVMbugs] [Bug 4446] New: Constructing recursive type { \1* } fails: unnecessarily resolves to abstract type

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Jun 25 09:08:04 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=4446

           Summary: Constructing recursive type { \1* } fails: unnecessarily
                    resolves to abstract type
           Product: new-bugs
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: tinmanmoves at gmail.com
                CC: llvmbugs at cs.uiuc.edu


In pseudo-code:

%p = type opaque*
%q = type %q
%r = type %q*
resolve(%q, %r)
... leads to type %t = type \1*

Using the same method for { \1* } :

%p = type opaque*
%q = type { %p }
%r = type { %p* }
resolve(%q, %r)
... leads to type { opaque** }, when I expect something equivalent to { \1* }

Below is the C code to reproduce this problem:

#include <llvm-c/Core.h>

int main (int argc, const char * argv[]) {
  LLVMTypeHandleRef handle;
  LLVMTypeRef concrete;

  // type \1*
  LLVMTypeRef back1star = LLVMPointerType(LLVMOpaqueType(), 0);
  concrete = LLVMPointerType(back1star, 0);
  handle = LLVMCreateTypeHandle(back1star);
  LLVMRefineType(back1star, concrete);
  back1star = LLVMResolveTypeHandle(handle);
  LLVMDisposeTypeHandle(handle);

  // type { \1* }
  LLVMTypeRef inner_back1star = LLVMPointerType(LLVMOpaqueType(), 0);
  LLVMTypeRef struct_back1star = LLVMStructType(&inner_back1star, 1, 0);
  LLVMTypeRef inner_concrete = LLVMPointerType(inner_back1star, 0);
  concrete = LLVMStructType(&inner_concrete, 1, 0);
  handle = LLVMCreateTypeHandle(struct_back1star);
  LLVMRefineType(struct_back1star, concrete);
  struct_back1star = LLVMResolveTypeHandle(handle);
  LLVMDisposeTypeHandle(handle);

  /* output:

   ; ModuleID = 'type-info'
     type opaque                ; type %0
     %back1star = type %back1star*
     %struct_back1star = type { %0** }

   expected:

   ; ModuleID = 'type-info'
     %back1star = type %back1star*
     %struct_back1star = type { \1* }

   or:

   ; ModuleID = 'type-info'
     type \1*           ; type %0
     %back1star = type %back1star*
     %struct_back1star = type { %0 }

   */
  LLVMModuleRef m = LLVMModuleCreateWithName("type-info");
  LLVMAddTypeName(m, "back1star", back1star);
  LLVMAddTypeName(m, "struct_back1star", struct_back1star);
  LLVMDumpModule(m);
  LLVMDisposeModule(m);
}


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list