Hans Wennborg
2009-Dec-10 08:18 UTC
[LLVMdev] Problem with code generated for call using stdcall convention
I too have stumbled over this. Wouldn't it be a good idea to add a check for this to the function verifier pass? Hans Anton Korobeynikov wrote:> Hello > >> I naively though it would pick up the call convention from the declaration >> as there was no error like we have when the wrong number of parameters is >> used. > This is not an error, you're just invoking undefined behaviour. >
Duncan Sands
2009-Dec-10 10:07 UTC
[LLVMdev] Problem with code generated for call using stdcall convention
Hi,> Wouldn't it be a good idea to add a check for this to the function > verifier pass?no, because it is valid. The problem is that the optimizers can expose this kind of thing. For example, imagine you have an indirect call, where the calling convention is CC_X. Suppose the optimizers are able to deduce the function that is being called, say F, and turn the call into a direct call to F. If the calling convention for F is different, say CC_Y, then having the verifier reject the bitcode because CC_X != CC_Y would result in a compiler crash. So you would have to teach all kind of optimizers to be careful because they might turn a valid program into an invalid one. That's too painful. Ciao, Duncan.
Nick Lewycky
2009-Dec-10 17:21 UTC
[LLVMdev] Problem with code generated for call using stdcall convention
Hans Wennborg wrote:> I too have stumbled over this. > > Wouldn't it be a good idea to add a check for this to the function > verifier pass?No. This is a FAQ: http://llvm.org/docs/FAQ.html#callconvwrong Nick> > > Hans > > Anton Korobeynikov wrote: >> Hello >> >>> I naively though it would pick up the call convention from the declaration >>> as there was no error like we have when the wrong number of parameters is >>> used. >> This is not an error, you're just invoking undefined behaviour. >> > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Reid Kleckner
2009-Dec-10 17:39 UTC
[LLVMdev] Problem with code generated for call using stdcall convention
On Thu, Dec 10, 2009 at 12:21 PM, Nick Lewycky <nicholas at mxc.ca> wrote:> Hans Wennborg wrote: >> I too have stumbled over this. >> >> Wouldn't it be a good idea to add a check for this to the function >> verifier pass? > > No. This is a FAQ: http://llvm.org/docs/FAQ.html#callconvwrongIMO you could move the cc to the type and still replace mismatched calls with unreachable. Are there other design considerations for not doing this? Reid
Seemingly Similar Threads
- [LLVMdev] Problem with code generated for call using stdcall convention
- [LLVMdev] Problem with code generated for call using stdcall convention
- [LLVMdev] Problem with code generated for call using stdcall convention
- [LLVMdev] Problem with code generated for call using stdcall convention
- [LLVMdev] Changes between 2.6 and 2.7: SSA Verifier and visitFreeInst