From 9b0df95ed22e6c747e2087b0d47f4af95f7abec5 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Mon, 3 Nov 2014 13:36:21 +0100 Subject: [PATCH] [mc] Fix the previous stack-cleaning optimisation --- tools/stack-cleaner/README | 9 +++++++-- tools/stack-cleaner/clean-stack-filter | 2 +- tools/stack-cleaner/fortran | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100755 tools/stack-cleaner/fortran diff --git a/tools/stack-cleaner/README b/tools/stack-cleaner/README index 0aa98f8f4a..3aff70a29c 100644 --- a/tools/stack-cleaner/README +++ b/tools/stack-cleaner/README @@ -3,15 +3,20 @@ Provides stack-cleaning compilers for x86_64: * as * cc * c++ + * fortran Each of them modify the generated/given X86_64 assembly by prepending stack-cleanup code to each function: + movq $0x7ffff7ff8000, %r11 + cmpq %r11, %rsp + jbe .Lstack_cleaner_done0 movq $QSIZE, %r11 -.Lloop: +.Lstack_cleaner_loop0: movq $0, OFFSET(%rsp,%r11,8) subq $1, %r11 - jne .Lloop + jne .Lstack_cleaner_loop0: +.Lstack_cleaner_done0: The modification of the assembly is done by the clean-stack-filter program. diff --git a/tools/stack-cleaner/clean-stack-filter b/tools/stack-cleaner/clean-stack-filter index fdeacfc4b0..a7c87fe117 100755 --- a/tools/stack-cleaner/clean-stack-filter +++ b/tools/stack-cleaner/clean-stack-filter @@ -28,7 +28,7 @@ sub emit_code { # the address space and the other stacks are in the hap (lower). print("\tmovq \$0x7ffff7ff8000, %r11\n"); print("\tcmpq %r11, %rsp\n"); - print("\tjle .Lstack_cleaner_done$id\n"); + print("\tjbe .Lstack_cleaner_done$id\n"); # Loop over the stack frame quadwords and zero it: print("\tmovabsq \$$qsize, %r11\n"); diff --git a/tools/stack-cleaner/fortran b/tools/stack-cleaner/fortran new file mode 100755 index 0000000000..c435b4aae9 --- /dev/null +++ b/tools/stack-cleaner/fortran @@ -0,0 +1,3 @@ +#!/bin/sh +path="$(dirname $0)" +exec "${FILTER_CC:-gfortran}" -B "$path" "$@" -- 2.20.1