As reported in PR46735:
void* f(void *d, const void *s, size_t l)
{
return __builtin___mempcpy_chk(d, s, l, __builtin_object_size(d, 0));
}
This can be optimized to return mempcpy(d, s, l);.
Paths
| Differential D86019
[SLC] Optimize mempcpy_chk to mempcpy ClosedPublic Authored by xbolva00 on Aug 15 2020, 9:04 AM.
Details
Summary As reported in PR46735: void* f(void *d, const void *s, size_t l) return __builtin___mempcpy_chk(d, s, l, __builtin_object_size(d, 0)); } This can be optimized to return mempcpy(d, s, l);.
Diff Detail Event Timeline
xbolva00 retitled this revision from [SLC] Optimize _mempcpy_chk to direct call to mempcpy to [SLC] Optimize mempcpy_chk to mempcpy.Aug 15 2020, 10:09 AM Comment Actions This patch has an obvious miscompile; please try to be more careful testing your patches. This revision is now accepted and ready to land.Oct 4 2020, 10:07 PM Closed by commit rG3f1fd59de300: [SLC] Optimize mempcpy_chk to mempcpy (authored by xbolva00). · Explain WhyOct 5 2020, 1:19 PM This revision was automatically updated to reflect the committed changes. xbolva00 added a reverting change: rGa4bae56ab8e9: Revert "[SLC] Optimize mempcpy_chk to mempcpy".Oct 5 2020, 1:27 PM
Revision Contents
Diff 290128 llvm/include/llvm/Analysis/TargetLibraryInfo.def
llvm/include/llvm/Transforms/Utils/BuildLibCalls.h
llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/fortify-folding.ll
|
Well actually LLVM goes futher and transforms mempcpy to memcpy + dst, since we have more optimizations for memcpy.