File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ class Enzyme : public ModulePass {
147147 bool AtomicAdd = Arch == Triple::nvptx || Arch == Triple::nvptx64 ||
148148 Arch == Triple::amdgcn;
149149
150+ std::map<int , Type*> byVal;
150151 for (unsigned i = 1 ; i < CI->getNumArgOperands (); ++i) {
151152 Value *res = CI->getArgOperand (i);
152153
@@ -357,7 +358,9 @@ class Enzyme : public ModulePass {
357358 }
358359 res = Builder.CreateBitCast (res, PTy);
359360 }
360-
361+ if (CI->isByValArgument (i)) {
362+ byVal[args.size ()] = CI->getParamByValType (i);
363+ }
361364 args.push_back (res);
362365 if (ty == DIFFE_TYPE::DUP_ARG || ty == DIFFE_TYPE::DUP_NONEED) {
363366 ++i;
@@ -476,6 +479,9 @@ class Enzyme : public ModulePass {
476479 CallInst *diffret = cast<CallInst>(Builder.CreateCall (newFunc, args));
477480 diffret->setCallingConv (CI->getCallingConv ());
478481 diffret->setDebugLoc (CI->getDebugLoc ());
482+ for (auto pair : byVal) {
483+ diffret->addParamAttr (pair.first , Attribute::getWithByValType (diffret->getContext (), pair.second ));
484+ }
479485
480486 if (!diffret->getType ()->isEmptyTy () && !diffret->getType ()->isVoidTy ()) {
481487 unsigned idxs[] = {0 };
You can’t perform that action at this time.
0 commit comments