Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone name hint decoration when emiting Undefined #6415

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/slang/slang-ir-ssa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ IRInst* readVarRec(ConstructSSAContext* context, SSABlockInfo* blockInfo, IRVar*

auto type = var->getDataType()->getValueType();
val = blockInfo->builder.emitUndefined(type);
cloneRelevantDecorations(var, val);
}
else if (!multiplePreds)
{
Expand Down Expand Up @@ -776,6 +777,7 @@ IRInst* readVar(ConstructSSAContext* context, SSABlockInfo* blockInfo, IRVar* va
//
auto type = var->getDataType()->getValueType();
val = blockInfo->builder.emitUndefined(type);
cloneRelevantDecorations(var, val);
writeVar(context, blockInfo, var, val);
return val;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//TEST:SIMPLE(filecheck=CHK):

// Test if the variable name is a part of the error message
// when it is used inside of for-loop

RWStructuredBuffer<float> gInput;
RWStructuredBuffer<float> outputBuffer;

//CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'a'
float func1() { float a; return a; }

//CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'b'
float func2() { float b; return b; }

int test(int inVal)
{
return inVal;
}

[Shader("compute")]
[NumThreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
int tid = dispatchThreadID.x;
int inVal1; // intentionally uninitialized
int inVal2; // intentionally uninitialized

for (int i = 0; i <2; ++i)
{
// CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'inVal1'
int outVal = test(inVal1);

// CHK-DAG: ([[#@LINE+1]]): warning 41016: use of uninitialized variable 'inVal2'
outVal += test(inVal2);
outputBuffer[tid] = outVal;
}
}
Loading