Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix the previous stack-cleaning optimisation
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 3 Nov 2014 12:36:21 +0000 (13:36 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 3 Nov 2014 12:36:21 +0000 (13:36 +0100)
tools/stack-cleaner/README
tools/stack-cleaner/clean-stack-filter
tools/stack-cleaner/fortran [new file with mode: 0755]

index 0aa98f8..3aff70a 100644 (file)
@@ -3,15 +3,20 @@ Provides stack-cleaning compilers for x86_64:
  * as
  * cc
  * c++
  * as
  * cc
  * c++
+ * fortran
 
 Each of them modify the generated/given X86_64 assembly by prepending
 stack-cleanup code to each function:
 
 
 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
        movq $QSIZE, %r11
-.Lloop:
+.Lstack_cleaner_loop0:
         movq $0, OFFSET(%rsp,%r11,8)
         subq $1, %r11
         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.
 
 The modification of the assembly is done by the clean-stack-filter
 program.
index fdeacfc..a7c87fe 100755 (executable)
@@ -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");
       # 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");
 
       # 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 (executable)
index 0000000..c435b4a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+path="$(dirname $0)"
+exec "${FILTER_CC:-gfortran}" -B "$path" "$@"