Skip to content

Commit

Permalink
Mark getenv/strtol/fwrite as nondifferentiable (#1868)
Browse files Browse the repository at this point in the history
* Mark getenv/strtol/fwrite as nondifferentiable

* also mark no escaping alloc

* add nlopt
  • Loading branch information
wsmoses committed May 8, 2024
1 parent f3dd860 commit f22916f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ const StringSet<> KnownInactiveFunctions = {
"__cxa_guard_acquire",
"__cxa_guard_release",
"__cxa_guard_abort",
"getenv",
"strtol",
"fwrite",
"snprintf",
"sprintf",
"printf",
Expand Down
3 changes: 2 additions & 1 deletion enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ bool attributeKnownFunctions(llvm::Function &F) {
"createERmm" ||
F.getName() ==
"_ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm" ||
F.getName() == "fprintf") {
F.getName() == "fprintf" || F.getName() == "fwrite" ||
F.getName() == "strtol" || F.getName() == "getenv") {
changed = true;
F.addAttribute(
AttributeList::FunctionIndex,
Expand Down
4 changes: 3 additions & 1 deletion enzyme/Enzyme/EnzymeLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6377,7 +6377,9 @@ llvm::Function *EnzymeLogic::CreateNoFree(RequestContext context, Function *F) {
"MPI_Allreduce",
"lgamma",
"lgamma_r",
"__kmpc_global_thread_num"};
"__kmpc_global_thread_num",
"nlopt_force_stop"
};
// clang-format on

if (startsWith(F->getName(), "_ZNSolsE") || NoFrees.count(F->getName()))
Expand Down

0 comments on commit f22916f

Please sign in to comment.