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

Asmprinter emits cast of constant wrong #1225

Closed
llvmbot opened this issue Jul 29, 2006 · 7 comments
Closed

Asmprinter emits cast of constant wrong #1225

llvmbot opened this issue Jul 29, 2006 · 7 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm:codegen

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 29, 2006

Bugzilla Link 853
Resolution FIXED
Resolved on Feb 22, 2010 12:44
Version 1.0
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

ribrdb@ribox:/tmp$ cat >inner.cc
#include
class B : std::ostrstream{
public:
B() {}
B(char* buf, int len, int ctr) : std::ostrstream(buf, len) { }
virtual int foo() { return 0; }
};
class A {
public:
A() : b((char*)0, 0, 0) { }
B b;
};
class C : public B {
public:
virtual int foo();
};
int C::foo() { return 5;};

int main() {
A *a = new A();
B b = new B((char)0, 0, 0);
b->foo();
a->b.foo();
return 0;
}
^D
ribrdb@ribox:/tmp$ gcc-3.4 -Wno-deprecated -S inner.cc
ribrdb@ribox:/tmp$ /usr/local/llvm/cfrontend/install/bin/llvm-gcc
-Wno-deprecated -S inner.cc -o inner-llvm.s
inner.cc:29: note: LLVM does not support aliases yet
inner.cc:29: note: LLVM does not support aliases yet
inner.cc:29: note: LLVM does not support aliases yet
inner.cc:29: note: LLVM does not support aliases yet

inner.s contains this vtable:
_ZTV1B:
.long 56
.long 0
.long _ZTI1B
.long _ZN1BD1Ev
.long _ZN1BD0Ev
.long _ZN1B3fooEv
.long -56
.long -56
.long _ZTI1B
.long _ZTv0_n12_N1BD1Ev
.long _ZTv0_n12_N1BD0Ev

but inner-llvm.s contains this vtable:
_ZTV1B: # _ZTV1B
.size _ZTV1B, 44
.long 56
.zero 4
.long _ZTI1B
.long _ZN1BD1Ev
.long _ZN1BD0Ev
.long _ZN1B3fooEv
.long 18446744073709551560
.long -56
.long _ZTI1B
.long _ZTv0_n12_N1BD1Ev
.long _ZTv0_n12_N1BD0Ev

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 29, 2006

assigned to @lattner

@lattner
Copy link
Collaborator

lattner commented Jul 29, 2006

Are you sure this is a problem? 18446744073709551560 = -56.

What platform (target triple) is this on? Is .long a 32-bit value? If so, this is definitely a bug. Can you
run:

/usr/local/llvm/cfrontend/install/bin/llvm-gcc
-Wno-deprecated -S inner.cc -o inner-llvm.ll -emit-llvm

and attach inner-llvm.ll plz ?

Thanks,

-Chris

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 29, 2006

inner-llvm.ll

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jul 29, 2006

It's 32 bit intel linux. When compiling the .s file, gcc says "Warning: bignum
truncated to 4 bytes"

@lattner
Copy link
Collaborator

lattner commented Jul 29, 2006

Definitely a bug.

@lattner
Copy link
Collaborator

lattner commented Jul 29, 2006

A reduced .ll testcase:

%X = global int* cast (ulong 18446744073709551560 to int*)

Produces:

_X: ; 'X'
.long 18446744073709551560

@lattner
Copy link
Collaborator

lattner commented Jul 29, 2006

Fixed. Testcase here: Regression/CodeGen/X86/2006-07-28-AsmPrint-Long-As-Pointer.ll

Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20060724/036351.html

Thanks!

-Chris

@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
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm:codegen
Projects
None yet
Development

No branches or pull requests

2 participants