llvm-project/clang/lib/Parse
Kito Cheng 7a5cb15ea6 [RISCV] Lazily add RVV C intrinsics.
Leverage the method OpenCL uses that adds C intrinsics when the lookup
failed. There is no need to define C intrinsics in the header file any
more. It could help to avoid the large header file to speed up the
compilation of RVV source code. Besides that, only the C intrinsics used
by the users will be added into the declaration table.

This patch is based on https://reviews.llvm.org/D103228 and inspired by
OpenCL implementation.

### Experimental Results

#### TL;DR:

- Binary size of clang increase ~200k, which is +0.07%  for debug build and +0.13% for release build.
- Single file compilation speed up ~33x for debug build and ~8.5x for release build
- Regression time reduce ~10% (`ninja check-all`, enable all targets)

#### Header size change
```
       |      size |     LoC |
------------------------------
Before | 4,434,725 |  69,749 |
After  |     6,140 |     162 |
```

#### Single File Compilation Time
Testcase:
```
#include <riscv_vector.h>

vint32m1_t test_vadd_vv_vfloat32m1_t(vint32m1_t op1, vint32m1_t op2, size_t vl) {
  return vadd(op1, op2, vl);
}
```
##### Debug build:
Before:
```
real    0m19.352s
user    0m19.252s
sys     0m0.092s
```

After:
```
real    0m0.576s
user    0m0.552s
sys     0m0.024s
```

~33x speed up for debug build

##### Release build:
Before:
```
real    0m0.773s
user    0m0.741s
sys     0m0.032s
```

After:
```
real    0m0.092s
user    0m0.080s
sys     0m0.012s
```

~8.5x speed up for release build

#### Regression time
Note: the failed case is `tools/llvm-debuginfod-find/debuginfod.test` which is unrelated to this patch.

##### Debug build
Before:
```
Testing Time: 1358.38s
  Skipped          :    11
  Unsupported      :   446
  Passed           : 75767
  Expectedly Failed:   190
  Failed           :     1
```
After
```
Testing Time: 1220.29s
  Skipped          :    11
  Unsupported      :   446
  Passed           : 75767
  Expectedly Failed:   190
  Failed           :     1
```
##### Release build
Before:
```
Testing Time: 381.98s
  Skipped          :    12
  Unsupported      :  1407
  Passed           : 74765
  Expectedly Failed:   176
  Failed           :     1
```
After:
```
Testing Time: 346.25s
  Skipped          :    12
  Unsupported      :  1407
  Passed           : 74765
  Expectedly Failed:   176
  Failed           :     1
```

#### Binary size of clang

##### Debug build
Before
```
   text    data     bss     dec     hex filename
335261851       12726004         552812 348540667       14c64efb        bin/clang
```
After
```
   text    data     bss     dec     hex filename
335442803       12798708         552940 348794451       14ca2e53        bin/clang
```
+253K, +0.07% code size

##### Release build
Before
```
   text    data     bss     dec     hex filename
144123975       8374648  483140 152981763       91e5103 bin/clang
```
After
```
   text    data     bss     dec     hex filename
144255762       8447296  483268 153186326       9217016 bin/clang
```
+204K, +0.13%

Authored-by: Kito Cheng <kito.cheng@sifive.com>
Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com>

Reviewed By: khchen, aaron.ballman

Differential Revision: https://reviews.llvm.org/D111617
2022-07-26 15:47:47 +08:00
..
CMakeLists.txt [HLSL] Add Semantic syntax, and SV_GroupIndex 2022-04-14 10:21:58 -05:00
ParseAST.cpp re-land [C++20][Modules] Build module static initializers per P1874R1. 2022-07-22 08:38:07 +01:00
ParseCXXInlineMethods.cpp [clang][parse] Move source range into ParsedAttibutesView 2022-03-24 08:11:57 +01:00
ParseDecl.cpp [clang] better error message for while loops outside of control flow 2022-07-25 11:48:24 +08:00
ParseDeclCXX.cpp Rewording "static_assert" diagnostics 2022-07-25 07:22:54 -04:00
ParseExpr.cpp [clang] Reject non-declaration C++11 attributes on declarations 2022-06-15 11:58:26 +02:00
ParseExprCXX.cpp [clang][NFC] Remove unused parameter from ActOnCXXNestedNameSpecifier 2022-06-15 16:06:06 +02:00
ParseHLSL.cpp [HLSL] Add Semantic syntax, and SV_GroupIndex 2022-04-14 10:21:58 -05:00
ParseInit.cpp [clang] Use true/false instead of 1/0 (NFC) 2022-01-09 00:19:47 -08:00
ParseObjc.cpp [clang] Reject non-declaration C++11 attributes on declarations 2022-06-15 11:58:26 +02:00
ParseOpenMP.cpp [clang] Use value instead of getValue (NFC) 2022-07-13 23:39:33 -07:00
ParsePragma.cpp [RISCV] Lazily add RVV C intrinsics. 2022-07-26 15:47:47 +08:00
ParseStmt.cpp Stop wrapping GCCAsmStmts inside StmtExprs to destruct temporaries 2022-06-17 17:28:00 -07:00
ParseStmtAsm.cpp [clang] Fix bugprone argument comments (NFC) 2022-01-09 00:19:49 -08:00
ParseTemplate.cpp [Clang] Fix: Restore warning inadvertently removed by D126061. 2022-06-28 08:52:58 +02:00
ParseTentative.cpp [clang][parse] Move source range into ParsedAttibutesView 2022-03-24 08:11:57 +01:00
Parser.cpp Rewording "static_assert" diagnostics 2022-07-25 07:22:54 -04:00