[LLVMdev] Prevent merging of names to types

Johannes Schaub - litb schaub.johannes at googlemail.com
Wed Apr 6 08:47:10 PDT 2011

Hello all, 

in my runtime lowlevel IR module I have several type definitions, some of 
which may turn out to be structurally equivalent. They look like follows

%enumeration_ty = type { 
   ; count of enumerators
   ; enumerators
   [0 x %enumerator_ty] 

%lookupresult_ty = type {
   ; kind of lookup result

Now when I link this module to the code generation module (where I emit code 
into), llvm may unify structurally equivalent types and remove arbitrary 
names (I use Linker::LinkInFile).

Let's assume it merges "lookupresult_ty" with a structurally equivalent 
unnamed type, and decides to remove the "%lookupresult_ty" name from the 
module's symbol table. How can I access the type that lookupresult_ty was 
aliased to afterwards? I thought about adding dummy global variables whose 
type is %lookupresult_ty for retaining a handle to the type, but there must 
be a more clean way to do this. 

Thanks for any support!

More information about the llvm-dev mailing list