summaryrefslogtreecommitdiff
path: root/0017-Add-the-support-for-classic-flang.patch
blob: 74bcbc85bfc64c610d63cd5afa47bb5235f4816b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
From b297f30783da0dfb3098fe6d39b209caacd45691 Mon Sep 17 00:00:00 2001
From: luofeng14 <luofeng13@huawei.com>
Date: Fri, 1 Mar 2024 18:39:52 +0800
Subject: [PATCH] sync classic flang patch

---
 llvm/cmake/modules/HandleLLVMOptions.cmake    |   8 +
 llvm/include/llvm-c/DebugInfo.h               |   5 +-
 .../include/llvm/Analysis/TargetLibraryInfo.h |   6 +-
 llvm/include/llvm/Analysis/VecFuncs.def       | 592 ++++++++++++++++++
 llvm/include/llvm/IR/DIBuilder.h              |  28 +-
 llvm/include/llvm/IR/DebugInfoMetadata.h      |  32 +-
 llvm/lib/Analysis/TargetLibraryInfo.cpp       |  38 +-
 llvm/lib/AsmParser/LLParser.cpp               |  22 +-
 llvm/lib/Bitcode/Reader/MetadataLoader.cpp    |  42 +-
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp     |   3 +-
 llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h   |  54 ++
 .../lib/CodeGen/AsmPrinter/DebugLocStream.cpp |   5 +
 llvm/lib/CodeGen/AsmPrinter/DebugLocStream.h  |   6 +
 .../CodeGen/AsmPrinter/DwarfCompileUnit.cpp   |   3 +
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h      |   4 +
 llvm/lib/IR/AsmWriter.cpp                     |   1 +
 llvm/lib/IR/DIBuilder.cpp                     |  12 +-
 llvm/lib/IR/DebugInfo.cpp                     |  10 +-
 llvm/lib/IR/DebugInfoMetadata.cpp             |  12 +-
 llvm/lib/IR/LLVMContextImpl.h                 |  11 +-
 .../Instrumentation/InstrProfiling.cpp        |   4 +-
 .../invalid-diglobalvariable-empty-name.ll    |   1 +
 .../Generic/fortran-subprogram-at.ll          |  24 +
 .../DebugInfo/Generic/more-subprogram-attr.ll |  38 ++
 llvm/test/DebugInfo/X86/DICommonBlock.ll      |  36 ++
 llvm/test/lit.cfg.py                          |   3 +
 llvm/test/lit.site.cfg.py.in                  |   1 +
 llvm/tools/llvm-c-test/debuginfo.c            |   4 +-
 llvm/unittests/IR/MetadataTest.cpp            |  47 +-
 llvm/utils/lit/lit/TestingConfig.py           |   1 +
 llvm/utils/lit/lit/llvm/config.py             |  10 +
 31 files changed, 983 insertions(+), 80 deletions(-)
 create mode 100644 llvm/test/DebugInfo/Generic/fortran-subprogram-at.ll
 create mode 100644 llvm/test/DebugInfo/Generic/more-subprogram-attr.ll
 create mode 100644 llvm/test/DebugInfo/X86/DICommonBlock.ll

diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 76723be696e5..492ea25b179b 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -89,6 +89,14 @@ if( LLVM_ENABLE_ASSERTIONS )
   add_compile_definitions(_LIBCPP_ENABLE_HARDENED_MODE)
 endif()
 
+option(LLVM_ENABLE_CLASSIC_FLANG "Build support for classic Flang instead of the new built-in Flang" OFF)
+if(LLVM_ENABLE_CLASSIC_FLANG)
+  set(LLVM_ENABLE_CLASSIC_FLANG 1)
+  add_definitions( -DENABLE_CLASSIC_FLANG )
+else()
+  set(LLVM_ENABLE_CLASSIC_FLANG 0)
+endif()
+
 if(LLVM_ENABLE_EXPENSIVE_CHECKS)
   add_compile_definitions(EXPENSIVE_CHECKS)
 
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 5924294708cc..09d584c24711 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -1148,7 +1148,8 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
     size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
