view 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
line wrap: on
line source

#!/usr/bin/perl

use strict;
use warnings;
use File::stat;
use Time::localtime;

my $llvm_src = `perl @LLVM_CONFIG@ --src-root`;

my $svn_info = `svn info $llvm_src 2>/dev/null`;

my $extra_includes = "";
my $llvm_rev_str;
my $llvm_rev_nr;
my $llvm_date = "";

if ($svn_info =~ /^URL:.*\/trunk\s*$/m && $svn_info =~ /^Last Changed Rev:\s*(\d+)\s*/m) {
    $llvm_rev_str = qq!"LLVM trunk rev. $1"!;
    $llvm_rev_nr = $1;
} else {
    # Either non-trunk or 'svn info' didn't report "Last Changed Rev".
    $extra_includes = qq!#include "llvm/Config/config.h"!;
    $llvm_rev_str = "PACKAGE_STRING";
    # Assume latest release, so < any version we should be testing for.
    $llvm_rev_nr = 0;
}

# Use SVN date even if non-trunk:
if ($svn_info =~ /^Last Changed Date: ([^(]*?)\s*(\(|$)/m) {
    $llvm_date = qq!" ($1)"!;
} else {
    # Otherwise, try to get it from the libdir
    my $llvm_lib = `perl @LLVM_CONFIG@ --libdir`;
    $llvm_lib =~ s/\s+$//;
    if (-d $llvm_lib) {
        my $mod_time = ctime(stat($llvm_lib)->mtime);
        $llvm_date = qq!" ($mod_time)"!;
    }
}

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})'`;

my $out = qq!#ifndef LDC_VERSIONS_H
#define LDC_VERSIONS_H
$extra_includes

// LLVM version string, for use in -version output
#define LLVM_REV_STR $llvm_rev_str$llvm_date
// LDC version string, for use in -version output
#define LDC_REV "rev. $ldc_rev"

#endif // LDC_VERSIONS_H\n!;

my $revh;
my $old = "";
open $revh, "revisions.h" and $old = join "", <$revh>;

if ($old ne $out) {
	open $revh, ">revisions.h" or die "cannot create revisions.h: $!";
	print $revh $out;
	close $revh;
}

$out = qq!#ifndef LDC_LLVM_VERSION_H
#define LDC_LLVM_VERSION_H

// LLVM svn revision number, used to adapt to changes in LLVM
// (Is 0 if LLVM is not an SVN trunk version)
#define LLVM_REV $llvm_rev_nr

#endif // LDC_LLVM_VERSION_H\n!;

$old = "";
open $revh, "llvm-version.h" and $old = join "", <$revh>;

if ($old ne $out) {
	open $revh, ">llvm-version.h" or die "cannot create llvm-version.h: $!";
	print $revh $out;
	close $revh;
}