Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

need store motion for partial dead stores #5192

Open Quuxplusone opened 15 years ago

Quuxplusone commented 15 years ago
Bugzilla Link PR4679
Status NEW
Importance P normal
Reported by Evan Phoenix (evan@fallingsnow.net)
Reported on 2009-08-03 19:06:13 -0700
Last modified on 2009-08-14 13:54:27 -0700
Version trunk
Hardware PC MacOS X
CC clattner@nondot.org, devang.patel@gmail.com, llvm-bugs@lists.llvm.org, llvm@sunfishcode.online
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Give the following IR and x86:

[[[ LLVM Optimized IR: bleh ]]]

define %"struct.rubinius::Object"* @0(%"struct.rubinius::VM"* %state,
%"struct.rubinius::CallFrame"* %previous, %"struct.rubinius::Dispatch"* %msg,
%"struct.rubinius::Arguments"* %args) {
entry:
    %cfstk94 = alloca [9 x %"struct.rubinius::Object"*], align 4        ; <[9 x
%"struct.rubinius::Object"*]*> [#uses=8]
    %var_mem93 = alloca [5 x %"struct.rubinius::Object"*], align 4      ; <[5 x
%"struct.rubinius::Object"*]*> [#uses=6]
    %cfstk94.sub = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32
0, i32 0        ; <%"struct.rubinius::Object"**> [#uses=1]
    %var_mem93.sub = getelementptr [5 x %"struct.rubinius::Object"*]* %var_mem93,
i32 0, i32 0        ; <%"struct.rubinius::Object"**> [#uses=1]
    %stack = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32 0, i32
8       ; <%"struct.rubinius::Object"**> [#uses=1]
    %0 = getelementptr %"struct.rubinius::Dispatch"* %msg, i32 0, i32 2     ;
<%"struct.rubinius::Executable"**> [#uses=1]
    %msg.exec = load %"struct.rubinius::Executable"** %0        ;
<%"struct.rubinius::Executable"*> [#uses=1]
    %1 = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32 0, i32
3       ; <%"struct.rubinius::Object"**> [#uses=1]
    %previous.c = bitcast %"struct.rubinius::CallFrame"* %previous to
%"struct.rubinius::Object"*     ; <%"struct.rubinius::Object"*> [#uses=1]
    store %"struct.rubinius::Object"* %previous.c, %"struct.rubinius::Object"**
%cfstk94.sub
    %2 = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32 0, i32
2       ; <%"struct.rubinius::Object"**> [#uses=1]
    %msg.c = bitcast %"struct.rubinius::Dispatch"* %msg to
%"struct.rubinius::Object"*     ; <%"struct.rubinius::Object"*> [#uses=1]
    store %"struct.rubinius::Object"* %msg.c, %"struct.rubinius::Object"** %2
    %cm.c = getelementptr %"struct.rubinius::Executable"* %msg.exec, i32 0, i32
0       ; <%"struct.rubinius::Object"*> [#uses=1]
    store %"struct.rubinius::Object"* %cm.c, %"struct.rubinius::Object"** %1
    %3 = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32 0, i32
4       ; <%"struct.rubinius::Object"**> [#uses=1]
    store %"struct.rubinius::Object"* inttoptr (i32 16 to
%"struct.rubinius::Object"*), %"struct.rubinius::Object"** %3
    %4 = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32 0, i32
5       ; <%"struct.rubinius::Object"**> [#uses=1]
    %5 = getelementptr [9 x %"struct.rubinius::Object"*]* %cfstk94, i32 0, i32
7       ; <%"struct.rubinius::Object"**> [#uses=1]
    %vars.c = bitcast [5 x %"struct.rubinius::Object"*]* %var_mem93 to
%"struct.rubinius::Object"*     ; <%"struct.rubinius::Object"*> [#uses=1]
    store %"struct.rubinius::Object"* %vars.c, %"struct.rubinius::Object"** %5
    store %"struct.rubinius::Object"* null, %"struct.rubinius::Object"**
%var_mem93.sub
    %6 = getelementptr %"struct.rubinius::Arguments"* %args, i32 0, i32 0       ;
<%"struct.rubinius::Object"**> [#uses=1]
    %args.recv = load %"struct.rubinius::Object"** %6       ;
<%"struct.rubinius::Object"*> [#uses=3]
    %7 = getelementptr [5 x %"struct.rubinius::Object"*]* %var_mem93, i32 0, i32
2       ; <%"struct.rubinius::Object"**> [#uses=1]
    store %"struct.rubinius::Object"* %args.recv, %"struct.rubinius::Object"** %7
    %8 = getelementptr %"struct.rubinius::Dispatch"* %msg, i32 0, i32 1     ;
<%"struct.rubinius::Module"**> [#uses=1]
    %msg.module = load %"struct.rubinius::Module"** %8      ;
<%"struct.rubinius::Module"*> [#uses=1]
    %9 = getelementptr [5 x %"struct.rubinius::Object"*]* %var_mem93, i32 0, i32
4       ; <%"struct.rubinius::Object"**> [#uses=1]
    %msg.module.c = getelementptr %"struct.rubinius::Module"* %msg.module, i32 0,
i32 0       ; <%"struct.rubinius::Object"*> [#uses=1]
    store %"struct.rubinius::Object"* %msg.module.c, %"struct.rubinius::Object"**
%9
    %10 = getelementptr %"struct.rubinius::Arguments"* %args, i32 0, i32 1      ;
<%"struct.rubinius::Object"**> [#uses=1]
    %args.block = load %"struct.rubinius::Object"** %10     ;
<%"struct.rubinius::Object"*> [#uses=1]
    %11 = getelementptr [5 x %"struct.rubinius::Object"*]* %var_mem93, i32 0, i32
3       ; <%"struct.rubinius::Object"**> [#uses=1]
    store %"struct.rubinius::Object"* %args.block, %"struct.rubinius::Object"** %11
    %12 = getelementptr [5 x %"struct.rubinius::Object"*]* %var_mem93, i32 0, i32
1       ; <%"struct.rubinius::Object"**> [#uses=1]
    store %"struct.rubinius::Object"* null, %"struct.rubinius::Object"** %12
    store %"struct.rubinius::Object"* %args.recv, %"struct.rubinius::Object"**
%stack
    store %"struct.rubinius::Object"* inttoptr (i32 2 to
%"struct.rubinius::Object"*), %"struct.rubinius::Object"** %4
    %class_pos = getelementptr %"struct.rubinius::Object"* %args.recv, i32 0, i32
0, i32 1        ; <%"struct.rubinius::Class"**> [#uses=1]
    %ref_class = load %"struct.rubinius::Class"** %class_pos        ;
<%"struct.rubinius::Class"*> [#uses=1]
    %class_id_pos = getelementptr %"struct.rubinius::Class"* %ref_class, i32 0,
i32 3       ; <i32*> [#uses=1]
    %class_id = load i32* %class_id_pos     ; <i32> [#uses=1]
    %check_class_id = icmp eq i32 %class_id, 1076       ; <i1> [#uses=1]
    br i1 %check_class_id, label %correct_class, label %use_send

correct_class:      ; preds = %entry
    ret %"struct.rubinius::Object"* inttoptr (i32 23 to
%"struct.rubinius::Object"*)

use_send:       ; preds = %entry
    %call_frame = bitcast [9 x %"struct.rubinius::Object"*]* %cfstk94 to
%"struct.rubinius::CallFrame"*      ; <%"struct.rubinius::CallFrame"*> [#uses=1]
    %13 = call %"struct.rubinius::Object"*
@rbx_continue_uncommon(%"struct.rubinius::VM"* %state,
%"struct.rubinius::CallFrame"* %call_frame, %"struct.rubinius::Arguments"*
%args, i32 0)       ; <%"struct.rubinius::Object"*> [#uses=1]
    ret %"struct.rubinius::Object"* %13
}

[[[ JIT Machine Code ]]]
 0x26b1010  sub $0x4c, %esp
 0x26b1013  mov 0x58(%esp), %eax
 0x26b1017  mov 0x8(%eax), %ecx
 0x26b101a  mov 0x54(%esp), %edx
 0x26b101e  mov %edx, 0x28(%esp)
 0x26b1022  mov %eax, 0x30(%esp)
 0x26b1026  mov %ecx, 0x34(%esp)
 0x26b102a  mov $0x10, 0x38(%esp)
 0x26b1032  lea 0x14(%esp), %ecx
 0x26b1036  mov %ecx, 0x44(%esp)
 0x26b103a  mov $0x0, 0x14(%esp)
 0x26b1042  mov 0x5c(%esp), %ecx
 0x26b1046  mov (%ecx), %edx
 0x26b1048  mov %edx, 0x1c(%esp)
 0x26b104c  mov 0x4(%eax), %eax
 0x26b104f  mov %eax, 0x24(%esp)
 0x26b1053  mov 0x4(%ecx), %eax
 0x26b1056  mov %eax, 0x20(%esp)
 0x26b105a  mov $0x0, 0x18(%esp)
 0x26b1062  mov %edx, 0x48(%esp)
 0x26b1066  mov $0x2, 0x3c(%esp)
 0x26b106e  mov 0x4(%edx), %eax
 0x26b1071  cmp $0x434, 0x24(%eax)
 0x26b1078  jnz 0x77                 ; 0x26b1087
 0x26b107e  mov $0x17, %eax
 0x26b1083  add $0x4c, %esp
 0x26b1086  ret
 0x26b1087  mov 0x50(%esp), %eax
 0x26b108b  mov %ecx, 0x8(%esp)
 0x26b108f  lea 0x28(%esp), %ecx
 0x26b1093  mov %ecx, 0x4(%esp)
 0x26b1097  mov %eax, (%esp)
 0x26b109a  mov $0x0, 0xc(%esp)
 0x26b10a2  call 0xfffffffffda6c5c0  ; 0x11d5d0 rbx_continue_uncommon
 0x26b10a7  add $0x4c, %esp
 0x26b10aa  ret

The vast majority of those mov instructions before 0x26b106e could be sunk to
around 0x26b1087, as their values are unused in the terminating branch starting
on 0x26b107e.

Is there a construct in here that is preventing sinking? Is the sinker not
working correctly? Please advise.
Quuxplusone commented 15 years ago

Your example is all wrapped up in gunk, please attach as a .ll file. If you want stores to allocas to be sunk, then we need to do this at the IR level, this would be partial DSE.