Skip to content

Commit 4bffcac

Browse files
Merge pull request swiftlang#36496 from aschwaighofer/revert_ptrauth-returns_workaround
Revert "arm64e: Workaround ptrauth-returns failure for swifttailcc"
2 parents 4d0e4a8 + 340ccb2 commit 4bffcac

File tree

6 files changed

+11
-28
lines changed

6 files changed

+11
-28
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4845,9 +4845,8 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
48454845
auto *fnTy = llvm::FunctionType::get(
48464846
IGM.VoidTy, {IGM.Int8PtrTy},
48474847
false /*vaargs*/);
4848-
auto signature = Signature(
4849-
fnTy, IGM.constructInitialAttributes(true /*disable ptrauth-returns*/),
4850-
IGM.SwiftAsyncCC);
4848+
auto signature =
4849+
Signature(fnTy, IGM.constructInitialAttributes(), IGM.SwiftAsyncCC);
48514850
auto fnPtr = FunctionPointer(
48524851
FunctionPointer::Kind::Function,
48534852
Builder.CreateBitOrPointerCast(resume, fnTy->getPointerTo()),

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,11 +2100,7 @@ llvm::Function *irgen::createFunction(IRGenModule &IGM,
21002100
.to(fn, linkInfo.isForDefinition());
21012101

21022102
llvm::AttrBuilder initialAttrs;
2103-
// Workaround an llvm bug that does not handle this case correctly.
2104-
bool disablePtrAuthReturns =
2105-
signature.getCallingConv() == llvm::CallingConv::SwiftTail;
2106-
IGM.constructInitialFnAttributes(initialAttrs, disablePtrAuthReturns,
2107-
FuncOptMode);
2103+
IGM.constructInitialFnAttributes(initialAttrs, FuncOptMode);
21082104
// Merge initialAttrs with attrs.
21092105
auto updatedAttrs =
21102106
signature.getAttributes().addAttributes(IGM.getLLVMContext(),
@@ -2815,7 +2811,7 @@ llvm::Constant *swift::irgen::emitCXXConstructorThunkIfNeeded(
28152811
thunk->setCallingConv(llvm::CallingConv::C);
28162812

28172813
llvm::AttrBuilder attrBuilder;
2818-
IGM.constructInitialFnAttributes(attrBuilder, false /*disablePtrAuthReturns*/);
2814+
IGM.constructInitialFnAttributes(attrBuilder);
28192815
attrBuilder.addAttribute(llvm::Attribute::AlwaysInline);
28202816
llvm::AttributeList attr = signature.getAttributes().addAttributes(
28212817
IGM.getLLVMContext(), llvm::AttributeList::FunctionIndex, attrBuilder);

lib/IRGen/GenFunc.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,9 +1198,7 @@ static llvm::Value *emitPartialApplicationForwarder(IRGenModule &IGM,
11981198
fwd->setAttributes(outAttrs);
11991199
// Merge initial attributes with outAttrs.
12001200
llvm::AttrBuilder b;
1201-
bool disablePtrAuthReturns =
1202-
outSig.getCallingConv() == llvm::CallingConv::SwiftTail;
1203-
IGM.constructInitialFnAttributes(b, disablePtrAuthReturns);
1201+
IGM.constructInitialFnAttributes(b);
12041202
fwd->addAttributes(llvm::AttributeList::FunctionIndex, b);
12051203

12061204
IRGenFunction subIGF(IGM, fwd);

lib/IRGen/GenObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
717717
fwd->setAttributes(attrs);
718718
// Merge initial attributes with attrs.
719719
llvm::AttrBuilder b;
720-
IGM.constructInitialFnAttributes(b, false /*disable ptr auth returns*/);
720+
IGM.constructInitialFnAttributes(b);
721721
fwd->addAttributes(llvm::AttributeList::FunctionIndex, b);
722722

723723
IRGenFunction subIGF(IGM, fwd);

lib/IRGen/IRGenModule.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,18 +1111,11 @@ void IRGenModule::setHasNoFramePointer(llvm::Function *F) {
11111111
}
11121112

11131113
/// Construct initial function attributes from options.
1114-
void IRGenModule::constructInitialFnAttributes(
1115-
llvm::AttrBuilder &Attrs, bool disablePtrAuthReturns,
1116-
OptimizationMode FuncOptMode) {
1114+
void IRGenModule::constructInitialFnAttributes(llvm::AttrBuilder &Attrs,
1115+
OptimizationMode FuncOptMode) {
11171116
// Add the default attributes for the Clang configuration.
11181117
clang::CodeGen::addDefaultFunctionDefinitionAttributes(getClangCGM(), Attrs);
11191118

1120-
// Disable `ptrauth-returns`. It does not work for swifttailcc lowering atm.
1121-
// The `autibsp` instruction executed before a tail call that adjust the stack
1122-
// will currently fail.
1123-
if (disablePtrAuthReturns)
1124-
Attrs.removeAttribute("ptrauth-returns");
1125-
11261119
// Add/remove MinSize based on the appropriate setting.
11271120
if (FuncOptMode == OptimizationMode::NotSet)
11281121
FuncOptMode = IRGen.Opts.OptMode;
@@ -1135,10 +1128,9 @@ void IRGenModule::constructInitialFnAttributes(
11351128
}
11361129
}
11371130

1138-
llvm::AttributeList
1139-
IRGenModule::constructInitialAttributes(bool disablePtrAuthReturns) {
1131+
llvm::AttributeList IRGenModule::constructInitialAttributes() {
11401132
llvm::AttrBuilder b;
1141-
constructInitialFnAttributes(b, disablePtrAuthReturns);
1133+
constructInitialFnAttributes(b);
11421134
return llvm::AttributeList::get(getLLVMContext(),
11431135
llvm::AttributeList::FunctionIndex, b);
11441136
}

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,13 +1362,11 @@ private: \
13621362
bool finalize();
13631363

13641364
void constructInitialFnAttributes(llvm::AttrBuilder &Attrs,
1365-
bool disablePtrAuthReturns,
13661365
OptimizationMode FuncOptMode =
13671366
OptimizationMode::NotSet);
13681367
void setHasNoFramePointer(llvm::AttrBuilder &Attrs);
13691368
void setHasNoFramePointer(llvm::Function *F);
1370-
llvm::AttributeList
1371-
constructInitialAttributes(bool disablePtrAuthReturns = false);
1369+
llvm::AttributeList constructInitialAttributes();
13721370

13731371
void emitProtocolDecl(ProtocolDecl *D);
13741372
void emitEnumDecl(EnumDecl *D);

0 commit comments

Comments
 (0)