<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - The direction flag in the FLAGS register may be wrong in interrupt handler"
   href="https://llvm.org/bugs/show_bug.cgi?id=26406">26406</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The direction flag in the FLAGS register may be wrong in interrupt handler
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hjl.tools@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>a.bataev@hotmail.com, amjad.aboud@intel.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The x86 psABI says

The direction flag DF in the FLAGS register must be clear (set to “forward”
direction) on function entry and return. Other user flags have no specified
role in the standard calling sequence and are not preserved across calls

Since the direction flag (DF) in the FLAGS register is undetermined in
interrupt handler, the result will be wrong if DF isn't cleared:

[hjl@gnu-6 bin]$ cat /tmp/x.i
extern void *a;
extern int b;

__attribute__ ((interrupt))
void
foo (void *frame)
{
  __builtin_memset (a, b, 40);
}
[hjl@gnu-6 bin]$ ./clang -S -Os /tmp/x.i -m32 -mno-sse
[hjl@gnu-6 bin]$ cat x.s
    .text
    .file    "/tmp/x.i"
    .globl    foo
    .type    foo,@function
foo:                                    # @foo
# BB#0:                                 # %entry
    pushl    %esp
    pushl    %edx
    pushl    %ecx
    pushl    %eax
    subl    $12, %esp
    subl    $4, %esp
    pushl    $40
    pushl    b
    pushl    a
    calll    memset
    addl    $16, %esp
    addl    $12, %esp
    popl    %eax
    popl    %ecx
    popl    %edx
    popl    %esp
    iretl
.Lfunc_end0:
    .size    foo, .Lfunc_end0-foo


    .ident    "clang version 3.9.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
1f64ddbc4c5d1036b68ec896765a7535537ded85) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
43b517fe4e0a181b1cf20f36fd9eb92f7b32946c)"
    .section    ".note.GNU-stack","",@progbits
[hjl@gnu-6 bin]$ 

The current interrupt spec:

<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66960#c4">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66960#c4</a>

has

Since the direction flag in the FLAGS register in interrupt (exception)
handlers is undetermined, cld instruction must be emitted in function
prologue if rep string instructions are used in interrupt (exception)
handler or interrupt (exception) handler isn't a leaf function.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>