-    LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits);
+    LLVMMetadataRef Expr, LLVMMetadataRef Decl, LLVMDIFlags Flags,
+    uint32_t AlignInBits);
 
 
 /**
@@ -1246,7 +1247,7 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
     size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File,
     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
-    LLVMMetadataRef Decl, uint32_t AlignInBits);
+    LLVMMetadataRef Decl, LLVMDIFlags Flags, uint32_t AlignInBits);
 
 /**
  * Insert a new llvm.dbg.declare intrinsic call before the given instruction.
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index 5d62e837c1f3..490252cd018a 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -22,7 +22,6 @@ namespace llvm {
 template <typename T> class ArrayRef;
 class Function;
 class Module;
-class Triple;
 
 /// Describes a possible vectorization of a function.
 /// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
@@ -81,6 +80,8 @@ class TargetLibraryInfoImpl {
   bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F,
                               const Module &M) const;
 
+  Triple T;
+
 public:
   /// List of known vector-functions libraries.
   ///
@@ -95,6 +96,9 @@ public:
     DarwinLibSystemM, // Use Darwin's libsystem_m.
     LIBMVEC_X86,      // GLIBC Vector Math library.
     MASSV,            // IBM MASS vector library.
+#ifdef ENABLE_CLASSIC_FLANG
+    PGMATH,           // PGI math library.
+#endif
     SVML,             // Intel short vector math library.
     SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions.
     ArmPL        // Arm Performance Libraries.
diff --git a/llvm/include/llvm/Analysis/VecFuncs.def b/llvm/include/llvm/Analysis/VecFuncs.def
index b884c1e3911e..d1712d158423 100644
--- a/llvm/include/llvm/Analysis/VecFuncs.def
+++ b/llvm/include/llvm/Analysis/VecFuncs.def
@@ -909,6 +909,596 @@ TLI_DEFINE_VECFUNC("tgammaf", "armpl_vtgammaq_f32", FIXED(4), NOMASK)
 TLI_DEFINE_VECFUNC("tgamma", "armpl_svtgamma_f64_x",  SCALABLE(2), MASKED)
 TLI_DEFINE_VECFUNC("tgammaf", "armpl_svtgamma_f32_x", SCALABLE(4), MASKED)
 
+#elif defined(TLI_DEFINE_PGMATH_AARCH64_VECFUNCS)
+// Classic flang libpgmath library's Vector Functions for AArch64
+
+TLI_DEFINE_VECFUNC("__fd_sin_1", "__fd_sin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_sin_1", "__fs_sin_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_sin_1", "__pd_sin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_sin_1", "__ps_sin_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_sin_1", "__rd_sin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_sin_1", "__rs_sin_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_cos_1", "__fd_cos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_cos_1", "__fs_cos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_cos_1", "__pd_cos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_cos_1", "__ps_cos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_cos_1", "__rd_cos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_sincos_1", "__fd_sincos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_sincos_1", "__fs_sincos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_sincos_1", "__pd_sincos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_sincos_1", "__ps_sincos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_sincos_1", "__rd_sincos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_sincos_1", "__rs_sincos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_tan_1", "__fs_tan_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_tan_1", "__pd_tan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_tan_1", "__ps_tan_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_tan_1", "__rd_tan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_tan_1", "__rs_tan_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_sinh_1", "__fd_sinh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_sinh_1", "__fs_sinh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_sinh_1", "__pd_sinh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_sinh_1", "__ps_sinh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_sinh_1", "__rd_sinh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_sinh_1", "__rs_sinh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_cosh_1", "__fd_cosh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_cosh_1", "__fs_cosh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_cosh_1", "__pd_cosh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_cosh_1", "__ps_cosh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_cosh_1", "__rd_cosh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_cosh_1", "__rs_cosh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_tanh_1", "__fd_tanh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_tanh_1", "__fs_tanh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_tanh_1", "__pd_tanh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_tanh_1", "__ps_tanh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_tanh_1", "__rd_tanh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_tanh_1", "__rs_tanh_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_asin_1", "__fd_asin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_asin_1", "__fs_asin_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_asin_1", "__pd_asin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_asin_1", "__ps_asin_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_asin_1", "__rd_asin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_asin_1", "__rs_asin_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_acos_1", "__fd_acos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_acos_1", "__fs_acos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_acos_1", "__pd_acos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_acos_1", "__ps_acos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_acos_1", "__rd_acos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_acos_1", "__rs_acos_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_atan_1", "__fd_atan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_atan_1", "__fs_atan_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_atan_1", "__pd_atan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_atan_1", "__ps_atan_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_atan_1", "__rd_atan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_atan_1", "__rs_atan_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_atan2_1", "__fd_atan2_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_atan2_1", "__fs_atan2_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_atan2_1", "__pd_atan2_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_atan2_1", "__ps_atan2_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_atan2_1", "__rd_atan2_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_atan2_1", "__rs_atan2_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_pow_1", "__fd_pow_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_pow_1", "__fs_pow_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_pow_1", "__pd_pow_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_pow_1", "__ps_pow_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_pow_1", "__rd_pow_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_pow_1", "__rs_pow_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fs_powi_1", "__fs_powi_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__ps_powi_1", "__ps_powi_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rs_powi_1", "__rs_powi_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_powi1_1", "__fd_powi1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_powi1_1", "__fs_powi1_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_powi1_1", "__pd_powi1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_powi1_1", "__ps_powi1_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_powi1_1", "__rd_powi1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_powi1_1", "__rs_powi1_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_powk_1", "__fd_powk_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_powk_1", "__fs_powk_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_powk_1", "__pd_powk_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_powk_1", "__ps_powk_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_powk_1", "__rd_powk_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_powk_1", "__rs_powk_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_powk1_1", "__fd_powk1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_powk1_1", "__fs_powk1_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_powk1_1", "__pd_powk1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_powk1_1", "__ps_powk1_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_powk1_1", "__rd_powk1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_powk1_1", "__rs_powk1_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_log10_1", "__fd_log10_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_log10_1", "__fs_log10_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_log10_1", "__pd_log10_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_log10_1", "__ps_log10_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_log10_1", "__rd_log10_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_log10_1", "__rs_log10_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_log_1", "__fd_log_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_log_1", "__fs_log_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_log_1", "__pd_log_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_log_1", "__ps_log_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_log_1", "__rd_log_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_log_1", "__rs_log_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__fd_exp_1", "__fd_exp_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fs_exp_1", "__fs_exp_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__pd_exp_1", "__pd_exp_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__ps_exp_1", "__ps_exp_4", FIXED(4))
+
+TLI_DEFINE_VECFUNC("__rd_exp_1", "__rd_exp_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_4", FIXED(4))
+
+#elif defined(TLI_DEFINE_PGMATH_X86_VECFUNCS)
+// Classic flang libpgmath library's Vector Functions for X86
+
+TLI_DEFINE_VECFUNC("__fd_sin_1", "__fd_sin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_sin_1", "__fd_sin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_sin_1", "__fd_sin_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_sin_1", "__fs_sin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_sin_1", "__fs_sin_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_sin_1", "__fs_sin_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_sin_1", "__pd_sin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_sin_1", "__pd_sin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_sin_1", "__pd_sin_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_sin_1", "__ps_sin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_sin_1", "__ps_sin_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_sin_1", "__ps_sin_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_sin_1", "__rd_sin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_sin_1", "__rd_sin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_sin_1", "__rd_sin_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_sin_1", "__rs_sin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_sin_1", "__rs_sin_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_sin_1", "__rs_sin_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_cos_1", "__fd_cos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_cos_1", "__fd_cos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_cos_1", "__fd_cos_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_cos_1", "__fs_cos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_cos_1", "__fs_cos_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_cos_1", "__fs_cos_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_cos_1", "__pd_cos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_cos_1", "__pd_cos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_cos_1", "__pd_cos_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_cos_1", "__ps_cos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_cos_1", "__ps_cos_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_cos_1", "__ps_cos_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_cos_1", "__rd_cos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_cos_1", "__rd_cos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_cos_1", "__rd_cos_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_tan_1", "__fs_tan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_tan_1", "__fs_tan_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_tan_1", "__fs_tan_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_tan_1", "__pd_tan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_tan_1", "__pd_tan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_tan_1", "__pd_tan_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_tan_1", "__ps_tan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_tan_1", "__ps_tan_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_tan_1", "__ps_tan_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_tan_1", "__rd_tan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_tan_1", "__rd_tan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_tan_1", "__rd_tan_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_tan_1", "__rs_tan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_tan_1", "__rs_tan_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_tan_1", "__rs_tan_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_sinh_1", "__fd_sinh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_sinh_1", "__fd_sinh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_sinh_1", "__fd_sinh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_sinh_1", "__fs_sinh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_sinh_1", "__fs_sinh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_sinh_1", "__fs_sinh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_sinh_1", "__pd_sinh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_sinh_1", "__pd_sinh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_sinh_1", "__pd_sinh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_sinh_1", "__ps_sinh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_sinh_1", "__ps_sinh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_sinh_1", "__ps_sinh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_sinh_1", "__rd_sinh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_sinh_1", "__rd_sinh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_sinh_1", "__rd_sinh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_sinh_1", "__rs_sinh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_sinh_1", "__rs_sinh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_sinh_1", "__rs_sinh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_cosh_1", "__fd_cosh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_cosh_1", "__fd_cosh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_cosh_1", "__fd_cosh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_cosh_1", "__fs_cosh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_cosh_1", "__fs_cosh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_cosh_1", "__fs_cosh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_cosh_1", "__pd_cosh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_cosh_1", "__pd_cosh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_cosh_1", "__pd_cosh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_cosh_1", "__ps_cosh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_cosh_1", "__ps_cosh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_cosh_1", "__ps_cosh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_cosh_1", "__rd_cosh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_cosh_1", "__rd_cosh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_cosh_1", "__rd_cosh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_cosh_1", "__rs_cosh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_cosh_1", "__rs_cosh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_cosh_1", "__rs_cosh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_tanh_1", "__fd_tanh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_tanh_1", "__fd_tanh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_tanh_1", "__fd_tanh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_tanh_1", "__fs_tanh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_tanh_1", "__fs_tanh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_tanh_1", "__fs_tanh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_tanh_1", "__pd_tanh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_tanh_1", "__pd_tanh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_tanh_1", "__pd_tanh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_tanh_1", "__ps_tanh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_tanh_1", "__ps_tanh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_tanh_1", "__ps_tanh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_tanh_1", "__rd_tanh_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_tanh_1", "__rd_tanh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_tanh_1", "__rd_tanh_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_tanh_1", "__rs_tanh_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_tanh_1", "__rs_tanh_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_tanh_1", "__rs_tanh_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_asin_1", "__fd_asin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_asin_1", "__fd_asin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_asin_1", "__fd_asin_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_asin_1", "__fs_asin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_asin_1", "__fs_asin_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_asin_1", "__fs_asin_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_asin_1", "__pd_asin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_asin_1", "__pd_asin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_asin_1", "__pd_asin_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_asin_1", "__ps_asin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_asin_1", "__ps_asin_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_asin_1", "__ps_asin_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_asin_1", "__rd_asin_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_asin_1", "__rd_asin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_asin_1", "__rd_asin_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_asin_1", "__rs_asin_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_asin_1", "__rs_asin_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_asin_1", "__rs_asin_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_acos_1", "__fd_acos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_acos_1", "__fd_acos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_acos_1", "__fd_acos_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_acos_1", "__fs_acos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_acos_1", "__fs_acos_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_acos_1", "__fs_acos_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_acos_1", "__pd_acos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_acos_1", "__pd_acos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_acos_1", "__pd_acos_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_acos_1", "__ps_acos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_acos_1", "__ps_acos_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_acos_1", "__ps_acos_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_acos_1", "__rd_acos_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_acos_1", "__rd_acos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_acos_1", "__rd_acos_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_acos_1", "__rs_acos_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_acos_1", "__rs_acos_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_acos_1", "__rs_acos_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_atan_1", "__fd_atan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_atan_1", "__fd_atan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_atan_1", "__fd_atan_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_atan_1", "__fs_atan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_atan_1", "__fs_atan_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_atan_1", "__fs_atan_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_atan_1", "__pd_atan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_atan_1", "__pd_atan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_atan_1", "__pd_atan_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_atan_1", "__ps_atan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_atan_1", "__ps_atan_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_atan_1", "__ps_atan_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_atan_1", "__rd_atan_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_atan_1", "__rd_atan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_atan_1", "__rd_atan_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_atan_1", "__rs_atan_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_atan_1", "__rs_atan_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_atan_1", "__rs_atan_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_atan2_1", "__fd_atan2_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_atan2_1", "__fd_atan2_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_atan2_1", "__fd_atan2_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_atan2_1", "__fs_atan2_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_atan2_1", "__fs_atan2_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_atan2_1", "__fs_atan2_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_atan2_1", "__pd_atan2_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_atan2_1", "__pd_atan2_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_atan2_1", "__pd_atan2_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_atan2_1", "__ps_atan2_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_atan2_1", "__ps_atan2_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_atan2_1", "__ps_atan2_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_atan2_1", "__rd_atan2_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_atan2_1", "__rd_atan2_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_atan2_1", "__rd_atan2_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_atan2_1", "__rs_atan2_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_atan2_1", "__rs_atan2_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_atan2_1", "__rs_atan2_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_pow_1", "__fd_pow_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_pow_1", "__fd_pow_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_pow_1", "__fd_pow_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_pow_1", "__fs_pow_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_pow_1", "__fs_pow_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_pow_1", "__fs_pow_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_pow_1", "__pd_pow_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_pow_1", "__pd_pow_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_pow_1", "__pd_pow_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_pow_1", "__ps_pow_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_pow_1", "__ps_pow_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_pow_1", "__ps_pow_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_pow_1", "__rd_pow_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_pow_1", "__rd_pow_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_pow_1", "__rd_pow_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_pow_1", "__rs_pow_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_pow_1", "__rs_pow_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_pow_1", "__rs_pow_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fs_powi_1", "__fs_powi_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_powi_1", "__fs_powi_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_powi_1", "__fs_powi_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__ps_powi_1", "__ps_powi_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_powi_1", "__ps_powi_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_powi_1", "__ps_powi_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rs_powi_1", "__rs_powi_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_powi_1", "__rs_powi_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_powi_1", "__rs_powi_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_powi1_1", "__fd_powi1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_powi1_1", "__fd_powi1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_powi1_1", "__fd_powi1_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_powi1_1", "__fs_powi1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_powi1_1", "__fs_powi1_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_powi1_1", "__fs_powi1_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_powi1_1", "__pd_powi1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_powi1_1", "__pd_powi1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_powi1_1", "__pd_powi1_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_powi1_1", "__ps_powi1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_powi1_1", "__ps_powi1_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_powi1_1", "__ps_powi1_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_powi1_1", "__rd_powi1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_powi1_1", "__rd_powi1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_powi1_1", "__rd_powi1_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_powi1_1", "__rs_powi1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_powi1_1", "__rs_powi1_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_powi1_1", "__rs_powi1_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_powk_1", "__fd_powk_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_powk_1", "__fd_powk_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_powk_1", "__fd_powk_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_powk_1", "__fs_powk_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_powk_1", "__fs_powk_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_powk_1", "__fs_powk_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_powk_1", "__pd_powk_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_powk_1", "__pd_powk_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_powk_1", "__pd_powk_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_powk_1", "__ps_powk_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_powk_1", "__ps_powk_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_powk_1", "__ps_powk_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_powk_1", "__rd_powk_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_powk_1", "__rd_powk_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_powk_1", "__rd_powk_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_powk_1", "__rs_powk_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_powk_1", "__rs_powk_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_powk_1", "__rs_powk_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_powk1_1", "__fd_powk1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_powk1_1", "__fd_powk1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_powk1_1", "__fd_powk1_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_powk1_1", "__fs_powk1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_powk1_1", "__fs_powk1_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_powk1_1", "__fs_powk1_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_powk1_1", "__pd_powk1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_powk1_1", "__pd_powk1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_powk1_1", "__pd_powk1_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_powk1_1", "__ps_powk1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_powk1_1", "__ps_powk1_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_powk1_1", "__ps_powk1_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_powk1_1", "__rd_powk1_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_powk1_1", "__rd_powk1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_powk1_1", "__rd_powk1_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_powk1_1", "__rs_powk1_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_powk1_1", "__rs_powk1_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_powk1_1", "__rs_powk1_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_log10_1", "__fd_log10_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_log10_1", "__fd_log10_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_log10_1", "__fd_log10_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_log10_1", "__fs_log10_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_log10_1", "__fs_log10_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_log10_1", "__fs_log10_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_log10_1", "__pd_log10_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_log10_1", "__pd_log10_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_log10_1", "__pd_log10_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_log10_1", "__ps_log10_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_log10_1", "__ps_log10_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_log10_1", "__ps_log10_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_log10_1", "__rd_log10_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_log10_1", "__rd_log10_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_log10_1", "__rd_log10_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_log10_1", "__rs_log10_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_log10_1", "__rs_log10_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_log10_1", "__rs_log10_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fd_log_1", "__fd_log_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__fd_log_1", "__fd_log_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fd_log_1", "__fd_log_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__fs_log_1", "__fs_log_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_log_1", "__fs_log_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_log_1", "__fs_log_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_log_1", "__pd_log_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_log_1", "__pd_log_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_log_1", "__pd_log_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_log_1", "__ps_log_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_log_1", "__ps_log_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_log_1", "__ps_log_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_log_1", "__rd_log_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_log_1", "__rd_log_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_log_1", "__rd_log_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_log_1", "__rs_log_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_log_1", "__rs_log_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_log_1", "__rs_log_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__fs_exp_1", "__fs_exp_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__fs_exp_1", "__fs_exp_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__fs_exp_1", "__fs_exp_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__pd_exp_1", "__pd_exp_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pd_exp_1", "__pd_exp_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pd_exp_1", "__pd_exp_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__ps_exp_1", "__ps_exp_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__ps_exp_1", "__ps_exp_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__ps_exp_1", "__ps_exp_16", FIXED(16))
+
+TLI_DEFINE_VECFUNC("__rd_exp_1", "__rd_exp_2", FIXED(2))
+TLI_DEFINE_VECFUNC("__rd_exp_1", "__rd_exp_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rd_exp_1", "__rd_exp_8", FIXED(8))
+
+TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_4", FIXED(4))
+TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_8", FIXED(8))
+TLI_DEFINE_VECFUNC("__rs_exp_1", "__rs_exp_16", FIXED(16))
+
 #else
 #error "Must choose which vector library functions are to be defined."
 #endif
@@ -929,3 +1519,5 @@ TLI_DEFINE_VECFUNC("tgammaf", "armpl_svtgamma_f32_x", SCALABLE(4), MASKED)
 #undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
 #undef TLI_DEFINE_MASSV_VECFUNCS_NAMES
 #undef TLI_DEFINE_ARMPL_VECFUNCS
+#undef TLI_DEFINE_PGMATH_AARCH64_VECFUNCS
+#undef TLI_DEFINE_PGMATH_X86_VECFUNCS
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index ecd6dd7b0a4f..e0e64c662f18 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -681,15 +681,22 @@ namespace llvm {
         DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
         unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined = true,
         DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
-        MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0,
-        DINodeArray Annotations = nullptr);
+        MDTuple *TemplateParams = nullptr,
+#ifdef ENABLE_CLASSIC_FLANG
+        DINode::DIFlags Flags = DINode::FlagZero,
+#endif
+        uint32_t AlignInBits = 0, DINodeArray Annotations = nullptr);
 
     /// Identical to createGlobalVariable
     /// except that the resulting DbgNode is temporary and meant to be RAUWed.
     DIGlobalVariable *createTempGlobalVariableFwdDecl(
         DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
-        unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl = nullptr,
-        MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0);
+        unsigned LineNo, DIType *Ty, bool isLocalToUnit, MDNode *Decl = nullptr,
+        MDTuple *TemplateParams = nullptr,
+#ifdef ENABLE_CLASSIC_FLANG
+        DINode::DIFlags Flags = DINode::FlagZero,
+#endif
+        uint32_t AlignInBits = 0);
 
     /// Create a new descriptor for an auto variable.  This is a local variable
     /// that is not a subprogram parameter.
@@ -820,6 +827,19 @@ namespace llvm {
                                      StringRef Name, DIFile *File,
                                      unsigned LineNo);
 
+#ifdef ENABLE_CLASSIC_FLANG
+    /// Create common block entry for a Fortran common block
+    /// \param Scope       Scope of this common block
+    /// \param Name        The name of this common block
+    /// \param File        The file this common block is defined
+    /// \param LineNo      Line number
+    /// \param VarList     List of variables that a located in common block
+    /// \param AlignInBits Common block alignment
+    DICommonBlock *createCommonBlock(DIScope *Scope, DIGlobalVariable *decl,
+                                     StringRef Name, DIFile *File,
+                                     unsigned LineNo, uint32_t AlignInBits = 0);
+
+#endif
     /// This creates new descriptor for a namespace with the specified
     /// parent scope.
     /// \param Scope       Namespace scope
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 656122405209..9bd86172a4c0 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -3062,12 +3062,14 @@ class DIGlobalVariable : public DIVariable {
 
   bool IsLocalToUnit;
   bool IsDefinition;
+  DIFlags Flags;
 
   DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
-                   bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
-                   ArrayRef<Metadata *> Ops)
+                   bool IsLocalToUnit, bool IsDefinition, DIFlags Flags,
+                   uint32_t AlignInBits, ArrayRef<Metadata *> Ops)
       : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
-        IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
+        IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition),
+        Flags(Flags) {}
   ~DIGlobalVariable() = default;
 
   static DIGlobalVariable *
@@ -3075,12 +3077,12 @@ class DIGlobalVariable : public DIVariable {
           StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
           bool IsLocalToUnit, bool IsDefinition,
           DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
-          uint32_t AlignInBits, DINodeArray Annotations, StorageType Storage,
-          bool ShouldCreate = true) {
+          DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations,
+          StorageType Storage, bool ShouldCreate = true) {
     return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
                    getCanonicalMDString(Context, LinkageName), File, Line, Type,
                    IsLocalToUnit, IsDefinition, StaticDataMemberDeclaration,
-                   cast_or_null<Metadata>(TemplateParams), AlignInBits,
+                   cast_or_null<Metadata>(TemplateParams), Flags, AlignInBits,
                    Annotations.get(), Storage, ShouldCreate);
   }
   static DIGlobalVariable *
@@ -3088,14 +3090,14 @@ class DIGlobalVariable : public DIVariable {
           MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
           bool IsLocalToUnit, bool IsDefinition,
           Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
-          uint32_t AlignInBits, Metadata *Annotations, StorageType Storage,
-          bool ShouldCreate = true);
+          DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations,
+          StorageType Storage, bool ShouldCreate = true);
 
   TempDIGlobalVariable cloneImpl() const {
     return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
                         getFile(), getLine(), getType(), isLocalToUnit(),
                         isDefinition(), getStaticDataMemberDeclaration(),
-                        getTemplateParams(), getAlignInBits(),
+                        getTemplateParams(), getFlags(), getAlignInBits(),
                         getAnnotations());
   }
 
@@ -3105,22 +3107,26 @@ public:
       (DIScope * Scope, StringRef Name, StringRef LinkageName, DIFile *File,
        unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition,
        DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
-       uint32_t AlignInBits, DINodeArray Annotations),
+       DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations),
       (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
-       StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations))
+       StaticDataMemberDeclaration, TemplateParams, Flags, AlignInBits,
+       Annotations))
   DEFINE_MDNODE_GET(
       DIGlobalVariable,
       (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
        unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
        Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
-       uint32_t AlignInBits, Metadata *Annotations),
+       DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations),
       (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
-       StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations))
+       StaticDataMemberDeclaration, TemplateParams, Flags, AlignInBits,
+       Annotations))
 
   TempDIGlobalVariable clone() const { return cloneImpl(); }
 
   bool isLocalToUnit() const { return IsLocalToUnit; }
   bool isDefinition() const { return IsDefinition; }
+  DIFlags getFlags() const { return Flags; }
+  bool isArtificial() const { return getFlags() & FlagArtificial; }
   StringRef getDisplayName() const { return getStringOperand(4); }
   StringRef getLinkageName() const { return getStringOperand(5); }
   DIDerivedType *getStaticDataMemberDeclaration() const {
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 05fa67d0bbf1..a6593f6b3757 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -30,6 +30,10 @@ static cl::opt<TargetLibraryInfoImpl::VectorLibrary> ClVectorLibrary(
                           "GLIBC Vector Math library"),
                clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV",
                           "IBM MASS vector library"),
+#ifdef ENABLE_CLASSIC_FLANG
+               clEnumValN(TargetLibraryInfoImpl::PGMATH, "PGMATH",
+                          "PGI math library"),
+#endif
                clEnumValN(TargetLibraryInfoImpl::SVML, "SVML",
                           "Intel SVML library"),
                clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi",
@@ -867,14 +871,14 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
   TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary, T);
 }
 
-TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
+TargetLibraryInfoImpl::TargetLibraryInfoImpl() : T(Triple()) {
   // Default to everything being available.
   memset(AvailableArray, -1, sizeof(AvailableArray));
 
-  initialize(*this, Triple(), StandardNames);
+  initialize(*this, T, StandardNames);
 }
 
-TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
+TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) : T(T) {
   // Default to everything being available.
   memset(AvailableArray, -1, sizeof(AvailableArray));
 
@@ -886,7 +890,7 @@ TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
       ShouldExtI32Return(TLI.ShouldExtI32Return),
       ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
       ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
-      SizeOfInt(TLI.SizeOfInt) {
+      SizeOfInt(TLI.SizeOfInt), T(TLI.T) {
   memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
   VectorDescs = TLI.VectorDescs;
   ScalarDescs = TLI.ScalarDescs;
@@ -898,7 +902,7 @@ TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
       ShouldExtI32Return(TLI.ShouldExtI32Return),
       ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
       ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),
-      SizeOfInt(TLI.SizeOfInt) {
+      SizeOfInt(TLI.SizeOfInt), T(TLI.T) {
   std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
             AvailableArray);
   VectorDescs = TLI.VectorDescs;
@@ -912,6 +916,7 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoI
   ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
   ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
   SizeOfInt = TLI.SizeOfInt;
+  T = TLI.T;
   memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
   return *this;
 }
@@ -923,6 +928,7 @@ TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&
   ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
   ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;
   SizeOfInt = TLI.SizeOfInt;
+  T = TLI.T;
   std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
             AvailableArray);
   return *this;
@@ -1234,6 +1240,28 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
     }
     break;
   }
+#ifdef ENABLE_CLASSIC_FLANG
+  // NOTE: All routines listed here are not available on all the architectures.
+  // Based on the size of vector registers available and the size of data, the
+  // vector width should be chosen correctly.
+  case PGMATH: {
+    if (T.getArch() == Triple::aarch64) {
+      const VecDesc VecFuncs[] = {
+      #define TLI_DEFINE_PGMATH_AARCH64_VECFUNCS
+      #include "llvm/Analysis/VecFuncs.def"
+      };
+      addVectorizableFunctions(VecFuncs);
+    } else if (T.getArch() == Triple::x86_64) {
+      const VecDesc VecFuncs[] = {
+      #define TLI_DEFINE_PGMATH_X86_VECFUNCS
+      #include "llvm/Analysis/VecFuncs.def"
+      };
+      addVectorizableFunctions(VecFuncs);
+    }
+    break;
+  }
+#endif
+
   case NoLibrary:
     break;
   }
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 5f0d1a76de79..d7eb34e3d148 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -5405,6 +5405,22 @@ bool LLParser::parseDITemplateValueParameter(MDNode *&Result, bool IsDistinct) {
 ///                         isDefinition: true, templateParams: !3,
 ///                         declaration: !4, align: 8)
 bool LLParser::parseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
+#ifdef ENABLE_CLASSIC_FLANG
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \
+  OPTIONAL(name, MDStringField, (/* AllowEmpty */ true));                      \
+  OPTIONAL(scope, MDField, );                                                  \
+  OPTIONAL(linkageName, MDStringField, );                                      \
+  OPTIONAL(file, MDField, );                                                   \
+  OPTIONAL(line, LineField, );                                                 \
+  OPTIONAL(type, MDField, );                                                   \
+  OPTIONAL(isLocal, MDBoolField, );                                            \
+  OPTIONAL(isDefinition, MDBoolField, (true));                                 \
+  OPTIONAL(templateParams, MDField, );                                         \
+  OPTIONAL(declaration, MDField, );                                            \
+  OPTIONAL(flags, DIFlagField, );                                              \
+  OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \
+  OPTIONAL(annotations, MDField, );
+#else
 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED)                                    \
   OPTIONAL(name, MDStringField, (/* AllowEmpty */ false));                     \
   OPTIONAL(scope, MDField, );                                                  \
