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

attempt to define llvm intrinsic not rejected by verifier #1419

Closed
llvmbot opened this issue Dec 13, 2006 · 9 comments
Closed

attempt to define llvm intrinsic not rejected by verifier #1419

llvmbot opened this issue Dec 13, 2006 · 9 comments
Assignees
Labels
accepts-invalid bugzilla Issues migrated from bugzilla llvm:core

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 13, 2006

Bugzilla Link 1047
Resolution FIXED
Resolved on Feb 22, 2010 12:50
Version 1.9
OS MacOS X
Reporter LLVM Bugzilla Contributor

Extended Description

To reproduce the bug:

  1. unzip llvm-bug.zip
  2. cd into the directory
  3. run make

you will see the diff of hello1.ll and hello2.ll
hello1.c and hello2.c are similar hello world examples using our custom libc
the makefile should compile them without using the default system libraries

notice that the string literal "Hello World!\n" is not an argument to printf in hello1.
instead, int 0 is the only argument.
it looks like it has been optimized to nothing.

rather than being a bug in my library, i believe this is an optimizer problem, because you can edit the
Makefile, removing the -O3 optimization argument, and the problem seems to disappear.

this is my first bugzilla report, pardon me if my n00bness is apparent! :P

thanks!

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 13, 2006

assigned to @lattner

@lattner
Copy link
Collaborator

lattner commented Dec 13, 2006

The reason that you get the:
WARNING: While resolving call to function '__stdio_outs' arguments were dropped!

warnings is because you are relying undefined behavior. In vprintf you cast __stdio_outs to take three
parameters. __v_printf passes three arguments to it, but __stdio_outs only takes two arguments.

LLVM "devirtualizes" the function pointer, turning it into a direct call, at which point it sees that you're
passing three arguments (the third being fn->data) instead of two. You should really change
__stdio_outs to take three arguments.

However, there is still an llvm bug. I'm investigating.

-Chris

@lattner
Copy link
Collaborator

lattner commented Dec 13, 2006

The bug is in your code. This is not valid LLVM:

void %llvm.memcpy.i32(sbyte*, sbyte*, uint, uint) {
entry:
ret void
}

You've turned memcpy and others into a noop. I will make the verifier reject this. What are you trying to
accomplish?

@lattner
Copy link
Collaborator

lattner commented Dec 13, 2006

Fixed, patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061211/041334.html

Testcase here:
Verifier/2006-12-12-IntrinsicDefine.ll

-Chris

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 15, 2006

My purpose for defining intrinsics is to eliminate all declares from the final linked bytecode.
Declares are not handled by our compiler, so I need to resolve all of them.
I will fix the problem by writing C definitions for the intrinsics, and renaming them by hand.
That will allow me to link them in.
Thanks for all your help!

@lattner
Copy link
Collaborator

lattner commented Dec 15, 2006

another solution is to handle intrinsics like llvm.mempcy.* as calls to memcpy.

-Chris

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 16, 2006

Yes, after some discussion we decided to do it that way.
Thanks again for your help!

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 16, 2006

I have made the two changes you mentioned.
I got rid of llvm.o which re-defined intrinsics.
Shame on me for doing that in the first place!
Also, __stdio_puts() now has a thrid parameter.

However, the problem still exists.

tail call void (int, ...)* %printf( int 0 )
This problem is only apparent when using optimizer passes.

Am I still doing something stupid?
Should I open a new bug report and let you close this one?

I uploaded llvm-bug2.zip (see bug URL) so you can see it for yourself.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 16, 2006

Ok, I just talked to nicholas, and he realized that the string literal is being accessed directly in printf()
instead of being passed as an argument.

So, I was chasing a red haring. Sorry!!

I set the bug back to fixed.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
trevor-m pushed a commit to trevor-m/llvm-project that referenced this issue Apr 20, 2023
This should fix the problem reported by the lld buildbots:
 - Builder lld-x86_64-darwin13, Build llvm#19782
 - Builder lld-perf-testsuite, Build llvm#1419

llvm-svn: 329068
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

2 participants