[PATCH] D31270: [wip] IR: Move linker options to top-level global metadata and remove dllexport storage class.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 16:43:11 PDT 2017


pcc created this revision.
Herald added a subscriber: mehdi_amini.

dllexport is not actually a global-level attribute. At the object file
level, it is in fact a module-level attribute and is represented with an
/export flag in the directive section. Trying to shoehorn it into being a
global-level attribute creates unnecessary complexity and a burden on the
rest of the compiler and invites bugs.

Independent of whether it is a global- or module-level attribute, it makes
sense to split dllimport from dllexport, as they are somewhat orthogonal. The
meaning of dllexport is similar to ELF symbol visibility, while the meaning
of dllimport is closer to preemptability (see also https://reviews.llvm.org/D20217). With this,
dllimport can potentially receive a meaning in other object formats without
being in the confusing situation where dllexport only has meaning for COFF
and dllimport also has meaning elsewhere.

This patch does three things:

- Moves the linker options from a module flag to top-level module metadata. Storing it as a module flag only makes it harder to manipulate the linker options.
- Causes clang to add an /export flag to the linker options metadata if it is emitting a definition that will be dllexported.
- Removes the dllexport storage class and stores dllimport as a boolean.

Test cases to be updated.

Fixes PR32334.


https://reviews.llvm.org/D31270

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/Target/TargetLoweringObjectFile.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOModule.cpp
  llvm/lib/Linker/LinkModules.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/ARM/ARMAsmPrinter.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/IPO/Internalize.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31270.92740.patch
Type: text/x-patch
Size: 64793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170322/d70771b9/attachment-0001.bin>


More information about the llvm-commits mailing list