aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.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/CodeGenFunction.cpp
parentb9f547e8e51182d32f1912f97a3e53f4899ea6be (diff)
downloadllvm-c3717b6858d32d64514a187ede1a77be8ba4e542.zip
llvm-c3717b6858d32d64514a187ede1a77be8ba4e542.tar.gz
llvm-c3717b6858d32d64514a187ede1a77be8ba4e542.tar.bz2
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/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index fddc1c4..da9a530 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1294,6 +1294,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
FunctionArgList Args;
QualType ResTy = BuildFunctionArgList(GD, Args);
+ // Give a different name to inline builtin to avoid conflict with actual
+ // builtins.
+ if (FD->isInlineBuiltinDeclaration() && Fn)
+ Fn->setName(Fn->getName() + ".inline");
+
// Check if we should generate debug info for this function.
if (FD->hasAttr<NoDebugAttr>()) {
// Clear non-distinct debug info that was possibly attached to the function