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