@@ -2246,11 +2246,11 @@ static bool isPointerTo(llvm::Type *ptrTy, llvm::Type *objTy) {
22462246}
22472247
22482248// / Get or create an LLVM function with these linkage rules.
2249- llvm::Function *irgen::createFunction (IRGenModule &IGM,
2250- LinkInfo &linkInfo,
2249+ llvm::Function *irgen::createFunction (IRGenModule &IGM, LinkInfo &linkInfo,
22512250 const Signature &signature,
22522251 llvm::Function *insertBefore,
2253- OptimizationMode FuncOptMode) {
2252+ OptimizationMode FuncOptMode,
2253+ StackProtectorMode stackProtect) {
22542254 auto name = linkInfo.getName ();
22552255
22562256 llvm::Function *existing = IGM.Module .getFunction (name);
@@ -2282,7 +2282,7 @@ llvm::Function *irgen::createFunction(IRGenModule &IGM,
22822282 .to (fn, linkInfo.isForDefinition ());
22832283
22842284 llvm::AttrBuilder initialAttrs;
2285- IGM.constructInitialFnAttributes (initialAttrs, FuncOptMode);
2285+ IGM.constructInitialFnAttributes (initialAttrs, FuncOptMode, stackProtect );
22862286 // Merge initialAttrs with attrs.
22872287 auto updatedAttrs = signature.getAttributes ().addFnAttributes (
22882288 IGM.getLLVMContext (), initialAttrs);
@@ -3059,7 +3059,7 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) {
30593059 LinkInfo implLink = LinkInfo::get (*this , entity, ForDefinition);
30603060 auto implFn =
30613061 createFunction (*this , implLink, signature, nullptr /* insertBefore*/ ,
3062- f->getOptimizationMode ());
3062+ f->getOptimizationMode (), shouldEmitStackProtector (f) );
30633063 implFn->addFnAttr (llvm::Attribute::NoInline);
30643064
30653065 IRGenFunction IGF (*this , implFn);
@@ -3168,6 +3168,10 @@ llvm::Constant *swift::irgen::emitCXXConstructorThunkIfNeeded(
31683168 return thunk;
31693169}
31703170
3171+ StackProtectorMode IRGenModule::shouldEmitStackProtector (SILFunction *f) {
3172+ return IRGen.Opts .getStackProtectorMode ();
3173+ }
3174+
31713175// / Find the entry point for a SIL function.
31723176llvm::Function *IRGenModule::getAddrOfSILFunction (
31733177 SILFunction *f, ForDefinition_t forDefinition,
@@ -3263,7 +3267,7 @@ llvm::Function *IRGenModule::getAddrOfSILFunction(
32633267 LinkInfo link = LinkInfo::get (*this , entity, forDefinition);
32643268
32653269 fn = createFunction (*this , link, signature, insertBefore,
3266- f->getOptimizationMode ());
3270+ f->getOptimizationMode (), shouldEmitStackProtector (f) );
32673271
32683272 // If `hasCReferences` is true, then the function is either marked with
32693273 // @_silgen_name OR @_cdecl. If it is the latter, it must have a definition
0 commit comments