test_mklog.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. #!/usr/bin/env python3
  2. # Copyright (C) 2020 Free Software Foundation, Inc.
  3. #
  4. # This file is part of GCC.
  5. #
  6. # GCC is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3, or (at your option)
  9. # any later version.
  10. #
  11. # GCC is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with GCC; see the file COPYING. If not, write to
  18. # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
  19. # Boston, MA 02110-1301, USA.
  20. # This script parses a .diff file generated with 'diff -up' or 'diff -cp'
  21. # and adds a skeleton ChangeLog file to the file. It does not try to be
  22. # too smart when parsing function names, but it produces a reasonable
  23. # approximation.
  24. #
  25. # Author: Martin Liska <mliska@suse.cz>
  26. import unittest
  27. from mklog import generate_changelog
  28. import unidiff
  29. unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')
  30. PATCH1 = '''\
  31. diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
  32. index 567c23380fe..e6209ede9d6 100644
  33. --- a/gcc/config/riscv/riscv.h
  34. +++ b/gcc/config/riscv/riscv.h
  35. @@ -920,6 +920,7 @@ extern unsigned riscv_stack_boundary;
  36. #define SHIFT_RS1 15
  37. #define SHIFT_IMM 20
  38. #define IMM_BITS 12
  39. +#define C_S_BITS 5
  40. #define C_SxSP_BITS 6
  41. #define IMM_REACH (1LL << IMM_BITS)
  42. @@ -929,6 +930,10 @@ extern unsigned riscv_stack_boundary;
  43. #define SWSP_REACH (4LL << C_SxSP_BITS)
  44. #define SDSP_REACH (8LL << C_SxSP_BITS)
  45. +/* This is the maximum value that can be represented in a compressed load/store
  46. + offset (an unsigned 5-bit value scaled by 4). */
  47. +#define CSW_MAX_OFFSET ((4LL << C_S_BITS) - 1) & ~3
  48. +
  49. /* Called from RISCV_REORG, this is defined in riscv-sr.c. */
  50. extern void riscv_remove_unneeded_save_restore_calls (void);
  51. '''
  52. EXPECTED1 = '''\
  53. gcc/ChangeLog:
  54. * config/riscv/riscv.h (C_S_BITS):
  55. (CSW_MAX_OFFSET):
  56. '''
  57. PATCH2 = '''\
  58. diff --git a/gcc/targhooks.h b/gcc/targhooks.h
  59. index 9704d23f1db..b572a36e8cf 100644
  60. --- a/gcc/targhooks.h
  61. +++ b/gcc/targhooks.h
  62. @@ -120,7 +120,7 @@ extern bool default_empty_mask_is_expensive (unsigned);
  63. extern void *default_init_cost (class loop *);
  64. extern unsigned default_add_stmt_cost (class vec_info *, void *, int,
  65. enum vect_cost_for_stmt,
  66. - class _stmt_vec_info *, int,
  67. + class _stmt_vec_info *, tree, int,
  68. enum vect_cost_model_location);
  69. extern void default_finish_cost (void *, unsigned *, unsigned *, unsigned *);
  70. extern void default_destroy_cost_data (void *);
  71. @@ -186,6 +186,7 @@ extern tree default_emutls_var_init (tree, tree, tree);
  72. extern unsigned int default_hard_regno_nregs (unsigned int, machine_mode);
  73. extern bool default_hard_regno_scratch_ok (unsigned int);
  74. extern bool default_mode_dependent_address_p (const_rtx, addr_space_t);
  75. +extern bool default_new_address_profitable_p (rtx, rtx_insn *, rtx);
  76. extern bool default_target_option_valid_attribute_p (tree, tree, tree, int);
  77. extern bool default_target_option_pragma_parse (tree, tree);
  78. extern bool default_target_can_inline_p (tree, tree);
  79. '''
  80. EXPECTED2 = '''\
  81. gcc/ChangeLog:
  82. * targhooks.h (default_add_stmt_cost):
  83. (default_new_address_profitable_p):
  84. '''
  85. PATCH3 = '''\
  86. diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
  87. index 2b1e33f94ae..7f47402f9b9 100644
  88. --- a/libcpp/include/cpplib.h
  89. +++ b/libcpp/include/cpplib.h
  90. @@ -173,7 +173,7 @@ enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, CLK_GNUC2X,
  91. CLK_STDC2X,
  92. CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
  93. CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17,
  94. - CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
  95. + CLK_GNUCXX20, CLK_CXX20, CLK_ASM};
  96. /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */
  97. struct GTY(()) cpp_string {
  98. @@ -484,7 +484,7 @@ struct cpp_options
  99. /* Nonzero for C2X decimal floating-point constants. */
  100. unsigned char dfp_constants;
  101. - /* Nonzero for C++2a __VA_OPT__ feature. */
  102. + /* Nonzero for C++20 __VA_OPT__ feature. */
  103. unsigned char va_opt;
  104. /* Nonzero for the '::' token. */
  105. '''
  106. EXPECTED3 = '''\
  107. libcpp/ChangeLog:
  108. * include/cpplib.h (enum c_lang):
  109. (struct cpp_options):
  110. '''
  111. EXPECTED3B = '''\
  112. libcpp/ChangeLog:
  113. * include/cpplib.h:
  114. '''
  115. PATCH4 = '''\
  116. diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
  117. index aab79492357..f0df1002488 100644
  118. --- a/gcc/ipa-icf.c
  119. +++ b/gcc/ipa-icf.c
  120. @@ -1,5 +1,7 @@
  121. +
  122. +
  123. /* Interprocedural Identical Code Folding pass
  124. Copyright (C) 2014-2020 Free Software Foundation, Inc.
  125. diff --git a/gcc/testsuite/gcc.dg/pr32374.c b/gcc/testsuite/gcc.dg/pr32374.c
  126. deleted file mode 100644
  127. index de15d559f5b..00000000000
  128. --- a/gcc/testsuite/gcc.dg/pr32374.c
  129. +++ /dev/null
  130. @@ -1,20 +0,0 @@
  131. -/* { dg-do compile } */
  132. -/* { dg-options "-O2" } */
  133. -
  134. -extern int *stderr;
  135. -
  136. -void f (int *, const char *, ...);
  137. -
  138. -void g (const char *conf_name)
  139. -{
  140. - typedef struct
  141. - {
  142. - const char *label;
  143. - const int value;
  144. - } Section;
  145. -
  146. - const Section sections[2] = { {"", 0}, {"", 1} };
  147. -
  148. - f (stderr, "", "", conf_name, 0, sections[0]);
  149. - f (stderr, "", "", conf_name, 0, sections[0]);
  150. -}
  151. diff --git a/gcc/testsuite/gcc.dg/pr40209.c b/gcc/testsuite/gcc.dg/pr40209.c
  152. index 4e77df5c2e6..c23d69d1f1b 100644
  153. --- a/gcc/testsuite/gcc.dg/pr40209.c
  154. +++ b/gcc/testsuite/gcc.dg/pr40209.c
  155. @@ -1,6 +1,8 @@
  156. /* { dg-do compile } */
  157. /* { dg-options "-O2 -fprofile-use -fopt-info -Wno-missing-profile" } */
  158. +
  159. +
  160. void process(const char *s);
  161. struct BaseHolder {
  162. diff --git a/gcc/testsuite/gcc.dg/pr50209.c b/gcc/testsuite/gcc.dg/pr50209.c
  163. new file mode 100644
  164. index 00000000000..b28b04f6431
  165. --- /dev/null
  166. +++ b/gcc/testsuite/gcc.dg/pr50209.c
  167. @@ -0,0 +1,3 @@
  168. +
  169. +
  170. +
  171. diff --git a/gcc/testsuite/gcc.dg/pr63567-1.c b/gcc/testsuite/gcc.dg/pr63567-1.c
  172. index 97da171563e..00c5ecc11fa 100644
  173. --- a/gcc/testsuite/gcc.dg/pr63567-1.c
  174. +++ b/gcc/testsuite/gcc.dg/pr63567-1.c
  175. @@ -1,3 +1,4 @@
  176. +
  177. /* PR c/63567 */
  178. /* { dg-do compile } */
  179. /* { dg-options "" } */
  180. diff --git a/gcc/varasm.c b/gcc/varasm.c
  181. index f062e48071f..fd3c7ca8cf3 100644
  182. --- a/gcc/varasm.c
  183. +++ b/gcc/varasm.c
  184. @@ -1,3 +1,5 @@
  185. +
  186. +
  187. /* Output variables, constants and external declarations, for GNU compiler.
  188. Copyright (C) 1987-2020 Free Software Foundation, Inc.
  189. diff --git a/libssp/gets-chk.c b/libssp/gets-chk.c
  190. index 4ad78c1f77b..6687b368038 100644
  191. --- a/libssp/gets-chk.c
  192. +++ b/libssp/gets-chk.c
  193. @@ -32,6 +32,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  194. <http://www.gnu.org/licenses/>. */
  195. +
  196. +
  197. #include "config.h"
  198. #include <ssp/ssp.h>
  199. #include <stdarg.h>
  200. '''
  201. EXPECTED4 = '''\
  202. PR 50209
  203. gcc/ChangeLog:
  204. * ipa-icf.c:
  205. * varasm.c:
  206. libssp/ChangeLog:
  207. * gets-chk.c:
  208. gcc/testsuite/ChangeLog:
  209. * gcc.dg/pr40209.c:
  210. * gcc.dg/pr63567-1.c:
  211. * gcc.dg/pr32374.c: Removed.
  212. * gcc.dg/pr50209.c: New test.
  213. '''
  214. PATCH5 = '''\
  215. diff --git a/gcc/testsuite/gcc.target/i386/pr95046-6.c b/gcc/testsuite/gcc.target/i386/pr95046-6.c
  216. new file mode 100644
  217. index 00000000000..dcc8999c446
  218. --- /dev/null
  219. +++ b/gcc/testsuite/gcc.target/i386/pr95046-6.c
  220. @@ -0,0 +1,44 @@
  221. +/* PR target/95046 */
  222. +/* { dg-do compile { target { ! ia32 } } } */
  223. +/* { dg-options "-O3 -mavx512vl" } */
  224. +
  225. +
  226. +double r[2];
  227. +int s[2];
  228. +unsigned int u[2];
  229. +
  230. +void
  231. +test_float (void)
  232. +{
  233. + for (int i = 0; i < 2; i++)
  234. + r[i] = s[i];
  235. +}
  236. +
  237. +/* { dg-final { scan-assembler "\tvcvtdq2pd" } } */
  238. +
  239. +void
  240. +test_ufloat (void)
  241. +{
  242. + for (int i = 0; i < 2; i++)
  243. + r[i] = u[i];
  244. +}
  245. +
  246. +/* { dg-final { scan-assembler "\tvcvtudq2pd" } } */
  247. +
  248. +void
  249. +test_fix (void)
  250. +{
  251. + for (int i = 0; i < 2; i++)
  252. + s[i] = r[i];
  253. +}
  254. +
  255. +/* { dg-final { scan-assembler "\tvcvttpd2dqx" } } */
  256. +
  257. +void
  258. +test_ufix (void)
  259. +{
  260. + for (int i = 0; i < 2; i++)
  261. + u[i] = r[i];
  262. +}
  263. +
  264. +/* { dg-final { scan-assembler "\tvcvttpd2udqx" } } */
  265. --
  266. 2.26.2
  267. '''
  268. EXPECTED5 = '''\
  269. PR target/95046 - Vectorize V2SFmode operations
  270. PR target/95046
  271. gcc/testsuite/ChangeLog:
  272. * gcc.target/i386/pr95046-6.c: New test.
  273. '''
  274. PATCH6 = '''\
  275. diff --git a/gcc/cgraph.h b/gcc/cgraph.h
  276. index 5ddeb65269b..cfae6e91da9 100644
  277. --- a/gcc/cgraph.h
  278. +++ b/gcc/cgraph.h
  279. @@ -937,7 +937,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
  280. split_part (false), indirect_call_target (false), local (false),
  281. versionable (false), can_change_signature (false),
  282. redefined_extern_inline (false), tm_may_enter_irr (false),
  283. - ipcp_clone (false), m_uid (uid), m_summary_id (-1)
  284. + ipcp_clone (false), declare_variant_alt (false),
  285. + calls_declare_variant_alt (false), m_uid (uid), m_summary_id (-1)
  286. {}
  287. /* Remove the node from cgraph and all inline clones inlined into it.
  288. '''
  289. EXPECTED6 = '''\
  290. gcc/ChangeLog:
  291. * cgraph.h (struct cgraph_node):
  292. '''
  293. PATCH7 = '''\
  294. diff --git a/gcc/testsuite/g++.dg/DRs/dr2237.C b/gcc/testsuite/g++.dg/DRs/dr2237.C
  295. new file mode 100644
  296. index 00000000000..f3d6d11e61e
  297. --- /dev/null
  298. +++ b/gcc/testsuite/g++.dg/DRs/dr2237.C
  299. @@ -0,0 +1,18 @@
  300. +// DR 2237 - Can a template-id name a constructor?
  301. +
  302. +template<class T>
  303. +struct X {
  304. + X<T>(); // { dg-error "expected" "" { target c++20 } }
  305. + X(int); // OK, injected-class-name used
  306. + ~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
  307. +};
  308. +
  309. +// ill-formed since DR1435
  310. +template<typename T> X<T>::X<T>() {} // { dg-error "names the constructor|as no template constructors" }
  311. +template<typename T> X<T>::~X<T>() {} // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
  312. +
  313. +struct Q {
  314. + // ill-formed since DR1435
  315. + template<typename T> friend X<T>::X<T>(); // { dg-error "names the constructor|as no template constructors" }
  316. + template<typename T> friend X<T>::~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
  317. +};
  318. '''
  319. EXPECTED7 = '''\
  320. DR 2237
  321. gcc/testsuite/ChangeLog:
  322. * g++.dg/DRs/dr2237.C: New test.
  323. '''
  324. PATCH8 = '''\
  325. diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf2.c
  326. similarity index 100%
  327. rename from gcc/ipa-icf.c
  328. rename to gcc/ipa-icf2.c
  329. '''
  330. EXPECTED8 = '''\
  331. gcc/ChangeLog:
  332. * ipa-icf.c: Moved to...
  333. * ipa-icf2.c: ...here.
  334. '''
  335. PATCH9 = '''\
  336. diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
  337. index 2a260c1cfbd..7f03fc491c3 100644
  338. --- a/gcc/config/i386/sse.md
  339. +++ b/gcc/config/i386/sse.md
  340. @@ -17611,6 +17611,23 @@ (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
  341. (set_attr "prefix" "maybe_evex")
  342. (set_attr "mode" "OI")])
  343. +(define_insn_and_split "*avx2_zero_extendv16qiv16hi2_1"
  344. + [(set (match_operand:V32QI 0 "register_operand" "=v")
  345. + (vec_select:V32QI
  346. + (vec_concat:V64QI
  347. + (match_operand:V32QI 1 "nonimmediate_operand" "vm")
  348. + (match_operand:V32QI 2 "const0_operand" "C"))
  349. + (match_parallel 3 "pmovzx_parallel"
  350. + [(match_operand 4 "const_int_operand" "n")])))]
  351. + "TARGET_AVX2"
  352. + "#"
  353. + "&& reload_completed"
  354. + [(set (match_dup 0) (zero_extend:V16HI (match_dup 1)))]
  355. +{
  356. + operands[0] = lowpart_subreg (V16HImode, operands[0], V32QImode);
  357. + operands[1] = lowpart_subreg (V16QImode, operands[1], V32QImode);
  358. +})
  359. +
  360. (define_expand "<insn>v16qiv16hi2"
  361. [(set (match_operand:V16HI 0 "register_operand")
  362. (any_extend:V16HI
  363. '''
  364. EXPECTED9 = '''\
  365. gcc/ChangeLog:
  366. * config/i386/sse.md (*avx2_zero_extendv16qiv16hi2_1):
  367. '''
  368. PATCH10 = '''\
  369. diff --git a/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst b/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst
  370. new file mode 100644
  371. index 00000000000..ad3c6d856fc
  372. --- /dev/null
  373. +++ b/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst
  374. @@ -0,0 +1,3 @@
  375. +
  376. +
  377. +
  378. '''
  379. EXPECTED10 = '''\
  380. libgomp/ChangeLog:
  381. * doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst:
  382. New file.
  383. '''
  384. class TestMklog(unittest.TestCase):
  385. def test_macro_definition(self):
  386. changelog = generate_changelog(PATCH1)
  387. assert changelog == EXPECTED1
  388. def test_changed_argument(self):
  389. changelog = generate_changelog(PATCH2)
  390. assert changelog == EXPECTED2
  391. def test_enum_and_struct(self):
  392. changelog = generate_changelog(PATCH3)
  393. assert changelog == EXPECTED3
  394. def test_no_function(self):
  395. changelog = generate_changelog(PATCH3, True)
  396. assert changelog == EXPECTED3B
  397. def test_sorting(self):
  398. changelog = generate_changelog(PATCH4)
  399. assert changelog == EXPECTED4
  400. def test_pr_bugzilla_download(self):
  401. changelog = generate_changelog(PATCH5, fill_pr_titles=True)
  402. assert changelog == EXPECTED5
  403. def test_gty_in_struct(self):
  404. changelog = generate_changelog(PATCH6, fill_pr_titles=True)
  405. assert changelog == EXPECTED6
  406. def test_dr_detection_in_test_case(self):
  407. changelog = generate_changelog(PATCH7)
  408. assert changelog == EXPECTED7
  409. @unittest.skipIf(not unidiff_supports_renaming,
  410. 'Newer version of unidiff is needed (0.6.0+)')
  411. def test_renaming(self):
  412. changelog = generate_changelog(PATCH8)
  413. assert changelog == EXPECTED8
  414. def test_define_macro_parsing(self):
  415. changelog = generate_changelog(PATCH9)
  416. assert changelog == EXPECTED9
  417. def test_long_filenames(self):
  418. changelog = generate_changelog(PATCH10)
  419. assert changelog == EXPECTED10