This function has a bug which will incorrectly reschedule instructions
after an INLINEASM_BR (which can branch). (The bug may also allow
scheduling past a throwing-CALL, I'm not certain.)
I could fix that bug, but, as the removed FIXME notes, it's better to
attempt rescheduling before converting to 3-addr form, as that may
remove the need to convert in the first place. In fact, the code to do
such reordering was added to this pass only a few months later, in
2011, via the addition of the function rescheduleMIBelowKill. That
code does not contain the same bug.
The removal of the sink3AddrInstruction function is not a no-op: in
some cases it would move an instruction post-conversion, when
rescheduleMIBelowKill would not move the instruction pre-converison.
However, this does not appear to be important: the machine instruction
scheduler can reorder the after-conversion instructions, in any case.
This patch fixes a kernel panic 4.4 LTS x86_64 Linux kernels, when
built with clang after 4b0aa5724f.
Link: https://github.com/ClangBuiltLinux/linux/issues/1085
Differential Revision: https://reviews.llvm.org/D83708
36 lines
1.1 KiB
LLVM
36 lines
1.1 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
|
|
|
|
;; Verify that the machine instructions generated from the first
|
|
;; getelementptr don't get sunk below the callbr. (Reduced from a bug
|
|
;; report.)
|
|
|
|
%struct1 = type { i8*, i32 }
|
|
|
|
define void @klist_dec_and_del(%struct1*) {
|
|
; CHECK-LABEL: klist_dec_and_del:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: leaq 8(%rdi), %rax
|
|
; CHECK-NEXT: #APP
|
|
; CHECK-NEXT: # 8(%rdi) .Ltmp0
|
|
; CHECK-NEXT: #NO_APP
|
|
; CHECK-NEXT: # %bb.2:
|
|
; CHECK-NEXT: retq
|
|
; CHECK-NEXT: .Ltmp0: # Block address taken
|
|
; CHECK-NEXT: .LBB0_1:
|
|
; CHECK-NEXT: movq $0, -8(%rax)
|
|
; CHECK-NEXT: retq
|
|
%2 = getelementptr inbounds %struct1, %struct1* %0, i64 0, i32 1
|
|
callbr void asm sideeffect "# $0 $1", "*m,X,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %2, i8* blockaddress(@klist_dec_and_del, %3))
|
|
to label %6 [label %3]
|
|
|
|
3:
|
|
%4 = getelementptr i32, i32* %2, i64 -2
|
|
%5 = bitcast i32* %4 to i8**
|
|
store i8* null, i8** %5, align 8
|
|
br label %6
|
|
|
|
6:
|
|
ret void
|
|
}
|