summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2021-09-16 18:13:15 +0200
committerserge-sans-paille <sguelton@redhat.com>2021-09-28 21:00:47 +0200
commitc3717b6858d32d64514a187ede1a77be8ba4e542 (patch)
tree8aaa16ae5f4dd3ad04dd2c2603ed6d929917a1ac /clang/lib/CodeGen/CodeGenModule.cpp
parentb9f547e8e51182d32f1912f97a3e53f4899ea6be (diff)
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 9715657b4c6e..83418014f0b5 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3169,6 +3169,11 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
}
}
+ // Inline builtins declaration must be emitted. They often are fortified
+ // functions.
+ if (F->isInlineBuiltinDeclaration())
+ return true;
+
// PR9614. Avoid cases where the source code is lying to us. An available
// externally function should have an equivalent function somewhere else,
// but a function that calls itself through asm label/`__builtin_` trickery is