Merge pull request #54 from mknejp/master
SPIR-V: Return undefined values from implicit returns instead of dummy
This commit is contained in:
@@ -791,9 +791,7 @@ void Builder::leaveFunction(bool main)
|
||||
if (function.getReturnType() == makeVoidType())
|
||||
makeReturn(true);
|
||||
else {
|
||||
Id retStorage = createVariable(StorageClassFunction, function.getReturnType(), "dummyReturn");
|
||||
Id retValue = createLoad(retStorage);
|
||||
makeReturn(true, retValue);
|
||||
makeReturn(true, createUndefined(function.getReturnType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -844,6 +842,14 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name)
|
||||
return inst->getResultId();
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
Id Builder::createUndefined(Id type)
|
||||
{
|
||||
Instruction* inst = new Instruction(getUniqueId(), type, OpUndef);
|
||||
buildPoint->addInstruction(inst);
|
||||
return inst->getResultId();
|
||||
}
|
||||
|
||||
// Comments in header
|
||||
void Builder::createStore(Id rValue, Id lValue)
|
||||
{
|
||||
|
||||
@@ -218,6 +218,9 @@ public:
|
||||
// Create a global or function local or IO variable.
|
||||
Id createVariable(StorageClass, Id type, const char* name = 0);
|
||||
|
||||
// Create an imtermediate with an undefined value.
|
||||
Id createUndefined(Id type);
|
||||
|
||||
// Store into an Id and return the l-value
|
||||
void createStore(Id rValue, Id lValue);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user