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 13:24:25 +0200
commit3d6f49a56995b845c40be5827ded5d1e3f692cec (patch)
treec7de77b8d0040ff4d774ced4c26ed0b1d6ce4c25 /clang/lib/CodeGen/CodeGenFunction.cpp
parent5aa4c74c9a2ee3c4e6e87adfa2ef218c5aeed1d6 (diff)
downloadllvm-3d6f49a56995b845c40be5827ded5d1e3f692cec.zip
llvm-3d6f49a56995b845c40be5827ded5d1e3f692cec.tar.gz
llvm-3d6f49a56995b845c40be5827ded5d1e3f692cec.tar.bz2
Simplify handling of builtin with inline redefinition
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 5f63461a..fbb0688 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1301,6 +1301,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