diff options
| author | Serge Guelton <sguelton@quarkslab.com> | 2018-01-05 19:41:19 +0000 |
|---|---|---|
| committer | Serge Guelton <sguelton@quarkslab.com> | 2018-01-05 19:41:19 +0000 |
| commit | 4c975578b42a3adcfa5f7d08d67feff589f03398 (patch) | |
| tree | 1f801ff57ceaee8fe68853241b414a6a9c9f94de /llvm/lib | |
| parent | 9e52e50ac0afc182a899706f436934b570eaf09b (diff) | |
| download | bcm5719-llvm-4c975578b42a3adcfa5f7d08d67feff589f03398.tar.gz bcm5719-llvm-4c975578b42a3adcfa5f7d08d67feff589f03398.zip | |
Limit size of non-GlobalValue name
Otherwise, in some extreme test case, very long names are created and the
compiler consumes large amount of memory. Size limit is set to a relatively
high value not to disturb debugging.
Compiler flag -non-global-value-max-name-size=<value> can be used to customize
the size.
Differential Revision: https://reviews.llvm.org/D41296
llvm-svn: 321886
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/Value.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 163c785f5d7..01b7aff0f15 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -39,6 +39,10 @@ using namespace llvm; +static cl::opt<unsigned> NonGlobalValueMaxNameSize( + "non-global-value-max-name-size", cl::Hidden, cl::init(1024), + cl::desc("Maximum size for the name of non-global values.")); + //===----------------------------------------------------------------------===// // Value Class //===----------------------------------------------------------------------===// @@ -244,6 +248,11 @@ void Value::setNameImpl(const Twine &NewName) { if (getName() == NameRef) return; + // Cap the size of non-GlobalValue names. + if (NameRef.size() > NonGlobalValueMaxNameSize && !isa<GlobalValue>(this)) + NameRef = + NameRef.substr(0, std::max(1u, (unsigned)NonGlobalValueMaxNameSize)); + assert(!getType()->isVoidTy() && "Cannot assign a name to void values!"); // Get the symbol table to update for this object. |

