diff options
author | Reid Kleckner <rnk@google.com> | 2018-09-06 18:25:39 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2018-09-06 18:25:39 +0000 |
commit | 7a368968648cb2faec42c9f41c062ef8177a075f (patch) | |
tree | cd46ec411856f6c14319b26c90e66a619512a843 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 1e8edd13ee60d59a3b9c578f6be0d9a3cf6e1bd2 (diff) | |
download | bcm5719-llvm-7a368968648cb2faec42c9f41c062ef8177a075f.tar.gz bcm5719-llvm-7a368968648cb2faec42c9f41c062ef8177a075f.zip |
Re-land r334417 "[MS] Use mangled names and comdats for string merging with ASan"
The issue with -fprofile-generate was fixed and the dependent CL
relanded in r340232.
llvm-svn: 341572
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 51869ef7cbe..5fec6c7bcb0 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4305,15 +4305,13 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef GlobalVariableName; llvm::GlobalValue::LinkageTypes LT; - // Mangle the string literal if the ABI allows for it. However, we cannot - // do this if we are compiling with ASan or -fwritable-strings because they - // rely on strings having normal linkage. - if (!LangOpts.WritableStrings && - !LangOpts.Sanitize.has(SanitizerKind::Address) && - getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) { + // Mangle the string literal if that's how the ABI merges duplicate strings. + // Don't do it if they are writable, since we don't want writes in one TU to + // affect strings in another. + if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) && + !LangOpts.WritableStrings) { llvm::raw_svector_ostream Out(MangledNameBuffer); getCXXABI().getMangleContext().mangleStringLiteral(S, Out); - LT = llvm::GlobalValue::LinkOnceODRLinkage; GlobalVariableName = MangledNameBuffer; } else { |