[LLVMdev] llvm-gcc Bug, Looking for Advice on Fix

David Greene greened at obbligato.org
Fri Apr 20 09:52:29 PDT 2007


David Greene wrote:

> The problem is that Intrinsic::getDeclaration takes four
> parameters but is only passed two:
> 
> Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys,
>                                      unsigned numTys)

It turns out that this happens all over llvm-convert.c.  Tys and numTys
default to zero, which is why it builds.  The problem is, getDeclaration
calls getType(id, Tys, numTys) where this code is executed:

   case Intrinsic::memcpy_i32:		// llvm.memcpy.i32
   case Intrinsic::memmove_i32:		// llvm.memmove.i32
     ResultTy = Type::getPrimitiveType(Type::VoidTyID);
     ArgTys.push_back(Tys[1]);
     ArgTys.push_back(Tys[2]);
     ArgTys.push_back(IntegerType::get(32));
     ArgTys.push_back(IntegerType::get(32));

Oops, Tys is 0!

Similar code exists for llvm.memcpy.i64, so it's not the case that
the select expression returned the "wrong" answer.

How the heck did this ever work?

                                         -Dave



More information about the llvm-dev mailing list