LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1258 - type planes not collapsed for unnamed variables
Summary: type planes not collapsed for unnamed variables
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Core LLVM classes (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Reid Spencer
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2007-03-18 09:52 PDT by Nick Lewycky
Modified: 2010-02-22 12:43 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Lewycky 2007-03-18 09:52:27 PDT
The following program assembles with llvm-as:

  define i32 @test1(i32 %a, i32 %b) {
  entry:
          icmp eq i32 %b, %a              ; <i1>:0 [#uses=1]
          zext i1 %0 to i32               ; <i32>:0 [#uses=1]
          ret i32 %0
  }

The type of %0 is simultaneously i1 and i32. By contrast, naming the variable %A
makes it invalid. This does not assemble

  define i32 @test2(i32 %a, i32 %b) {
  entry:
          %A = icmp eq i32 %b, %a
          %A = zext i1 %A to i32
          ret i32 %A
  }

with the error "Redefinition of value 'A' of type 'i32'" which is desired. I'd
like this C code:

  int test1(int a, int b) { return a == b; }

to produce this llvm assembly:

  define i32 @test1(i32 %a, i32 %b) {
  entry:
          icmp eq i32 %b, %a              ; <i1>:0 [#uses=1]
          zext i1 %1 to i32               ; <i32>:1 [#uses=1]
          ret i32 %1
  }
Comment 1 Chris Lattner 2007-03-18 17:06:32 PDT
You're right, this is certainly a bug.  This may have llvm-upgrade implications, what do you think Reid?

-Chris
Comment 2 Reid Spencer 2007-03-18 18:25:50 PDT
I really don't get it. If there's a bug here, it is only in the output of the
comment: 
          icmp eq i32 %b, %a              ; <i1>:0 [#uses=1]
          zext i1 %0 to i32               ; <i32>:0 [#uses=1]

That should be <i32>:1 on the zext instruction.

Otherwise it is fine. The program should assemble because %0 (icmp) is type i1
and %1 (zext) is type i32. Giving the same name to these instructions should
fail because of redefinition of a name.  I don't see where %0 is redefined. 

This has no bearing on llvm-upgrade as far as I can see. 
Comment 3 Nick Lewycky 2007-03-18 18:28:30 PDT
No, look at the ret:

          ret i32 %0

That's returning the result of the zext, not the icmp.
Comment 4 Reid Spencer 2007-03-18 18:33:28 PDT
Okay, sorry, missed that. Yeah, its a bug.