Skip to content

Commit db6961d

Browse files
committed
[FuncitonComparator] Clamp StringRef compare output to [-1,1]
The comparison can have different values (but same sign) on big endian platforms, avoid that to make the unit test green there.
1 parent 0069255 commit db6961d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Transforms/Utils/FunctionComparator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int FunctionComparator::cmpMem(StringRef L, StringRef R) const {
110110

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

116116
int FunctionComparator::cmpAttrs(const AttributeList L,

0 commit comments

Comments
 (0)