@@ -5416,8 +5432,10 @@ bool LLParser::parseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
   OPTIONAL(isDefinition, MDBoolField, (true));                                 \
   OPTIONAL(templateParams, MDField, );                                         \
   OPTIONAL(declaration, MDField, );                                            \
+  OPTIONAL(flags, DIFlagField, );                                              \
   OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));                           \
   OPTIONAL(annotations, MDField, );
+#endif
   PARSE_MD_FIELDS();
 #undef VISIT_MD_FIELDS
 
@@ -5425,8 +5443,8 @@ bool LLParser::parseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
       GET_OR_DISTINCT(DIGlobalVariable,
                       (Context, scope.Val, name.Val, linkageName.Val, file.Val,
                        line.Val, type.Val, isLocal.Val, isDefinition.Val,
-                       declaration.Val, templateParams.Val, align.Val,
-                       annotations.Val));
+                       declaration.Val, templateParams.Val, flags.Val,
+                       align.Val, annotations.Val));
   return false;
 }
 
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 0a9a80688a41..c21e5e5dba97 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1979,25 +1979,43 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
     break;
   }
   case bitc::METADATA_GLOBAL_VAR: {
-    if (Record.size() < 11 || Record.size() > 13)
+    if (Record.size() < 11 || Record.size() > 14)
       return error("Invalid record");
 
     IsDistinct = Record[0] & 1;
     unsigned Version = Record[0] >> 1;
 
-    if (Version == 2) {
+    if (Version == 3) {
+      // Add support for DIFlags
+      Metadata *Annotations = nullptr;
+      if (Record.size() > 13)
+        Annotations = getMDOrNull(Record[13]);
+
+      MetadataList.assignValue(
+          GET_OR_DISTINCT(
+              DIGlobalVariable,
+              (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
+               getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
+               getDITypeRefOrNull(Record[6]), Record[7], Record[8],
+               getMDOrNull(Record[9]), getMDOrNull(Record[10]),
+               static_cast<DINode::DIFlags>(Record[11]), Record[12],
+               Annotations)),
+          NextMetadataNo);
+
+      NextMetadataNo++;
+    } else if (Version == 2) {
       Metadata *Annotations = nullptr;
       if (Record.size() > 12)
         Annotations = getMDOrNull(Record[12]);
 
       MetadataList.assignValue(
-          GET_OR_DISTINCT(DIGlobalVariable,
-                          (Context, getMDOrNull(Record[1]),
-                           getMDString(Record[2]), getMDString(Record[3]),
-                           getMDOrNull(Record[4]), Record[5],
-                           getDITypeRefOrNull(Record[6]), Record[7], Record[8],
-                           getMDOrNull(Record[9]), getMDOrNull(Record[10]),
-                           Record[11], Annotations)),
+          GET_OR_DISTINCT(
+              DIGlobalVariable,
+              (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
+               getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
+               getDITypeRefOrNull(Record[6]), Record[7], Record[8],
+               getMDOrNull(Record[9]), getMDOrNull(Record[10]),
+               DINode::FlagZero, Record[11], Annotations)),
           NextMetadataNo);
 
       NextMetadataNo++;
@@ -2010,7 +2028,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
               (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
                getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
                getDITypeRefOrNull(Record[6]), Record[7], Record[8],
-               getMDOrNull(Record[10]), nullptr, Record[11], nullptr)),
+               getMDOrNull(Record[10]), nullptr, DINode::FlagZero, Record[11],
+               nullptr)),
           NextMetadataNo);
 
       NextMetadataNo++;
