A exception about "Found call before load/move"

Hi:
When I compile a optix function:

__device__ __forceinline__ bool isPointOnLight(const MixedLight& light, const float3& point) {
	if (light.type() != MixedLight::AREA_LIGHT)
		 return false;
	
	float3 Q1 = light.v1 - light.v3;
	float3 Q2 = light.v2 - light.v3;
	float3 R = point - light.v3;
	
	......
	
	// check whether R = a Q1  b Q2 with a > 0, b > 0 and a  b < 1
	float aboveTheLine = R.y - (R.x * Q1.y / Q1.x);
	float underTheLine = Q2.y - (Q1.y * Q2.x / Q1.x);
	float b = aboveTheLine / underTheLine;
	float a = (R.x - b * Q2.x) / Q1.x;
	float Rz = a * Q1.z +  b * Q2.z;
	
		    //check if Rz == R.z
	Rz -= R.z;
	if (Rz > scene_epsilon*10.f || Rz < -scene_epsilon*10.f)
		 return false;
	
		return true;
	
}

It can be compiled successfully.
But when I add the same code with line 20 before “return true”, i.e. the function become:

__device__ __forceinline__ bool isPointOnLight(const MixedLight& light, const float3& point) {
	if (light.type() != MixedLight::AREA_LIGHT)
		 return false;
	
	float3 Q1 = light.v1 - light.v3;
	float3 Q2 = light.v2 - light.v3;
	float3 R = point - light.v3;
	
	......
	
	// check whether R = a Q1  b Q2 with a > 0, b > 0 and a  b < 1
	float aboveTheLine = R.y - (R.x * Q1.y / Q1.x);
	float underTheLine = Q2.y - (Q1.y * Q2.x / Q1.x);
	float b = aboveTheLine / underTheLine;
	float a = (R.x - b * Q2.x) / Q1.x;
	float Rz = a * Q1.z +  b * Q2.z;
	
		    //check if Rz == R.z
	Rz -= R.z;
	if (Rz > scene_epsilon*10.f || Rz < -scene_epsilon*10.f)
		 return false;
	if (Rz > scene_epsilon*10.f || Rz < -scene_epsilon*10.f)
		 return false;
		return true;
	
}

The compiler throws a exception:

Unknown error (Details: Function \"_rtProgramCreateFromPTXFile\" caught exception: Assertion failed: \"ref != vlm->m_variables.end() : Found call before load/move\", [5571733])"

Does any one can help me to sovle the problem ?
Thanks!

That would be an internal error which would need to be debugged.
On the other hand the code in line 20+21 is exactly the same as in 22+23, means line 23 can never be reached and I would guess either some optimization in the CUDA compiler went wrong and/or the resulting code couldn’t be handled by the OptiX parser or stitcher.

If this also happens with code which can be reached, post a full reproducer which could be analyzed.
Search for OptiX API Capture (OAC) on this forum for how to produce a reproducer trace.

When reporting any OptiX issues please always list the following system information:
OS version and bitness, installed GPU(s), display driver version, OptiX version, CUDA toolkit version, application bitness (should be 64-bit).