From 17965d42f420a0ca6d7bd5b9a0d7d472dfc5689d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 13 Jun 2019 19:00:16 +0000 Subject: C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue conversion applied to a member access or similar not-quite-trivial lvalue expression. Summary: When a variable is named in a context where we can't directly emit a reference to it (because we don't know for sure that it's going to be defined, or it's from an enclosing function and not captured, or the reference might not "work" for some reason), we emit a copy of the variable as a global and use that for the known-to-be-read-only access. Reviewers: rjmccall Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63157 llvm-svn: 363295 --- clang/lib/CodeGen/CodeGenModule.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.h') diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 8c1bc0777de..95964afed4e 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -362,6 +362,10 @@ private: llvm::SmallVector, 8> GlobalValReplacements; + /// Variables for which we've emitted globals containing their constant + /// values along with the corresponding globals, for opportunistic reuse. + llvm::DenseMap InitializerConstants; + /// Set of global decls for which we already diagnosed mangled name conflict. /// Required to not issue a warning (on a mangling conflict) multiple times /// for the same decl. @@ -623,6 +627,9 @@ public: StaticLocalDeclGuardMap[D] = C; } + Address createUnnamedGlobalFrom(const VarDecl &D, llvm::Constant *Constant, + CharUnits Align); + bool lookupRepresentativeDecl(StringRef MangledName, GlobalDecl &Result) const; -- cgit v1.2.3