mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Fixing a corner-case bug in strchr and strrchr lib call optimizations where
the input character is not converted to char before comparing with zero. The patch was discussed in this thread: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130812/184069.html git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188489 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -477,7 +477,7 @@ struct StrChrOpt : public LibCallOptimization {
|
||||
|
||||
// Compute the offset, make sure to handle the case when we're searching for
|
||||
// zero (a weird way to spell strlen).
|
||||
size_t I = CharC->getSExtValue() == 0 ?
|
||||
size_t I = (255 & CharC->getSExtValue()) == 0 ?
|
||||
Str.size() : Str.find(CharC->getSExtValue());
|
||||
if (I == StringRef::npos) // Didn't find the char. strchr returns null.
|
||||
return Constant::getNullValue(CI->getType());
|
||||
@ -513,7 +513,7 @@ struct StrRChrOpt : public LibCallOptimization {
|
||||
}
|
||||
|
||||
// Compute the offset.
|
||||
size_t I = CharC->getSExtValue() == 0 ?
|
||||
size_t I = (255 & CharC->getSExtValue()) == 0 ?
|
||||
Str.size() : Str.rfind(CharC->getSExtValue());
|
||||
if (I == StringRef::npos) // Didn't find the char. Return null.
|
||||
return Constant::getNullValue(CI->getType());
|
||||
|
Reference in New Issue
Block a user