Report referenced pipeline overridable constants

Adding this information to each entry point reported by the inspector.

BUG=tint:855

Change-Id: I043e48afed1503a4267dc4cb198fb86245984551
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53820
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ryan Harrison
2021-06-09 20:45:09 +00:00
committed by Tint LUCI CQ
parent 14b3403148
commit 3832b8e05d
6 changed files with 203 additions and 58 deletions

View File

@@ -135,8 +135,8 @@ void Resolver::set_referenced_from_function_if_needed(VariableInfo* var,
if (current_function_ == nullptr) {
return;
}
if (var->storage_class == ast::StorageClass::kNone ||
var->storage_class == ast::StorageClass::kFunction) {
if (var->kind != VariableKind::kGlobal) {
return;
}
@@ -496,7 +496,7 @@ Resolver::VariableInfo* Resolver::Variable(ast::Variable* var,
}
auto* info = variable_infos_.Create(var, const_cast<sem::Type*>(type),
type_name, storage_class, access);
type_name, storage_class, access, kind);
variable_to_info_.emplace(var, info);
return info;
@@ -3377,12 +3377,14 @@ Resolver::VariableInfo::VariableInfo(const ast::Variable* decl,
sem::Type* ty,
const std::string& tn,
ast::StorageClass sc,
ast::Access ac)
ast::Access ac,
VariableKind k)
: declaration(decl),
type(ty),
type_name(tn),
storage_class(sc),
access(ac) {}
access(ac),
kind(k) {}
Resolver::VariableInfo::~VariableInfo() = default;

View File

@@ -86,6 +86,9 @@ class Resolver {
bool IsHostShareable(const sem::Type* type);
private:
/// Describes the context in which a variable is declared
enum class VariableKind { kParameter, kLocal, kGlobal };
/// Structure holding semantic information about a variable.
/// Used to build the sem::Variable nodes at the end of resolving.
struct VariableInfo {
@@ -93,7 +96,8 @@ class Resolver {
sem::Type* type,
const std::string& type_name,
ast::StorageClass storage_class,
ast::Access ac);
ast::Access ac,
VariableKind k);
~VariableInfo();
ast::Variable const* const declaration;
@@ -103,6 +107,7 @@ class Resolver {
ast::Access const access;
std::vector<ast::IdentifierExpression*> users;
sem::BindingPoint binding_point;
VariableKind kind;
};
struct IntrinsicCallInfo {
@@ -190,9 +195,6 @@ class Resolver {
sem::Type* const sem;
};
/// Describes the context in which a variable is declared
enum class VariableKind { kParameter, kLocal, kGlobal };
/// Resolves the program, without creating final the semantic nodes.
/// @returns true on success, false on error
bool ResolveInternal();

View File

@@ -23,6 +23,7 @@
#include "src/ast/break_statement.h"
#include "src/ast/call_statement.h"
#include "src/ast/continue_statement.h"
#include "src/ast/float_literal.h"
#include "src/ast/if_statement.h"
#include "src/ast/intrinsic_texture_helper_test.h"
#include "src/ast/loop_statement.h"
@@ -903,6 +904,33 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionVariable) {
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
}
TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) {
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
{
Decl(Const("var", ty.f32(), Construct(ty.f32()))),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* func_sem = Sem().Get(func);
ASSERT_NE(func_sem, nullptr);
EXPECT_EQ(func_sem->ReferencedModuleVariables().size(), 0u);
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
}
TEST_F(ResolverTest, Function_NotRegisterFunctionParams) {
auto* func = Func("my_func", {Const("var", ty.f32(), Construct(ty.f32()))},
ty.void_(), {});
EXPECT_TRUE(r()->Resolve()) << r()->error();
auto* func_sem = Sem().Get(func);
ASSERT_NE(func_sem, nullptr);
EXPECT_EQ(func_sem->ReferencedModuleVariables().size(), 0u);
EXPECT_TRUE(func_sem->ReturnType()->Is<sem::Void>());
}
TEST_F(ResolverTest, Function_ReturnStatements) {
auto* var = Var("foo", ty.f32());