[LLVMdev] Win32 JIT issue + bug in ScheduleDAGSNodes.h?
srs
skaflotten at gmail.com
Wed Dec 31 16:56:26 PST 2008
Bill Wendling wrote:
> On Dec 31, 2008, at 5:57 AM, srs wrote
>> Bill Wendling wrote:
>>
>>> On Dec 30, 2008, at 4:51 PM, srs wrote:
>>>
>>>
>>>
>>>> 2. There seems to be an issue in ScheduleDAGSDNodes.h when in debug
>>>> mode. The problem is the evaluation of "&SUnits[0];" which
>>>> ASSERT's in
>>>> VC++'s vector[] implementation (when _HAS_ITERATOR_DEBUGGING is on).
>>>>
>>>> As a work-around, I commented out the debug code (see "patch"
>>>> below.)
>>>>
>>>> What would the proper solution be? The idiom appears to be allowed
>>>> by
>>>> the C++03 standard, but at least VC++ 2008 Express Edition with
>>>> _HAS_ITERATOR_DEBUGGING fails.
>>>>
>>> What is the assertion message?
>>>
>> "vector subscript out of range"
>>
>> This is the asserting code from <vector> :
>>
>>
>> const_reference operator[](size_type _Pos) const
>> { // subscript nonmutable sequence
>>
>> #if _HAS_ITERATOR_DEBUGGING
>> if (size() <= _Pos)
>> {
>> _DEBUG_ERROR("vector subscript out of range");
>> _SCL_SECURE_OUT_OF_RANGE;
>> }
>> #endif /* _HAS_ITERATOR_DEBUGGING */
>> _SCL_SECURE_VALIDATE_RANGE(_Pos < size());
>>
>> return (*(_Myfirst + _Pos));
>> }
>>
>>
>>
> Okay. I wonder if we can modify it to check that the vector has
> elements in it. Could you try this patch and let me know if it works
> for you?
>
> -bw
>
> Index: include/llvm/CodeGen/ScheduleDAGSDNodes.h
> ===================================================================
> --- include/llvm/CodeGen/ScheduleDAGSDNodes.h (revision 61532)
> +++ include/llvm/CodeGen/ScheduleDAGSDNodes.h (working copy)
> @@ -103,10 +103,13 @@
> ///
> SUnit *NewSUnit(SDNode *N) {
> #ifndef NDEBUG
> - const SUnit *Addr = &SUnits[0];
> + const SUnit *Addr = 0;
> + if (SUnits.size() > 0)
> + Addr = &SUnits[0];
> #endif
> SUnits.push_back(SUnit(N, (unsigned)SUnits.size()));
> - assert(Addr == &SUnits[0] && "SUnits std::vector reallocated on
> the fly!");
> + assert((Addr == 0 || Addr == &SUnits[0]) &&
> + "SUnits std::vector reallocated on the fly!");
> SUnits.back().OrigNode = &SUnits.back();
> return &SUnits.back();
> }
>
This works fine for me.
/Stein Roger
More information about the llvm-dev
mailing list