Skip to content

Commit

Permalink
Extended analysis to ignore fputc (#2031)
Browse files Browse the repository at this point in the history
* extended analysis to ignore fputc

* fixed format

---------

Co-authored-by: Rasmit Devkota <rdatch101@gmail.com>
  • Loading branch information
RasmitDevkota and weberaphg authored Aug 7, 2024
1 parent 87eed6b commit e5888a4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const StringSet<> KnownInactiveFunctions = {
"vprintf",
"vsnprintf",
"puts",
"fputc",
"fflush",
"__kmpc_for_static_init_4",
"__kmpc_for_static_init_4u",
Expand Down
1 change: 1 addition & 0 deletions enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ bool attributeKnownFunctions(llvm::Function &F) {
"_ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm",
"fprintf",
"fwrite",
"fputc",
"strtol",
"getenv",
"memchr",
Expand Down
1 change: 1 addition & 0 deletions enzyme/Enzyme/EnzymeLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6343,6 +6343,7 @@ llvm::Function *EnzymeLogic::CreateNoFree(RequestContext context, Function *F) {

StringSet<> NoFrees = {"mpfr_greater_p",
"fprintf",
"fputc",
"memchr",
"time",
"strlen",
Expand Down
1 change: 1 addition & 0 deletions enzyme/Enzyme/MLIR/Analysis/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static const std::set<std::string> KnownInactiveFunctions = {
"vprintf",
"vsnprintf",
"puts",
"fputc",
"fflush",
"__kmpc_for_static_init_4",
"__kmpc_for_static_init_4u",
Expand Down
3 changes: 2 additions & 1 deletion enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5549,7 +5549,8 @@ void TypeAnalyzer::visitCallBase(CallBase &call) {
}

if (funcName == "__cxa_guard_acquire" || funcName == "printf" ||
funcName == "vprintf" || funcName == "puts" || funcName == "fprintf") {
funcName == "vprintf" || funcName == "puts" || funcName == "fputc" ||
funcName == "fprintf") {
updateAnalysis(&call, TypeTree(BaseType::Integer).Only(-1, &call), &call);
}

Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static inline bool endsWith(llvm::StringRef string, llvm::StringRef suffix) {

static inline bool isCertainPrint(const llvm::StringRef name) {
if (name == "printf" || name == "puts" || name == "fprintf" ||
name == "putchar" ||
name == "putchar" || name == "fputc" ||
startsWith(name,
"_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_") ||
startsWith(name, "_ZNSolsE") || startsWith(name, "_ZNSo9_M_insert") ||
Expand Down

0 comments on commit e5888a4

Please sign in to comment.