@@ -2043,7 +2062,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
           (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
            getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
            getDITypeRefOrNull(Record[6]), Record[7], Record[8],
-           getMDOrNull(Record[10]), nullptr, AlignInBits, nullptr));
+           getMDOrNull(Record[10]), nullptr, DINode::FlagZero, AlignInBits,
+           nullptr));
 
       DIGlobalVariableExpression *DGVE = nullptr;
       if (Attach || Expr)
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 9416c7f5a03e..013e7ce2d425 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2014,7 +2014,7 @@ void ModuleBitcodeWriter::writeDITemplateValueParameter(
 void ModuleBitcodeWriter::writeDIGlobalVariable(
     const DIGlobalVariable *N, SmallVectorImpl<uint64_t> &Record,
     unsigned Abbrev) {
-  const uint64_t Version = 2 << 1;
+  const uint64_t Version = 3 << 1;
   Record.push_back((uint64_t)N->isDistinct() | Version);
   Record.push_back(VE.getMetadataOrNullID(N->getScope()));
   Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
@@ -2026,6 +2026,7 @@ void ModuleBitcodeWriter::writeDIGlobalVariable(
   Record.push_back(N->isDefinition());
   Record.push_back(VE.getMetadataOrNullID(N->getStaticDataMemberDeclaration()));
   Record.push_back(VE.getMetadataOrNullID(N->getTemplateParams()));
+  Record.push_back(N->getFlags());
   Record.push_back(N->getAlignInBits());
   Record.push_back(VE.getMetadataOrNullID(N->getAnnotations().get()));
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
index 726aba18bb80..ee8be3921ab7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -115,6 +115,29 @@ class DbgValueLoc {
   SmallVector<DbgValueLocEntry, 2> ValueLocEntries;
 
   bool IsVariadic;
+  /// Type of entry that this represents.
+  enum EntryType {
+    E_Location,
+    E_Integer,
+    E_ConstantFP,
+    E_ConstantInt,
+    E_TargetIndexLocation
+  };
+  enum EntryType EntryKind;
+
+  /// Either a constant,
+  union {
+    int64_t Int;
+    const ConstantFP *CFP;
+    const ConstantInt *CIP;
+  } Constant;
+
+  union {
+    /// Or a location in the machine frame.
+    MachineLocation Loc;
+    /// Or a location from target specific location.
+    TargetIndexLocation TIL;
+  };
 
 public:
   DbgValueLoc(const DIExpression *Expr, ArrayRef<DbgValueLocEntry> Locs)
@@ -139,6 +162,37 @@ public:
     assert(((Expr && Expr->isValid()) || !Loc.isLocation()) &&
            "DBG_VALUE with a machine location must have a valid expression.");
   }
+  DbgValueLoc(const DIExpression *Expr, int64_t i)
+      : Expression(Expr), EntryKind(E_Integer) {
+    Constant.Int = i;
+  }
+  DbgValueLoc(const DIExpression *Expr, const ConstantFP *CFP)
+      : Expression(Expr), EntryKind(E_ConstantFP) {
+    Constant.CFP = CFP;
+  }
+  DbgValueLoc(const DIExpression *Expr, const ConstantInt *CIP)
+      : Expression(Expr), EntryKind(E_ConstantInt) {
+    Constant.CIP = CIP;
+  }
+  DbgValueLoc(const DIExpression *Expr, MachineLocation Loc)
+      : Expression(Expr), EntryKind(E_Location), Loc(Loc) {
+    assert(cast<DIExpression>(Expr)->isValid());
+  }
+  DbgValueLoc(const DIExpression *Expr, TargetIndexLocation Loc)
+      : Expression(Expr), EntryKind(E_TargetIndexLocation), TIL(Loc) {}
+
+  bool isLocation() const { return EntryKind == E_Location; }
+  bool isTargetIndexLocation() const {
+    return EntryKind == E_TargetIndexLocation;
+  }
+  bool isInt() const { return EntryKind == E_Integer; }
+  bool isConstantFP() const { return EntryKind == E_ConstantFP; }
+  bool isConstantInt() const { return EntryKind == E_ConstantInt; }
+  int64_t getInt() const { return Constant.Int; }
+  const ConstantFP *getConstantFP() const { return Constant.CFP; }
+  const ConstantInt *getConstantInt() const { return Constant.CIP; }
+  MachineLocation getLoc() const { return Loc; }
+  TargetIndexLocation getTargetIndexLocation() const { return TIL; }
 
   bool isFragment() const { return getExpression()->isFragment(); }
   bool isEntryVal() const { return getExpression()->isEntryValue(); }
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
index 8c6109880afc..fbfcf65a34ec 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
@@ -38,6 +38,11 @@ void DebugLocStream::finalizeEntry() {
 }
 
 DebugLocStream::ListBuilder::~ListBuilder() {
+#ifdef ENABLE_CLASSIC_FLANG
+  if (Finalized)
+    return;
+  Finalized = true;
+#endif
   if (!Locs.finalizeList(Asm))
     return;
   V.initializeDbgValue(&MI);
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.h
index a96bdd034918..0600f4f09d5e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.h
@@ -158,12 +158,18 @@ class DebugLocStream::ListBuilder {
   DbgVariable &V;
   const MachineInstr &MI;
   size_t ListIndex;
+#ifdef ENABLE_CLASSIC_FLANG
+  bool Finalized;
+#endif
   std::optional<uint8_t> TagOffset;
 
 public:
   ListBuilder(DebugLocStream &Locs, DwarfCompileUnit &CU, AsmPrinter &Asm,
               DbgVariable &V, const MachineInstr &MI)
       : Locs(Locs), Asm(Asm), V(V), MI(MI), ListIndex(Locs.startList(&CU)),
+#ifdef ENABLE_CLASSIC_FLANG
+        Finalized(false),
+#endif
         TagOffset(std::nullopt) {}
 
   void setTagOffset(uint8_t TO) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 58ed21379d29..78ff0d351492 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -185,6 +185,9 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
   else
     addGlobalName(GV->getName(), *VariableDIE, DeclContext);
 
+  if (GV->isArtificial())
+    addFlag(*VariableDIE, dwarf::DW_AT_artificial);
+
   addAnnotation(*VariableDIE, GV->getAnnotations());
 
   if (uint32_t AlignInBytes = GV->getAlignInBytes())
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 1af4b643eb17..e526614792c7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -284,6 +284,8 @@ struct SymbolCU {
   DwarfCompileUnit *CU;
 };
 
+class DummyDwarfExpression;
+
 /// The kind of accelerator tables we should emit.
 enum class AccelTableKind {
   Default, ///< Platform default.
@@ -437,6 +439,8 @@ private:
   /// Map for tracking Fortran deferred CHARACTER lengths.
   DenseMap<const DIStringType *, unsigned> StringTypeLocMap;
 
+  DenseMap<const DIVariable*,const DIType*> VariableInDependentType;
+
   AddressPool AddrPool;
 
   /// Accelerator tables.
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index be4a3ed79d88..c47dd4664ea6 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2281,6 +2281,7 @@ static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N,
   Printer.printBool("isDefinition", N->isDefinition());
   Printer.printMetadata("declaration", N->getRawStaticDataMemberDeclaration());
   Printer.printMetadata("templateParams", N->getRawTemplateParams());
+  Printer.printDIFlags("flags", N->getFlags());
   Printer.printInt("align", N->getAlignInBits());
   Printer.printMetadata("annotations", N->getRawAnnotations());
   Out << ")";
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 1ce8c17f8a88..af6ebf702165 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -725,14 +725,14 @@ DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression(
     DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
     unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined,
     DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams,
-    uint32_t AlignInBits, DINodeArray Annotations) {
+    DINode::DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations) {
   checkGlobalVariableScope(Context);
 
   auto *GV = DIGlobalVariable::getDistinct(
       VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
       LineNumber, Ty, IsLocalToUnit, isDefined,
-      cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
-      Annotations);
+      cast_or_null<DIDerivedType>(Decl), TemplateParams, Flags,
+      AlignInBits, Annotations);
   if (!Expr)
     Expr = createExpression();
   auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr);
@@ -743,14 +743,14 @@ DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression(
 DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl(
     DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
     unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, MDNode *Decl,
-    MDTuple *TemplateParams, uint32_t AlignInBits) {
+    MDTuple *TemplateParams, DINode::DIFlags Flags, uint32_t AlignInBits) {
   checkGlobalVariableScope(Context);
 
   return DIGlobalVariable::getTemporary(
              VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
              LineNumber, Ty, IsLocalToUnit, false,
-             cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
-             nullptr)
+             cast_or_null<DIDerivedType>(Decl), TemplateParams, Flags,
+             AlignInBits, nullptr)
       .release();
 }
 
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 48b5501c55ba..3696beccdd0c 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1547,12 +1547,13 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
     size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
-    LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits) {
+    LLVMMetadataRef Expr, LLVMMetadataRef Decl, LLVMDIFlags Flags,
+    uint32_t AlignInBits) {
   return wrap(unwrap(Builder)->createGlobalVariableExpression(
       unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LinkLen},
       unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
       true, unwrap<DIExpression>(Expr), unwrapDI<MDNode>(Decl),
-      nullptr, AlignInBits));
+      nullptr, map_from_llvmDIFlags(Flags), AlignInBits));
 }
 
 LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE) {
@@ -1597,11 +1598,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
     LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
     size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File,
     unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
-    LLVMMetadataRef Decl, uint32_t AlignInBits) {
+    LLVMMetadataRef Decl, LLVMDIFlags Flags, uint32_t AlignInBits) {
   return wrap(unwrap(Builder)->createTempGlobalVariableFwdDecl(
       unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LnkLen},
       unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
-      unwrapDI<MDNode>(Decl), nullptr, AlignInBits));
+      unwrapDI<MDNode>(Decl), nullptr, map_from_llvmDIFlags(Flags),
+      AlignInBits));
 }
 
 LLVMValueRef
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 4933b6032688..d599896ee456 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -1258,15 +1258,16 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
                           MDString *LinkageName, Metadata *File, unsigned Line,
                           Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
                           Metadata *StaticDataMemberDeclaration,
