Zhou Sheng
2006-Oct-08 08:15 UTC
[LLVMdev] How to insert two instructions with the same name?
Hi, i want to insert a PHI into one basicblock like this: %s.1 = phi int [ 80, %entry ], [ %tmp21, %bb17 ] then, insert a cast inst. into another basicblock like this: %s.1 = cast int %s.1 to uint But, when i do this, the llvm automatically change the same name into a new one. Actually, i found that sometimes, llvm will create bytecode containing two instructions with same name. So, how can i implement that? Thanks, Sheng. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20061008/17b4fc85/attachment.html>
Bill Wendling
2006-Oct-08 08:37 UTC
[LLVMdev] How to insert two instructions with the same name?
On Oct 8, 2006, at 1:15 AM, Zhou Sheng wrote:> i want to insert a PHI into one basicblock like this: > > %s.1 = phi int [ 80, %entry ], [ %tmp21, %bb17 ] > > then, insert a cast inst. into another basicblock like this: > > %s.1 = cast int %s.1 to uint > > But, when i do this, the llvm automatically change the same name > into a new one. >In SSA, any assignment creates a new variable. So it'd probably be called something like "%s.2" or whatever. Technically, LLVM doesn't care what the names of these variables are. They aren't used in the internal representation. Only pointers to instructions matter (and they're unique).> 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. -bw
Reid Spencer
2006-Oct-08 18:16 UTC
[LLVMdev] How to insert two instructions with the same name?
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.
Seemingly Similar Threads
- [LLVMdev] How to insert two instructions with the same name?
- [LLVMdev] scalar-evolution + indvars fail to get the loop trip count?
- [LLVMdev] llvm-gcc not compatible with gcc on a small case?
- [LLVMdev] A simple case about SDiv
- [LLVMdev] llvm-gcc 4.2 building failed on x86-64