From fd09f12f32f57564d619a28b8826d33ade47b12e Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 16 Jan 2020 11:56:41 +0100 Subject: Implement -fsemantic-interposition First attempt at implementing -fsemantic-interposition. Rely on GlobalValue::isInterposable that already captures most of the expected behavior. Rely on a ModuleFlag to state whether we should respect SemanticInterposition or not. The default remains no. So this should be a no-op if -fsemantic-interposition isn't used, and if it is, isInterposable being already used in most optimisation, they should honor it properly. Note that it only impacts architecture compiled with -fPIC and no pie. Differential Revision: https://reviews.llvm.org/D72829 --- clang/lib/CodeGen/CodeGenModule.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 03c3fec5ebec..6a43b6bba627 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -483,6 +483,11 @@ void CodeGenModule::Release() { getModule().addModuleFlag(llvm::Module::Max, "Dwarf Version", CodeGenOpts.DwarfVersion); } + + if (Context.getLangOpts().SemanticInterposition) + // Require various optimization to respect semantic interposition. + getModule().setSemanticInterposition(1); + if (CodeGenOpts.EmitCodeView) { // Indicate that we want CodeView in the metadata. getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1); @@ -872,7 +877,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, if (isa(GV) && !CGOpts.NoPLT && RM == llvm::Reloc::Static) return true; - // Otherwise don't assue it is local. + // Otherwise don't assume it is local. return false; } -- cgit v1.2.3