Caller and Callee with different calling conventions


If a call instruction and the function being called differ in their call
convention, InstructionCombine will insert a "store true, undef", then
CFGSimplify transforms this store to a llvm.trap() call, and finally,
during execution an InvalidInstruction exception is signaled.

Is there any reason not to detect the calling convention mismatch in the
verifier ? I would like to add such check.



Basically, you can imagine code like this:

enum CC { cdecl, stdcall, fastcall };
void callit(CC cc, void fp) {
switch (cc) {
case cdecl: ((void(__cdecl
)())fp)(); break;
case stdcall: ((void(__stdcall*)())fp)(); break;
case fastcall: ((void(__fastcall*)())fp)(); break;

If we inline ‘callit’, and discover the true target of fp, those calls become direct, and the verifier should not reject them just because we discovered additional information.