Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type planes not collapsed for unnamed variables #1630

Closed
nlewycky opened this issue Mar 18, 2007 · 5 comments
Closed

type planes not collapsed for unnamed variables #1630

nlewycky opened this issue Mar 18, 2007 · 5 comments
Labels
accepts-invalid bugzilla Issues migrated from bugzilla llvm:core

Comments

@nlewycky
Copy link
Contributor

Bugzilla Link 1258
Resolution FIXED
Resolved on Feb 22, 2010 12:43
Version trunk
OS All

Extended Description

The following program assembles with llvm-as:

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

@lattner
Copy link
Collaborator

lattner commented Mar 19, 2007

You're right, this is certainly a bug. This may have llvm-upgrade implications, what do you think Reid?

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 19, 2007

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 ; :0 [#uses=1]
zext i1 %0 to i32 ; :0 [#uses=1]

That should be :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.

@nlewycky
Copy link
Contributor Author

No, look at the ret:

      ret i32 %0

That's returning the result of the zext, not the icmp.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 19, 2007

Okay, sorry, missed that. Yeah, its a bug.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts-invalid bugzilla Issues migrated from bugzilla llvm:core
Projects
None yet
Development

No branches or pull requests

3 participants