From 7963e8bebb90543d997bf99ae5f8cf9be579d9ea Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Wed, 18 Jul 2018 20:04:48 +0000 Subject: Add support for __declspec(code_seg("segname")) This patch uses CodeSegAttr to represent __declspec(code_seg) rather than building on the existing support for #pragma code_seg. The code_seg declspec is applied on functions and classes. This attribute enables the placement of code into separate named segments, including compiler- generated codes and template instantiations. For more information, please see the following: https://msdn.microsoft.com/en-us/library/dn636922.aspx This patch fixes the regression for the support for attribute ((section). https://github.com/llvm-mirror/clang/commit/746b78de7812bc785fbb5207b788348040b23fa7 Patch by Soumi Manna (Manna) Differential Revision: https://reviews.llvm.org/D48841 llvm-svn: 337420 --- clang/lib/CodeGen/CodeGenModule.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b412d30..6886870 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1387,8 +1387,10 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD, F->addAttributes(llvm::AttributeList::FunctionIndex, Attrs); } } - - if (const SectionAttr *SA = D->getAttr()) + + if (const auto *CSA = D->getAttr()) + GO->setSection(CSA->getName()); + else if (const auto *SA = D->getAttr()) GO->setSection(SA->getName()); } @@ -1485,8 +1487,10 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, setLinkageForGV(F, FD); setGVProperties(F, FD); - if (const SectionAttr *SA = FD->getAttr()) - F->setSection(SA->getName()); + if (const auto *CSA = FD->getAttr()) + F->setSection(CSA->getName()); + else if (const auto *SA = FD->getAttr()) + F->setSection(SA->getName()); if (FD->isReplaceableGlobalAllocationFunction()) { // A replaceable global allocation function does not act like a builtin by -- cgit v1.1