-                          Metadata *TemplateParams, uint32_t AlignInBits,
-                          Metadata *Annotations, StorageType Storage,
-                          bool ShouldCreate) {
+                          Metadata *TemplateParams, DIFlags Flags,
+                          uint32_t AlignInBits, Metadata *Annotations,
+                          StorageType Storage, bool ShouldCreate) {
   assert(isCanonical(Name) && "Expected canonical MDString");
   assert(isCanonical(LinkageName) && "Expected canonical MDString");
   DEFINE_GETIMPL_LOOKUP(
       DIGlobalVariable,
       (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
-       StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations));
+       StaticDataMemberDeclaration, TemplateParams, Flags, AlignInBits,
+       Annotations));
   Metadata *Ops[] = {Scope,
                      Name,
                      File,
@@ -1277,7 +1278,8 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
                      TemplateParams,
                      Annotations};
   DEFINE_GETIMPL_STORE(DIGlobalVariable,
-                       (Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops);
+                       (Line, IsLocalToUnit, IsDefinition, Flags, AlignInBits),
+                       Ops);
 }
 
 DILocalVariable *
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 4cc3f8da6b75..8a621725f55e 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -1055,6 +1055,7 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
   bool IsDefinition;
   Metadata *StaticDataMemberDeclaration;
   Metadata *TemplateParams;
