Skip to content

Commit fd96f41

Browse files
committed
Work around a bug in the x86_64 swiftasync argument treatment.
r11 is the linker scratch register, so we need to make sure that we don't end up in the linker when making cross-library direct async calls. Since there are currently only a few special symbols that we do that for, we can achieve this by disabling lazy binding for those symbols specifically.
1 parent 2012195 commit fd96f41

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,13 @@ void IRGenSILFunction::visitFunctionRefBaseInst(FunctionRefBaseInst *i) {
23162316
value = llvm::ConstantExpr::getBitCast(value, fnPtr->getType());
23172317
} else {
23182318
value = fnPtr;
2319+
2320+
// HACK: the swiftasync argument treatment is currently using
2321+
// a register that can be clobbered by the linker. Use nonlazybind
2322+
// as a workaround.
2323+
if (fpKind.isSpecial()) {
2324+
cast<llvm::Function>(value)->addFnAttr(llvm::Attribute::NonLazyBind);
2325+
}
23192326
}
23202327
FunctionPointer fp = FunctionPointer(fpKind, value, sig);
23212328

0 commit comments

Comments
 (0)