mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
arm64e: Workaround ptrauth-returns failure for swifttailcc
The current code generation will emit an autibsp after adjusting the stack pointe for the tail call. If callee and caller argument area does not match this would fail.
This commit is contained in:
@@ -1111,11 +1111,18 @@ void IRGenModule::setHasNoFramePointer(llvm::Function *F) {
|
||||
}
|
||||
|
||||
/// Construct initial function attributes from options.
|
||||
void IRGenModule::constructInitialFnAttributes(llvm::AttrBuilder &Attrs,
|
||||
OptimizationMode FuncOptMode) {
|
||||
void IRGenModule::constructInitialFnAttributes(
|
||||
llvm::AttrBuilder &Attrs, bool disablePtrAuthReturns,
|
||||
OptimizationMode FuncOptMode) {
|
||||
// Add the default attributes for the Clang configuration.
|
||||
clang::CodeGen::addDefaultFunctionDefinitionAttributes(getClangCGM(), Attrs);
|
||||
|
||||
// Disable `ptrauth-returns`. It does not work for swifttailcc lowering atm.
|
||||
// The `autibsp` instruction executed before a tail call that adjust the stack
|
||||
// will currently fail.
|
||||
if (disablePtrAuthReturns)
|
||||
Attrs.removeAttribute("ptrauth-returns");
|
||||
|
||||
// Add/remove MinSize based on the appropriate setting.
|
||||
if (FuncOptMode == OptimizationMode::NotSet)
|
||||
FuncOptMode = IRGen.Opts.OptMode;
|
||||
@@ -1128,9 +1135,10 @@ void IRGenModule::constructInitialFnAttributes(llvm::AttrBuilder &Attrs,
|
||||
}
|
||||
}
|
||||
|
||||
llvm::AttributeList IRGenModule::constructInitialAttributes() {
|
||||
llvm::AttributeList
|
||||
IRGenModule::constructInitialAttributes(bool disablePtrAuthReturns) {
|
||||
llvm::AttrBuilder b;
|
||||
constructInitialFnAttributes(b);
|
||||
constructInitialFnAttributes(b, disablePtrAuthReturns);
|
||||
return llvm::AttributeList::get(getLLVMContext(),
|
||||
llvm::AttributeList::FunctionIndex, b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user