llvm.org GIT mirror llvm / 382cb21
Revert this. There's no way to verifiy indirect calls, and an optimizer can turn indirect call into direct call, thus the verifier would reject something it previously accepted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72249 91177308-0d34-0410-b5e6-96231b3b80d8 Torok Edwin 11 years ago
3 changed file(s) with 0 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
10221022 Assert3(CS.getArgument(i)->getType() == FTy->getParamType(i),
10231023 "Call parameter type does not match function signature!",
10241024 CS.getArgument(i), FTy->getParamType(i), I);
1025
1026 Assert2(CS.getType() == FTy->getReturnType(),
1027 "Call return type does not match function signature!",
1028 CS.getInstruction(), FTy->getReturnType());
1029
1030 // Verify calling convention for direct calls
1031 Value *CalledF = CS.getCalledValue()->stripPointerCasts();
1032 if (Function *F = dyn_cast(CalledF)) {
1033 unsigned CC1 = CS.getCallingConv();
1034 unsigned CC2 = F->getCallingConv();
1035 if(CC1 != CC2) {
1036 // tolerate some mismatch among C prototype and LLVM-specific calling conv
1037 if (CC2 >= CallingConv::FirstTargetCC ||
1038 CC1 >= CallingConv::FirstTargetCC) {
1039 Instruction *I = CS.getInstruction()->clone();
1040 if (CallInst *CI = dyn_cast(I)) {
1041 CI->setCallingConv(F->getCallingConv());
1042 } else
1043 cast(I)->setCallingConv(F->getCallingConv());
1044 Assert2(0,"Calling convention does not match function signature!",
1045 CS.getInstruction(), I);
1046 delete I;
1047 }
1048 }
1049 }
10501025
10511026 if (CS.getCalledValue()->getNameLen() < 5 ||
10521027 strncmp(CS.getCalledValue()->getNameStart(), "llvm.", 5) != 0) {
+0
-9
test/Assembler/2009-05-22-CC.ll less more
None ; RUN: llvm-as < %s
1
2 ; Verify that calls with correct calling conv are accepted
3 declare x86_stdcallcc i32 @re_string_construct(i8* inreg %pstr, i8* inreg %str, i32 inreg %len, i8* %trans, i32 %icase, i8* %dfa);
4 define void @main() {
5 entry:
6 %0 = call x86_stdcallcc i32 (...)* bitcast (i32 (i8*, i8*, i32, i8*, i32, i8*)* @re_string_construct to i32 (...)*)(i32 inreg 0, i32 inreg 0, i32 inreg 0, i32 0, i32 0, i8* inttoptr (i32 673194176 to i8*));
7 ret void
8 }
+0
-11
test/Verifier/2009-05-22-CC.ll less more
None ; RUN: not llvm-as < %s |& grep {Calling convention does not match function signature}
1 ; PR 4239
2
3 ; Verify that the calling convention on the call instruction matches the
4 ; declared calling convention
5 declare x86_stdcallcc i32 @re_string_construct(i8* inreg %pstr, i8* inreg %str, i32 inreg %len, i8* %trans, i32 %icase, i8* %dfa);
6 define void @main() {
7 entry:
8 %0 = call i32 (...)* bitcast (i32 (i8*, i8*, i32, i8*, i32, i8*)* @re_string_construct to i32 (...)*)(i32 inreg 0, i32 inreg 0, i32 inreg 0, i32 0, i32 0, i8* inttoptr (i32 673194176 to i8*))
9 ret void
10 }