[LLVMdev] How to insert two instructions with the same name?

Reid Spencer rspencer at reidspencer.com
Sun Oct 8 11:16:35 PDT 2006


Just to be clear ...

On Sun, 2006-10-08 at 01:37 -0700, Bill Wendling wrote:
> On Oct 8, 2006, at 1:15 AM, Zhou Sheng wrote:

> > Actually, i found that sometimes, llvm will create bytecode  
> > containing two instructions with same name. So, how can i implement  
> > that?
> >
> Again, the names are meaningless and are given only because the user  
> needs to be able to understand the .ll code. So it's entirely  
> possible to have multiple variables with the same name.

The same variable name can only appear across "type planes". That is,
there cannot be two identical names that refer to the same type.
However, the same name can be used to refer to different types.  To
assist in this, the LLVM SymbolTable will automatically append an
monotonically increasing integer value to the name of any duplicate.
For example:

void %func() { 
  %s = cast int 1 to int
  %s = cast long 1 to long
  %a = cast int 2 to int
  %a = cast long 2 to long
ret void 
}

is completely legal. The %s and %a names don't conflict because they
have different types (int and long).

Reid.




More information about the llvm-dev mailing list