Lines Matching refs:Function
12 // only passed into function calls as dead arguments of other functions. This
53 /// Struct that represents (part of) either a return value or a function
57 RetOrArg(const Function *F, unsigned Idx, bool IsArg) : F(F), Idx(Idx),
59 const Function *F;
80 + utostr(Idx) + " of function " + F->getName().str();
92 RetOrArg CreateRet(const Function *F, unsigned Idx) {
96 RetOrArg CreateArg(const Function *F, unsigned Idx) {
108 /// This means that some function calls G and passes its result as an
118 typedef std::set<const Function*> LiveFuncSet;
127 // Map each LLVM function to corresponding metadata with debug info. If
128 // the function is replaced with another one, we should patch the pointer
129 // to LLVM function in metadata.
133 typedef DenseMap<Function*, DISubprogram> FunctionDIMap;
157 void SurveyFunction(const Function &F);
161 void MarkLive(const Function &F);
163 bool RemoveDeadStuffFromFunction(Function *F);
164 bool DeleteDeadVarargs(Function &Fn);
165 bool RemoveDeadArgumentsFromCallers(Function &Fn);
191 /// which are not used by the body of the function.
196 /// CollectFunctionDIs - Map each function in the module to its debug info
216 if (Function *F = SP.getFunction())
223 /// DeleteDeadVarargs - If this is an function that takes a ... list, and if
224 /// llvm.vastart is never called, the varargs list is dead for the function.
225 bool DAE::DeleteDeadVarargs(Function &Fn) {
226 assert(Fn.getFunctionType()->isVarArg() && "Function isn't varargs!");
229 // Ensure that the function is only directly called.
233 // Okay, we know we can transform this function if safe. Scan its body
235 for (Function::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
244 // If we get here, there are no calls to llvm.vastart in the function body,
247 // Start by computing a new prototype for the function, which is the same as
248 // the old function, but doesn't have isVarArg set.
256 // Create the new function body and insert it into the module...
257 Function *NF = Function::Create(NFTy, Fn.getLinkage());
262 // Loop over all of the callers of the function, transforming the call sites
263 // to pass in a smaller number of arguments into the new function.
312 // Since we have now created the new function, splice the body of the old
313 // function right into the new function, leaving the old rotting hulk of the
314 // function empty.
321 for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end(),
328 // Patch the pointer to LLVM function in debug info descriptor.
333 // Finally, nuke the old function.
338 /// RemoveDeadArgumentsFromCallers - Checks if the given function has any
341 bool DAE::RemoveDeadArgumentsFromCallers(Function &Fn)
354 for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
367 for (Function::use_iterator I = Fn.use_begin(), E = Fn.use_end();
387 /// Convenience function that returns the number of return values. It returns 0
390 static unsigned NumRetVals(const Function *F) {
403 // We're live if our use or its Function is already marked as live.
425 // The value is returned from a function. It's only live when the
426 // function's return value is live. We use RetValNum here, for the case
455 const Function *F = CS.getCalledFunction();
460 // argument, since if it was the function argument this would be an
474 // argument to the called function turns out live.
502 // SurveyFunction - This performs the initial survey of the specified function,
510 void DAE::SurveyFunction(const Function &F) {
522 for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
541 // Loop all uses of the function.
544 // If the function is PASSED IN as an argument, its address has been
552 // If this use is anything other than a call site, the function is alive.
559 // If we end up here, we are looking at a direct call to our function.
605 for (Function::const_arg_iterator AI = F.arg_begin(),
617 /// MarkValue - This function marks the liveness of RA depending on L. If L is
637 /// MarkLive - Mark the given Function as alive, meaning that it cannot be
639 /// mark any values that are used as this function's parameters or by its return
641 void DAE::MarkLive(const Function &F) {
643 // Mark the function as live.
658 return; // Function was already marked Live.
685 // that are not in LiveValues. Transform the function and all of the callees of
686 // the function to not have these arguments and return values.
688 bool DAE::RemoveDeadStuffFromFunction(Function *F) {
693 // Start by computing a new prototype for the function, which is the same as
694 // the old function, but has fewer arguments and a different return type.
756 // The existing function return attributes.
786 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
814 // Create the new function type based on the recomputed parameters.
821 // Create the new function body and insert it into the module...
822 Function *NF = Function::Create(NFTy, F->getLinkage());
825 // Insert the new function before the old function, so we won't be processing
830 // Loop over all of the callers of the function, transforming the call sites
831 // to pass in a smaller number of arguments into the new function.
844 // Adjust in case the function was changed to return void.
860 // original function, and add those that are still alive.
959 // Since we have now created the new function, splice the body of the old
960 // function right into the new function, leaving the old rotting hulk of the
961 // function empty.
967 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(),
982 // If we change the return value of the function we must rewrite any return
985 for (Function::iterator BB = NF->begin(), E = NF->end(); BB != E; ++BB)
1024 // Patch the pointer to LLVM function in debug info descriptor.
1029 // Now that the old function is dead, delete it.
1043 // fused with the next loop, because deleting a function invalidates
1047 Function &F = *I++;
1060 // Now, remove all dead arguments and return values from each function in
1063 // Increment now, because the function will probably get removed (ie.
1065 Function *F = I++;
1072 Function& F = *I;