Skip to content

Commit

Permalink
Work around a bug in the x86_64 swiftasync argument treatment.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjmccall committed Feb 22, 2021
1 parent 2012195 commit fd96f41
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,13 @@ void IRGenSILFunction::visitFunctionRefBaseInst(FunctionRefBaseInst *i) {
value = llvm::ConstantExpr::getBitCast(value, fnPtr->getType());
} else {
value = fnPtr;

// HACK: the swiftasync argument treatment is currently using
// a register that can be clobbered by the linker. Use nonlazybind
// as a workaround.
if (fpKind.isSpecial()) {
cast<llvm::Function>(value)->addFnAttr(llvm::Attribute::NonLazyBind);
}
}
FunctionPointer fp = FunctionPointer(fpKind, value, sig);

Expand Down

0 comments on commit fd96f41

Please sign in to comment.