Skip to content

Commit

Permalink
Zero sret copy
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Dec 16, 2023
1 parent d22dd49 commit 65fd8ac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions enzyme/Enzyme/CApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,17 @@ void EnzymeFixupJuliaCallingConvention(LLVMValueRef F_C) {
ArrayRef<int> inds, int sretCount, Type *ptrTy) {
if (auto PT = dyn_cast<PointerType>(curType)) {
if (PT->getAddressSpace() == 10) {
SmallVector<Value *, 1> outinds;
auto c0 = ConstantInt::get(B.getInt64Ty(), 0);
outinds.push_back(c0);
if (sretCount >= 0)
outinds.push_back(ConstantInt::get(B.getInt32Ty(), sretCount));
for (auto v : inds) {
outinds.push_back(ConstantInt::get(B.getInt32Ty(), v));
}
if (outinds.size() > 1)
out = B.CreateInBoundsGEP(sretTy, out, outinds);
B.CreateStore(ConstantPointerNull::get(PT), out);
return;
}
}
Expand Down

0 comments on commit 65fd8ac

Please sign in to comment.