From b401e940be030bfd6d9e26f77a256ed6fc832931 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sun, 28 Sep 2008 17:22:37 +0200 Subject: LLVM compiler: Allocate va_list objects as i8** rather than i8*. This fixes a terrible stack smashing bug that was most visible on PowerPC-based machines. --- MLKLLVMCompiler.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm index 9e51112..b3a47d3 100644 --- a/MLKLLVMCompiler.mm +++ b/MLKLLVMCompiler.mm @@ -644,13 +644,14 @@ static Constant false), PointerType::get(Type::Int8Ty, 0)); - Value *ap = builder.CreateAlloca (Type::Int8Ty, NULL, "ap"); + Value *ap = builder.CreateAlloca (PointerTy, NULL, "ap"); + Value *ap2 = builder.CreateBitCast (ap, PointerTy); builder.CreateCall (module->getOrInsertFunction ("llvm.va_start", Type::VoidTy, PointerTy, NULL), - ap); + ap2); Value *mlkcons = [_compiler insertClassLookup:@"MLKCons"]; @@ -707,7 +708,7 @@ static Constant Type::VoidTy, PointerTy, NULL), - ap); + ap2); if ([_bodyContext variableHeapAllocationForSymbol:_lambdaListName]) { -- cgit v1.2.3