aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2005-06-22 21:04:42 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2005-06-22 21:04:42 +0000
commit213e557cef3e653e2d3a00b07b137c143128430a (patch)
tree2b864d830fba118c8d2fa07144629603caf85214 /lib/Bytecode
parentd0a4c62a031ea9f0e2be2fe1f16af2209602ed94 (diff)
If we support structs as va_list, we must pass pointers to them to va_copy
See last commit for LangRef, this implements it on all targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/ReaderWrappers.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp
index c000c9a3f5..a198447d72 100644
--- a/lib/Bytecode/Reader/ReaderWrappers.cpp
+++ b/lib/Bytecode/Reader/ReaderWrappers.cpp
@@ -221,20 +221,24 @@ static ModuleProvider* CheckVarargs(ModuleProvider* MP) {
//foo = vacopy(bar)
// ->
//a = alloca 1 of typeof(foo)
- //vacopy(a, bar)
+ //b = alloca 1 of typeof(foo)
+ //store bar -> b
+ //vacopy(a, b)
//foo = load a
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
const Type* ArgTy = F->getFunctionType()->getReturnType();
const Type* ArgTyPtr = PointerType::get(ArgTy);
Function* NF = M->getOrInsertFunction("llvm.va_copy",
- RetTy, ArgTyPtr, ArgTy, 0);
+ RetTy, ArgTyPtr, ArgTyPtr, 0);
for(Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E;)
if (CallInst* CI = dyn_cast<CallInst>(*I++)) {
AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
- new CallInst(NF, a, CI->getOperand(1), "", CI);
- Value* foo = new LoadInst(a, "vacopy.fix.2", CI);
+ AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
+ new StoreInst(CI->getOperand(1), b, CI);
+ new CallInst(NF, a, b, "", CI);
+ Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
CI->replaceAllUsesWith(foo);
CI->getParent()->getInstList().erase(CI);
}