Paste: LLVM type resolution bug(?)

Author: yuuki
Mode: c
Date: Thu, 25 Jun 2009 15:57:51
Plain Text |
#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);
}

New Annotation

Summary:
Author:
Mode:
Body: