Lines Matching refs:Function
12 // only passed into function calls as dead arguments of other functions. This
50 /// Struct that represents (part of) either a return value or a function
54 RetOrArg(const Function *F, unsigned Idx, bool IsArg) : F(F), Idx(Idx),
56 const Function *F;
77 + utostr(Idx) + " of function " + F->getNameStr();
89 RetOrArg CreateRet(const Function *F, unsigned Idx) {
93 RetOrArg CreateArg(const Function *F, unsigned Idx) {
105 /// This means that some function calls G and passes its result as an
115 typedef std::set<const Function*> LiveFuncSet;
144 void SurveyFunction(const Function &F);
148 void MarkLive(const Function &F);
150 bool RemoveDeadStuffFromFunction(Function *F);
151 bool DeleteDeadVarargs(Function &Fn);
152 bool RemoveDeadArgumentsFromCallers(Function &Fn);
178 /// which are not used by the body of the function.
183 /// DeleteDeadVarargs - If this is an function that takes a ... list, and if
184 /// llvm.vastart is never called, the varargs list is dead for the function.
185 bool DAE::DeleteDeadVarargs(Function &Fn) {
186 assert(Fn.getFunctionType()->isVarArg() && "Function isn't varargs!");
189 // Ensure that the function is only directly called.
193 // Okay, we know we can transform this function if safe. Scan its body
195 for (Function::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
204 // If we get here, there are no calls to llvm.vastart in the function body,
207 // Start by computing a new prototype for the function, which is the same as
208 // the old function, but doesn't have isVarArg set.
216 // Create the new function body and insert it into the module...
217 Function *NF = Function::Create(NFTy, Fn.getLinkage());
222 // Loop over all of the callers of the function, transforming the call sites
223 // to pass in a smaller number of arguments into the new function.
271 // Since we have now created the new function, splice the body of the old
272 // function right into the new function, leaving the old rotting hulk of the
273 // function empty.
280 for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end(),
287 // Finally, nuke the old function.
292 /// RemoveDeadArgumentsFromCallers - Checks if the given function has any
295 bool DAE::RemoveDeadArgumentsFromCallers(Function &Fn)
308 for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
321 for (Function::use_iterator I = Fn.use_begin(), E = Fn.use_end();
341 /// Convenience function that returns the number of return values. It returns 0
344 static unsigned NumRetVals(const Function *F) {
357 // We're live if our use or its Function is already marked as live.
379 // The value is returned from a function. It's only live when the
380 // function's return value is live. We use RetValNum here, for the case
409 const Function *F = CS.getCalledFunction();
414 // argument, since if it was the function argument this would be an
428 // argument to the called function turns out live.
456 // SurveyFunction - This performs the initial survey of the specified function,
464 void DAE::SurveyFunction(const Function &F) {
476 for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
495 // Loop all uses of the function.
498 // If the function is PASSED IN as an argument, its address has been
506 // If this use is anything other than a call site, the function is alive.
513 // If we end up here, we are looking at a direct call to our function.
559 for (Function::const_arg_iterator AI = F.arg_begin(),
571 /// MarkValue - This function marks the liveness of RA depending on L. If L is
591 /// MarkLive - Mark the given Function as alive, meaning that it cannot be
593 /// mark any values that are used as this function's parameters or by its return
595 void DAE::MarkLive(const Function &F) {
597 // Mark the function as live.
612 return; // Function was already marked Live.
639 // that are not in LiveValues. Transform the function and all of the callees of
640 // the function to not have these arguments and return values.
642 bool DAE::RemoveDeadStuffFromFunction(Function *F) {
647 // Start by computing a new prototype for the function, which is the same as
648 // the old function, but has fewer arguments and a different return type.
656 // The existing function return attributes.
734 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
759 // Create the new function type based on the recomputed parameters.
766 // Create the new function body and insert it into the module...
767 Function *NF = Function::Create(NFTy, F->getLinkage());
770 // Insert the new function before the old function, so we won't be processing
775 // Loop over all of the callers of the function, transforming the call sites
776 // to pass in a smaller number of arguments into the new function.
789 // Adjust in case the function was changed to return void.
799 // original function, and add those that are still alive.
892 // Since we have now created the new function, splice the body of the old
893 // function right into the new function, leaving the old rotting hulk of the
894 // function empty.
900 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(),
915 // If we change the return value of the function we must rewrite any return
918 for (Function::iterator BB = NF->begin(), E = NF->end(); BB != E; ++BB)
957 // Now that the old function is dead, delete it.
968 // fused with the next loop, because deleting a function invalidates
972 Function &F = *I++;
985 // Now, remove all dead arguments and return values from each function in
988 // Increment now, because the function will probably get removed (ie.
990 Function *F = I++;
997 Function& F = *I;