From 248ed074199e4aa65c706a11033de88da883856d Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 7 Dec 2018 15:31:23 +0000 Subject: Make CPUDispatch resolver emit dependent functions. Inline cpu_specific versions referenced before the cpu_dispatch function weren't properly emitted, since they hadn't been referred to. This patch ensures that during resolver generation that all appropriate versions are emitted. Change-Id: I94c3766aaf9c75ca07a0ad8258efdbb834654ff8 llvm-svn: 348600 --- clang/lib/CodeGen/CodeGenModule.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8130449..b80a43b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2585,11 +2585,22 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { llvm::Constant *Func = GetGlobalValue(MangledName); - if (!Func) + if (!Func) { + GlobalDecl ExistingDecl = Manglings.lookup(MangledName); + if (ExistingDecl.getDecl() && + ExistingDecl.getDecl()->getAsFunction()->isDefined()) { + EmitGlobalFunctionDefinition(ExistingDecl, nullptr); + Func = GetGlobalValue(MangledName); + } else { + if (!ExistingDecl.getDecl()) + ExistingDecl = GD.getWithMultiVersionIndex(Index); + Func = GetOrCreateLLVMFunction( - MangledName, DeclTy, GD.getWithMultiVersionIndex(Index), + MangledName, DeclTy, ExistingDecl, /*ForVTable=*/false, /*DontDefer=*/true, /*IsThunk=*/false, llvm::AttributeList(), ForDefinition); + } + } llvm::SmallVector Features; Target.getCPUSpecificCPUDispatchFeatures(II->getName(), Features); -- cgit v1.1