Skip to content

Commit

Permalink
mark strcmp as inactive2 (rust-lang#716)
Browse files Browse the repository at this point in the history
* mark strcmp as inactive2

* mark strcmp as inactive3

* mark strcmp as ro

* mark Fn too
  • Loading branch information
ZuseZ4 committed Jun 26, 2022
1 parent 3316e62 commit 5d5ee10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,12 @@ class Enzyme : public ModulePass {
Fn->getName() == "__mth_i_ipowi") {
CI->addAttribute(AttributeList::FunctionIndex, Attribute::ReadNone);
}
if (Fn->getName().contains("strcmp")) {
Fn->addParamAttr(0, Attribute::ReadOnly);
Fn->addParamAttr(1, Attribute::ReadOnly);
Fn->addFnAttr(Attribute::ReadOnly);
CI->addAttribute(AttributeList::FunctionIndex, Attribute::ReadOnly);
}
if (Fn->getName() == "f90io_fmtw_end" ||
Fn->getName() == "f90io_unf_end") {
Fn->addFnAttr(Attribute::InaccessibleMemOnly);
Expand Down
8 changes: 8 additions & 0 deletions enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4039,6 +4039,14 @@ void TypeAnalyzer::visitCallInst(CallInst &call) {
&call);
return;
}
if (funcName == "strcmp") {
updateAnalysis(&call, TypeTree(BaseType::Integer).Only(-1), &call);
updateAnalysis(call.getOperand(0), TypeTree(BaseType::Pointer).Only(-1),
&call);
updateAnalysis(call.getOperand(1), TypeTree(BaseType::Pointer).Only(-1),
&call);
return;
}
if (funcName == "bcmp") {
updateAnalysis(&call, TypeTree(BaseType::Integer).Only(-1), &call);
updateAnalysis(call.getOperand(0), TypeTree(BaseType::Pointer).Only(-1),
Expand Down

0 comments on commit 5d5ee10

Please sign in to comment.