[llvm-commits] [llvm] r72248 - in /llvm/trunk: lib/VMCore/Verifier.cpp test/Assembler/2009-05-22-CC.ll test/Verifier/2009-05-22-CC.ll

Török Edwin edwintorok at gmail.com
Thu May 21 23:57:16 PDT 2009


On 2009-05-22 09:45, Eli Friedman wrote:
> On Thu, May 21, 2009 at 11:41 PM, Torok Edwin<edwintorok at gmail.com> wrote:
>   
>> Author: edwin
>> Date: Fri May 22 01:41:43 2009
>> New Revision: 72248
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=72248&view=rev
>> Log:
>> Verify that calling conventions match function prototype.
>> This only rejects mismatches between target specific calling convention
>> and C/LLVM specific calling convention.
>>     
>
> It might be undefined behavior, but I don't think it's safe to make
> the validator reject it: suppose you store the pointer into a stack
> variable first.  mem2reg would then generate invalid code.
>   

If the verifier doesn't reject it, then it would silently generate bad
code (see PR 4239) like stdcall vs C calling conv. mismatch.

It does allow some mismatches: C, coldcc, fastcc, ...
In fact it only rejects C/coldcc/fastcc vs target-specific (stdcallcc,
fastcallcc)

You shouldn't have a function prototype with a target specific calling
convention, clang even warns you:
2009-05-22-callingconv.c:25:35: warning: 'stdcall' attribute only
applies to function types
     __attribute__ ((regparm (3), stdcall));

So you can't have a local variable pointing to a stdcall function, and
expect that calling it "will just work".

Best regards,
--Edwin



More information about the llvm-commits mailing list