diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-12-20 01:05:42 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-12-20 01:05:42 +0000 |
commit | a747027bc6455cafcc380bd075ec98065f780494 (patch) | |
tree | 6e6cd58082dd2578586dc21bb6f9b7cc2a2ffee8 /clang/lib/CodeGen/CodeGenModule.h | |
parent | 891cbcc093f112fb9f4ec839cd286364f4b0bcb0 (diff) | |
download | bcm5719-llvm-a747027bc6455cafcc380bd075ec98065f780494.tar.gz bcm5719-llvm-a747027bc6455cafcc380bd075ec98065f780494.zip |
Add the alloc_size attribute to clang.
This patch does three things:
- Gives us the alloc_size attribute in clang, which lets us infer the
number of bytes handed back to us by malloc/realloc/calloc/any user
functions that act in a similar manner.
- Teaches our constexpr evaluator that evaluating some `const` variables
is OK sometimes. This is why we have a change in
test/SemaCXX/constant-expression-cxx11.cpp and other seemingly
unrelated tests. Richard Smith okay'ed this idea some time ago in
person.
- Uniques some Blocks in CodeGen, which was reviewed separately at
D26410. Lack of uniquing only really shows up as a problem when
combined with our new eagerness in the face of const.
Differential Revision: https://reviews.llvm.org/D14274
llvm-svn: 290149
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index f26c92d5670..5f06ba90cf1 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -455,6 +455,10 @@ private: bool isTriviallyRecursive(const FunctionDecl *F); bool shouldEmitFunction(GlobalDecl GD); + /// Map of the global blocks we've emitted, so that we don't have to re-emit + /// them if the constexpr evaluator gets aggressive. + llvm::DenseMap<const BlockExpr *, llvm::Constant *> EmittedGlobalBlocks; + /// @name Cache for Blocks Runtime Globals /// @{ @@ -776,6 +780,16 @@ public: /// Gets the address of a block which requires no captures. llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name); + + /// Returns the address of a block which requires no caputres, or null if + /// we've yet to emit the block for BE. + llvm::Constant *getAddrOfGlobalBlockIfEmitted(const BlockExpr *BE) { + return EmittedGlobalBlocks.lookup(BE); + } + + /// Notes that BE's global block is available via Addr. Asserts that BE + /// isn't already emitted. + void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr); /// Return a pointer to a constant CFString object for the given string. ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal); |