Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

373 lines
15KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Final Actions (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Final Actions (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Final Actions (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Test-Directives.html#Test-Directives" rel="up" title="Test Directives">
  30. <link href="Ada-Tests.html#Ada-Tests" rel="next" title="Ada Tests">
  31. <link href="Require-Support.html#Require-Support" rel="prev" title="Require Support">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Final-Actions"></a>
  62. <div class="header">
  63. <p>
  64. Previous: <a href="Require-Support.html#Require-Support" accesskey="p" rel="prev">Require Support</a>, Up: <a href="Test-Directives.html#Test-Directives" accesskey="u" rel="up">Test Directives</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Commands-for-use-in-dg_002dfinal"></a>
  68. <h4 class="subsection">7.2.6 Commands for use in <code>dg-final</code></h4>
  69. <p>The GCC testsuite defines the following directives to be used within
  70. <code>dg-final</code>.
  71. </p>
  72. <a name="Scan-a-particular-file"></a>
  73. <h4 class="subsubsection">7.2.6.1 Scan a particular file</h4>
  74. <dl compact="compact">
  75. <dt><code>scan-file <var>filename</var> <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  76. <dd><p>Passes if <var>regexp</var> matches text in <var>filename</var>.
  77. </p></dd>
  78. <dt><code>scan-file-not <var>filename</var> <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  79. <dd><p>Passes if <var>regexp</var> does not match text in <var>filename</var>.
  80. </p></dd>
  81. <dt><code>scan-module <var>module</var> <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  82. <dd><p>Passes if <var>regexp</var> matches in Fortran module <var>module</var>.
  83. </p></dd>
  84. <dt><code>dg-check-dot <var>filename</var></code></dt>
  85. <dd><p>Passes if <var>filename</var> is a valid <samp>.dot</samp> file (by running
  86. <code>dot -Tpng</code> on it, and verifying the exit code is 0).
  87. </p></dd>
  88. </dl>
  89. <a name="Scan-the-assembly-output"></a>
  90. <h4 class="subsubsection">7.2.6.2 Scan the assembly output</h4>
  91. <dl compact="compact">
  92. <dt><code>scan-assembler <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  93. <dd><p>Passes if <var>regex</var> matches text in the test&rsquo;s assembler output.
  94. </p>
  95. </dd>
  96. <dt><code>scan-assembler-not <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  97. <dd><p>Passes if <var>regex</var> does not match text in the test&rsquo;s assembler output.
  98. </p>
  99. </dd>
  100. <dt><code>scan-assembler-times <var>regex</var> <var>num</var> [{ target/xfail <var>selector</var> }]</code></dt>
  101. <dd><p>Passes if <var>regex</var> is matched exactly <var>num</var> times in the test&rsquo;s
  102. assembler output.
  103. </p>
  104. </dd>
  105. <dt><code>scan-assembler-dem <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  106. <dd><p>Passes if <var>regex</var> matches text in the test&rsquo;s demangled assembler output.
  107. </p>
  108. </dd>
  109. <dt><code>scan-assembler-dem-not <var>regex</var> [{ target/xfail <var>selector</var> }]</code></dt>
  110. <dd><p>Passes if <var>regex</var> does not match text in the test&rsquo;s demangled assembler
  111. output.
  112. </p>
  113. </dd>
  114. <dt><code>scan-hidden <var>symbol</var> [{ target/xfail <var>selector</var> }]</code></dt>
  115. <dd><p>Passes if <var>symbol</var> is defined as a hidden symbol in the test&rsquo;s
  116. assembly output.
  117. </p>
  118. </dd>
  119. <dt><code>scan-not-hidden <var>symbol</var> [{ target/xfail <var>selector</var> }]</code></dt>
  120. <dd><p>Passes if <var>symbol</var> is not defined as a hidden symbol in the test&rsquo;s
  121. assembly output.
  122. </p>
  123. </dd>
  124. <dt><code>check-function-bodies <var>prefix</var> <var>terminator</var> [<var>options</var> [{ target/xfail <var>selector</var> }]]</code></dt>
  125. <dd><p>Looks through the source file for comments that give the expected assembly
  126. output for selected functions. Each line of expected output starts with the
  127. prefix string <var>prefix</var> and the expected output for a function as a whole
  128. is followed by a line that starts with the string <var>terminator</var>.
  129. Specifying an empty terminator is equivalent to specifying &lsquo;<samp>&quot;*/&quot;</samp>&rsquo;.
  130. </p>
  131. <p><var>options</var>, if specified, is a list of regular expressions, each of
  132. which matches a full command-line option. A non-empty list prevents
  133. the test from running unless all of the given options are present on the
  134. command line. This can help if a source file is compiled both with
  135. and without optimization, since it is rarely useful to check the full
  136. function body for unoptimized code.
  137. </p>
  138. <p>The first line of the expected output for a function <var>fn</var> has the form:
  139. </p>
  140. <div class="smallexample">
  141. <pre class="smallexample"><var>prefix</var> <var>fn</var>: [{ target/xfail <var>selector</var> }]
  142. </pre></div>
  143. <p>Subsequent lines of the expected output also start with <var>prefix</var>.
  144. In both cases, whitespace after <var>prefix</var> is not significant.
  145. </p>
  146. <p>The test discards assembly directives such as <code>.cfi_startproc</code>
  147. and local label definitions such as <code>.LFB0</code> from the compiler&rsquo;s
  148. assembly output. It then matches the result against the expected
  149. output for a function as a single regular expression. This means that
  150. later lines can use backslashes to refer back to &lsquo;<samp>(&hellip;)</samp>&rsquo;
  151. captures on earlier lines. For example:
  152. </p>
  153. <div class="smallexample">
  154. <pre class="smallexample">/* { dg-final { check-function-bodies &quot;**&quot; &quot;&quot; &quot;-DCHECK_ASM&quot; } } */
  155. &hellip;
  156. /*
  157. ** add_w0_s8_m:
  158. ** mov (z[0-9]+\.b), w0
  159. ** add z0\.b, p0/m, z0\.b, \1
  160. ** ret
  161. */
  162. svint8_t add_w0_s8_m (&hellip;) { &hellip; }
  163. &hellip;
  164. /*
  165. ** add_b0_s8_m:
  166. ** mov (z[0-9]+\.b), b0
  167. ** add z1\.b, p0/m, z1\.b, \1
  168. ** ret
  169. */
  170. svint8_t add_b0_s8_m (&hellip;) { &hellip; }
  171. </pre></div>
  172. <p>checks whether the implementations of <code>add_w0_s8_m</code> and
  173. <code>add_b0_s8_m</code> match the regular expressions given. The test only
  174. runs when &lsquo;<samp>-DCHECK_ASM</samp>&rsquo; is passed on the command line.
  175. </p>
  176. <p>It is possible to create non-capturing multi-line regular expression
  177. groups of the form &lsquo;<samp>(<var>a</var>|<var>b</var>|&hellip;)</samp>&rsquo; by putting the
  178. &lsquo;<samp>(</samp>&rsquo;, &lsquo;<samp>|</samp>&rsquo; and &lsquo;<samp>)</samp>&rsquo; on separate lines (each still using
  179. <var>prefix</var>). For example:
  180. </p>
  181. <div class="smallexample">
  182. <pre class="smallexample">/*
  183. ** cmple_f16_tied:
  184. ** (
  185. ** fcmge p0\.h, p0/z, z1\.h, z0\.h
  186. ** |
  187. ** fcmle p0\.h, p0/z, z0\.h, z1\.h
  188. ** )
  189. ** ret
  190. */
  191. svbool_t cmple_f16_tied (&hellip;) { &hellip; }
  192. </pre></div>
  193. <p>checks whether <code>cmple_f16_tied</code> is implemented by the
  194. <code>fcmge</code> instruction followed by <code>ret</code> or by the
  195. <code>fcmle</code> instruction followed by <code>ret</code>. The test is
  196. still a single regular rexpression.
  197. </p>
  198. <p>A line containing just:
  199. </p>
  200. <div class="smallexample">
  201. <pre class="smallexample"><var>prefix</var> ...
  202. </pre></div>
  203. <p>stands for zero or more unmatched lines; the whitespace after
  204. <var>prefix</var> is again not significant.
  205. </p>
  206. </dd>
  207. </dl>
  208. <a name="Scan-optimization-dump-files"></a>
  209. <h4 class="subsubsection">7.2.6.3 Scan optimization dump files</h4>
  210. <p>These commands are available for <var>kind</var> of <code>tree</code>, <code>ltrans-tree</code>,
  211. <code>offload-tree</code>, <code>rtl</code>, <code>offload-rtl</code>, <code>ipa</code>, and
  212. <code>wpa-ipa</code>.
  213. </p>
  214. <dl compact="compact">
  215. <dt><code>scan-<var>kind</var>-dump <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  216. <dd><p>Passes if <var>regex</var> matches text in the dump file with suffix <var>suffix</var>.
  217. </p>
  218. </dd>
  219. <dt><code>scan-<var>kind</var>-dump-not <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  220. <dd><p>Passes if <var>regex</var> does not match text in the dump file with suffix
  221. <var>suffix</var>.
  222. </p>
  223. </dd>
  224. <dt><code>scan-<var>kind</var>-dump-times <var>regex</var> <var>num</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  225. <dd><p>Passes if <var>regex</var> is found exactly <var>num</var> times in the dump file
  226. with suffix <var>suffix</var>.
  227. </p>
  228. </dd>
  229. <dt><code>scan-<var>kind</var>-dump-dem <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  230. <dd><p>Passes if <var>regex</var> matches demangled text in the dump file with
  231. suffix <var>suffix</var>.
  232. </p>
  233. </dd>
  234. <dt><code>scan-<var>kind</var>-dump-dem-not <var>regex</var> <var>suffix</var> [{ target/xfail <var>selector</var> }]</code></dt>
  235. <dd><p>Passes if <var>regex</var> does not match demangled text in the dump file with
  236. suffix <var>suffix</var>.
  237. </p></dd>
  238. </dl>
  239. <a name="Check-for-output-files"></a>
  240. <h4 class="subsubsection">7.2.6.4 Check for output files</h4>
  241. <dl compact="compact">
  242. <dt><code>output-exists [{ target/xfail <var>selector</var> }]</code></dt>
  243. <dd><p>Passes if compiler output file exists.
  244. </p>
  245. </dd>
  246. <dt><code>output-exists-not [{ target/xfail <var>selector</var> }]</code></dt>
  247. <dd><p>Passes if compiler output file does not exist.
  248. </p>
  249. </dd>
  250. <dt><code>scan-symbol <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  251. <dd><p>Passes if the pattern is present in the final executable.
  252. </p>
  253. </dd>
  254. <dt><code>scan-symbol-not <var>regexp</var> [{ target/xfail <var>selector</var> }]</code></dt>
  255. <dd><p>Passes if the pattern is absent from the final executable.
  256. </p></dd>
  257. </dl>
  258. <a name="Checks-for-gcov-tests"></a>
  259. <h4 class="subsubsection">7.2.6.5 Checks for <code>gcov</code> tests</h4>
  260. <dl compact="compact">
  261. <dt><code>run-gcov <var>sourcefile</var></code></dt>
  262. <dd><p>Check line counts in <code>gcov</code> tests.
  263. </p>
  264. </dd>
  265. <dt><code>run-gcov [branches] [calls] { <var>opts</var> <var>sourcefile</var> }</code></dt>
  266. <dd><p>Check branch and/or call counts, in addition to line counts, in
  267. <code>gcov</code> tests.
  268. </p></dd>
  269. </dl>
  270. <a name="Clean-up-generated-test-files"></a>
  271. <h4 class="subsubsection">7.2.6.6 Clean up generated test files</h4>
  272. <p>Usually the test-framework removes files that were generated during
  273. testing. If a testcase, for example, uses any dumping mechanism to
  274. inspect a passes dump file, the testsuite recognized the dump option
  275. passed to the tool and schedules a final cleanup to remove these files.
  276. </p>
  277. <p>There are, however, following additional cleanup directives that can be
  278. used to annotate a testcase &quot;manually&quot;.
  279. </p><dl compact="compact">
  280. <dt><code>cleanup-coverage-files</code></dt>
  281. <dd><p>Removes coverage data files generated for this test.
  282. </p>
  283. </dd>
  284. <dt><code>cleanup-modules &quot;<var>list-of-extra-modules</var>&quot;</code></dt>
  285. <dd><p>Removes Fortran module files generated for this test, excluding the
  286. module names listed in keep-modules.
  287. Cleaning up module files is usually done automatically by the testsuite
  288. by looking at the source files and removing the modules after the test
  289. has been executed.
  290. </p><div class="smallexample">
  291. <pre class="smallexample">module MoD1
  292. end module MoD1
  293. module Mod2
  294. end module Mod2
  295. module moD3
  296. end module moD3
  297. module mod4
  298. end module mod4
  299. ! { dg-final { cleanup-modules &quot;mod1 mod2&quot; } } ! redundant
  300. ! { dg-final { keep-modules &quot;mod3 mod4&quot; } }
  301. </pre></div>
  302. </dd>
  303. <dt><code>keep-modules &quot;<var>list-of-modules-not-to-delete</var>&quot;</code></dt>
  304. <dd><p>Whitespace separated list of module names that should not be deleted by
  305. cleanup-modules.
  306. If the list of modules is empty, all modules defined in this file are kept.
  307. </p><div class="smallexample">
  308. <pre class="smallexample">module maybe_unneeded
  309. end module maybe_unneeded
  310. module keep1
  311. end module keep1
  312. module keep2
  313. end module keep2
  314. ! { dg-final { keep-modules &quot;keep1 keep2&quot; } } ! just keep these two
  315. ! { dg-final { keep-modules &quot;&quot; } } ! keep all
  316. </pre></div>
  317. </dd>
  318. <dt><code>dg-keep-saved-temps &quot;<var>list-of-suffixes-not-to-delete</var>&quot;</code></dt>
  319. <dd><p>Whitespace separated list of suffixes that should not be deleted
  320. automatically in a testcase that uses <samp>-save-temps</samp>.
  321. </p><div class="smallexample">
  322. <pre class="smallexample">// { dg-options &quot;-save-temps -fpch-preprocess -I.&quot; }
  323. int main() { return 0; }
  324. // { dg-keep-saved-temps &quot;.s&quot; } ! just keep assembler file
  325. // { dg-keep-saved-temps &quot;.s&quot; &quot;.i&quot; } ! ... and .i
  326. // { dg-keep-saved-temps &quot;.ii&quot; &quot;.o&quot; } ! or just .ii and .o
  327. </pre></div>
  328. </dd>
  329. <dt><code>cleanup-profile-file</code></dt>
  330. <dd><p>Removes profiling files generated for this test.
  331. </p>
  332. </dd>
  333. </dl>
  334. <hr>
  335. <div class="header">
  336. <p>
  337. Previous: <a href="Require-Support.html#Require-Support" accesskey="p" rel="prev">Require Support</a>, Up: <a href="Test-Directives.html#Test-Directives" accesskey="u" rel="up">Test Directives</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  338. </div>
  339. </body>
  340. </html>