+  unsigned Flags;
   uint32_t AlignInBits;
   Metadata *Annotations;
 
@@ -1062,20 +1063,21 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
                 Metadata *File, unsigned Line, Metadata *Type,
                 bool IsLocalToUnit, bool IsDefinition,
                 Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
+                unsigned Flags,
                 uint32_t AlignInBits, Metadata *Annotations)
       : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
         Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
         IsDefinition(IsDefinition),
         StaticDataMemberDeclaration(StaticDataMemberDeclaration),
-        TemplateParams(TemplateParams), AlignInBits(AlignInBits),
-        Annotations(Annotations) {}
+        TemplateParams(TemplateParams), Flags(Flags),
+        AlignInBits(AlignInBits), Annotations(Annotations) {}
   MDNodeKeyImpl(const DIGlobalVariable *N)
       : Scope(N->getRawScope()), Name(N->getRawName()),
         LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
         Line(N->getLine()), Type(N->getRawType()),
         IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
         StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
-        TemplateParams(N->getRawTemplateParams()),
+        TemplateParams(N->getRawTemplateParams()), Flags(N->getFlags()),
         AlignInBits(N->getAlignInBits()), Annotations(N->getRawAnnotations()) {}
 
   bool isKeyOf(const DIGlobalVariable *RHS) const {
@@ -1087,6 +1089,7 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
            StaticDataMemberDeclaration ==
                RHS->getRawStaticDataMemberDeclaration() &&
            TemplateParams == RHS->getRawTemplateParams() &&
+           Flags == RHS->getFlags() &&
            AlignInBits == RHS->getAlignInBits() &&
            Annotations == RHS->getRawAnnotations();
   }
