aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/DecoderEmitter.cpp
diff options
context:
space:
mode:
authorRahul Joshi <rjoshi@nvidia.com>2025-04-18 10:05:40 -0700
committerGitHub <noreply@github.com>2025-04-18 10:05:40 -0700
commitc244daec1cbcd221c073fc40284ee23399257684 (patch)
tree4668bd6e7e94f22ebcd19d7712368111343c0c64 /llvm/utils/TableGen/DecoderEmitter.cpp
parent2a692d265bbd84dae807d470caed7be507e4118d (diff)
downloadllvm-c244daec1cbcd221c073fc40284ee23399257684.zip
llvm-c244daec1cbcd221c073fc40284ee23399257684.tar.gz
llvm-c244daec1cbcd221c073fc40284ee23399257684.tar.bz2
[LLVM][TableGen] Fix Windows failure in DecoderEmitter (#136310)
- Avoid dereferencing the end() iterator to get the end pointer, instead calculate it explicitly - Fixes a regression introduced in https://github.com/llvm/llvm-project/pull/136220. - The windows build failure shows the following call stack: ``` | Exception Code: 0x80000003 | #0 0x00007ff74bc05897 std::_Vector_const_iterator<class std::_Vector_val<struct std::_Simple_types<unsigned char>>>::operator*(void) const C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:52:0 | #1 0x00007ff74bbd3d64 `anonymous namespace'::DecoderEmitter::emitTable D:\buildbot\llvm-worker\clang-cmake-x86_64-avx512-win\llvm\llvm\utils\TableGen\DecoderEmitter.cpp:852:0 ```
Diffstat (limited to 'llvm/utils/TableGen/DecoderEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/DecoderEmitter.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index a3fe49e..485647d 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -833,6 +833,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
// appropriate indentation levels.
DecoderTable::const_iterator I = Table.begin();
DecoderTable::const_iterator E = Table.end();
+ const uint8_t *const EndPtr = Table.data() + Table.size();
while (I != E) {
assert(I < E && "incomplete decode table entry!");
@@ -849,7 +850,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
// ULEB128 encoded start value.
const char *ErrMsg = nullptr;
- unsigned Start = decodeULEB128(&*I, nullptr, &*E, &ErrMsg);
+ unsigned Start = decodeULEB128(&*I, nullptr, EndPtr, &ErrMsg);
assert(ErrMsg == nullptr && "ULEB128 value too large!");
emitULEB128(I, OS);
@@ -903,7 +904,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
++I;
// Decode the Opcode value.
const char *ErrMsg = nullptr;
- unsigned Opc = decodeULEB128(&*I, nullptr, &*E, &ErrMsg);
+ unsigned Opc = decodeULEB128(&*I, nullptr, EndPtr, &ErrMsg);
assert(ErrMsg == nullptr && "ULEB128 value too large!");
OS << Indent << "MCD::OPC_" << (IsTry ? "Try" : "") << "Decode, ";
@@ -935,12 +936,12 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
OS << Indent << "MCD::OPC_SoftFail, ";
// Decode the positive mask.
const char *ErrMsg = nullptr;
- uint64_t PositiveMask = decodeULEB128(&*I, nullptr, &*E, &ErrMsg);
+ uint64_t PositiveMask = decodeULEB128(&*I, nullptr, EndPtr, &ErrMsg);
assert(ErrMsg == nullptr && "ULEB128 value too large!");
emitULEB128(I, OS);
// Decode the negative mask.
- uint64_t NegativeMask = decodeULEB128(&*I, nullptr, &*E, &ErrMsg);
+ uint64_t NegativeMask = decodeULEB128(&*I, nullptr, EndPtr, &ErrMsg);
assert(ErrMsg == nullptr && "ULEB128 value too large!");
emitULEB128(I, OS);
OS << "// +ve mask: 0x";