[LLVMbugs] [Bug 24193] New: Shrink wrapping creates invalid epilogue for Win64 binaries

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 20 15:22:32 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24193

            Bug ID: 24193
           Summary: Shrink wrapping creates invalid epilogue for Win64
                    binaries
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I retargetted this test case from x86-shrink-wrapping.ll:

$ cat test.ll
; ModuleID = '<stdin>'
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "x86_64-windows-gnu"

; Function Attrs: uwtable
define i32 @loopInfoSaveOutsideLoop(i32 %cond, i32 %N) #0 {
entry:
  %tobool = icmp eq i32 %cond, 0
  br i1 %tobool, label %if.else, label %for.preheader

for.preheader:                                    ; preds = %entry
  tail call void asm "nop", ""()
  br label %for.body

for.body:                                         ; preds = %for.body,
%for.preheader
  %i.05 = phi i32 [ %inc, %for.body ], [ 0, %for.preheader ]
  %sum.04 = phi i32 [ %add, %for.body ], [ 0, %for.preheader ]
  %call = tail call i32 asm "movl $$1, $0", "=r,~{ebx}"()
  %add = add nsw i32 %call, %sum.04
  %inc = add nuw nsw i32 %i.05, 1
  %exitcond = icmp eq i32 %inc, 10
  br i1 %exitcond, label %for.end, label %for.body

for.end:                                          ; preds = %for.body
  tail call void asm "nop", "~{ebx}"()
  %shl = shl i32 %add, 3
  br label %if.end

if.else:                                          ; preds = %entry
  %mul = shl nsw i32 %N, 1
  br label %if.end

if.end:                                           ; preds = %if.else, %for.end
  %sum.1 = phi i32 [ %shl, %for.end ], [ %mul, %if.else ]
  ret i32 %sum.1
}

attributes #0 = { uwtable }

It produces an epilogue with a register-to-register move after starting to pop
CSRs, which is illegal:

$ llc -enable-shrink-wrap=true test.ll -o - | grep -A4 popq
        popq    %rbx
        movl    %esi, %eax  ; <-- not allowed by win64 epilogue rules
        retq
.LBB0_4:                                # %if.else
        addl    %esi, %esi

We might want to try to make the win64 epilogue more generally resilient to
other MI passes in order to fix this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150720/98df80a8/attachment.html>


More information about the llvm-bugs mailing list