File tree Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -6487,7 +6487,8 @@ class AdjointGenerator
6487
6487
// may load uncacheable data)
6488
6488
// Store and reload it
6489
6489
if (Mode != DerivativeMode::ReverseModeCombined && subretused &&
6490
- !orig->doesNotAccessMemory ()) {
6490
+ (orig->mayWriteToMemory () ||
6491
+ !gutils->legalRecompute (orig, ValueToValueMapTy (), nullptr ))) {
6491
6492
if (!gutils->unnecessaryIntermediates .count (orig)) {
6492
6493
gutils->cacheForReverse (BuilderZ, newCall,
6493
6494
getIndex (orig, CacheType::Self));
Original file line number Diff line number Diff line change @@ -816,10 +816,13 @@ class Enzyme : public ModulePass {
816
816
if (Fn->getName ().contains (" __enzyme_call_inactive" )) {
817
817
InactiveCalls.insert (CI);
818
818
}
819
- if (F.getName () == " omp_get_max_threads" ||
820
- F.getName () == " omp_get_thread_num" ) {
821
- F.addFnAttr (Attribute::ReadOnly);
822
- F.addFnAttr (Attribute::InaccessibleMemOnly);
819
+ if (Fn->getName () == " omp_get_max_threads" ||
820
+ Fn->getName () == " omp_get_thread_num" ) {
821
+ Fn->addFnAttr (Attribute::ReadOnly);
822
+ CI->addAttribute (AttributeList::FunctionIndex, Attribute::ReadOnly);
823
+ Fn->addFnAttr (Attribute::InaccessibleMemOnly);
824
+ CI->addAttribute (AttributeList::FunctionIndex,
825
+ Attribute::InaccessibleMemOnly);
823
826
}
824
827
if ((Fn->getName () == " cblas_ddot" || Fn->getName () == " cblas_sdot" ) &&
825
828
Fn->isDeclaration ()) {
Original file line number Diff line number Diff line change @@ -195,20 +195,6 @@ struct CacheAnalysis {
195
195
// Pointer operands originating from call instructions that are not
196
196
// malloc/free are conservatively considered uncacheable.
197
197
if (auto obj_op = dyn_cast<CallInst>(obj)) {
198
- Function *called = obj_op->getCalledFunction ();
199
- #if LLVM_VERSION_MAJOR >= 11
200
- if (auto castinst = dyn_cast<ConstantExpr>(obj_op->getCalledOperand ()))
201
- #else
202
- if (auto castinst = dyn_cast<ConstantExpr>(obj_op->getCalledValue ()))
203
- #endif
204
- {
205
- if (castinst->isCast ()) {
206
- if (auto fn = dyn_cast<Function>(castinst->getOperand (0 ))) {
207
- called = fn;
208
- }
209
- }
210
- }
211
-
212
198
// If this is a known allocation which is not captured or returned,
213
199
// a caller function cannot overwrite this (since it cannot access).
214
200
// Since we don't currently perform this check, we can instead check
You can’t perform that action at this time.
0 commit comments