2017-03-28 23:41:12 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2018-04-12 00:03:07 +08:00
|
|
|
; RUN: llc -fast-isel-sink-local-values -O0 -mtriple=x86_64-unknown-linux-gnu -o - %s | FileCheck %s -check-prefix=X640
|
|
|
|
; RUN: llc -fast-isel-sink-local-values -O0 -mtriple=i686-unknown -o - %s | FileCheck %s -check-prefix=6860
|
|
|
|
; RUN: llc -fast-isel-sink-local-values -mtriple=x86_64-unknown-linux-gnu -o - %s | FileCheck %s -check-prefix=X64
|
|
|
|
; RUN: llc -fast-isel-sink-local-values -mtriple=i686-unknown -o - %s | FileCheck %s -check-prefix=686
|
2017-03-28 23:41:12 +08:00
|
|
|
|
|
|
|
@var_22 = external global i16, align 2
|
|
|
|
@var_27 = external global i16, align 2
|
|
|
|
|
|
|
|
define void @foo() {
|
|
|
|
; X640-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X640: # %bb.0: # %bb
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; X640-NEXT: movzwl var_22, %eax
|
2017-03-28 23:41:12 +08:00
|
|
|
; X640-NEXT: movzwl var_27, %ecx
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; X640-NEXT: xorl %ecx, %eax
|
|
|
|
; X640-NEXT: movzwl var_27, %ecx
|
|
|
|
; X640-NEXT: xorl %ecx, %eax
|
|
|
|
; X640-NEXT: movslq %eax, %rdx
|
|
|
|
; X640-NEXT: movq %rdx, -{{[0-9]+}}(%rsp)
|
|
|
|
; X640-NEXT: movzwl var_22, %eax
|
|
|
|
; X640-NEXT: movzwl var_27, %ecx
|
|
|
|
; X640-NEXT: xorl %ecx, %eax
|
|
|
|
; X640-NEXT: movzwl var_27, %ecx
|
|
|
|
; X640-NEXT: xorl %ecx, %eax
|
|
|
|
; X640-NEXT: movslq %eax, %rdx
|
|
|
|
; X640-NEXT: movzwl var_27, %eax
|
|
|
|
; X640-NEXT: subl $16610, %eax # imm = 0x40E2
|
|
|
|
; X640-NEXT: movl %eax, %eax
|
|
|
|
; X640-NEXT: movl %eax, %ecx
|
2018-02-01 06:04:26 +08:00
|
|
|
; X640-NEXT: # kill: def $cl killed $rcx
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; X640-NEXT: sarq %cl, %rdx
|
|
|
|
; X640-NEXT: movb %dl, %cl
|
|
|
|
; X640-NEXT: # implicit-def: $rdx
|
|
|
|
; X640-NEXT: movb %cl, (%rdx)
|
2017-03-28 23:41:12 +08:00
|
|
|
; X640-NEXT: retq
|
|
|
|
;
|
|
|
|
; 6860-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; 6860: # %bb.0: # %bb
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: pushl %ebp
|
|
|
|
; 6860-NEXT: .cfi_def_cfa_offset 8
|
|
|
|
; 6860-NEXT: .cfi_offset %ebp, -8
|
|
|
|
; 6860-NEXT: movl %esp, %ebp
|
|
|
|
; 6860-NEXT: .cfi_def_cfa_register %ebp
|
|
|
|
; 6860-NEXT: pushl %ebx
|
|
|
|
; 6860-NEXT: pushl %edi
|
|
|
|
; 6860-NEXT: pushl %esi
|
|
|
|
; 6860-NEXT: andl $-8, %esp
|
|
|
|
; 6860-NEXT: subl $32, %esp
|
|
|
|
; 6860-NEXT: .cfi_offset %esi, -20
|
|
|
|
; 6860-NEXT: .cfi_offset %edi, -16
|
|
|
|
; 6860-NEXT: .cfi_offset %ebx, -12
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; 6860-NEXT: movw var_22, %ax
|
|
|
|
; 6860-NEXT: movzwl var_27, %ecx
|
|
|
|
; 6860-NEXT: movw %cx, %dx
|
|
|
|
; 6860-NEXT: xorw %dx, %ax
|
|
|
|
; 6860-NEXT: # implicit-def: $esi
|
|
|
|
; 6860-NEXT: movw %ax, %si
|
|
|
|
; 6860-NEXT: xorl %ecx, %esi
|
|
|
|
; 6860-NEXT: movw %si, %ax
|
|
|
|
; 6860-NEXT: movzwl %ax, %ecx
|
|
|
|
; 6860-NEXT: movl %ecx, {{[0-9]+}}(%esp)
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: movl $0, {{[0-9]+}}(%esp)
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; 6860-NEXT: movw var_22, %ax
|
|
|
|
; 6860-NEXT: movzwl var_27, %ecx
|
|
|
|
; 6860-NEXT: movw %cx, %dx
|
|
|
|
; 6860-NEXT: xorw %dx, %ax
|
|
|
|
; 6860-NEXT: # implicit-def: $esi
|
|
|
|
; 6860-NEXT: movw %ax, %si
|
|
|
|
; 6860-NEXT: xorl %ecx, %esi
|
|
|
|
; 6860-NEXT: movw %si, %ax
|
|
|
|
; 6860-NEXT: movzwl %ax, %esi
|
|
|
|
; 6860-NEXT: addl $-16610, %ecx # imm = 0xBF1E
|
|
|
|
; 6860-NEXT: movb %cl, %bl
|
|
|
|
; 6860-NEXT: xorl %ecx, %ecx
|
2018-04-25 06:35:27 +08:00
|
|
|
; 6860-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: movb %bl, %cl
|
2018-04-25 06:35:27 +08:00
|
|
|
; 6860-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; 6860-NEXT: shrdl %cl, %edi, %esi
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: testb $32, %bl
|
2018-04-25 06:35:27 +08:00
|
|
|
; 6860-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
|
2018-11-07 14:57:03 +08:00
|
|
|
; 6860-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: jne .LBB0_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; 6860-NEXT: # %bb.1: # %bb
|
2018-04-25 06:35:27 +08:00
|
|
|
; 6860-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
|
|
|
|
; 6860-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: .LBB0_2: # %bb
|
2018-04-25 06:35:27 +08:00
|
|
|
; 6860-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: movb %al, %cl
|
[FastISel] Sink local value materializations to first use
Summary:
Local values are constants, global addresses, and stack addresses that
can't be folded into the instruction that uses them. For example, when
storing the address of a global variable into memory, we need to
materialize that address into a register.
FastISel doesn't want to materialize any given local value more than
once, so it generates all local value materialization code at
EmitStartPt, which always dominates the current insertion point. This
allows it to maintain a map of local value registers, and it knows that
the local value area will always dominate the current insertion point.
The downside is that local value instructions are always emitted without
a source location. This is done to prevent jumpy line tables, but it
means that the local value area will be considered part of the previous
statement. Consider this C code:
call1(); // line 1
++global; // line 2
++global; // line 3
call2(&global, &local); // line 4
Today we end up with assembly and line tables like this:
.loc 1 1
callq call1
leaq global(%rip), %rdi
leaq local(%rsp), %rsi
.loc 1 2
addq $1, global(%rip)
.loc 1 3
addq $1, global(%rip)
.loc 1 4
callq call2
The LEA instructions in the local value area have no source location and
are treated as being on line 1. Stepping through the code in a debugger
and correlating it with the assembly won't make much sense, because
these materializations are only required for line 4.
This is actually problematic for the VS debugger "set next statement"
feature, which effectively assumes that there are no registers live
across statement boundaries. By sinking the local value code into the
statement and fixing up the source location, we can make that feature
work. This was filed as https://bugs.llvm.org/show_bug.cgi?id=35975 and
https://crbug.com/793819.
This change is obviously not enough to make this feature work reliably
in all cases, but I felt that it was worth doing anyway because it
usually generates smaller, more comprehensible -O0 code. I measured a
0.12% regression in code generation time with LLC on the sqlite3
amalgamation, so I think this is worth doing.
There are some special cases worth calling out in the commit message:
1. local values materialized for phis
2. local values used by no-op casts
3. dead local value code
Local values can be materialized for phis, and this does not show up as
a vreg use in MachineRegisterInfo. In this case, if there are no other
uses, this patch sinks the value to the first terminator, EH label, or
the end of the BB if nothing else exists.
Local values may also be used by no-op casts, which adds the register to
the RegFixups table. Without reversing the RegFixups map direction, we
don't have enough information to sink these instructions.
Lastly, if the local value register has no other uses, we can delete it.
This comes up when fastisel tries two instruction selection approaches
and the first materializes the value but fails and the second succeeds
without using the local value.
Reviewers: aprantl, dblaikie, qcolombet, MatzeB, vsk, echristo
Subscribers: dotdash, chandlerc, hans, sdardis, amccarth, javed.absar, zturner, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D43093
llvm-svn: 327581
2018-03-15 05:54:21 +08:00
|
|
|
; 6860-NEXT: # implicit-def: $eax
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: movb %cl, (%eax)
|
|
|
|
; 6860-NEXT: leal -12(%ebp), %esp
|
|
|
|
; 6860-NEXT: popl %esi
|
|
|
|
; 6860-NEXT: popl %edi
|
|
|
|
; 6860-NEXT: popl %ebx
|
|
|
|
; 6860-NEXT: popl %ebp
|
2018-04-24 18:32:08 +08:00
|
|
|
; 6860-NEXT: .cfi_def_cfa %esp, 4
|
2017-03-28 23:41:12 +08:00
|
|
|
; 6860-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0: # %bb
|
[X86FixupBWInsts] More precise register liveness if no <imp-use> on MOVs.
Summary:
Subregister liveness tracking is not implemented for X86 backend, so
sometimes the whole super register is said to be live, when only a
subregister is really live. That might happen if the def and the use
are located in different MBBs, see added fixup-bw-isnt.mir test.
However, using knowledge of the specific instructions handled by the
bw-fixup-pass we can get more precise liveness information which this
change does.
Reviewers: MatzeB, DavidKreitzer, ab, andrew.w.kaylor, craig.topper
Reviewed By: craig.topper
Subscribers: n.bozhenov, myatsina, llvm-commits, hiraditya
Patch by Andrei Elovikov <andrei.elovikov@intel.com>
Differential Revision: https://reviews.llvm.org/D37559
llvm-svn: 313524
2017-09-18 18:17:59 +08:00
|
|
|
; X64-NEXT: movzwl {{.*}}(%rip), %eax
|
2018-04-25 06:35:27 +08:00
|
|
|
; X64-NEXT: movzwl {{.*}}(%rip), %ecx
|
|
|
|
; X64-NEXT: movl %ecx, %edx
|
|
|
|
; X64-NEXT: xorl %edx, %edx
|
|
|
|
; X64-NEXT: xorl %eax, %edx
|
|
|
|
; X64-NEXT: movzwl %dx, %eax
|
2017-03-28 23:41:12 +08:00
|
|
|
; X64-NEXT: movq %rax, -{{[0-9]+}}(%rsp)
|
|
|
|
; X64-NEXT: addl $-16610, %ecx # imm = 0xBF1E
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $cl killed $cl killed $ecx
|
2017-03-28 23:41:12 +08:00
|
|
|
; X64-NEXT: shrq %cl, %rax
|
|
|
|
; X64-NEXT: movb %al, (%rax)
|
|
|
|
; X64-NEXT: retq
|
|
|
|
;
|
|
|
|
; 686-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; 686: # %bb.0: # %bb
|
2017-03-28 23:41:12 +08:00
|
|
|
; 686-NEXT: pushl %ebp
|
|
|
|
; 686-NEXT: .cfi_def_cfa_offset 8
|
|
|
|
; 686-NEXT: .cfi_offset %ebp, -8
|
|
|
|
; 686-NEXT: movl %esp, %ebp
|
|
|
|
; 686-NEXT: .cfi_def_cfa_register %ebp
|
|
|
|
; 686-NEXT: andl $-8, %esp
|
|
|
|
; 686-NEXT: subl $8, %esp
|
[X86FixupBWInsts] More precise register liveness if no <imp-use> on MOVs.
Summary:
Subregister liveness tracking is not implemented for X86 backend, so
sometimes the whole super register is said to be live, when only a
subregister is really live. That might happen if the def and the use
are located in different MBBs, see added fixup-bw-isnt.mir test.
However, using knowledge of the specific instructions handled by the
bw-fixup-pass we can get more precise liveness information which this
change does.
Reviewers: MatzeB, DavidKreitzer, ab, andrew.w.kaylor, craig.topper
Reviewed By: craig.topper
Subscribers: n.bozhenov, myatsina, llvm-commits, hiraditya
Patch by Andrei Elovikov <andrei.elovikov@intel.com>
Differential Revision: https://reviews.llvm.org/D37559
llvm-svn: 313524
2017-09-18 18:17:59 +08:00
|
|
|
; 686-NEXT: movzwl var_22, %eax
|
2018-04-25 06:35:27 +08:00
|
|
|
; 686-NEXT: movzwl var_27, %ecx
|
|
|
|
; 686-NEXT: movl %ecx, %edx
|
|
|
|
; 686-NEXT: xorl %ecx, %edx
|
|
|
|
; 686-NEXT: xorl %eax, %edx
|
|
|
|
; 686-NEXT: movzwl %dx, %eax
|
2017-03-28 23:41:12 +08:00
|
|
|
; 686-NEXT: movl %eax, (%esp)
|
|
|
|
; 686-NEXT: movl $0, {{[0-9]+}}(%esp)
|
|
|
|
; 686-NEXT: addl $-16610, %ecx # imm = 0xBF1E
|
|
|
|
; 686-NEXT: xorl %edx, %edx
|
|
|
|
; 686-NEXT: shrdl %cl, %edx, %eax
|
|
|
|
; 686-NEXT: testb $32, %cl
|
|
|
|
; 686-NEXT: jne .LBB0_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; 686-NEXT: # %bb.1: # %bb
|
2017-03-28 23:41:12 +08:00
|
|
|
; 686-NEXT: movl %eax, %edx
|
|
|
|
; 686-NEXT: .LBB0_2: # %bb
|
|
|
|
; 686-NEXT: movb %dl, (%eax)
|
|
|
|
; 686-NEXT: movl %ebp, %esp
|
|
|
|
; 686-NEXT: popl %ebp
|
2018-04-24 18:32:08 +08:00
|
|
|
; 686-NEXT: .cfi_def_cfa %esp, 4
|
2017-03-28 23:41:12 +08:00
|
|
|
; 686-NEXT: retl
|
|
|
|
bb:
|
|
|
|
%tmp = alloca i64, align 8
|
|
|
|
%tmp1 = load i16, i16* @var_22, align 2
|
|
|
|
%tmp2 = zext i16 %tmp1 to i32
|
|
|
|
%tmp3 = load i16, i16* @var_27, align 2
|
|
|
|
%tmp4 = zext i16 %tmp3 to i32
|
|
|
|
%tmp5 = xor i32 %tmp2, %tmp4
|
|
|
|
%tmp6 = load i16, i16* @var_27, align 2
|
|
|
|
%tmp7 = zext i16 %tmp6 to i32
|
|
|
|
%tmp8 = xor i32 %tmp5, %tmp7
|
|
|
|
%tmp9 = sext i32 %tmp8 to i64
|
|
|
|
store i64 %tmp9, i64* %tmp, align 8
|
|
|
|
%tmp10 = load i16, i16* @var_22, align 2
|
|
|
|
%tmp11 = zext i16 %tmp10 to i32
|
|
|
|
%tmp12 = load i16, i16* @var_27, align 2
|
|
|
|
%tmp13 = zext i16 %tmp12 to i32
|
|
|
|
%tmp14 = xor i32 %tmp11, %tmp13
|
|
|
|
%tmp15 = load i16, i16* @var_27, align 2
|
|
|
|
%tmp16 = zext i16 %tmp15 to i32
|
|
|
|
%tmp17 = xor i32 %tmp14, %tmp16
|
|
|
|
%tmp18 = sext i32 %tmp17 to i64
|
|
|
|
%tmp19 = load i16, i16* @var_27, align 2
|
|
|
|
%tmp20 = zext i16 %tmp19 to i32
|
|
|
|
%tmp21 = sub nsw i32 %tmp20, 16610
|
|
|
|
%tmp22 = zext i32 %tmp21 to i64
|
|
|
|
%tmp23 = ashr i64 %tmp18, %tmp22
|
|
|
|
%tmp24 = trunc i64 %tmp23 to i8
|
|
|
|
store i8 %tmp24, i8* undef, align 1
|
|
|
|
ret void
|
|
|
|
}
|