@@ -44,10 +44,10 @@ static Instruction *getFirstNonAllocaInTheEntryBlock(Function *F) {
44
44
// Create an alloca in the caller, using FrameSize and FrameAlign as the callee
45
45
// coroutine's activation frame.
46
46
static Value *allocateFrameInCaller (Function *Caller, uint64_t FrameSize,
47
- Align FrameAlign) {
47
+ Align FrameAlign) {
48
48
LLVMContext &C = Caller->getContext ();
49
49
BasicBlock::iterator InsertPt =
50
- getFirstNonAllocaInTheEntryBlock (Caller)->getIterator ();
50
+ getFirstNonAllocaInTheEntryBlock (Caller)->getIterator ();
51
51
const DataLayout &DL = Caller->getDataLayout ();
52
52
auto FrameTy = ArrayType::get (Type::getInt8Ty (C), FrameSize);
53
53
auto *Frame = new AllocaInst (FrameTy, DL.getAllocaAddrSpace (), " " , InsertPt);
@@ -61,7 +61,7 @@ static Value *allocateFrameInCaller(Function *Caller, uint64_t FrameSize,
61
61
// - Replace the old CB with a new Call or Invoke to `NewCallee`, with the
62
62
// pointer to the frame as an additional argument to NewCallee.
63
63
static void processCall (CallBase *CB, Function *Caller, Function *NewCallee,
64
- uint64_t FrameSize, Align FrameAlign) {
64
+ uint64_t FrameSize, Align FrameAlign) {
65
65
// TODO: generate the lifetime intrinsics for the new frame. This will require
66
66
// introduction of two pesudo lifetime intrinsics in the frontend around the
67
67
// `co_await` expression and convert them to real lifetime intrinsics here.
@@ -74,13 +74,13 @@ static void processCall(CallBase *CB, Function *Caller, Function *NewCallee,
74
74
75
75
if (auto *CI = dyn_cast<CallInst>(CB)) {
76
76
auto *NewCI = CallInst::Create (NewCallee->getFunctionType (), NewCallee,
77
- NewArgs, " " , NewCBInsertPt);
77
+ NewArgs, " " , NewCBInsertPt);
78
78
NewCI->setTailCallKind (CI->getTailCallKind ());
79
79
NewCB = NewCI;
80
80
} else if (auto *II = dyn_cast<InvokeInst>(CB)) {
81
81
NewCB = InvokeInst::Create (NewCallee->getFunctionType (), NewCallee,
82
- II->getNormalDest (), II->getUnwindDest (),
83
- NewArgs, {}, " " , NewCBInsertPt);
82
+ II->getNormalDest (), II->getUnwindDest (),
83
+ NewArgs, {}, " " , NewCBInsertPt);
84
84
} else {
85
85
llvm_unreachable (" CallBase should either be Call or Invoke!" );
86
86
}
@@ -90,7 +90,7 @@ static void processCall(CallBase *CB, Function *Caller, Function *NewCallee,
90
90
NewCB->setAttributes (CB->getAttributes ());
91
91
NewCB->setDebugLoc (CB->getDebugLoc ());
92
92
std::copy (CB->bundle_op_info_begin (), CB->bundle_op_info_end (),
93
- NewCB->bundle_op_info_begin ());
93
+ NewCB->bundle_op_info_begin ());
94
94
95
95
NewCB->removeFnAttr (llvm::Attribute::CoroElideSafe);
96
96
CB->replaceAllUsesWith (NewCB);
@@ -106,15 +106,15 @@ static void processCall(CallBase *CB, Function *Caller, Function *NewCallee,
106
106
}
107
107
108
108
PreservedAnalyses CoroAnnotationElidePass::run (LazyCallGraph::SCC &C,
109
- CGSCCAnalysisManager &AM,
110
- LazyCallGraph &CG,
111
- CGSCCUpdateResult &UR) {
109
+ CGSCCAnalysisManager &AM,
110
+ LazyCallGraph &CG,
111
+ CGSCCUpdateResult &UR) {
112
112
bool Changed = false ;
113
113
CallGraphUpdater CGUpdater;
114
114
CGUpdater.initialize (CG, C, AM, UR);
115
115
116
116
auto &FAM =
117
- AM.getResult <FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager ();
117
+ AM.getResult <FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager ();
118
118
119
119
for (LazyCallGraph::Node &N : C) {
120
120
Function *Callee = &N.getFunction ();
@@ -131,8 +131,10 @@ PreservedAnalyses CoroAnnotationElidePass::run(LazyCallGraph::SCC &C,
131
131
}
132
132
}
133
133
auto FramePtrArgPosition = NewCallee->arg_size () - 1 ;
134
- auto FrameSize = NewCallee->getParamDereferenceableBytes (FramePtrArgPosition);
135
- auto FrameAlign = NewCallee->getParamAlign (FramePtrArgPosition).valueOrOne ();
134
+ auto FrameSize =
135
+ NewCallee->getParamDereferenceableBytes (FramePtrArgPosition);
136
+ auto FrameAlign =
137
+ NewCallee->getParamAlign (FramePtrArgPosition).valueOrOne ();
136
138
137
139
auto &ORE = FAM.getResult <OptimizationRemarkEmitterAnalysis>(*Callee);
138
140
@@ -149,26 +151,28 @@ PreservedAnalyses CoroAnnotationElidePass::run(LazyCallGraph::SCC &C,
149
151
processCall (CB, Caller, NewCallee, FrameSize, FrameAlign);
150
152
151
153
ORE.emit ([&]() {
152
- return OptimizationRemark (DEBUG_TYPE, " CoroAnnotationElide" , Caller)
153
- << " '" << ore::NV (" callee" , Callee->getName ()) << " ' elided in '"
154
- << ore::NV (" caller" , Caller->getName ()) << " '" ;
155
- });
154
+ return OptimizationRemark (DEBUG_TYPE, " CoroAnnotationElide" , Caller)
155
+ << " '" << ore::NV (" callee" , Callee->getName ())
156
+ << " ' elided in '" << ore::NV (" caller" , Caller->getName ())
157
+ << " '" ;
158
+ });
156
159
157
160
FAM.invalidate (*Caller, PreservedAnalyses::none ());
158
161
Changed = true ;
159
162
updateCGAndAnalysisManagerForCGSCCPass (CG, *CallerC, *CallerN, AM, UR,
160
- FAM);
163
+ FAM);
161
164
162
165
} else {
163
166
ORE.emit ([&]() {
164
- return OptimizationRemarkMissed (DEBUG_TYPE, " CoroAnnotationElide" ,
165
- Caller)
166
- << " '" << ore::NV (" callee" , Callee->getName ()) << " ' not elided in '"
167
- << ore::NV (" caller" , Caller->getName ()) << " ' (caller_presplit="
168
- << ore::NV (" caller_presplit" , IsCallerPresplitCoroutine)
169
- << " , elide_safe_attr=" << ore::NV (" elide_safe_attr" , HasAttr)
170
- << " )" ;
171
- });
167
+ return OptimizationRemarkMissed (DEBUG_TYPE, " CoroAnnotationElide" ,
168
+ Caller)
169
+ << " '" << ore::NV (" callee" , Callee->getName ())
170
+ << " ' not elided in '" << ore::NV (" caller" , Caller->getName ())
171
+ << " ' (caller_presplit="
172
+ << ore::NV (" caller_presplit" , IsCallerPresplitCoroutine)
173
+ << " , elide_safe_attr=" << ore::NV (" elide_safe_attr" , HasAttr)
174
+ << " )" ;
175
+ });
172
176
}
173
177
}
174
178
}
0 commit comments