diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-13 19:00:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-13 19:00:16 +0000 |
commit | 17965d42f420a0ca6d7bd5b9a0d7d472dfc5689d (patch) | |
tree | d4b3f16ca1e33d6a0f70eab45704213457617e5c /clang/lib/CodeGen/CodeGenModule.h | |
parent | 4244dd5e3f9e423db39dc8d1d235f67edf9b1875 (diff) | |
download | bcm5719-llvm-17965d42f420a0ca6d7bd5b9a0d7d472dfc5689d.tar.gz bcm5719-llvm-17965d42f420a0ca6d7bd5b9a0d7d472dfc5689d.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 7 |
1 files changed, 7 insertions, 0 deletions
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<std::pair<llvm::GlobalValue *, llvm::Constant *>, 8> GlobalValReplacements; + /// Variables for which we've emitted globals containing their constant + /// values along with the corresponding globals, for opportunistic reuse. + llvm::DenseMap<const VarDecl*, llvm::GlobalVariable*> 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; |