diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-06-22 16:21:14 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-06-22 16:21:14 +0000 |
commit | 9565cf581e35f5e73930ab48493943bffe4941a1 (patch) | |
tree | b8bd6157a2e8133efbc7266cb54ac0580b7b6f59 /clang/lib/CodeGen/CGCleanup.h | |
parent | 0df350589f6481c42514a4e0d02c8ac362ca4c49 (diff) | |
download | bcm5719-llvm-9565cf581e35f5e73930ab48493943bffe4941a1.tar.gz bcm5719-llvm-9565cf581e35f5e73930ab48493943bffe4941a1.zip |
Widen EHScope::ClenupBitFields::FixupDepth to avoid overflowing it (PR23490)
It currently only takes 2048 gotos to overflow the FixupDepth bitfield,
causing silent miscompilation. Apparently some parser generators run into
this (see PR).
I don't know that that data structure is terribly size sensitive anyway,
and since there's no room to widen the bitfield, let's just use a separate
word in EHCatchScope for it.
Differential Revision: http://reviews.llvm.org/D21566
llvm-svn: 273434
Diffstat (limited to 'clang/lib/CodeGen/CGCleanup.h')
-rw-r--r-- | clang/lib/CodeGen/CGCleanup.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h index 4823773a43a..98d01b1326c 100644 --- a/clang/lib/CodeGen/CGCleanup.h +++ b/clang/lib/CodeGen/CGCleanup.h @@ -86,11 +86,6 @@ protected: /// The amount of extra storage needed by the Cleanup. /// Always a multiple of the scope-stack alignment. unsigned CleanupSize : 12; - - /// The number of fixups required by enclosing scopes (not including - /// this one). If this is the top cleanup scope, all the fixups - /// from this index onwards belong to this scope. - unsigned FixupDepth : 32 - 18 - NumCommonBits; // currently 12 }; class FilterBitFields { @@ -188,6 +183,7 @@ public: EHScopeStack::stable_iterator enclosingEHScope) : EHScope(Catch, enclosingEHScope) { CatchBits.NumHandlers = numHandlers; + assert(CatchBits.NumHandlers == numHandlers && "NumHandlers overflow?"); } unsigned getNumHandlers() const { @@ -263,6 +259,11 @@ class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EHCleanupScope : public EHScope { }; mutable struct ExtInfo *ExtInfo; + /// The number of fixups required by enclosing scopes (not including + /// this one). If this is the top cleanup scope, all the fixups + /// from this index onwards belong to this scope. + unsigned FixupDepth; + struct ExtInfo &getExtInfo() { if (!ExtInfo) ExtInfo = new struct ExtInfo(); return *ExtInfo; @@ -288,8 +289,9 @@ public: unsigned cleanupSize, unsigned fixupDepth, EHScopeStack::stable_iterator enclosingNormal, EHScopeStack::stable_iterator enclosingEH) - : EHScope(EHScope::Cleanup, enclosingEH), EnclosingNormal(enclosingNormal), - NormalBlock(nullptr), ActiveFlag(nullptr), ExtInfo(nullptr) { + : EHScope(EHScope::Cleanup, enclosingEH), + EnclosingNormal(enclosingNormal), NormalBlock(nullptr), + ActiveFlag(nullptr), ExtInfo(nullptr), FixupDepth(fixupDepth) { CleanupBits.IsNormalCleanup = isNormal; CleanupBits.IsEHCleanup = isEH; CleanupBits.IsActive = isActive; @@ -297,7 +299,6 @@ public: CleanupBits.TestFlagInNormalCleanup = false; CleanupBits.TestFlagInEHCleanup = false; CleanupBits.CleanupSize = cleanupSize; - CleanupBits.FixupDepth = fixupDepth; assert(CleanupBits.CleanupSize == cleanupSize && "cleanup size overflow"); } @@ -343,7 +344,7 @@ public: return CleanupBits.TestFlagInEHCleanup; } - unsigned getFixupDepth() const { return CleanupBits.FixupDepth; } + unsigned getFixupDepth() const { return FixupDepth; } EHScopeStack::stable_iterator getEnclosingNormalCleanup() const { return EnclosingNormal; } @@ -451,6 +452,7 @@ public: EHFilterScope(unsigned numFilters) : EHScope(Filter, EHScopeStack::stable_end()) { FilterBits.NumFilters = numFilters; + assert(FilterBits.NumFilters == numFilters && "NumFilters overflow"); } static size_t getSizeForNumFilters(unsigned numFilters) { |