Merge pull request #1103 from KhronosGroup/fix-1100

MSL: Cleanup temporary use with emit_uninitialized_temporary.
This commit is contained in:
Hans-Kristian Arntzen 2019-07-26 14:35:18 +02:00 committed by GitHub
commit d378413040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 13 deletions

View File

@ -5285,7 +5285,6 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
case GLSLstd450ModfStruct: case GLSLstd450ModfStruct:
{ {
forced_temporaries.insert(id);
auto &type = get<SPIRType>(result_type); auto &type = get<SPIRType>(result_type);
emit_uninitialized_temporary_expression(result_type, id); emit_uninitialized_temporary_expression(result_type, id);
statement(to_expression(id), ".", to_member_name(type, 0), " = ", "modf(", to_expression(args[0]), ", ", statement(to_expression(id), ".", to_member_name(type, 0), " = ", "modf(", to_expression(args[0]), ", ",
@ -5425,7 +5424,6 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop,
case GLSLstd450FrexpStruct: case GLSLstd450FrexpStruct:
{ {
forced_temporaries.insert(id);
auto &type = get<SPIRType>(result_type); auto &type = get<SPIRType>(result_type);
emit_uninitialized_temporary_expression(result_type, id); emit_uninitialized_temporary_expression(result_type, id);
statement(to_expression(id), ".", to_member_name(type, 0), " = ", "frexp(", to_expression(args[0]), ", ", statement(to_expression(id), ".", to_member_name(type, 0), " = ", "frexp(", to_expression(args[0]), ", ",
@ -8533,7 +8531,6 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
uint32_t result_id = ops[1]; uint32_t result_id = ops[1];
uint32_t op0 = ops[2]; uint32_t op0 = ops[2];
uint32_t op1 = ops[3]; uint32_t op1 = ops[3];
forced_temporaries.insert(result_id);
auto &type = get<SPIRType>(result_type); auto &type = get<SPIRType>(result_type);
emit_uninitialized_temporary_expression(result_type, result_id); emit_uninitialized_temporary_expression(result_type, result_id);
const char *op = opcode == OpUMulExtended ? "umulExtended" : "imulExtended"; const char *op = opcode == OpUMulExtended ? "umulExtended" : "imulExtended";

View File

@ -4649,10 +4649,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction)
uint32_t result_id = ops[1]; uint32_t result_id = ops[1];
uint32_t op0 = ops[2]; uint32_t op0 = ops[2];
uint32_t op1 = ops[3]; uint32_t op1 = ops[3];
forced_temporaries.insert(result_id);
auto &type = get<SPIRType>(result_type); auto &type = get<SPIRType>(result_type);
statement(variable_decl(type, to_name(result_id)), ";"); emit_uninitialized_temporary_expression(result_type, result_id);
set<SPIRExpression>(result_id, to_name(result_id), result_type, true);
auto &res_type = get<SPIRType>(type.member_types[1]); auto &res_type = get<SPIRType>(type.member_types[1]);
if (opcode == OpIAddCarry) if (opcode == OpIAddCarry)
@ -4681,10 +4679,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction)
uint32_t result_id = ops[1]; uint32_t result_id = ops[1];
uint32_t op0 = ops[2]; uint32_t op0 = ops[2];
uint32_t op1 = ops[3]; uint32_t op1 = ops[3];
forced_temporaries.insert(result_id);
auto &type = get<SPIRType>(result_type); auto &type = get<SPIRType>(result_type);
statement(variable_decl(type, to_name(result_id)), ";"); emit_uninitialized_temporary_expression(result_type, result_id);
set<SPIRExpression>(result_id, to_name(result_id), result_type, true);
statement(to_expression(result_id), ".", to_member_name(type, 0), " = ", to_enclosed_expression(op0), " * ", statement(to_expression(result_id), ".", to_member_name(type, 0), " = ", to_enclosed_expression(op0), " * ",
to_enclosed_expression(op1), ";"); to_enclosed_expression(op1), ";");
@ -4966,8 +4962,6 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id,
uint32_t mem_order_2, bool has_mem_order_2, uint32_t obj, uint32_t op1, uint32_t mem_order_2, bool has_mem_order_2, uint32_t obj, uint32_t op1,
bool op1_is_pointer, bool op1_is_literal, uint32_t op2) bool op1_is_pointer, bool op1_is_literal, uint32_t op2)
{ {
forced_temporaries.insert(result_id);
string exp = string(op) + "("; string exp = string(op) + "(";
auto &type = get_pointee_type(expression_type(obj)); auto &type = get_pointee_type(expression_type(obj));
@ -5006,12 +5000,11 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id,
// the CAS loop, otherwise it will loop infinitely, with the comparison test always failing. // the CAS loop, otherwise it will loop infinitely, with the comparison test always failing.
// The function updates the comparitor value from the memory value, so the additional // The function updates the comparitor value from the memory value, so the additional
// comparison test evaluates the memory value against the expected value. // comparison test evaluates the memory value against the expected value.
statement(variable_decl(type, to_name(result_id)), ";"); emit_uninitialized_temporary_expression(result_type, result_id);
statement("do"); statement("do");
begin_scope(); begin_scope();
statement(to_name(result_id), " = ", to_expression(op1), ";"); statement(to_name(result_id), " = ", to_expression(op1), ";");
end_scope_decl(join("while (!", exp, " && ", to_name(result_id), " == ", to_enclosed_expression(op1), ")")); end_scope_decl(join("while (!", exp, " && ", to_name(result_id), " == ", to_enclosed_expression(op1), ")"));
set<SPIRExpression>(result_id, to_name(result_id), result_type, true);
} }
else else
{ {