@@ -1101,7 +1104,7 @@ template <> struct MDNodeKeyImpl<DIGlobalVariable> {
     // TODO: make hashing work fine with such situations
     return hash_combine(Scope, Name, LinkageName, File, Line, Type,
                         IsLocalToUnit, IsDefinition, /* AlignInBits, */
-                        StaticDataMemberDeclaration, Annotations);
+                        StaticDataMemberDeclaration, Flags, Annotations);
   }
 };
 
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index a7b1953ce81c..136132d7e65a 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1052,8 +1052,8 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfInstBase *Inc) {
           SP, CounterPtr->getName(), /*LinkageName=*/StringRef(), SP->getFile(),
           /*LineNo=*/0, DB.createUnspecifiedType("Profile Data Type"),
           CounterPtr->hasLocalLinkage(), /*IsDefined=*/true, /*Expr=*/nullptr,
-          /*Decl=*/nullptr, /*TemplateParams=*/nullptr, /*AlignInBits=*/0,
-          Annotations);
+          /*Decl=*/nullptr, /*TemplateParams=*/nullptr,
+          /*Flags=*/DINode::FlagZero, /*AlignInBits=*/0, Annotations);
       CounterPtr->addDebugInfo(DICounter);
       DB.finalize();
     } else {
diff --git a/llvm/test/Assembler/invalid-diglobalvariable-empty-name.ll b/llvm/test/Assembler/invalid-diglobalvariable-empty-name.ll
index a4e69f3c8b75..d3c476a03198 100644
--- a/llvm/test/Assembler/invalid-diglobalvariable-empty-name.ll
+++ b/llvm/test/Assembler/invalid-diglobalvariable-empty-name.ll
@@ -1,4 +1,5 @@
 ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+; UNSUPPORTED: classic_flang
 
 ; CHECK: <stdin>:[[@LINE+1]]:30: error: 'name' cannot be empty
 !0 = !DIGlobalVariable(name: "")
diff --git a/llvm/test/DebugInfo/Generic/fortran-subprogram-at.ll b/llvm/test/DebugInfo/Generic/fortran-subprogram-at.ll
new file mode 100644
index 000000000000..988c388fe218
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/fortran-subprogram-at.ll
@@ -0,0 +1,24 @@
+; Test for DIFlagPure, DIFlagElement and DIFlagRecursive. These three
+; DIFlags are used to attach DW_AT_pure, DW_AT_element, and DW_AT_recursive
+; attributes to DW_TAG_subprogram DIEs.
+
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
+; CHECK: !DISubprogram({{.*}}, spFlags: DISPFlagDefinition | DISPFlagPure | DISPFlagElemental | DISPFlagRecursive,
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+
+define void @subprgm() !dbg !6 {
+L:
+  ret void
+}
+
+!0 = !{i32 2, !"Dwarf Version", i32 2}
+!1 = !{i32 1, !"Debug Info Version", i32 3}
+!2 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !3, producer: "Flang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !4, imports: !4)
+!3 = !DIFile(filename: "fortran-subprogram-at.f", directory: "/")
+!4 = !{}
+!5 = !DIBasicType(name: "real", size: 32, align: 32, encoding: DW_ATE_float)
+!6 = distinct !DISubprogram(name: "subprgm", scope: !2, file: !3, line: 256, type: !7, scopeLine: 256, spFlags: DISPFlagDefinition | DISPFlagPure | DISPFlagElemental | DISPFlagRecursive, unit: !2)
+!7 = !DISubroutineType(types: !8)
+!8 = !{null, !5}
diff --git a/llvm/test/DebugInfo/Generic/more-subprogram-attr.ll b/llvm/test/DebugInfo/Generic/more-subprogram-attr.ll
new file mode 100644
index 000000000000..0533cf6b2367
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/more-subprogram-attr.ll
@@ -0,0 +1,38 @@
+; REQUIRES: object-emission
+
+; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
+; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
+
+; Make sure we're emitting DW_AT_{pure,elemental,recursive}.
+; CHECK: DW_TAG_subprogram
+; CHECK-NOT: {{DW_TAG|NULL}}
+; CHECK:   DW_AT_name {{.*}} "main"
+; CHECK-NOT: {{DW_TAG|NULL}}
+; CHECK:   DW_AT_pure [DW_FORM_flag_present] (true)
+; CHECK:   DW_AT_elemental [DW_FORM_flag_present] (true)
+; CHECK:   DW_AT_recursive [DW_FORM_flag_present] (true)
+
+define dso_local i32 @main() !dbg !7 {
+entry:
+  %retval = alloca i32, align 4
+  store i32 0, i32* %retval, align 4
+  ret i32 0, !dbg !12
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "x.c", directory: "/tmp")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang"}
+!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 1, type: !9, scopeLine: 2, spFlags: DISPFlagDefinition | DISPFlagPure | DISPFlagElemental | DISPFlagRecursive, unit: !0, retainedNodes: !2)
+!8 = !DIFile(filename: "x.c", directory: "/tmp")
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !DILocation(line: 3, column: 3, scope: !7)
diff --git a/llvm/test/DebugInfo/X86/DICommonBlock.ll b/llvm/test/DebugInfo/X86/DICommonBlock.ll
new file mode 100644
index 000000000000..6cfb7a90640d
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/DICommonBlock.ll
@@ -0,0 +1,36 @@
+; ModuleID = 'none.f90'
+; RUN: llc %s -o %t -filetype=obj
+; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
+; CHECK: DW_TAG_common_block
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx"
+
+@common_a = common global [32 x i8] zeroinitializer, align 8, !dbg !13
+
+define i32 @subr() !dbg !9 {
+    %1 = getelementptr inbounds [32 x i8], [32 x i8]* @common_a, i64 0, i32 8
+    %2 = bitcast i8* %1 to i32*
+    %3 = load i32, i32* %2
+    ret i32 %3
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !1, producer: "PGI Fortran", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, retainedTypes: !14, globals: !2)
+!1 = !DIFile(filename: "none.f90", directory: "/not/here/")
+!2 = !{!13}
+!3 = !{}
+!4 = !DIGlobalVariable(name: "common /a/", scope: !5, file: !1, line: 4, isLocal: false, isDefinition: true, type: !12)
+!5 = !DICommonBlock(scope: !9, declaration: !4, name: "a", file: !1, line: 4)
+!6 = !{i32 2, !"Dwarf Version", i32 4}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{!"PGI Fortran"}
+!9 = distinct !DISubprogram(name: "subrtn", scope: !0, file: !1, line: 1, type: !10, isLocal: false, isDefinition: true, unit: !0)
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12, !12}
+!12 = !DIBasicType(name: "int", size: 32)
+!13 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression())
+!14 = !{!12, !10}
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 4114bf7f54b2..9cc8520960c2 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -645,3 +645,6 @@ if "aix" in config.target_triple:
 # "OBJECT_MODE" to 'any' by default on AIX OS.
 if "system-aix" in config.available_features:
     config.environment["OBJECT_MODE"] = "any"
