[llvm-commits] [llvm-gcc-4.2] r63053 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Evan Cheng
evan.cheng at apple.com
Mon Jan 26 14:15:55 PST 2009
Author: evancheng
Date: Mon Jan 26 16:15:54 2009
New Revision: 63053
URL: http://llvm.org/viewvc/llvm-project?rev=63053&view=rev
Log:
llvm-gcc is asserting on this at -O1 and above (Calling a function with a bad signature!):
static int bar();
void foo() {
int a = bar();
}
int bar(unsigned a) {
}
It should pad the CallOperands vector with an undef before creating the call instruction.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=63053&r1=63052&r2=63053&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jan 26 16:15:54 2009
@@ -2828,6 +2828,21 @@
Value *Call;
if (!LandingPad) {
+ if (CallOperands.empty()) {
+ const FunctionType *FTy = cast<FunctionType>
+ (cast<PointerType>(Callee->getType())->getElementType());
+ if (!FTy->isVarArg() && FTy->getNumParams() > 0) {
+ // Something like this:
+ // static int func2();
+ // void func1() {
+ // int a = func2();
+ // }
+ // int func2(unsigned a) {
+ // }
+ // gcc4.2 allows this.
+ CallOperands.push_back(UndefValue::get(FTy->getParamType(0)));
+ }
+ }
Call = Builder.CreateCall(Callee, CallOperands.begin(), CallOperands.end());
cast<CallInst>(Call)->setCallingConv(CallingConvention);
cast<CallInst>(Call)->setAttributes(PAL);
More information about the llvm-commits
mailing list