diff options
author | Hasyimi Bahrudin <hasyimi@ridebeam.com> | 2021-05-27 04:01:20 +0000 |
---|---|---|
committer | Mehdi Amini <joker.eph@gmail.com> | 2021-05-27 04:20:03 +0000 |
commit | 8d25762720660aba3344752e577ae7017e6125c2 (patch) | |
tree | 4c8fb6c199e4ee22a94bcf93ebc87cc2726e81f6 /llvm/lib/IR/Function.cpp | |
parent | 0ce58c52d50bd2edd09df7c7ef3dd4dc85b05992 (diff) | |
download | llvm-8d25762720660aba3344752e577ae7017e6125c2.zip llvm-8d25762720660aba3344752e577ae7017e6125c2.tar.gz llvm-8d25762720660aba3344752e577ae7017e6125c2.tar.bz2 |
Fix non-global-value-max-name-size not considered by LLParser
`non-global-value-max-name-size` is used by `Value` to cap the length of local value name. However, this flag is not considered by `LLParser`, which leads to unexpected `use of undefined value error`. The fix is to move the responsibility of capping the length to `ValueSymbolTable`.
The test is the one provided by [[ https://bugs.llvm.org/show_bug.cgi?id=45899 | Mikael in the bug report ]].
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D102707
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index a5c4756..29e0c64 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -60,6 +60,7 @@ #include "llvm/IR/Value.h" #include "llvm/IR/ValueSymbolTable.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include <algorithm> @@ -76,6 +77,10 @@ using ProfileCount = Function::ProfileCount; // are not in the public header file... template class llvm::SymbolTableListTraits<BasicBlock>; +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.")); + //===----------------------------------------------------------------------===// // Argument Implementation //===----------------------------------------------------------------------===// @@ -391,7 +396,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, // We only need a symbol table for a function if the context keeps value names if (!getContext().shouldDiscardValueNames()) - SymTab = std::make_unique<ValueSymbolTable>(); + SymTab = std::make_unique<ValueSymbolTable>(NonGlobalValueMaxNameSize); // If the function has arguments, mark them as lazily built. if (Ty->getNumParams()) |