DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Infinite loop related to struct inheritance and empty struct

Open simontaylor81 opened this issue 4 years ago • 1 comments

I'm hitting an infinite loop when compiling a shader with a particular pattern of inheritance and function calls to a helper struct. From reducing the repro case the problem appears to occur when a parent struct declares a member of an empty helper struct, then a child struct derives from that and also declares its own member var (not zero-sized). Then calling a method on that helper struct from a function on the child will trigger the infinite loop.

The hang looks to be in the SROA pass, which suggestions a connection to #3770 (which also dealt with empty structs). However the fix for that does not seem to have fixed this issue, sadly.

Here's the minimal repro I came up with. Confirmed still occurs with the current-head e65a981. Compile with -T ps_6_7 -E main

struct Helper
{
	float getColor() { return 0; }
};

struct Parent
{
	Helper helper;
};

struct Child : Parent
{
	float memberVar;

	float color()
	{
		return helper.getColor();
	}
};

float main() : SV_Target
{
	Child instance;
	return instance.color();
}

simontaylor81 avatar Jul 13 '21 09:07 simontaylor81

Has there been any movement on this one? I just hit it again in a different place, this time a bit less easy to workaround :)

simontaylor81 avatar Mar 21 '22 16:03 simontaylor81