aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/lib/Analysis
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:46 +0300
commit81eddc8c0b55990194e112b02d127b87d54164a9 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /contrib/libs/llvm12/lib/Analysis
parent397cbe258b9e064f49c4ca575279f02f39fef76e (diff)
downloadydb-81eddc8c0b55990194e112b02d127b87d54164a9.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Analysis')
-rw-r--r--contrib/libs/llvm12/lib/Analysis/.yandex_meta/licenses.list.txt692
-rw-r--r--contrib/libs/llvm12/lib/Analysis/MLInlineAdvisor.cpp550
-rw-r--r--contrib/libs/llvm12/lib/Analysis/README.txt60
-rw-r--r--contrib/libs/llvm12/lib/Analysis/TFUtils.cpp452
-rw-r--r--contrib/libs/llvm12/lib/Analysis/ya.make28
5 files changed, 891 insertions, 891 deletions
diff --git a/contrib/libs/llvm12/lib/Analysis/.yandex_meta/licenses.list.txt b/contrib/libs/llvm12/lib/Analysis/.yandex_meta/licenses.list.txt
index 33ca2e033a..1da7eb6ff9 100644
--- a/contrib/libs/llvm12/lib/Analysis/.yandex_meta/licenses.list.txt
+++ b/contrib/libs/llvm12/lib/Analysis/.yandex_meta/licenses.list.txt
@@ -1,346 +1,346 @@
-====================Apache-2.0 WITH LLVM-exception====================
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-
-
-====================Apache-2.0 WITH LLVM-exception====================
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-
-====================COPYRIGHT====================
- // into sext(%x) + sext(c). We'll sext the Offset ourselves:
- unsigned OldWidth = Offset.getBitWidth();
- Offset = Offset.trunc(SmallWidth).sext(NewWidth).zextOrSelf(OldWidth);
-
-
-====================COPYRIGHT====================
- // sext(%x) + sext(c)
- Scale = 1;
- Offset = 0;
-
-
-====================COPYRIGHT====================
- // |X| < |C| --> X > -abs(C) and X < abs(C)
- Constant *PosDivisorC = ConstantInt::get(Ty, C->abs());
- Constant *NegDivisorC = ConstantInt::get(Ty, -C->abs());
-
-
-====================COPYRIGHT====================
- // {(a)->(b), (b)->(c), (c)->(d), ...} and the worklist is initially {b, a},
- // then after merging (a) and (b) together, we need to put (a,b) back in
- // the worklist so that (c) can get merged in as well resulting in
- // {(a,b,c) -> d}
- // We also need to remove the old target (b), from the worklist. We first
-
-
-====================COPYRIGHT====================
- if (match(BO.getOperand(0), m_APInt(C))) {
- if (IIQ.hasNoUnsignedWrap(&BO)) {
- // 'shl nuw C, x' produces [C, C << CLZ(C)]
- Lower = *C;
- Upper = Lower.shl(Lower.countLeadingZeros()) + 1;
-
-
-====================COPYRIGHT====================
- if (match(X, m_APInt(C)) && !C->isMinSignedValue()) {
- // Is the variable divisor magnitude always greater than the constant
- // dividend magnitude?
- // |Y| > |C| --> Y < -abs(C) or Y > abs(C)
- Constant *PosDividendC = ConstantInt::get(Ty, C->abs());
- Constant *NegDividendC = ConstantInt::get(Ty, -C->abs());
-
-
-====================File: LICENSE.TXT====================
-==============================================================================
-The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
-==============================================================================
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
----- LLVM Exceptions to the Apache 2.0 License ----
-
-As an exception, if, as a result of your compiling your source code, portions
-of this Software are embedded into an Object form of such source code, you
-may redistribute such embedded portions in such Object form without complying
-with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
-
-In addition, if you combine or link compiled forms of this Software with
-software that is licensed under the GPLv2 ("Combined Software") and if a
-court of competent jurisdiction determines that the patent provision (Section
-3), the indemnity provision (Section 9) or other Section of the License
-conflicts with the conditions of the GPLv2, you may retroactively and
-prospectively choose to deem waived or otherwise exclude such Section(s) of
-the License, but only in their entirety and only with respect to the Combined
-Software.
-
-==============================================================================
-Software from third parties included in the LLVM Project:
-==============================================================================
-The LLVM Project contains third party software which is under different license
-terms. All such code will be identified clearly using at least one of two
-mechanisms:
-1) It will be in a separate directory tree with its own `LICENSE.txt` or
- `LICENSE` file at the top containing the specific license and restrictions
- which apply to that software, or
-2) It will contain specific license and restriction terms at the top of every
- file.
-
-==============================================================================
-Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
-==============================================================================
-University of Illinois/NCSA
-Open Source License
-
-Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign.
-All rights reserved.
-
-Developed by:
-
- LLVM Team
-
- University of Illinois at Urbana-Champaign
-
- http://llvm.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal with
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimers.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimers in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the names of the LLVM Team, University of Illinois at
- Urbana-Champaign, nor the names of its contributors may be used to
- endorse or promote products derived from this Software without specific
- prior written permission.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
-SOFTWARE.
-
-
-
-====================File: include/llvm/Support/LICENSE.TXT====================
-LLVM System Interface Library
--------------------------------------------------------------------------------
-The LLVM System Interface Library is licensed under the Illinois Open Source
-License and has the following additional copyright:
-
-Copyright (C) 2004 eXtensible Systems, Inc.
-
-
-====================NCSA====================
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+====================Apache-2.0 WITH LLVM-exception====================
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+
+
+====================Apache-2.0 WITH LLVM-exception====================
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+
+====================COPYRIGHT====================
+ // into sext(%x) + sext(c). We'll sext the Offset ourselves:
+ unsigned OldWidth = Offset.getBitWidth();
+ Offset = Offset.trunc(SmallWidth).sext(NewWidth).zextOrSelf(OldWidth);
+
+
+====================COPYRIGHT====================
+ // sext(%x) + sext(c)
+ Scale = 1;
+ Offset = 0;
+
+
+====================COPYRIGHT====================
+ // |X| < |C| --> X > -abs(C) and X < abs(C)
+ Constant *PosDivisorC = ConstantInt::get(Ty, C->abs());
+ Constant *NegDivisorC = ConstantInt::get(Ty, -C->abs());
+
+
+====================COPYRIGHT====================
+ // {(a)->(b), (b)->(c), (c)->(d), ...} and the worklist is initially {b, a},
+ // then after merging (a) and (b) together, we need to put (a,b) back in
+ // the worklist so that (c) can get merged in as well resulting in
+ // {(a,b,c) -> d}
+ // We also need to remove the old target (b), from the worklist. We first
+
+
+====================COPYRIGHT====================
+ if (match(BO.getOperand(0), m_APInt(C))) {
+ if (IIQ.hasNoUnsignedWrap(&BO)) {
+ // 'shl nuw C, x' produces [C, C << CLZ(C)]
+ Lower = *C;
+ Upper = Lower.shl(Lower.countLeadingZeros()) + 1;
+
+
+====================COPYRIGHT====================
+ if (match(X, m_APInt(C)) && !C->isMinSignedValue()) {
+ // Is the variable divisor magnitude always greater than the constant
+ // dividend magnitude?
+ // |Y| > |C| --> Y < -abs(C) or Y > abs(C)
+ Constant *PosDividendC = ConstantInt::get(Ty, C->abs());
+ Constant *NegDividendC = ConstantInt::get(Ty, -C->abs());
+
+
+====================File: LICENSE.TXT====================
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
+==============================================================================
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign.
+All rights reserved.
+
+Developed by:
+
+ LLVM Team
+
+ University of Illinois at Urbana-Champaign
+
+ http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimers.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimers in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the names of the LLVM Team, University of Illinois at
+ Urbana-Champaign, nor the names of its contributors may be used to
+ endorse or promote products derived from this Software without specific
+ prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+
+
+====================File: include/llvm/Support/LICENSE.TXT====================
+LLVM System Interface Library
+-------------------------------------------------------------------------------
+The LLVM System Interface Library is licensed under the Illinois Open Source
+License and has the following additional copyright:
+
+Copyright (C) 2004 eXtensible Systems, Inc.
+
+
+====================NCSA====================
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
diff --git a/contrib/libs/llvm12/lib/Analysis/MLInlineAdvisor.cpp b/contrib/libs/llvm12/lib/Analysis/MLInlineAdvisor.cpp
index ba8a5bd922..89f4ff427d 100644
--- a/contrib/libs/llvm12/lib/Analysis/MLInlineAdvisor.cpp
+++ b/contrib/libs/llvm12/lib/Analysis/MLInlineAdvisor.cpp
@@ -1,254 +1,254 @@
-//===- MLInlineAdvisor.cpp - machine learned InlineAdvisor ----------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the interface between the inliner and a learned model.
-// It delegates model evaluation to either the AOT compiled model (the
-// 'release' mode) or a runtime-loaded model (the 'development' case).
-//
-//===----------------------------------------------------------------------===//
+//===- MLInlineAdvisor.cpp - machine learned InlineAdvisor ----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the interface between the inliner and a learned model.
+// It delegates model evaluation to either the AOT compiled model (the
+// 'release' mode) or a runtime-loaded model (the 'development' case).
+//
+//===----------------------------------------------------------------------===//
#include "llvm/Config/config.h"
#if defined(LLVM_HAVE_TF_AOT) || defined(LLVM_HAVE_TF_API)
-#include <limits>
-#include <unordered_map>
-#include <unordered_set>
-
-#include "llvm/ADT/SCCIterator.h"
-#include "llvm/Analysis/CallGraph.h"
+#include <limits>
+#include <unordered_map>
+#include <unordered_set>
+
+#include "llvm/ADT/SCCIterator.h"
+#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
-#include "llvm/Analysis/InlineCost.h"
-#include "llvm/Analysis/MLInlineAdvisor.h"
-#include "llvm/Analysis/MLModelRunner.h"
-#include "llvm/Analysis/OptimizationRemarkEmitter.h"
-#include "llvm/Analysis/TargetLibraryInfo.h"
-#include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/IR/InstIterator.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Path.h"
-
-using namespace llvm;
-
-#define DEBUG_TYPE "inline-ml"
-
-static cl::opt<float> SizeIncreaseThreshold(
- "ml-advisor-size-increase-threshold", cl::Hidden,
- cl::desc("Maximum factor by which expected native size may increase before "
- "blocking any further inlining."),
- cl::init(2.0));
-
-const std::array<std::string, NumberOfFeatures> llvm::FeatureNameMap{
-#define POPULATE_NAMES(INDEX_NAME, NAME, COMMENT) NAME,
- INLINE_FEATURE_ITERATOR(POPULATE_NAMES)
-#undef POPULATE_NAMES
-};
-
-const char *const llvm::DecisionName = "inlining_decision";
-const char *const llvm::DefaultDecisionName = "inlining_default";
-const char *const llvm::RewardName = "delta_size";
-
-CallBase *getInlinableCS(Instruction &I) {
- if (auto *CS = dyn_cast<CallBase>(&I))
- if (Function *Callee = CS->getCalledFunction()) {
- if (!Callee->isDeclaration()) {
- return CS;
- }
- }
- return nullptr;
-}
-
-MLInlineAdvisor::MLInlineAdvisor(Module &M, ModuleAnalysisManager &MAM,
- std::unique_ptr<MLModelRunner> Runner)
- : InlineAdvisor(
+#include "llvm/Analysis/InlineCost.h"
+#include "llvm/Analysis/MLInlineAdvisor.h"
+#include "llvm/Analysis/MLModelRunner.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "inline-ml"
+
+static cl::opt<float> SizeIncreaseThreshold(
+ "ml-advisor-size-increase-threshold", cl::Hidden,
+ cl::desc("Maximum factor by which expected native size may increase before "
+ "blocking any further inlining."),
+ cl::init(2.0));
+
+const std::array<std::string, NumberOfFeatures> llvm::FeatureNameMap{
+#define POPULATE_NAMES(INDEX_NAME, NAME, COMMENT) NAME,
+ INLINE_FEATURE_ITERATOR(POPULATE_NAMES)
+#undef POPULATE_NAMES
+};
+
+const char *const llvm::DecisionName = "inlining_decision";
+const char *const llvm::DefaultDecisionName = "inlining_default";
+const char *const llvm::RewardName = "delta_size";
+
+CallBase *getInlinableCS(Instruction &I) {
+ if (auto *CS = dyn_cast<CallBase>(&I))
+ if (Function *Callee = CS->getCalledFunction()) {
+ if (!Callee->isDeclaration()) {
+ return CS;
+ }
+ }
+ return nullptr;
+}
+
+MLInlineAdvisor::MLInlineAdvisor(Module &M, ModuleAnalysisManager &MAM,
+ std::unique_ptr<MLModelRunner> Runner)
+ : InlineAdvisor(
M, MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager()),
ModelRunner(std::move(Runner)), CG(new CallGraph(M)),
- InitialIRSize(getModuleIRSize()), CurrentIRSize(InitialIRSize) {
- assert(ModelRunner);
-
- // Extract the 'call site height' feature - the position of a call site
- // relative to the farthest statically reachable SCC node. We don't mutate
- // this value while inlining happens. Empirically, this feature proved
- // critical in behavioral cloning - i.e. training a model to mimic the manual
- // heuristic's decisions - and, thus, equally important for training for
- // improvement.
- for (auto I = scc_begin(CG.get()); !I.isAtEnd(); ++I) {
- const std::vector<CallGraphNode *> &CGNodes = *I;
- unsigned Level = 0;
- for (auto *CGNode : CGNodes) {
- Function *F = CGNode->getFunction();
- if (!F || F->isDeclaration())
- continue;
- for (auto &I : instructions(F)) {
- if (auto *CS = getInlinableCS(I)) {
- auto *Called = CS->getCalledFunction();
- auto Pos = FunctionLevels.find(Called);
- // In bottom up traversal, an inlinable callee is either in the
- // same SCC, or to a function in a visited SCC. So not finding its
- // level means we haven't visited it yet, meaning it's in this SCC.
- if (Pos == FunctionLevels.end())
- continue;
- Level = std::max(Level, Pos->second + 1);
- }
- }
- }
- for (auto *CGNode : CGNodes) {
- Function *F = CGNode->getFunction();
- if (F && !F->isDeclaration())
- FunctionLevels[F] = Level;
- }
- }
-}
-
-void MLInlineAdvisor::onPassEntry() {
- // Function passes executed between InlinerPass runs may have changed the
- // module-wide features.
- NodeCount = 0;
- EdgeCount = 0;
- for (auto &F : M)
- if (!F.isDeclaration()) {
- ++NodeCount;
- EdgeCount += getLocalCalls(F);
- }
-}
-
-int64_t MLInlineAdvisor::getLocalCalls(Function &F) {
+ InitialIRSize(getModuleIRSize()), CurrentIRSize(InitialIRSize) {
+ assert(ModelRunner);
+
+ // Extract the 'call site height' feature - the position of a call site
+ // relative to the farthest statically reachable SCC node. We don't mutate
+ // this value while inlining happens. Empirically, this feature proved
+ // critical in behavioral cloning - i.e. training a model to mimic the manual
+ // heuristic's decisions - and, thus, equally important for training for
+ // improvement.
+ for (auto I = scc_begin(CG.get()); !I.isAtEnd(); ++I) {
+ const std::vector<CallGraphNode *> &CGNodes = *I;
+ unsigned Level = 0;
+ for (auto *CGNode : CGNodes) {
+ Function *F = CGNode->getFunction();
+ if (!F || F->isDeclaration())
+ continue;
+ for (auto &I : instructions(F)) {
+ if (auto *CS = getInlinableCS(I)) {
+ auto *Called = CS->getCalledFunction();
+ auto Pos = FunctionLevels.find(Called);
+ // In bottom up traversal, an inlinable callee is either in the
+ // same SCC, or to a function in a visited SCC. So not finding its
+ // level means we haven't visited it yet, meaning it's in this SCC.
+ if (Pos == FunctionLevels.end())
+ continue;
+ Level = std::max(Level, Pos->second + 1);
+ }
+ }
+ }
+ for (auto *CGNode : CGNodes) {
+ Function *F = CGNode->getFunction();
+ if (F && !F->isDeclaration())
+ FunctionLevels[F] = Level;
+ }
+ }
+}
+
+void MLInlineAdvisor::onPassEntry() {
+ // Function passes executed between InlinerPass runs may have changed the
+ // module-wide features.
+ NodeCount = 0;
+ EdgeCount = 0;
+ for (auto &F : M)
+ if (!F.isDeclaration()) {
+ ++NodeCount;
+ EdgeCount += getLocalCalls(F);
+ }
+}
+
+int64_t MLInlineAdvisor::getLocalCalls(Function &F) {
return FAM.getResult<FunctionPropertiesAnalysis>(F)
.DirectCallsToDefinedFunctions;
-}
-
-// Update the internal state of the advisor, and force invalidate feature
-// analysis. Currently, we maintain minimal (and very simple) global state - the
-// number of functions and the number of static calls. We also keep track of the
-// total IR size in this module, to stop misbehaving policies at a certain bloat
-// factor (SizeIncreaseThreshold)
-void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
- bool CalleeWasDeleted) {
- assert(!ForceStop);
- Function *Caller = Advice.getCaller();
- Function *Callee = Advice.getCallee();
-
- // The caller features aren't valid anymore.
+}
+
+// Update the internal state of the advisor, and force invalidate feature
+// analysis. Currently, we maintain minimal (and very simple) global state - the
+// number of functions and the number of static calls. We also keep track of the
+// total IR size in this module, to stop misbehaving policies at a certain bloat
+// factor (SizeIncreaseThreshold)
+void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
+ bool CalleeWasDeleted) {
+ assert(!ForceStop);
+ Function *Caller = Advice.getCaller();
+ Function *Callee = Advice.getCallee();
+
+ // The caller features aren't valid anymore.
FAM.invalidate<FunctionPropertiesAnalysis>(*Caller);
- int64_t IRSizeAfter =
- getIRSize(*Caller) + (CalleeWasDeleted ? 0 : Advice.CalleeIRSize);
- CurrentIRSize += IRSizeAfter - (Advice.CallerIRSize + Advice.CalleeIRSize);
- if (CurrentIRSize > SizeIncreaseThreshold * InitialIRSize)
- ForceStop = true;
-
- // We can delta-update module-wide features. We know the inlining only changed
- // the caller, and maybe the callee (by deleting the latter).
- // Nodes are simple to update.
- // For edges, we 'forget' the edges that the caller and callee used to have
- // before inlining, and add back what they currently have together.
- int64_t NewCallerAndCalleeEdges =
+ int64_t IRSizeAfter =
+ getIRSize(*Caller) + (CalleeWasDeleted ? 0 : Advice.CalleeIRSize);
+ CurrentIRSize += IRSizeAfter - (Advice.CallerIRSize + Advice.CalleeIRSize);
+ if (CurrentIRSize > SizeIncreaseThreshold * InitialIRSize)
+ ForceStop = true;
+
+ // We can delta-update module-wide features. We know the inlining only changed
+ // the caller, and maybe the callee (by deleting the latter).
+ // Nodes are simple to update.
+ // For edges, we 'forget' the edges that the caller and callee used to have
+ // before inlining, and add back what they currently have together.
+ int64_t NewCallerAndCalleeEdges =
FAM.getResult<FunctionPropertiesAnalysis>(*Caller)
- .DirectCallsToDefinedFunctions;
-
- if (CalleeWasDeleted)
- --NodeCount;
- else
+ .DirectCallsToDefinedFunctions;
+
+ if (CalleeWasDeleted)
+ --NodeCount;
+ else
NewCallerAndCalleeEdges +=
FAM.getResult<FunctionPropertiesAnalysis>(*Callee)
.DirectCallsToDefinedFunctions;
- EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
- assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
-}
-
-int64_t MLInlineAdvisor::getModuleIRSize() const {
- int64_t Ret = 0;
- for (auto &F : CG->getModule())
- if (!F.isDeclaration())
- Ret += getIRSize(F);
- return Ret;
-}
-
+ EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
+ assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
+}
+
+int64_t MLInlineAdvisor::getModuleIRSize() const {
+ int64_t Ret = 0;
+ for (auto &F : CG->getModule())
+ if (!F.isDeclaration())
+ Ret += getIRSize(F);
+ return Ret;
+}
+
std::unique_ptr<InlineAdvice> MLInlineAdvisor::getAdviceImpl(CallBase &CB) {
- auto &Caller = *CB.getCaller();
- auto &Callee = *CB.getCalledFunction();
-
- auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
- return FAM.getResult<AssumptionAnalysis>(F);
- };
- auto &TIR = FAM.getResult<TargetIRAnalysis>(Callee);
- auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller);
-
+ auto &Caller = *CB.getCaller();
+ auto &Callee = *CB.getCalledFunction();
+
+ auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
+ return FAM.getResult<AssumptionAnalysis>(F);
+ };
+ auto &TIR = FAM.getResult<TargetIRAnalysis>(Callee);
+ auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller);
+
auto MandatoryKind = InlineAdvisor::getMandatoryKind(CB, FAM, ORE);
- // If this is a "never inline" case, there won't be any changes to internal
- // state we need to track, so we can just return the base InlineAdvice, which
- // will do nothing interesting.
- // Same thing if this is a recursive case.
+ // If this is a "never inline" case, there won't be any changes to internal
+ // state we need to track, so we can just return the base InlineAdvice, which
+ // will do nothing interesting.
+ // Same thing if this is a recursive case.
if (MandatoryKind == InlineAdvisor::MandatoryInliningKind::Never ||
- &Caller == &Callee)
+ &Caller == &Callee)
return getMandatoryAdvice(CB, false);
-
+
bool Mandatory =
MandatoryKind == InlineAdvisor::MandatoryInliningKind::Always;
-
- // If we need to stop, we won't want to track anymore any state changes, so
- // we just return the base InlineAdvice, which acts as a noop.
- if (ForceStop) {
- ORE.emit([&] {
- return OptimizationRemarkMissed(DEBUG_TYPE, "ForceStop", &CB)
- << "Won't attempt inlining because module size grew too much.";
- });
- return std::make_unique<InlineAdvice>(this, CB, ORE, Mandatory);
- }
-
- int CostEstimate = 0;
- if (!Mandatory) {
- auto IsCallSiteInlinable =
- llvm::getInliningCostEstimate(CB, TIR, GetAssumptionCache);
- if (!IsCallSiteInlinable) {
- // We can't inline this for correctness reasons, so return the base
- // InlineAdvice, as we don't care about tracking any state changes (which
- // won't happen).
- return std::make_unique<InlineAdvice>(this, CB, ORE, false);
- }
- CostEstimate = *IsCallSiteInlinable;
- }
-
- if (Mandatory)
+
+ // If we need to stop, we won't want to track anymore any state changes, so
+ // we just return the base InlineAdvice, which acts as a noop.
+ if (ForceStop) {
+ ORE.emit([&] {
+ return OptimizationRemarkMissed(DEBUG_TYPE, "ForceStop", &CB)
+ << "Won't attempt inlining because module size grew too much.";
+ });
+ return std::make_unique<InlineAdvice>(this, CB, ORE, Mandatory);
+ }
+
+ int CostEstimate = 0;
+ if (!Mandatory) {
+ auto IsCallSiteInlinable =
+ llvm::getInliningCostEstimate(CB, TIR, GetAssumptionCache);
+ if (!IsCallSiteInlinable) {
+ // We can't inline this for correctness reasons, so return the base
+ // InlineAdvice, as we don't care about tracking any state changes (which
+ // won't happen).
+ return std::make_unique<InlineAdvice>(this, CB, ORE, false);
+ }
+ CostEstimate = *IsCallSiteInlinable;
+ }
+
+ if (Mandatory)
return getMandatoryAdvice(CB, true);
-
- auto NrCtantParams = 0;
- for (auto I = CB.arg_begin(), E = CB.arg_end(); I != E; ++I) {
- NrCtantParams += (isa<Constant>(*I));
- }
-
+
+ auto NrCtantParams = 0;
+ for (auto I = CB.arg_begin(), E = CB.arg_end(); I != E; ++I) {
+ NrCtantParams += (isa<Constant>(*I));
+ }
+
auto &CallerBefore = FAM.getResult<FunctionPropertiesAnalysis>(Caller);
auto &CalleeBefore = FAM.getResult<FunctionPropertiesAnalysis>(Callee);
-
- ModelRunner->setFeature(FeatureIndex::CalleeBasicBlockCount,
- CalleeBefore.BasicBlockCount);
- ModelRunner->setFeature(FeatureIndex::CallSiteHeight,
- FunctionLevels[&Caller]);
- ModelRunner->setFeature(FeatureIndex::NodeCount, NodeCount);
- ModelRunner->setFeature(FeatureIndex::NrCtantParams, NrCtantParams);
- ModelRunner->setFeature(FeatureIndex::CostEstimate, CostEstimate);
- ModelRunner->setFeature(FeatureIndex::EdgeCount, EdgeCount);
- ModelRunner->setFeature(FeatureIndex::CallerUsers, CallerBefore.Uses);
- ModelRunner->setFeature(FeatureIndex::CallerConditionallyExecutedBlocks,
- CallerBefore.BlocksReachedFromConditionalInstruction);
- ModelRunner->setFeature(FeatureIndex::CallerBasicBlockCount,
- CallerBefore.BasicBlockCount);
- ModelRunner->setFeature(FeatureIndex::CalleeConditionallyExecutedBlocks,
- CalleeBefore.BlocksReachedFromConditionalInstruction);
- ModelRunner->setFeature(FeatureIndex::CalleeUsers, CalleeBefore.Uses);
- return getAdviceFromModel(CB, ORE);
-}
-
-std::unique_ptr<MLInlineAdvice>
-MLInlineAdvisor::getAdviceFromModel(CallBase &CB,
- OptimizationRemarkEmitter &ORE) {
- return std::make_unique<MLInlineAdvice>(this, CB, ORE, ModelRunner->run());
-}
-
+
+ ModelRunner->setFeature(FeatureIndex::CalleeBasicBlockCount,
+ CalleeBefore.BasicBlockCount);
+ ModelRunner->setFeature(FeatureIndex::CallSiteHeight,
+ FunctionLevels[&Caller]);
+ ModelRunner->setFeature(FeatureIndex::NodeCount, NodeCount);
+ ModelRunner->setFeature(FeatureIndex::NrCtantParams, NrCtantParams);
+ ModelRunner->setFeature(FeatureIndex::CostEstimate, CostEstimate);
+ ModelRunner->setFeature(FeatureIndex::EdgeCount, EdgeCount);
+ ModelRunner->setFeature(FeatureIndex::CallerUsers, CallerBefore.Uses);
+ ModelRunner->setFeature(FeatureIndex::CallerConditionallyExecutedBlocks,
+ CallerBefore.BlocksReachedFromConditionalInstruction);
+ ModelRunner->setFeature(FeatureIndex::CallerBasicBlockCount,
+ CallerBefore.BasicBlockCount);
+ ModelRunner->setFeature(FeatureIndex::CalleeConditionallyExecutedBlocks,
+ CalleeBefore.BlocksReachedFromConditionalInstruction);
+ ModelRunner->setFeature(FeatureIndex::CalleeUsers, CalleeBefore.Uses);
+ return getAdviceFromModel(CB, ORE);
+}
+
+std::unique_ptr<MLInlineAdvice>
+MLInlineAdvisor::getAdviceFromModel(CallBase &CB,
+ OptimizationRemarkEmitter &ORE) {
+ return std::make_unique<MLInlineAdvice>(this, CB, ORE, ModelRunner->run());
+}
+
std::unique_ptr<InlineAdvice> MLInlineAdvisor::getMandatoryAdvice(CallBase &CB,
bool Advice) {
// Make sure we track inlinings in all cases - mandatory or not.
@@ -262,53 +262,53 @@ std::unique_ptr<InlineAdvice> MLInlineAdvisor::getMandatoryAdvice(CallBase &CB,
return std::make_unique<InlineAdvice>(this, CB, getCallerORE(CB), Advice);
}
-std::unique_ptr<MLInlineAdvice>
+std::unique_ptr<MLInlineAdvice>
MLInlineAdvisor::getMandatoryAdviceImpl(CallBase &CB) {
return std::make_unique<MLInlineAdvice>(this, CB, getCallerORE(CB), true);
-}
-
-void MLInlineAdvice::reportContextForRemark(
- DiagnosticInfoOptimizationBase &OR) {
- using namespace ore;
- OR << NV("Callee", Callee->getName());
- for (size_t I = 0; I < NumberOfFeatures; ++I)
- OR << NV(FeatureNameMap[I], getAdvisor()->getModelRunner().getFeature(I));
- OR << NV("ShouldInline", isInliningRecommended());
-}
-
-void MLInlineAdvice::recordInliningImpl() {
- ORE.emit([&]() {
- OptimizationRemark R(DEBUG_TYPE, "InliningSuccess", DLoc, Block);
- reportContextForRemark(R);
- return R;
- });
- getAdvisor()->onSuccessfulInlining(*this, /*CalleeWasDeleted*/ false);
-}
-
-void MLInlineAdvice::recordInliningWithCalleeDeletedImpl() {
- ORE.emit([&]() {
- OptimizationRemark R(DEBUG_TYPE, "InliningSuccessWithCalleeDeleted", DLoc,
- Block);
- reportContextForRemark(R);
- return R;
- });
- getAdvisor()->onSuccessfulInlining(*this, /*CalleeWasDeleted*/ true);
-}
-
-void MLInlineAdvice::recordUnsuccessfulInliningImpl(
- const InlineResult &Result) {
- ORE.emit([&]() {
- OptimizationRemarkMissed R(DEBUG_TYPE, "InliningAttemptedAndUnsuccessful",
- DLoc, Block);
- reportContextForRemark(R);
- return R;
- });
-}
-void MLInlineAdvice::recordUnattemptedInliningImpl() {
- ORE.emit([&]() {
- OptimizationRemarkMissed R(DEBUG_TYPE, "IniningNotAttempted", DLoc, Block);
- reportContextForRemark(R);
- return R;
- });
+}
+
+void MLInlineAdvice::reportContextForRemark(
+ DiagnosticInfoOptimizationBase &OR) {
+ using namespace ore;
+ OR << NV("Callee", Callee->getName());
+ for (size_t I = 0; I < NumberOfFeatures; ++I)
+ OR << NV(FeatureNameMap[I], getAdvisor()->getModelRunner().getFeature(I));
+ OR << NV("ShouldInline", isInliningRecommended());
+}
+
+void MLInlineAdvice::recordInliningImpl() {
+ ORE.emit([&]() {
+ OptimizationRemark R(DEBUG_TYPE, "InliningSuccess", DLoc, Block);
+ reportContextForRemark(R);
+ return R;
+ });
+ getAdvisor()->onSuccessfulInlining(*this, /*CalleeWasDeleted*/ false);
+}
+
+void MLInlineAdvice::recordInliningWithCalleeDeletedImpl() {
+ ORE.emit([&]() {
+ OptimizationRemark R(DEBUG_TYPE, "InliningSuccessWithCalleeDeleted", DLoc,
+ Block);
+ reportContextForRemark(R);
+ return R;
+ });
+ getAdvisor()->onSuccessfulInlining(*this, /*CalleeWasDeleted*/ true);
+}
+
+void MLInlineAdvice::recordUnsuccessfulInliningImpl(
+ const InlineResult &Result) {
+ ORE.emit([&]() {
+ OptimizationRemarkMissed R(DEBUG_TYPE, "InliningAttemptedAndUnsuccessful",
+ DLoc, Block);
+ reportContextForRemark(R);
+ return R;
+ });
+}
+void MLInlineAdvice::recordUnattemptedInliningImpl() {
+ ORE.emit([&]() {
+ OptimizationRemarkMissed R(DEBUG_TYPE, "IniningNotAttempted", DLoc, Block);
+ reportContextForRemark(R);
+ return R;
+ });
}
#endif // defined(LLVM_HAVE_TF_AOT) || defined(LLVM_HAVE_TF_API)
diff --git a/contrib/libs/llvm12/lib/Analysis/README.txt b/contrib/libs/llvm12/lib/Analysis/README.txt
index 6d6b30e0b1..0e96e4c950 100644
--- a/contrib/libs/llvm12/lib/Analysis/README.txt
+++ b/contrib/libs/llvm12/lib/Analysis/README.txt
@@ -1,30 +1,30 @@
-Analysis Opportunities:
-
-//===---------------------------------------------------------------------===//
-
-In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
-ScalarEvolution expression for %r is this:
-
- {1,+,3,+,2}<loop>
-
-Outside the loop, this could be evaluated simply as (%n * %n), however
-ScalarEvolution currently evaluates it as
-
- (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))
-
-In addition to being much more complicated, it involves i65 arithmetic,
-which is very inefficient when expanded into code.
-
-//===---------------------------------------------------------------------===//
-
-In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,
-
-ScalarEvolution is forming this expression:
-
-((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))
-
-This could be folded to
-
-(-1 * (trunc i64 undef to i32))
-
-//===---------------------------------------------------------------------===//
+Analysis Opportunities:
+
+//===---------------------------------------------------------------------===//
+
+In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
+ScalarEvolution expression for %r is this:
+
+ {1,+,3,+,2}<loop>
+
+Outside the loop, this could be evaluated simply as (%n * %n), however
+ScalarEvolution currently evaluates it as
+
+ (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))
+
+In addition to being much more complicated, it involves i65 arithmetic,
+which is very inefficient when expanded into code.
+
+//===---------------------------------------------------------------------===//
+
+In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,
+
+ScalarEvolution is forming this expression:
+
+((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))
+
+This could be folded to
+
+(-1 * (trunc i64 undef to i32))
+
+//===---------------------------------------------------------------------===//
diff --git a/contrib/libs/llvm12/lib/Analysis/TFUtils.cpp b/contrib/libs/llvm12/lib/Analysis/TFUtils.cpp
index 1351db7d30..3f26bdfdc0 100644
--- a/contrib/libs/llvm12/lib/Analysis/TFUtils.cpp
+++ b/contrib/libs/llvm12/lib/Analysis/TFUtils.cpp
@@ -1,69 +1,69 @@
-//===- TFUtils.cpp - tensorflow evaluation utilities ----------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements utilities for interfacing with tensorflow C APIs.
-//
-//===----------------------------------------------------------------------===//
+//===- TFUtils.cpp - tensorflow evaluation utilities ----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements utilities for interfacing with tensorflow C APIs.
+//
+//===----------------------------------------------------------------------===//
#include "llvm/Config/config.h"
#if defined(LLVM_HAVE_TF_API)
-
+
#include "llvm/ADT/Twine.h"
-#include "llvm/Analysis/Utils/TFUtils.h"
-#include "llvm/Support/Debug.h"
+#include "llvm/Analysis/Utils/TFUtils.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/JSON.h"
-#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
-
+#include "llvm/Support/raw_ostream.h"
+
#error #include "tensorflow/c/c_api.h"
#error #include "tensorflow/c/c_api_experimental.h"
-
-#include <cassert>
+
+#include <cassert>
#include <numeric>
-
-using namespace llvm;
-
-namespace {
-
-using TFGraphPtr = std::unique_ptr<TF_Graph, decltype(&TF_DeleteGraph)>;
-using TFSessionOptionsPtr =
- std::unique_ptr<TF_SessionOptions, decltype(&TF_DeleteSessionOptions)>;
-using TFStatusPtr = std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)>;
-
-struct TFInitializer {
- TFInitializer() {
- assert(!IsInitialized && "TFInitialized should be called only once");
- int Argc = 1;
- const char *Name = "";
- const char **NamePtr = &Name;
- TF_InitMain(Name, &Argc, const_cast<char ***>(&NamePtr));
- IsInitialized = true;
- }
- bool IsInitialized = false;
-};
-
-llvm::ManagedStatic<TFInitializer> TFLibInitializer;
-
-bool ensureInitTF() { return TFLibInitializer->IsInitialized; }
-
-TFGraphPtr createTFGraph() {
- return TFGraphPtr(TF_NewGraph(), &TF_DeleteGraph);
-}
-
-TFStatusPtr createTFStatus() {
- return TFStatusPtr(TF_NewStatus(), &TF_DeleteStatus);
-}
-
-TFSessionOptionsPtr createTFSessionOptions() {
- return TFSessionOptionsPtr(TF_NewSessionOptions(), &TF_DeleteSessionOptions);
-}
+
+using namespace llvm;
+
+namespace {
+
+using TFGraphPtr = std::unique_ptr<TF_Graph, decltype(&TF_DeleteGraph)>;
+using TFSessionOptionsPtr =
+ std::unique_ptr<TF_SessionOptions, decltype(&TF_DeleteSessionOptions)>;
+using TFStatusPtr = std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)>;
+
+struct TFInitializer {
+ TFInitializer() {
+ assert(!IsInitialized && "TFInitialized should be called only once");
+ int Argc = 1;
+ const char *Name = "";
+ const char **NamePtr = &Name;
+ TF_InitMain(Name, &Argc, const_cast<char ***>(&NamePtr));
+ IsInitialized = true;
+ }
+ bool IsInitialized = false;
+};
+
+llvm::ManagedStatic<TFInitializer> TFLibInitializer;
+
+bool ensureInitTF() { return TFLibInitializer->IsInitialized; }
+
+TFGraphPtr createTFGraph() {
+ return TFGraphPtr(TF_NewGraph(), &TF_DeleteGraph);
+}
+
+TFStatusPtr createTFStatus() {
+ return TFStatusPtr(TF_NewStatus(), &TF_DeleteStatus);
+}
+
+TFSessionOptionsPtr createTFSessionOptions() {
+ return TFSessionOptionsPtr(TF_NewSessionOptions(), &TF_DeleteSessionOptions);
+}
/// Write the values of one tensor as a list.
template <typename T>
@@ -147,29 +147,29 @@ void writeRawTensorsAsFeatureLists(raw_ostream &OutFile,
OutFile << " }\n";
OutFile << " }\n";
}
-} // namespace
-
-namespace llvm {
-class EvaluationResultImpl {
-public:
- EvaluationResultImpl(size_t OutputSize)
- : OutputSize(OutputSize), Output(OutputSize){};
-
- ~EvaluationResultImpl() {
- for (auto *P : Output)
- if (P)
- TF_DeleteTensor(P);
- }
-
- EvaluationResultImpl(const EvaluationResultImpl &) = delete;
- EvaluationResultImpl(EvaluationResultImpl &&Other) = delete;
- std::vector<TF_Tensor *> &getOutput() { return Output; }
-
-private:
- const size_t OutputSize;
- std::vector<TF_Tensor *> Output;
-};
-
+} // namespace
+
+namespace llvm {
+class EvaluationResultImpl {
+public:
+ EvaluationResultImpl(size_t OutputSize)
+ : OutputSize(OutputSize), Output(OutputSize){};
+
+ ~EvaluationResultImpl() {
+ for (auto *P : Output)
+ if (P)
+ TF_DeleteTensor(P);
+ }
+
+ EvaluationResultImpl(const EvaluationResultImpl &) = delete;
+ EvaluationResultImpl(EvaluationResultImpl &&Other) = delete;
+ std::vector<TF_Tensor *> &getOutput() { return Output; }
+
+private:
+ const size_t OutputSize;
+ std::vector<TF_Tensor *> Output;
+};
+
size_t TensorSpec::getElementByteSize() const {
return TF_DataTypeSize(static_cast<TF_DataType>(TypeIndex));
}
@@ -280,110 +280,110 @@ loadOutputSpecs(LLVMContext &Ctx, StringRef ExpectedDecisionName,
return Ret;
}
-class TFModelEvaluatorImpl {
-public:
- TFModelEvaluatorImpl(StringRef SavedModelPath,
+class TFModelEvaluatorImpl {
+public:
+ TFModelEvaluatorImpl(StringRef SavedModelPath,
const std::vector<TensorSpec> &InputSpecs,
function_ref<TensorSpec(size_t)> GetOutputSpecs,
size_t OutputSpecsSize, const char *Tags);
-
- bool isValid() const { return IsValid; }
- size_t OutputSize() const { return OutputFeed.size(); }
-
- void evaluate(TF_Tensor **Output, TF_Status *Status) {
- TF_SessionRun(Session, nullptr, InputFeed.data(), Input.data(),
- Input.size(), OutputFeed.data(), Output, OutputFeed.size(),
- nullptr, 0, nullptr, Status);
- }
-
- void initInput(size_t Index, TF_DataType Type,
- const std::vector<int64_t> &Dimensions);
- const std::vector<TF_Tensor *> &getInput() const { return Input; }
-
- ~TFModelEvaluatorImpl();
-
-private:
- /// The objects necessary for carrying out an evaluation of the SavedModel.
- /// They are expensive to set up, and we maintain them accross all the
- /// evaluations of the model.
- TF_Session *Session = nullptr;
- TFGraphPtr Graph;
- TFSessionOptionsPtr Options;
-
- /// The specification of the input nodes.
- std::vector<TF_Output> InputFeed;
-
- /// The input tensors. They must match by index of the corresponding InputFeed
- /// value. We set up the tensors once and just mutate theirs scalars before
- /// each evaluation. The input tensors keep their value after an evaluation.
- std::vector<TF_Tensor *> Input;
-
- /// The specification of the output nodes. When evaluating, the tensors in the
- /// output tensor vector must match by index the corresponding element in the
- /// OutputFeed.
- std::vector<TF_Output> OutputFeed;
-
- void invalidate() { IsValid = false; }
-
- bool IsValid = true;
-
- /// Reusable utility for ensuring we can bind the requested Name to a node in
- /// the SavedModel Graph.
+
+ bool isValid() const { return IsValid; }
+ size_t OutputSize() const { return OutputFeed.size(); }
+
+ void evaluate(TF_Tensor **Output, TF_Status *Status) {
+ TF_SessionRun(Session, nullptr, InputFeed.data(), Input.data(),
+ Input.size(), OutputFeed.data(), Output, OutputFeed.size(),
+ nullptr, 0, nullptr, Status);
+ }
+
+ void initInput(size_t Index, TF_DataType Type,
+ const std::vector<int64_t> &Dimensions);
+ const std::vector<TF_Tensor *> &getInput() const { return Input; }
+
+ ~TFModelEvaluatorImpl();
+
+private:
+ /// The objects necessary for carrying out an evaluation of the SavedModel.
+ /// They are expensive to set up, and we maintain them accross all the
+ /// evaluations of the model.
+ TF_Session *Session = nullptr;
+ TFGraphPtr Graph;
+ TFSessionOptionsPtr Options;
+
+ /// The specification of the input nodes.
+ std::vector<TF_Output> InputFeed;
+
+ /// The input tensors. They must match by index of the corresponding InputFeed
+ /// value. We set up the tensors once and just mutate theirs scalars before
+ /// each evaluation. The input tensors keep their value after an evaluation.
+ std::vector<TF_Tensor *> Input;
+
+ /// The specification of the output nodes. When evaluating, the tensors in the
+ /// output tensor vector must match by index the corresponding element in the
+ /// OutputFeed.
+ std::vector<TF_Output> OutputFeed;
+
+ void invalidate() { IsValid = false; }
+
+ bool IsValid = true;
+
+ /// Reusable utility for ensuring we can bind the requested Name to a node in
+ /// the SavedModel Graph.
bool checkReportAndInvalidate(const TF_Output &Output,
const TensorSpec &OutputSpec);
-};
-} // namespace llvm
-
-TFModelEvaluatorImpl::TFModelEvaluatorImpl(
+};
+} // namespace llvm
+
+TFModelEvaluatorImpl::TFModelEvaluatorImpl(
StringRef SavedModelPath, const std::vector<TensorSpec> &InputSpecs,
function_ref<TensorSpec(size_t)> GetOutputSpecs, size_t OutputSpecsSize,
const char *Tags = "serve")
- : Graph(createTFGraph()), Options(createTFSessionOptions()),
+ : Graph(createTFGraph()), Options(createTFSessionOptions()),
InputFeed(InputSpecs.size()), Input(InputSpecs.size()),
OutputFeed(OutputSpecsSize) {
- if (!ensureInitTF()) {
- errs() << "Tensorflow should have been initialized";
- return;
- }
- auto Status = createTFStatus();
-
- Session = TF_LoadSessionFromSavedModel(Options.get(), nullptr,
- SavedModelPath.str().c_str(), &Tags, 1,
- Graph.get(), nullptr, Status.get());
- if (TF_GetCode(Status.get()) != TF_Code::TF_OK) {
- errs() << TF_Message(Status.get());
- invalidate();
- }
+ if (!ensureInitTF()) {
+ errs() << "Tensorflow should have been initialized";
+ return;
+ }
+ auto Status = createTFStatus();
+
+ Session = TF_LoadSessionFromSavedModel(Options.get(), nullptr,
+ SavedModelPath.str().c_str(), &Tags, 1,
+ Graph.get(), nullptr, Status.get());
+ if (TF_GetCode(Status.get()) != TF_Code::TF_OK) {
+ errs() << TF_Message(Status.get());
+ invalidate();
+ }
for (size_t I = 0; I < InputSpecs.size(); ++I) {
auto &InputSpec = InputSpecs[I];
- InputFeed[I] = {
+ InputFeed[I] = {
TF_GraphOperationByName(Graph.get(), (InputSpec.name()).c_str()),
InputSpec.port()};
if (!checkReportAndInvalidate(InputFeed[I], InputSpec))
- return;
+ return;
initInput(I, static_cast<TF_DataType>(InputSpec.typeIndex()),
InputSpec.shape());
- }
+ }
for (size_t I = 0; I < OutputSpecsSize; ++I) {
auto OutputSpec = GetOutputSpecs(I);
- OutputFeed[I] = {
+ OutputFeed[I] = {
TF_GraphOperationByName(Graph.get(), (OutputSpec.name()).c_str()),
OutputSpec.port()};
if (!checkReportAndInvalidate(OutputFeed[I], OutputSpec))
- return;
- }
-}
-
+ return;
+ }
+}
+
TFModelEvaluator::TFModelEvaluator(
StringRef SavedModelPath, const std::vector<TensorSpec> &InputSpecs,
function_ref<TensorSpec(size_t)> GetOutputSpecs, size_t OutputSpecsSize,
const char *Tags)
: Impl(new TFModelEvaluatorImpl(SavedModelPath, InputSpecs, GetOutputSpecs,
OutputSpecsSize, Tags)) {
- if (!Impl->isValid())
- Impl.reset();
-}
-
+ if (!Impl->isValid())
+ Impl.reset();
+}
+
TFModelEvaluator::TFModelEvaluator(StringRef SavedModelPath,
const std::vector<TensorSpec> &InputSpecs,
const std::vector<TensorSpec> &OutputSpecs,
@@ -392,90 +392,90 @@ TFModelEvaluator::TFModelEvaluator(StringRef SavedModelPath,
SavedModelPath, InputSpecs, [&](size_t I) { return OutputSpecs[I]; },
OutputSpecs.size(), Tags) {}
-TFModelEvaluatorImpl::~TFModelEvaluatorImpl() {
- for (auto *T : Input) {
- TF_DeleteTensor(T);
- }
- if (Session == nullptr)
- return;
- auto Status = createTFStatus();
- TF_DeleteSession(Session, Status.get());
- Session = nullptr;
- if (TF_GetCode(Status.get()) != TF_Code::TF_OK)
- errs() << "Could not delete TF session";
-}
-
+TFModelEvaluatorImpl::~TFModelEvaluatorImpl() {
+ for (auto *T : Input) {
+ TF_DeleteTensor(T);
+ }
+ if (Session == nullptr)
+ return;
+ auto Status = createTFStatus();
+ TF_DeleteSession(Session, Status.get());
+ Session = nullptr;
+ if (TF_GetCode(Status.get()) != TF_Code::TF_OK)
+ errs() << "Could not delete TF session";
+}
+
bool TFModelEvaluatorImpl::checkReportAndInvalidate(
const TF_Output &Output, const TensorSpec &OutputSpec) {
- if (Output.oper)
- return true;
+ if (Output.oper)
+ return true;
errs() << "Could not find TF_Output named: " + OutputSpec.name();
- IsValid = false;
- return IsValid;
-}
-
-Optional<TFModelEvaluator::EvaluationResult> TFModelEvaluator::evaluate() {
- if (!isValid())
- return None;
- std::unique_ptr<EvaluationResultImpl> Ret =
- std::make_unique<EvaluationResultImpl>(Impl->OutputSize());
- auto Status = createTFStatus();
- Impl->evaluate(Ret->getOutput().data(), Status.get());
- if (TF_GetCode(Status.get()) != TF_Code::TF_OK) {
- errs() << TF_Message(Status.get());
- Impl.reset();
- return None;
- }
- return EvaluationResult(std::move(Ret));
-}
-
-void TFModelEvaluatorImpl::initInput(size_t Index, TF_DataType Type,
- const std::vector<int64_t> &Dimensions) {
- int64_t TotalSize = TF_DataTypeSize(Type);
- for (auto &D : Dimensions)
- TotalSize *= D;
-
- Input[Index] =
- TF_AllocateTensor(Type, Dimensions.data(), Dimensions.size(), TotalSize);
- std::memset(TF_TensorData(Input[Index]), 0, TotalSize);
-}
-
-void *TFModelEvaluator::getUntypedInput(size_t Index) {
- return TF_TensorData(Impl->getInput()[Index]);
-}
-
-TFModelEvaluator::EvaluationResult::EvaluationResult(
- std::unique_ptr<EvaluationResultImpl> Impl)
- : Impl(std::move(Impl)) {}
-
-TFModelEvaluator::EvaluationResult::EvaluationResult(EvaluationResult &&Other)
- : Impl(std::move(Other.Impl)) {}
-
+ IsValid = false;
+ return IsValid;
+}
+
+Optional<TFModelEvaluator::EvaluationResult> TFModelEvaluator::evaluate() {
+ if (!isValid())
+ return None;
+ std::unique_ptr<EvaluationResultImpl> Ret =
+ std::make_unique<EvaluationResultImpl>(Impl->OutputSize());
+ auto Status = createTFStatus();
+ Impl->evaluate(Ret->getOutput().data(), Status.get());
+ if (TF_GetCode(Status.get()) != TF_Code::TF_OK) {
+ errs() << TF_Message(Status.get());
+ Impl.reset();
+ return None;
+ }
+ return EvaluationResult(std::move(Ret));
+}
+
+void TFModelEvaluatorImpl::initInput(size_t Index, TF_DataType Type,
+ const std::vector<int64_t> &Dimensions) {
+ int64_t TotalSize = TF_DataTypeSize(Type);
+ for (auto &D : Dimensions)
+ TotalSize *= D;
+
+ Input[Index] =
+ TF_AllocateTensor(Type, Dimensions.data(), Dimensions.size(), TotalSize);
+ std::memset(TF_TensorData(Input[Index]), 0, TotalSize);
+}
+
+void *TFModelEvaluator::getUntypedInput(size_t Index) {
+ return TF_TensorData(Impl->getInput()[Index]);
+}
+
+TFModelEvaluator::EvaluationResult::EvaluationResult(
+ std::unique_ptr<EvaluationResultImpl> Impl)
+ : Impl(std::move(Impl)) {}
+
+TFModelEvaluator::EvaluationResult::EvaluationResult(EvaluationResult &&Other)
+ : Impl(std::move(Other.Impl)) {}
+
TFModelEvaluator::EvaluationResult &
TFModelEvaluator::EvaluationResult::operator=(EvaluationResult &&Other) {
Impl = std::move(Other.Impl);
return *this;
}
-void *TFModelEvaluator::EvaluationResult::getUntypedTensorValue(size_t Index) {
- return TF_TensorData(Impl->getOutput()[Index]);
-}
-
+void *TFModelEvaluator::EvaluationResult::getUntypedTensorValue(size_t Index) {
+ return TF_TensorData(Impl->getOutput()[Index]);
+}
+
const void *
TFModelEvaluator::EvaluationResult::getUntypedTensorValue(size_t Index) const {
return TF_TensorData(Impl->getOutput()[Index]);
-}
-
+}
+
#define TFUTILS_GETDATATYPE_IMPL(T, E) \
template <> int TensorSpec::getDataType<T>() { return E; }
-
+
TFUTILS_SUPPORTED_TYPES(TFUTILS_GETDATATYPE_IMPL)
-
+
#undef TFUTILS_GETDATATYPE_IMPL
-
+
TFModelEvaluator::EvaluationResult::~EvaluationResult() {}
TFModelEvaluator::~TFModelEvaluator() {}
-
+
void Logger::print(raw_ostream &OS) {
if (RawLogData.empty())
return;
@@ -489,17 +489,17 @@ void Logger::print(raw_ostream &OS) {
size_t RewardSize =
RewardSpec.getElementCount() * RewardSpec.getElementByteSize();
size_t NumberOfRewards = RawLogData.back().size() / RewardSize;
-
+
OS << "feature_lists: {\n";
for (size_t I = 0; I < FeatureSpecs.size(); ++I)
writeRawTensorsAsFeatureLists(OS, FeatureSpecs[I], RawLogData[I].data(),
NumberOfRecords);
-
+
if (IncludeReward)
writeRawTensorsAsFeatureLists(OS, {RewardSpec, None},
RawLogData.back().data(), NumberOfRecords,
NumberOfRewards == 1);
-
+
OS << "}\n";
-}
+}
#endif // defined(LLVM_HAVE_TF_API)
diff --git a/contrib/libs/llvm12/lib/Analysis/ya.make b/contrib/libs/llvm12/lib/Analysis/ya.make
index a14158e86e..6e09c89fe4 100644
--- a/contrib/libs/llvm12/lib/Analysis/ya.make
+++ b/contrib/libs/llvm12/lib/Analysis/ya.make
@@ -2,18 +2,18 @@
LIBRARY()
-OWNER(
- orivej
- g:cpp-contrib
-)
+OWNER(
+ orivej
+ g:cpp-contrib
+)
+
+LICENSE(
+ Apache-2.0 WITH LLVM-exception AND
+ NCSA
+)
+
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-LICENSE(
- Apache-2.0 WITH LLVM-exception AND
- NCSA
-)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
PEERDIR(
contrib/libs/llvm12
contrib/libs/llvm12/include
@@ -24,9 +24,9 @@ PEERDIR(
contrib/libs/llvm12/lib/Support
)
-ADDINCL(
- contrib/libs/llvm12/lib/Analysis
-)
+ADDINCL(
+ contrib/libs/llvm12/lib/Analysis
+)
NO_COMPILER_WARNINGS()