[all-commits] [llvm/llvm-project] 7134d2: [SimplifyLibCalls] Fix memchr misoptimization (#10...
Sergei Barannikov via All-commits
all-commits at lists.llvm.org
Mon Aug 26 14:11:44 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7134d2e9ac36c833bb9ed90363def74fd84f7d13
https://github.com/llvm/llvm-project/commit/7134d2e9ac36c833bb9ed90363def74fd84f7d13
Author: Sergei Barannikov <barannikov88 at gmail.com>
Date: 2024-08-27 (Tue, 27 Aug 2024)
Changed paths:
M llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
M llvm/test/Transforms/InstCombine/memchr-7.ll
Log Message:
-----------
[SimplifyLibCalls] Fix memchr misoptimization (#106121)
The `ch` argument of memcmp should be truncated to `unsigned char`
before using it in comparisons. This didn't happen on all code paths.
The following program miscompiled at -O1 and higher:
```C++
#include <cstring>
#include <iostream>
char ch = '\x81';
int main() {
bool found = std::strchr("\x80\x81\x82", ch) != nullptr;
std::cout << std::boolalpha << found << '\n';
}
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list