Mercurial > projects > ldc
annotate revisions.pl.in @ 1117:4c20fcc4252b
Fun with parameter attributes: For several of the "synthetic" parameters added
to D functions, we can apply noalias and nocapture. They are sret parameters,
'nest' pointers passed to nested functions, and _argptr:
Nocapture:
- Sret and nest are nocapture because they don't represent D-level variables,
and thus the callee can't (validly) obtain a pointer to them, let alone keep
it around after it returns.
- _argptr is nocapture because although the callee has access to it as a
pointer, that pointer is invalidated when it returns.
All three are noalias because they're function-local variables
- Sret and _argptr are noalias because they're freshly alloca'd memory only
used for a single function call that's not allowed to keep an aliasing
pointer to it around (since the parameter is nocapture).
- 'Nest' is noalias because the callee only ever has access to one such pointer
per parent function, and every parent function has a different one.
This commit also ensures attributes set on sret, _arguments and _argptr are
propagated to calls to such functions.
It also adds one exception to the general rule that attributes on function types
should propagate to calls: the type of a delegate's function pointer has a
'nest' parameter, but this can either be a true 'nest' (for delegates to nested
functions) or a 'this' (for delegates to member functions). Since 'this' is
neither noalias nor nocapture, and there's generally no way to tell which one it
is, we remove these attributes at the call site if the callee is a delegate.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 14 Mar 2009 22:15:31 +0100 |
parents | 123812e02bc8 |
children | 165a920f4e88 |
rev | line source |
---|---|
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
2 |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
3 use strict; |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
4 use warnings; |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
5 use File::stat; |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
6 use Time::localtime; |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
7 |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
8 my $llvm_src = `perl @LLVM_CONFIG@ --src-root`; |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
9 |
1112
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
10 my $svn_info = `svn info $llvm_src 2>/dev/null`; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
11 |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
12 my $extra_includes = ""; |
1064
f0b6549055ab
Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents:
972
diff
changeset
|
13 my $llvm_rev_str; |
f0b6549055ab
Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents:
972
diff
changeset
|
14 my $llvm_rev_nr; |
1112
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
15 my $llvm_date = ""; |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
16 |
1112
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
17 if ($svn_info =~ /^URL:.*\/trunk\s*$/m && $svn_info =~ /^Last Changed Rev:\s*(\d+)\s*/m) { |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
18 $llvm_rev_str = qq!"LLVM trunk rev. $1"!; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
19 $llvm_rev_nr = $1; |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
20 } else { |
1112
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
21 # Either non-trunk or 'svn info' didn't report "Last Changed Rev". |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
22 $extra_includes = qq!#include "llvm/Config/config.h"!; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
23 $llvm_rev_str = "PACKAGE_STRING"; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
24 # Assume latest release, so < any version we should be testing for. |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
25 $llvm_rev_nr = 0; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
26 } |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
27 |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
28 # Use SVN date even if non-trunk: |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
29 if ($svn_info =~ /^Last Changed Date: ([^(]*?)\s*(\(|$)/m) { |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
30 $llvm_date = qq!" ($1)"!; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
31 } else { |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
32 # Otherwise, try to get it from the libdir |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
33 my $llvm_lib = `perl @LLVM_CONFIG@ --libdir`; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
34 $llvm_lib =~ s/\s+$//; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
35 if (-d $llvm_lib) { |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
36 my $mod_time = ctime(stat($llvm_lib)->mtime); |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
37 $llvm_date = qq!" ($mod_time)"!; |
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
38 } |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
39 } |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
40 |
972
d66ab756c75b
Change the way the version is printed (more verbose, with short hash)
Frits van Bommel <fvbommel wxs.nl>
parents:
873
diff
changeset
|
41 my $ldc_rev = `hg -R@PROJECT_SOURCE_DIR@ log -r qparent --template '{rev}:{node|short} ({date|isodate})' 2>/dev/null || hg -R@PROJECT_SOURCE_DIR@ tip --template '{rev}:{node|short} ({date|isodate})'`; |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
42 |
873
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
43 my $out = qq!#ifndef LDC_VERSIONS_H |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
44 #define LDC_VERSIONS_H |
1112
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
45 $extra_includes |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
46 |
1064
f0b6549055ab
Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents:
972
diff
changeset
|
47 // LLVM version string, for use in -version output |
1112
829ac3f30103
Updating revisions.pl.in:
Frits van Bommel <fvbommel wxs.nl>
parents:
1065
diff
changeset
|
48 #define LLVM_REV_STR $llvm_rev_str$llvm_date |
1064
f0b6549055ab
Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents:
972
diff
changeset
|
49 // LDC version string, for use in -version output |
972
d66ab756c75b
Change the way the version is printed (more verbose, with short hash)
Frits van Bommel <fvbommel wxs.nl>
parents:
873
diff
changeset
|
50 #define LDC_REV "rev. $ldc_rev" |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
51 |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
52 #endif // LDC_VERSIONS_H\n!; |
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
diff
changeset
|
53 |
873
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
54 my $revh; |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
55 my $old = ""; |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
56 open $revh, "revisions.h" and $old = join "", <$revh>; |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
57 |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
58 if ($old ne $out) { |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
59 open $revh, ">revisions.h" or die "cannot create revisions.h: $!"; |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
60 print $revh $out; |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
61 close $revh; |
a331ce9bc749
fix unnecessary revisions.h regeneration and mars.c recompilation
elrood
parents:
853
diff
changeset
|
62 } |
1113
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
63 |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
64 $out = qq!#ifndef LDC_LLVM_VERSION_H |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
65 #define LDC_LLVM_VERSION_H |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
66 |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
67 // LLVM svn revision number, used to adapt to changes in LLVM |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
68 // (Is 0 if LLVM is not an SVN trunk version) |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
69 #define LLVM_REV $llvm_rev_nr |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
70 |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
71 #endif // LDC_LLVM_VERSION_H\n!; |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
72 |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
73 $old = ""; |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
74 open $revh, "llvm-version.h" and $old = join "", <$revh>; |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
75 |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
76 if ($old ne $out) { |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
77 open $revh, ">llvm-version.h" or die "cannot create llvm-version.h: $!"; |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
78 print $revh $out; |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
79 close $revh; |
123812e02bc8
Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents:
1112
diff
changeset
|
80 } |