fix for frexp dataflow analysis

Bug: skia:
Change-Id: Ic20bedadfbf37fd78ce03872ece2d9552307cfcd
Reviewed-on: https://skia-review.googlesource.com/117243
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Ethan Nicholas 2018-03-29 16:46:56 -04:00 committed by Skia Commit-Bot
parent 5614ce1897
commit c6a19f1d04
3 changed files with 31 additions and 1 deletions

View File

@ -17,6 +17,7 @@
#include "ir/SkSLEnum.h"
#include "ir/SkSLExpression.h"
#include "ir/SkSLExpressionStatement.h"
#include "ir/SkSLFunctionCall.h"
#include "ir/SkSLIntLiteral.h"
#include "ir/SkSLModifiersDeclaration.h"
#include "ir/SkSLNop.h"
@ -291,6 +292,18 @@ void Compiler::addDefinitions(const BasicBlock::Node& node,
}
break;
}
case Expression::kFunctionCall_Kind: {
const FunctionCall& c = (const FunctionCall&) *expr;
for (size_t i = 0; i < c.fFunction.fParameters.size(); ++i) {
if (c.fFunction.fParameters[i]->fModifiers.fFlags & Modifiers::kOut_Flag) {
this->addDefinition(
c.fArguments[i].get(),
(std::unique_ptr<Expression>*) &fContext->fDefined_Expression,
definitions);
}
}
break;
}
case Expression::kPrefix_Kind: {
const PrefixExpression* p = (PrefixExpression*) expr;
if (p->fOperator == Token::MINUSMINUS || p->fOperator == Token::PLUSPLUS) {

View File

@ -102,7 +102,7 @@ $genType fma($genType a, $genType b, $genType c);
$genHType fma($genHType a, $genHType b, $genHType c);
$genDType fma($genDType a, $genDType b, $genDType c);
//$genDType fma($genDType a, $genDType b, $genDType c);
$genType frexp($genType x, out $genIType exp);
sk_has_side_effects $genType frexp($genType x, out $genIType exp);
//$genDType frexp($genDType x, out $genIType exp);
$genType ldexp($genType x, in $genIType exp);
//$genDType ldexp($genDType x, in $genIType exp);

View File

@ -1945,4 +1945,21 @@ DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
SkSL::Program::kFragment_Kind);
}
DEF_TEST(SkSLFrExp, r) {
test(r,
"void main() {"
" int exp;"
" float foo = frexp(0.5, exp);"
" sk_FragColor = float4(exp);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
"void main() {\n"
" int exp;\n"
" float foo = frexp(0.5, exp);\n"
" sk_FragColor = vec4(float(exp));\n"
"}\n");
}
#endif