Skip to content

Commit

Permalink
Generalize blas attributor (#2171)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Nov 19, 2024
1 parent d9d6338 commit e42f5aa
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,25 @@ void callMemcpyStridedBlas(llvm::IRBuilder<> &B, llvm::Module &M, BlasInfo blas,

FunctionType *FT = FunctionType::get(copy_retty, tys, false);
auto fn = M.getOrInsertFunction(copy_name, FT);
Function *F = cast<Function>(fn.getCallee());
attributeKnownFunctions(*F);
Value *callVal = fn.getCallee();
Function *called = nullptr;
while (!called) {
if (auto castinst = dyn_cast<ConstantExpr>(callVal))
if (castinst->isCast()) {
callVal = castinst->getOperand(0);
continue;
}
if (auto fn = dyn_cast<Function>(callVal)) {
called = fn;
break;
}
if (auto alias = dyn_cast<GlobalAlias>(callVal)) {
callVal = alias->getAliasee();
continue;
}
break;
}
attributeKnownFunctions(*called);

B.CreateCall(fn, args, bundles);
}
Expand Down

0 comments on commit e42f5aa

Please sign in to comment.