+
+if config.use_classic_flang:
+    config.available_features.add("classic_flang")
diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index 57ee2100dfb7..fc7ab6536309 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -61,6 +61,7 @@ config.expensive_checks = @LLVM_ENABLE_EXPENSIVE_CHECKS@
 config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
 config.dxil_tests = @LLVM_INCLUDE_DXIL_TESTS@
 config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
+config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c
index a3e41be12e95..906c96f1c24b 100644
--- a/llvm/tools/llvm-c-test/debuginfo.c
+++ b/llvm/tools/llvm-c-test/debuginfo.c
@@ -64,7 +64,7 @@ int llvm_test_dibuilder(void) {
       LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
   LLVMDIBuilderCreateGlobalVariableExpression(
       DIB, Module, "globalClass", 11, "", 0, File, 1, ClassTy, true,
-      GlobalClassValueExpr, NULL, 0);
+      GlobalClassValueExpr, NULL, LLVMDIFlagZero, 0);
 
   LLVMMetadataRef Int64Ty =
       LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
@@ -75,7 +75,7 @@ int llvm_test_dibuilder(void) {
       LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
   LLVMDIBuilderCreateGlobalVariableExpression(
       DIB, Module, "global", 6, "", 0, File, 1, Int64TypeDef, true,
-      GlobalVarValueExpr, NULL, 0);
+      GlobalVarValueExpr, NULL, LLVMDIFlagZero, 0);
 
   LLVMMetadataRef NameSpace =
       LLVMDIBuilderCreateNameSpace(DIB, Module, "NameSpace", 9, false);
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 5342360109d0..4bce26851d2f 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -2896,12 +2896,13 @@ TEST_F(DIGlobalVariableTest, get) {
   DIDerivedType *StaticDataMemberDeclaration =
       cast<DIDerivedType>(getDerivedType());
 
+  DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
   uint32_t AlignInBits = 8;
 
   auto *N = DIGlobalVariable::get(
       Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
-      IsDefinition, StaticDataMemberDeclaration, templateParams, AlignInBits,
-      nullptr);
+      IsDefinition, StaticDataMemberDeclaration, templateParams, Flags,
+      AlignInBits, nullptr);
 
   EXPECT_EQ(dwarf::DW_TAG_variable, N->getTag());
   EXPECT_EQ(Scope, N->getScope());
@@ -2914,57 +2915,66 @@ TEST_F(DIGlobalVariableTest, get) {
   EXPECT_EQ(IsDefinition, N->isDefinition());
   EXPECT_EQ(StaticDataMemberDeclaration, N->getStaticDataMemberDeclaration());
   EXPECT_EQ(templateParams, N->getTemplateParams());
+  EXPECT_EQ(Flags, N->getFlags());
   EXPECT_EQ(AlignInBits, N->getAlignInBits());
   EXPECT_EQ(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, Type, IsLocalToUnit, IsDefinition,
                                      StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits,
+                                     nullptr));
 
   EXPECT_NE(N, DIGlobalVariable::get(
                    Context, getSubprogram(), Name, LinkageName, File, Line,
                    Type, IsLocalToUnit, IsDefinition,
-                   StaticDataMemberDeclaration, templateParams, AlignInBits,
-                   nullptr));
+                   StaticDataMemberDeclaration, templateParams, Flags,
+                   AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, "other", LinkageName, File,
                                      Line, Type, IsLocalToUnit, IsDefinition,
                                      StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits,
+                                     nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, "other", File, Line,
                                      Type, IsLocalToUnit, IsDefinition,
                                      StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName,
                                      getFile(), Line, Type, IsLocalToUnit,
                                      IsDefinition, StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line + 1, Type, IsLocalToUnit,
                                      IsDefinition, StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, getDerivedType(), IsLocalToUnit,
                                      IsDefinition, StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, Type, !IsLocalToUnit, IsDefinition,
                                      StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, Type, IsLocalToUnit, !IsDefinition,
                                      StaticDataMemberDeclaration,
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, Type, IsLocalToUnit, IsDefinition,
                                      cast<DIDerivedType>(getDerivedType()),
-                                     templateParams, AlignInBits, nullptr));
+                                     templateParams, Flags, AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, Type, IsLocalToUnit, IsDefinition,
                                      StaticDataMemberDeclaration, nullptr,
+                                     Flags, AlignInBits, nullptr));
+  EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
+                                     Line, Type, IsLocalToUnit, IsDefinition,
+                                     StaticDataMemberDeclaration,
+                                     templateParams,
+                                     static_cast<DINode::DIFlags>(Flags + 1),
                                      AlignInBits, nullptr));
   EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
                                      Line, Type, IsLocalToUnit, IsDefinition,
                                      StaticDataMemberDeclaration,
-                                     templateParams, (AlignInBits << 1),
+                                     templateParams, Flags, (AlignInBits << 1),
                                      nullptr));
 
   TempDIGlobalVariable Temp = N->clone();
@@ -2987,16 +2997,17 @@ TEST_F(DIGlobalVariableExpressionTest, get) {
   auto *Expr2 = DIExpression::get(Context, {1, 2, 3});
   DIDerivedType *StaticDataMemberDeclaration =
       cast<DIDerivedType>(getDerivedType());
+  DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
   uint32_t AlignInBits = 8;
 
   auto *Var = DIGlobalVariable::get(
       Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
-      IsDefinition, StaticDataMemberDeclaration, templateParams, AlignInBits,
-      nullptr);
+      IsDefinition, StaticDataMemberDeclaration, templateParams, Flags,
+      AlignInBits, nullptr);
   auto *Var2 = DIGlobalVariable::get(
       Context, Scope, "other", LinkageName, File, Line, Type, IsLocalToUnit,
-      IsDefinition, StaticDataMemberDeclaration, templateParams, AlignInBits,
-      nullptr);
+      IsDefinition, StaticDataMemberDeclaration, templateParams, Flags,
+      AlignInBits, nullptr);
   auto *N = DIGlobalVariableExpression::get(Context, Var, Expr);
 
   EXPECT_EQ(Var, N->getVariable());
diff --git a/llvm/utils/lit/lit/TestingConfig.py b/llvm/utils/lit/lit/TestingConfig.py
index 76fd66502009..399b74c4f00d 100644
--- a/llvm/utils/lit/lit/TestingConfig.py
+++ b/llvm/utils/lit/lit/TestingConfig.py
@@ -26,6 +26,7 @@ class TestingConfig(object):
             "SYSTEMROOT",
             "TERM",
             "CLANG",
+            "FLANG",
             "LLDB",
             "LD_PRELOAD",
             "LLVM_SYMBOLIZER_PATH",
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 16cc2968034b..d8dec6160071 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -500,6 +500,8 @@ class LLVMConfig(object):
         just-built or optionally an installed clang, and add a set of standard
         substitutions useful to any test suite that makes use of clang.
 
+        Also sets up use of flang
+
         """
         # Clear some environment variables that might affect Clang.
         #
@@ -631,6 +633,14 @@ class LLVMConfig(object):
             self.add_tool_substitutions(tool_substitutions)
             self.config.substitutions.append(("%resource_dir", builtin_include_dir))
 
+        self.config.flang = self.use_llvm_tool(
+            'flang', search_env='FLANG', required=required)
+        if self.config.flang:
+            tool_substitutions = [
+                ToolSubst('%flang', command=self.config.flang)
+                ]
+            self.add_tool_substitutions(tool_substitutions)
+
         self.config.substitutions.append(
             (
                 "%itanium_abi_triple",
-- 
2.24.3 (Apple Git-128)