@@ -2130,28 +2130,26 @@ static void emitDynamicallyReplaceableThunk(IRGenModule &IGM,
2130
2130
implFn->addFnAttr (llvm::Attribute::NoInline);
2131
2131
2132
2132
// Load the function and dispatch to it forwarding our arguments.
2133
- llvm::BasicBlock *entryBB =
2134
- llvm::BasicBlock::Create (IGM.getLLVMContext (), " entry" , dispatchFn);
2135
- IRBuilder B (IGM.getLLVMContext (), false );
2136
- B.SetInsertPoint (entryBB);
2133
+ IRGenFunction IGF (IGM, dispatchFn);
2137
2134
if (IGM.DebugInfo )
2138
- IGM.DebugInfo ->emitArtificialFunction (B , dispatchFn);
2135
+ IGM.DebugInfo ->emitArtificialFunction (IGF , dispatchFn);
2139
2136
llvm::Constant *indices[] = {llvm::ConstantInt::get (IGM.Int32Ty , 0 ),
2140
2137
llvm::ConstantInt::get (IGM.Int32Ty , 0 )};
2141
- auto *fnPtr = B .CreateLoad (
2138
+ auto *fnPtr = IGF. Builder .CreateLoad (
2142
2139
llvm::ConstantExpr::getInBoundsGetElementPtr (nullptr , linkEntry, indices),
2143
2140
IGM.getPointerAlignment ());
2144
- auto *typeFnPtr = B.CreateBitOrPointerCast (fnPtr, implFn->getType ());
2141
+ auto *typeFnPtr =
2142
+ IGF.Builder .CreateBitOrPointerCast (fnPtr, implFn->getType ());
2145
2143
SmallVector<llvm::Value *, 16 > forwardedArgs;
2146
2144
for (auto &arg : dispatchFn->args ())
2147
2145
forwardedArgs.push_back (&arg);
2148
- auto *Res =
2149
- B. CreateCall ( FunctionPointer (typeFnPtr, signature), forwardedArgs);
2146
+ auto *Res = IGF. Builder . CreateCall ( FunctionPointer (typeFnPtr, signature),
2147
+ forwardedArgs);
2150
2148
Res->setTailCall ();
2151
2149
if (implFn->getReturnType ()->isVoidTy ())
2152
- B .CreateRetVoid ();
2150
+ IGF. Builder .CreateRetVoid ();
2153
2151
else
2154
- B .CreateRet (Res);
2152
+ IGF. Builder .CreateRet (Res);
2155
2153
}
2156
2154
2157
2155
void IRGenModule::emitOpaqueTypeDescriptorAccessor (OpaqueTypeDecl *opaque) {
@@ -2227,34 +2225,35 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) {
2227
2225
f->getOptimizationMode ());
2228
2226
implFn->addFnAttr (llvm::Attribute::NoInline);
2229
2227
2228
+ IRGenFunction IGF (*this , implFn);
2229
+ if (DebugInfo)
2230
+ DebugInfo->emitArtificialFunction (IGF, implFn);
2231
+
2230
2232
LinkEntity varEntity =
2231
2233
LinkEntity::forDynamicallyReplaceableFunctionVariable (f);
2232
2234
auto linkEntry = getChainEntryForDynamicReplacement (*this , varEntity, nullptr ,
2233
2235
NotForDefinition);
2234
2236
2235
2237
// Load the function and dispatch to it forwarding our arguments.
2236
- llvm::BasicBlock *entryBB =
2237
- llvm::BasicBlock::Create (getLLVMContext (), " entry" , implFn);
2238
- IRBuilder B (getLLVMContext (), false );
2239
- B.SetInsertPoint (entryBB);
2240
2238
llvm::Constant *indices[] = {llvm::ConstantInt::get (Int32Ty, 0 ),
2241
2239
llvm::ConstantInt::get (Int32Ty, 0 )};
2242
2240
2243
- auto *fnPtr = B .CreateLoad (
2241
+ auto *fnPtr = IGF. Builder .CreateLoad (
2244
2242
llvm::ConstantExpr::getInBoundsGetElementPtr (nullptr , linkEntry, indices),
2245
2243
getPointerAlignment ());
2246
- auto *typeFnPtr = B.CreateBitOrPointerCast (fnPtr, implFn->getType ());
2244
+ auto *typeFnPtr =
2245
+ IGF.Builder .CreateBitOrPointerCast (fnPtr, implFn->getType ());
2247
2246
2248
2247
SmallVector<llvm::Value *, 16 > forwardedArgs;
2249
2248
for (auto &arg : implFn->args ())
2250
2249
forwardedArgs.push_back (&arg);
2251
- auto *Res =
2252
- B. CreateCall ( FunctionPointer (typeFnPtr, signature), forwardedArgs);
2250
+ auto *Res = IGF. Builder . CreateCall ( FunctionPointer (typeFnPtr, signature),
2251
+ forwardedArgs);
2253
2252
2254
2253
if (implFn->getReturnType ()->isVoidTy ())
2255
- B .CreateRetVoid ();
2254
+ IGF. Builder .CreateRetVoid ();
2256
2255
else
2257
- B .CreateRet (Res);
2256
+ IGF. Builder .CreateRet (Res);
2258
2257
}
2259
2258
2260
2259
// / Find the entry point for a SIL function.
0 commit comments