Simplify handling of builtin with inline redefinition
authorserge-sans-paille <sguelton@redhat.com>
Thu, 16 Sep 2021 16:13:15 +0000 (18:13 +0200)
committerserge-sans-paille <sguelton@redhat.com>
Tue, 28 Sep 2021 19:00:47 +0000 (21:00 +0200)
commitc3717b6858d32d64514a187ede1a77be8ba4e542
tree8aaa16ae5f4dd3ad04dd2c2603ed6d929917a1ac
parentb9f547e8e51182d32f1912f97a3e53f4899ea6be
Simplify handling of builtin with inline redefinition

(This is a recommit of 3d6f49a56995b845 that should no longer break validation since
bd379915de38a9af3d65e1).

It is a common practice in glibc header to provide an inline redefinition of an
existing function. It is especially the case for fortified function.

Clang currently has an imperfect approach to the problem, using a combination of
trivially recursive function detection and noinline attribute.

Simplify the logic by suffixing these functions by `.inline` during codegen, so
that they are not recognized as builtin by llvm.

After that patch, clang passes all tests from https://github.com/serge-sans-paille/fortify-test-suite

Differential Revision: https://reviews.llvm.org/D109967
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/memcpy-inline-builtin.c [new file with mode: 0644]
clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c [deleted file]
clang/test/CodeGen/memcpy-nobuiltin.c
clang/test/CodeGen/pr9614.c