From 32549707cc9aa67dbc19cbdc0490ffebc8ec253c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 13 Feb 2018 10:22:54 -0800 Subject: Fix a bug in IR use-def information (#406) The basic problem here is that when unlinking an `IRUse` from the linked list of uses, there were several cases where I was failing to set the `prevLink` field of the next node to match the `prevLink` field of the node being removed. That doesn't show up when walking the linked list of uses forward, but it breaks it whenever you have subsequent unlinking operations. This change fixes the bugs of that kind I could find, and also adds a debug validation method to try to avoid breaking it again. I also made more access to `IRUse` go through accessor methods rather than using fields directly, to try to avoid this kind of error. I stopped short of making anything `private`, because I tend to find that it creates more hassles than it avoids. A few other fixes along the way: - Made the `List` type default-initialize elements when you resize it. I hadn't realized we weren't doing that. - Add a standalone `dumpIR(IRGlobalValue*)` so help when debugging issues. --- source/core/list.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/core/list.h') diff --git a/source/core/list.h b/source/core/list.h index 5a94d8b83..68563f20c 100644 --- a/source/core/list.h +++ b/source/core/list.h @@ -420,6 +420,12 @@ namespace Slang { for (UInt i = 0; i < _count; i++) newBuffer[i] = static_cast(buffer[i]); + + // Default-initialize the remaining elements + for(UInt i = _count; i < size; i++) + { + new(newBuffer + i) T(); + } } FreeBuffer(); } -- cgit v1.2.3