[PATCH] D130666: [InstCombine] Add support for strlcpy folding

Martin Sebor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 10:36:39 PDT 2022


msebor added a comment.

In D130666#3760810 <https://reviews.llvm.org/D130666#3760810>, @joanahalili wrote:

> This might break the following opensource lib https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
>
> In https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/configure#n445
>
> The compilation for the following code no longer fails when setting `-Wno-error-implicit-function-declaration`
>
>   #include <string.h>
>   int main(int argc, char **argv) {
>   	char dst[10];
>   	strlcpy(dst, "test", sizeof(dst));
>   	return 0;
>   }
>
> The behaviour difference between clang 14.0, clang trunk and gcc: https://godbolt.org/z/hKETMoEd6

The configuration test assumes the function call isn't optimized when it's compiled with optimization enabled.  A safer way to test for the presence of a function in a library than calling it without relying on the effect of the call in any way is to use its address in some nontrivial way, e.g., by printing it, or assigning it to a volatile-quialified pointer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130666/new/

https://reviews.llvm.org/D130666



More information about the llvm-commits mailing list