MS ABI: Eliminate Duplicate Strings
COFF doesn't have mergeable sections so LLVM/clang's normal tactics for string deduplication will not have any effect. To remedy this we place each string inside it's own section and mark the section as IMAGE_COMDAT_SELECT_ANY. However, we can only do this if the string has an external name that we can generate from it's contents. To be compatible with MSVC, we must use their scheme. Otherwise identical strings in translation units from clang may not be deduplicated with translation units in MSVC. This fixes PR18248. N.B. We will not attempt to do anything with a string literal which is not of type 'char' or 'wchar_t' because their compiler does not support unicode string literals as of this date. Further, we avoid doing this if either -fwritable-strings or -fsanitize=address are present. This reverts commit r204596. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204675 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/AST/Mangle.h 4 additions, 1 deletioninclude/clang/AST/Mangle.h
- lib/AST/ItaniumMangle.cpp 10 additions, 0 deletionslib/AST/ItaniumMangle.cpp
- lib/AST/MicrosoftMangle.cpp 174 additions, 0 deletionslib/AST/MicrosoftMangle.cpp
- lib/CodeGen/CodeGenModule.cpp 60 additions, 18 deletionslib/CodeGen/CodeGenModule.cpp
- lib/CodeGen/CodeGenModule.h 4 additions, 1 deletionlib/CodeGen/CodeGenModule.h
- test/CodeGen/c-strings.c 10 additions, 5 deletionstest/CodeGen/c-strings.c
- test/CodeGen/string-literal-short-wstring.c 6 additions, 3 deletionstest/CodeGen/string-literal-short-wstring.c
- test/CodeGen/wchar-const.c 1 addition, 1 deletiontest/CodeGen/wchar-const.c
- test/CodeGenCXX/mangle-ms-string-literals.cpp 719 additions, 0 deletionstest/CodeGenCXX/mangle-ms-string-literals.cpp
Loading
Please register or sign in to comment