src/compiler/translator/OutputTree.cpp


Log

Author Commit Date CI Message
Shahbaz Youssefi 1ae273ee 2025-08-27T10:47:59 Translator: Output struct members in OutputTree Bug: chromium:438038775 Change-Id: I2a1bed5207b1b2c26f20ee9ebd80fb00ec803bc2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6891072 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tom Sepez 25390156 2025-08-21T00:13:19 Suppress unsafe buffers on a file-by-file basis in src/ [1 of N] In this CL, we suppress many files but stop short of actually enabling the warning by not removing the line from the unsafe_buffers_paths.txt file. That will happen in a follow-on CL, along with resolving any stragglers missed here. This is mostly a manual change so as to familiarize myself with the kinds of issues faced by the Angle codebase when applying buffer safety warnings. -- Re-generate affected hashes. -- Clang-format applied to all changed files. -- Add a few missing .reserve() calls to vectors as noticed. -- Fix some mismatches between file names and header comments. -- Be more consistent with header comment format (blank lines and trailing //-only lines when a filename comment adjoins license boilerplate). Bug: b/436880895 Change-Id: I3bde5cc2059acbe8345057289214f1a26f1c34aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6869022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Kimmo Kinnunen c46e6bac 2024-11-12T13:55:01 Make intermediate output symbol names consistent Make intermediate output symbol names consistent across uses in parameter names, struct names, variable names: - built-in without quotes - '' empty - #satb ANGLE internal - 'a' user-defined Previously empty parameters would output the symbol id-generated name ("sabb"), which was surprising when this is used only when the symbol is in AngleInternal namespace, and not in Empty namespace. Bug: angleproject:378584780 Change-Id: I87b13cf964a1ae3ee54b8f4ef7a00eddcd474760 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6011018 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen efcb94ab 2024-11-06T15:55:02 Output the type of constant union Output the type of the constant union node in OutputTree output. This makes it easier to understand typing bugs related to the constant union. Adds a node nesting level for constant unions. This makes it easier to understand consecutive constant unions. Bug: angleproject:377330017 Change-Id: Ia83072b78c4d1713f839fd136692b254f6d2c517 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6000532 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen 197beb4d 2024-02-13T15:47:32 Metal: Crash if for loop body is optimized away Loops might have their bodies optimized away. For case like `for(;;) if(false);` the constant pruning happens at parse phase. The else branch (e.e. no else branch, nullptr) would be selected as the body. Some code treated the body as optional, some code treated it as required. Define it as required, and remove all conditional code related to the loop body. Bug: angleproject:8532 Change-Id: Ic35f1bf78e63ceb2cee7b96ba99e788efc282e6f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5291554 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi 8b869a95 2021-06-13T01:09:27 Translator: Generate Ops for all built-in functions EOpCallBuiltInFunction is removed in this change, as well as the "op": "auto" property in builtin_function_declarations.txt. Instead, gen_builtin_symbols.py automatically generates Ops for every built-in function and generates the TOperator enum accordingly. This simplifies SPIR-V code generation by allowing switches to be used on operators instead of string comparisons. Bug: angleproject:4589 Bug: angleproject:4889 Change-Id: Ia351524400b0e12a10a5572e27e9b88c6ec2e61c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2958869 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi fe2ed33a 2019-12-19T14:43:25 Translator: Output memory qualifiers in OutputTree Bug: angleproject:3602 Change-Id: I673d8080be874bea0a73a89f7499b652549c2f3d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1976498 Reviewed-by: Tobin Ehlis <tobine@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 795a3559 2019-12-03T11:31:18 Vulkan: EXT_gpu_shader5 support: precise The precise keyword is used in tessellation shaders but introduced in this extension. EXT_gpu_shader5 introduces a handful of features to shaders. This change only implements the `precise` keyword. Bug: angleproject:3569 Change-Id: I2252b79098eb8ba2d2faa040d7eaed7548b7051e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1939851 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 249cb200 2019-12-03T11:10:06 Translator: Rename TIntermInvariantDeclaration to ..GlobalQualifier.. This is to support the upcoming `precise` keyword. Bug: angleproject:3569 Change-Id: Idbcc8fd6f261757dbbf81b381e7a2dae938d8101 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1947451 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Olli Etuaho 72e3589c 2018-06-20T11:43:08 Refactor debug output of types Instead of passing around strings from TType::getCompleteString(), add a stream operator to InfoSinkBase that takes a TType. This makes the compiler executable a few kilobytes smaller and will help with getting rid of TString altogether. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I31a6693b40a28824b3959e19ad3c0a2ce0f0a35f Reviewed-on: https://chromium-review.googlesource.com/1107712 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 4002e92a 2018-04-04T16:55:34 Guard traversers used during parsing against stack overflow Traversers used during parsing can be vulnerable to stack overflow since the AST has not yet been validated for max depth. Make sure to check for traversal depth in traversers used during parsing. We set the maximum traversal depth in ValidateGlobalInitializer and ValidateSwitchStatementList to 256, which matches the default value for validating general AST complexity. The depth check is on regardless of compiler options. In case the traversers go over the maximum traversal depth, they fail validation. BUG=angleproject:2453 TEST=angle_unittests Change-Id: I89ba576e8ef69663ba35d7b9050a6da319f1757c Reviewed-on: https://chromium-review.googlesource.com/995795 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho c26214de 2018-03-16T10:43:11 Move AST utilities to a subdirectory Move AST related utilities to compiler/translator/tree_util. BUG=angleproject:2409 TEST=angle_unittests Change-Id: I7567c2f6f2710292029263257c7ac26e2a144ac8 Reviewed-on: https://chromium-review.googlesource.com/966032 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho d4bd963f 2018-03-08T16:32:44 Don't use TIntermSymbol nodes for function parameters Parameter nodes are not needed - it's simpler to just create a TVariable object for each parameter when the TFunction is initialized. With this change we also store only one object per each parameter type used in built-in functions, instead of one array of TConstParameter entries for each unique parameter sequence. This simplifies code and reduces binary size and compiler memory use. Compiler perf does not seem to be significantly affected. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I2b82400dd594731074309f92a705e75135a4c82c Reviewed-on: https://chromium-review.googlesource.com/955589 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho ea22b7a5 2018-01-04T17:09:11 Constant fold array indexing and comparison A virtual function to get the constant value of an AST node is added to TIntermTyped. This way a constant value can be retrieved conveniently from multiple different types of nodes. TIntermSymbol nodes pointing to a const variable can return the value associated with the variable, constructor nodes can build a constant value from their arguments, and indexing nodes can index into a constant array. This enables constant folding operations on constant arrays, while making sure that large amounts of data are not duplicated in the output shader. When folding an operation makes sense, the values of the arguments can be retrieved by using the new TIntermTyped::getConstantValue(). When folding an operation would result in duplicating data, the AST can just be left to be written out as is. For example, if the code contains a constant array of arrays, indexing into individual elements of the inner arrays can be folded, but indexing the top level array is left in place and not replaced with duplicated array literals. Constant folding is supported for indexing and comparisons of arrays. In case constant arrays are only referenced through foldable operations, the variable declarations will be pruned from the AST by the RemoveUnreferencedVariables step. BUG=angleproject:2298 TEST=angle_unittests Change-Id: I5b3be237b7e9fdba56aa9bf0a41b691f4d8f01eb Reviewed-on: https://chromium-review.googlesource.com/850973 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 8b5e8fdb 2017-12-15T14:59:15 Replace remaining usage of TName with TSymbol TName used to contain just a subset of the information stored in TSymbol. It makes more sense to use TSymbol directly instead of converting it to TName. This also improves type safety a bit by making some functions only take in TVariable or TFunction instead of the more generic TName. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Icb46923c25d33ebbbbc06ddc487da25957dda771 Reviewed-on: https://chromium-review.googlesource.com/829143 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho bed35d76 2017-12-20T16:36:26 Don't query names of empty symbols This makes it possible to return a reference from TSymbol::name() instead of a pointer. This is safer since it completely avoids the possibility of a nullptr dereference. An assert is making sure that the function is not being called for empty symbols. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I44279f65989dbb828322843fc0216ba84d91dedf Reviewed-on: https://chromium-review.googlesource.com/836894 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho b6af22b5 2017-12-15T14:05:44 Store TVariable* in TIntermSymbol instead of storing id This is an intermediate step to only storing a TVariable * in TIntermSymbol instead of copying the name. This makes it possible to get a constant value out of a TIntermSymbol without doing a symbol table lookup. BUG=angleproject:2267 TEST=angle_unittests Change-Id: Ibff588241a4ad4ac330063296273288b20a072c9 Reviewed-on: https://chromium-review.googlesource.com/829142 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho beb6dc74 2017-12-14T16:03:03 Always use TFunction instead of TFunctionSymbolInfo This reduces unnecessary memory allocations and conversions between different objects containing the same data. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I87316509ab1cd6d36756ff6af7fa2b5c5a76a8ea Reviewed-on: https://chromium-review.googlesource.com/827134 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 1bb8528c 2017-12-14T13:39:53 Remove TFunctionSymbolInfo from TIntermAggregate All the information stored in TFunctionSymbolInfo was duplicated from the TFunction that the aggregate node pointed to. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I1f5574ab0416e5cae00c3dae6fc11d2fe1fa128c Reviewed-on: https://chromium-review.googlesource.com/827065 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 0c37100d 2017-12-13T17:00:25 Always create TFunctions for function call nodes This simplifies code and ensures that nodes get consistent data. In the future function call nodes could have a pointer to the TFunction instead of converting the same information into a different data structure. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: Ic0c24bb86b44b9bcc4a5da7f6b03701081a3af5c Reviewed-on: https://chromium-review.googlesource.com/824606 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho bb2bbfbb 2017-08-24T15:43:33 Refactor GLSL array length method parsing This prepares for accepting arbitrary expressions as the "this" node of the array length method. BUG=angleproject:2142 TEST=angle_unittests Change-Id: I728adb6e76d2779dedbabfaeec7d096872e0d00d Reviewed-on: https://chromium-review.googlesource.com/633945 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho cccf2b00 2017-07-05T14:50:54 Reorganize AST traversal utility code Define TIntermTraverser and TIntermLValueTrackingTraverser in a separate header file. hash() function is moved out from TIntermTraverser as it is not related to the core functionality of traversing and transforming ASTs. Also reorganize some traversers to follow common conventions: - Intermediate output is now in OutputTree.h/.cpp - Max tree depth check is now in IsASTDepthBelowLimit.h/.cpp BUG=angleproject:1490 TEST=angle_unittests Change-Id: Id4968aa9d4e24d0c5bac90dc147fc9f310de0184 Reviewed-on: https://chromium-review.googlesource.com/559531 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>