[PATCH] InlineFunction doesn't update InlineFunctionInfo with allocas created for byval arguments

Julien Lerouge julien.lerouge at m4x.org
Fri Apr 4 17:15:14 PDT 2014


When llvm::InlineFunction inlines a function that has byval arguments,
it creates allocas in the caller. Those allocas aren't inserted in the
InlineFunctionInfo data structure. So after inlining, if the client code
wants to know where are the allocas that were created, it will miss
those.

Should InlineFunctionInfo contain these allocas, or is the omission
deliberate ?

The attached patch adds these new allocas.

Thanks,
Julien

-------------- next part --------------
commit 5acc9d2fc26ecfd7e4d9bb1f4bbd335d222dbe66
Author: Julien Lerouge <jlerouge at apple.com>
Date:   Wed Apr 2 17:07:18 2014 -0700

    Keep byval allocas.

diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 86def3e..130bcbf 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -368,6 +368,8 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall,
   
   Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), 
                                     &*Caller->begin()->begin());
+  IFI.StaticAllocas.push_back(cast<AllocaInst>(NewAlloca));
+
   // Emit a memcpy.
   Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)};
   Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(),


More information about the llvm-commits mailing list