Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
Show First 20 Lines • Show All 811 Lines • ▼ Show 20 Lines | do { | ||||
LocalChange = false; | LocalChange = false; | ||||
FunctionAnalysisManager &FAM = | FunctionAnalysisManager &FAM = | ||||
AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager(); | AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager(); | ||||
bool IsRecursive = C.size() > 1; | bool IsRecursive = C.size() > 1; | ||||
for (LazyCallGraph::Node &N : C) { | for (LazyCallGraph::Node &N : C) { | ||||
Function &OldF = N.getFunction(); | Function &OldF = N.getFunction(); | ||||
Function *NewF = promoteArguments(&OldF, FAM, MaxElements, IsRecursive); | |||||
// If the IR specifies a maximum element count via !argpromotion | |||||
// metadata, take that into account. | |||||
unsigned MaxElems = MaxElements; | |||||
if (MDNode *MD = OldF.getMetadata("argpromotion")) | |||||
MaxElems = | |||||
mdconst::extract<ConstantInt>(MD->getOperand(0))->getZExtValue(); | |||||
if (MaxElems == 0) | |||||
continue; | |||||
Function *NewF = promoteArguments(&OldF, FAM, MaxElems, IsRecursive); | |||||
if (!NewF) | if (!NewF) | ||||
continue; | continue; | ||||
LocalChange = true; | LocalChange = true; | ||||
// Directly substitute the functions in the call graph. Note that this | // Directly substitute the functions in the call graph. Note that this | ||||
// requires the old function to be completely dead and completely | // requires the old function to be completely dead and completely | ||||
// replaced by the new function. It does no call graph updates, it merely | // replaced by the new function. It does no call graph updates, it merely | ||||
// swaps out the particular function mapped to a particular node in the | // swaps out the particular function mapped to a particular node in the | ||||
Show All 26 Lines |