$:~/tmp$ llvm-gcc -emit-llvm -c svc.c -o svc.o cc1: ../../dst-directory/gcc/llvm-convert.cpp:216: void<unnamed>::FunctionPrologArgumentConversion::HandleScalarArgument(const llvm::Type*): Assertion `ArgVal->getType()->isIntegral() && LLVMTy->isIntegral() && "Lowerings don't match?"' failed. svc.c: In function ‘svc_register’: svc.c:11: internal compiler error: Aborted Please submit a full bug report, Source: [svc.c from dietlib v0.30] ------------------------------------------------ #include <rpc/rpc.h> static SVCXPRT **xports; bool_t svc_register(xprt, prog, vers, dispatch, protocol) SVCXPRT *xprt; unsigned long prog; unsigned long vers; void (*dispatch) (); rpcprot_t protocol; { return (TRUE); } ------------------------------------------------ Can be reproduced with: llvm-gcc [-emit-llvm] -c svc.c -o svc.o Domagoj
aKor has just pointed me to http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20070104/5c2b9cf1/attachment.txt suggesting that that patch is the most likely source of the problem. However, I don't have that patch applied. So, with, or without the patch, the code seems to be buggy. To clear any possible confusion, here's my current code: ------------------------------------------------ void HandleScalarArgument(const llvm::Type *LLVMTy) { Value *ArgVal = AI; if (ArgVal->getType() != LLVMTy) { // If this is just a mismatch between integer types, this could be due // to K&R prototypes, where the forward proto defines the arg as int and // the actual impls is a short or char. assert(ArgVal->getType()->isIntegral() && LLVMTy->isIntegral() && "Lowerings don't match?"); ArgVal = CastInst::createInferredCast(ArgVal, LLVMTy, NameStack.back(), CurBB); } assert(!LocStack.empty()); Value *Loc = LocStack.back(); if (cast<PointerType>(Loc->getType())->getElementType() != LLVMTy) // This cast only involves pointers, therefore BitCast Loc = CastInst::create(Instruction::BitCast, Loc, PointerType::get(LLVMTy), "tmp", CurBB); new StoreInst(ArgVal, Loc, CurBB); AI->setName(NameStack.back()); ++AI; } ------------------------------------------------ $:~/llvm/dst-directory/gcc$ svn info llvm-convert.cpp Path: llvm-convert.cpp Name: llvm-convert.cpp URL: svn://anonsvn.opensource.apple.com/svn/llvm/trunk/gcc/llvm-convert.cpp Repository Root: svn://anonsvn.opensource.apple.com/svn/llvm Repository UUID: 51af6f4a-8115-0410-a7cd-c0d7a57f2c62 Revision: 224 Node Kind: file Schedule: normal Last Changed Author: jlaskey Last Changed Rev: 219 Last Changed Date: 2006-12-01 01:54:57 -0800 (Fri, 01 Dec 2006) Text Last Updated: 2006-12-09 13:16:41 -0800 (Sat, 09 Dec 2006) Domagoj
Supplied source code includes some platform-dependent code (because it isn't preprocessed). However, it fails here too (on Linux/X86) but with another assertion: cc1: /home/asl/proj/llvm/src/lib/VMCore/Instructions.cpp:1568: static llvm::CastInst* llvm::CastInst::createIntegerCast(llvm::Value*, const llvm::Type*, bool, const std::string&, llvm::BasicBlock*): Assertion `C->getType()->isIntegral() && Ty->isIntegral() && "Invalid cast"' failed. Will supply preprocessed & reduced source soon
Created attachment 541 [details] delta-reduced testcase This file fails for me with TOT with assertion message printed before.
just to confirm that Anton's reduced testcase produces the same msg. Domagoj
Verified, the reduced testcase crashes with TOT, investigating.
Further reduced testcase: int svc_register (void (*dispatch) (int)); int svc_register (dispatch) void (*dispatch) (); {}
Fixed. Testcase here: test/Regression/CFrontend/2007-01-06-KNR-Proto.c Patch sent to llvm-commits, but the mailing lists are apparently blocked, so no URL provided. -Chris
Patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070101/042147.html