Skip to content

Commit

Permalink
[FuncitonComparator] Clamp StringRef compare output to [-1,1]
Browse files Browse the repository at this point in the history
The comparison can have different values (but same sign) on big endian
platforms, avoid that to make the unit test green there.
  • Loading branch information
d0k committed Jan 16, 2023
1 parent 0069255 commit db6961d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/FunctionComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int FunctionComparator::cmpMem(StringRef L, StringRef R) const {

// Compare strings lexicographically only when it is necessary: only when
// strings are equal in size.
return L.compare(R);
return std::clamp(L.compare(R), -1, 1);
}

int FunctionComparator::cmpAttrs(const AttributeList L,
Expand Down

0 comments on commit db6961d

Please sign in to comment.