Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.4 x86_64 defconfig panic at boot #1085

Closed
nathanchance opened this issue Jul 8, 2020 · 23 comments
Closed

4.4 x86_64 defconfig panic at boot #1085

nathanchance opened this issue Jul 8, 2020 · 23 comments
Assignees
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 asm goto related to the implementation of asm goto [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) [FIXED][LLVM] 11 This bug was fixed in LLVM 11.0 [FIXED][LLVM] 12 This bug was fixed in LLVM 12.0

Comments

@nathanchance
Copy link
Member

According to bisect, this is due to the asm goto rework that happened in llvm/llvm-project@4b0aa57.

Panic can be viewed here: https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/358738630

I have not done any triage beyond the bisect.

@nathanchance nathanchance added [BUG] Untriaged Something isn't working [ARCH] x86_64 This bug impacts ARCH=x86_64 labels Jul 8, 2020
@nathanchance
Copy link
Member Author

$ git bisect log
# bad: [054704082b461418d3dac3a379792cdaf52d40b3] [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.
# good: [983a4b520ea384ac978cbfc40bb956fbb98cd735] Skip arm-(fp|gp)-read.test on Darwin.
git bisect start 'origin/master~255' 'origin/master~750'
# bad: [3d12e79094d2d3cb3d7e16dc16a456e1ec25ac1b] [NewPM][LSR] Rename strength-reduce -> loop-reduce
git bisect bad 3d12e79094d2d3cb3d7e16dc16a456e1ec25ac1b
# bad: [565e37c7702d181804c12d36b6010c513c9b3417] [Coroutines] Fix code coverage for coroutine
git bisect bad 565e37c7702d181804c12d36b6010c513c9b3417
# good: [76b2d9cbebd227d42e2099a0eb89c800b945997a] [AMDGPU] Correct AMDGPUUsage.rst DW_AT_LLVM_lane_pc example
git bisect good 76b2d9cbebd227d42e2099a0eb89c800b945997a
# good: [e35a5876e4c7f67211dd600a3006bede2ccab25c] Revert "[StackSafety,NFC] Remove unneded constexpr"
git bisect good e35a5876e4c7f67211dd600a3006bede2ccab25c
# good: [a61fa1a4b9d247e34ea5541422f7040a37baf6e7] Revert "[RISCV] Temporarily move riscv-expand-pseudo pass to PreEmitPass2"
git bisect good a61fa1a4b9d247e34ea5541422f7040a37baf6e7
# good: [6bd1db08e7ccd61996d3867d22ff8eb1979f8621] [InstCombine] Don't let an alignment assume prevent new/delete removals.
git bisect good 6bd1db08e7ccd61996d3867d22ff8eb1979f8621
# good: [78c69a00a4cff786e0ef13c895d0db309d6b3f42] [NFC] Clean up uses of MachineModuleInfoWrapperPass
git bisect good 78c69a00a4cff786e0ef13c895d0db309d6b3f42
# bad: [3eacfdc72f1aa3ac53eb300116f194d560053ec7] [BPF] Fix a BTF gen bug related to a pointer struct member
git bisect bad 3eacfdc72f1aa3ac53eb300116f194d560053ec7
# bad: [4b0aa5724feaa89a9538dcab97e018110b0e4bc3] Change the INLINEASM_BR MachineInstr to be a non-terminating instruction.
git bisect bad 4b0aa5724feaa89a9538dcab97e018110b0e4bc3
# first bad commit: [4b0aa5724feaa89a9538dcab97e018110b0e4bc3] Change the INLINEASM_BR MachineInstr to be a non-terminating instruction.

$ cat /tmp/tmp.RVgV5ipJWl.sh
#!/usr/bin/env bash

set -x

"${HOME}"/cbl/github/tc-build/build-llvm.py \
    --assertions \
    --build-stage1-only \
    --no-update \
    --projects "clang;lld" \
    --targets X86 || exit 125

PATH=${HOME}/cbl/github/tc-build/build/llvm/stage1/bin:${PATH} \
    make \
    -C "${HOME}"/src/linux-stable \
    -skj"$(nproc)" \
    CC=clang \
    LD=ld.lld \
    O=out/x86_64 \
    distclean defconfig bzImage || exit 125

"${HOME}"/cbl/github/boot-utils/boot-qemu.sh \
    -a x86_64 \
    -k "${HOME}"/src/linux-stable/out/x86_64 \
    -t 30s

In case anyone needs to reproduce.

@nickdesaulniers nickdesaulniers self-assigned this Jul 8, 2020
@nickdesaulniers
Copy link
Member

I'm having trouble reproducing.

  • llvm-project: 158feabde4cb98021469ed4126682d8ee57456eb
  • linux-stable (4.4.229): 480787e

I also tried removing -smp $(nproc) from boot-qemu.sh to no avail.

Though I'm doing make LLVM=1 -j71 to build. Ah, that's it. Ok, I'm able to repro now...

@bwendling
Copy link

My immediate thought is that we forgot a situation where code is being moved past an INLINEASM_BR.

@nickdesaulniers
Copy link
Member

Let's compare disassembly of object files before and after that suspected llvm commit.

$ diff -u <(objdump -d ../78c69a0_llvm/drivers/char/agp/amd64-agp.o ) <(objdump -d ../tot_llvm/drivers/char/agp/amd64-agp.o )
<no change>
$ diff -u <(objdump -d ../78c69a0_llvm/lib/klist.o ) <(objdump -d ../tot_llvm/lib/klist.o )
<big change in klist_dec_and_del and klist_next>

Checking the ir:

$ make CC=clang LD=ld.lld O=../78c69a0_llvm -j71 lib/klist.ll

There's only one callbr:

define internal fastcc i32 @klist_dec_and_del(%struct.klist_node* %0) unnamed_addr #1 {                                                                                                                                                                             
  %2 = getelementptr inbounds %struct.klist_node, %struct.klist_node* %0, i64 0, i32 2                                                                                                                                                                              
  %3 = getelementptr inbounds %struct.kref, %struct.kref* %2, i64 0, i32 0, i32 0                                                                                                                                                                                   
  callbr void asm sideeffect ".pushsection .smp_locks,\22a\22\0A.balign 4\0A.long 671f - .\0A.popsection\0A671:\0A\09lock; subl $1, $0; je ${2:l}", "*m,er,X,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %3, i32 1, i8* blockaddress(@klist_dec_and_del, %5)) #6    
738           to label %4 [label %5], !srcloc !13

so that's kind of our smoking gun, since @klist_dec_and_del is also in our stack trace.

".pushsection .smp_locks,\22a\22\0A.balign 4\0A.long 671f - .\0A.popsection\0A671:\0A\09lock; subl $1, $0; je ${2:l}"

might be a hint at which struct static_key this is.

@nickdesaulniers nickdesaulniers added the asm goto related to the implementation of asm goto label Jul 9, 2020
@nickdesaulniers
Copy link
Member

call chain looks something like:
agp_amd64_init -> pci_unregister_driver -> driver_unregister -> bus_remove_driver -> klist_remove-> ??? -> klist_dec_and_del -> kref_put -> kref_sub -> atomic_sub_and_test -> GEN_BINARY_RMWcc -> __GEN_RMWcc -> asm goto and je <cond>.

@nickdesaulniers
Copy link
Member

I'm extracting the IR for klist_dec_and_del to compare good vs bad callbr placement.

@nickdesaulniers
Copy link
Member

Seems there's no difference between IR?

$ make CC=clang LD=ld.lld O=../tot_llvm -j71 lib/klist.ll
$ llvm-extract --func=klist_dec_and_del lib/klist.ll -o=klist_dec_and_del.bc
$ llvm-dis klist_dec_and_del.bc
<same for 78c69a00a4cff786e0ef13c895d0db309d6b3f42>
$ diff -u <(cat ../78c69a0_llvm/klist_dec_and_del.ll) <(cat ../tot_llvm/klist_dec_and_del.ll)
<no difference>

does that imply a difference in lowering? ie. MachineBasicBlock placement or such, if the IRs match but the disassembly does not? Maybe I should dump+compare the .s files. Will do so tomorrow. Likely PEBKAC anyways.

@bwendling
Copy link

Yes. I think this is a code-gen bug, not an optimization bug.

@bwendling
Copy link

I looked at klist.s before and after the change and there aren't any significant differences.

        .globl  klist_init              # -- Begin funct   |            .globl  klist_init                      # -- Beg
.Lklist_init$local:                                        <
        .globl  klist_add_head          # -- Begin funct   |            .globl  klist_add_head                  # -- Beg
.Lklist_add_head$local:                                    <
        .globl  klist_add_tail          # -- Begin funct   |            .globl  klist_add_tail                  # -- Beg
.Lklist_add_tail$local:                                    <
        .globl  klist_add_behind        # -- Begin funct   |            .globl  klist_add_behind                # -- Beg
.Lklist_add_behind$local:                                  <
        .globl  klist_add_before        # -- Begin funct   |            .globl  klist_add_before                # -- Beg
.Lklist_add_before$local:                                  <
        .globl  klist_del               # -- Begin funct   |            .globl  klist_del                       # -- Beg
.Lklist_del$local:                                         <
        jmp     __x86_indirect_thunk_r11 # TAILCALL        |            jmp     __x86_indirect_thunk_r11        # TAILCA
        .globl  klist_remove            # -- Begin funct   |            .globl  klist_remove                    # -- Beg
.Lklist_remove$local:                                      <
        .globl  klist_node_attached     # -- Begin funct   |            .globl  klist_node_attached             # -- Beg
.Lklist_node_attached$local:                               <
        .globl  klist_iter_init_node    # -- Begin funct   |            .globl  klist_iter_init_node            # -- Beg
.Lklist_iter_init_node$local:                              <
        .globl  klist_iter_init         # -- Begin funct   |            .globl  klist_iter_init                 # -- Beg
.Lklist_iter_init$local:                                   <
        .globl  klist_iter_exit         # -- Begin funct   |            .globl  klist_iter_exit                 # -- Beg
.Lklist_iter_exit$local:                                   <
        .globl  klist_prev              # -- Begin funct   |            .globl  klist_prev                      # -- Beg
.Lklist_prev$local:                                        <
        .p2align        4, 0x90         # -- Begin funct   |            .p2align        4, 0x90                         
        movabsq $-2401263026318606080, %r14 # imm = 0xDE   |            movabsq $-2401263026318606080, %r14     # imm = 
        .globl  klist_next              # -- Begin funct   |            .globl  klist_next                      # -- Beg
.Lklist_next$local:                                        <
        .type   klist_remove_lock,@object # @klist_remov   |            .type   klist_remove_lock,@object       # @klist
        .type   klist_remove_waiters,@object # @klist_re   |            .type   klist_remove_waiters,@object    # @klist
        .type   .L.str,@object          # @.str            |            .type   .L.str,@object                  # @.str
        .ident  "clang version google3-trunk (992fbce4e9   |            .ident  "clang version 11.0.0 (https://github.co

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jul 9, 2020

@gwelymernans , I think you're holding it wrong. 🔥 It looks like you might be comparing before/after Fangrui's change involving local labels? I'm comparing 78c69a00a4cff786e0ef13c895d0db309d6b3f42 vs 158feabde4cb98021469ed4126682d8ee57456eb (which, admittedly, could be narrower).

$ make CC=clang LD=ld.lld O=../78c69a0_llvm -j71 lib/klist.s
<same for ToT LLVM>
$ diff -u <(cat ../78c69a0_llvm/lib/klist.s ) <(cat ../tot_llvm/lib/klist.s )
@@ -615,7 +615,8 @@
 671:
        lock; subl $1, 24(%rdi); je .Ltmp0
        #NO_APP
-.LBB12_1:
+       leaq    24(%rdi), %rbx
+# %bb.1:
        #APP
        #NO_APP
        xorl    %eax, %eax
@@ -629,12 +630,10 @@
        retq
 .Ltmp0:                                 # Block address taken
 .LBB12_2:
-       movq    %rdi, %rbx
-       addq    $24, %rbx
        testb   $1, -24(%rbx)
        je      .LBB12_3
 .LBB12_4:

So before, the inline asm from asm goto, if we took the je (jump if equal) branch, then we don't load 24(%rdi) into %rbx correctly. Instead, we do so in the fallthrough case, which proceeds on to the function epilog leaving %rbx unused.

Ok, now let me dump the output from llc -O2 <ir.ll> for both and diff that to see what pass do they start to diverge.

@nickdesaulniers
Copy link
Member

$ llc -O2 lib/klist.ll -print-after-all -o /dev/null &> klist.txt
<same for both versions of LLVM>
$ diff -u <(cat ../78c69a0_llvm/klist.txt ) <(cat ../tot_llvm/klist.txt)
...
<first hunk in the diff is (ignoring many srcloc differences)>
@@ -74602,6 +74602,7 @@
   successors: %bb.1(0x80000000), %bb.2(0x00000000); %bb.1(100.00%), %bb.2(0.00%)
   liveins: $rdi
   %7:gr64 = COPY $rdi
+  %0:gr64 = nuw ADD64ri8 %7:gr64(tied-def 0), 24, implicit-def dead $eflags
   INLINEASM_BR &".pushsection .smp_locks,\22a\22\0A.balign 4\0A.long 671f - .\0A.popsection\0A671:\0A\09lock; subl $1, $0; je ${2:l}" [sideeffect] [mayload] [maystore] [attdialect], $0:[mem:m], %7:gr64, 1, $noreg, 24, $noreg, $1:[imm], 1, $2:[imm], blockaddress(@klist_dec_and_del, %ir-block.5), $3:[clobber], implicit-def early-clobber $df, $4:[clobber], implicit-def early-clobber $fpsw, $5:[clobber], implicit-def early-clobber $eflags, !13
   JMP_1 %bb.1

so looking around L74602 in either file for the pass (vim ../tot_llvm/klist.txt +74602):

74597 # *** IR Dump After Machine code sinking ***:                                                                                                                                                                                                                     
74598 # Machine code for function klist_dec_and_del: IsSSA, TracksLiveness                                                                                                                                                                                              
74599 Function Live Ins: $rdi in %7                                                                                                                                                                                                                                     
74600                                                                                                                                                                                                                                                                   
74601 bb.0 (%ir-block.1):                                                                                                                                                                                                                                               
74602   successors: %bb.1(0x80000000), %bb.2(0x00000000); %bb.1(100.00%), %bb.2(0.00%)                                                                                                                                                                                  
74603   liveins: $rdi                                                                                                                                                                                                                                                   
74604   %7:gr64 = COPY $rdi                                                                                                                                                                                                                                             
74605   %0:gr64 = nuw ADD64ri8 %7:gr64(tied-def 0), 24, implicit-def dead $eflags                                                                                                                                                                                       
74606   INLINEASM_BR &".pushsection .smp_locks,\22a\22\0A.balign 4\0A.long 671f - .\0A.popsection\0A671:\0A\09lock; subl $1, $0; je ${2:l}" [sideeffect] [mayload] [maystore] [attdialect], $0:[mem:m], %7:gr64, 1, $noreg, 24, $noreg, $1:[imm], 1, $2:[imm], blockaddr      ess(@klist_dec_and_del, %ir-block.5), $3:[clobber], implicit-def early-clobber $df, $4:[clobber], implicit-def early-clobber $fpsw, $5:[clobber], implicit-def early-clobber $eflags, !13                                                                         
74607   JMP_1 %bb.1

So looks like "Machine code sinking" is the first source of divergence.

FWIW, in 78c69a0, this code looks like:

74597 # *** IR Dump After Machine code sinking ***:                                                                                                                                                                                                                     
74598 # Machine code for function klist_dec_and_del: IsSSA, TracksLiveness                                                                                                                                                                                              
74599 Function Live Ins: $rdi in %7                                                                                                                                                                                                                                     
74600                                                                                                                                                                                                                                                                   
74601 bb.0 (%ir-block.1):                                                                                                                                                                                                                                               
74602   successors: %bb.1(0x80000000), %bb.2(0x00000000); %bb.1(100.00%), %bb.2(0.00%)                                                                                                                                                                                  
74603   liveins: $rdi                                                                                                                                                                                                                                                   
74604   %7:gr64 = COPY $rdi                                                                                                                                                                                                                                             
74605   INLINEASM_BR &".pushsection .smp_locks,\22a\22\0A.balign 4\0A.long 671f - .\0A.popsection\0A671:\0A\09lock; subl $1, $0; je ${2:l}" [sideeffect] [mayload] [maystore] [attdialect], $0:[mem:m], %7:gr64, 1, $noreg, 24, $noreg, $1:[imm], 1, $2:[imm], blockaddr      ess(@klist_dec_and_del, %ir-block.5), $3:[clobber], implicit-def early-clobber $df, $4:[clobber], implicit-def early-clobber $fpsw, $5:[clobber], implicit-def early-clobber $eflags, !13

@nickdesaulniers
Copy link
Member

Let me rerun this with a tighter range of LLVM SHA's (just before and after @jyknight 's change). I worry that I might be conflating other changes to LLVM. Sorry.

@nickdesaulniers
Copy link
Member

Using 4b0aa5724fea (just @jyknight 's change) instead of ToT LLVM, I get the same results.

Ok, now let's see if I can reduce the IR in order to get us a test case that we can commit to LLVM with a fix.

@bwendling
Copy link

@gwelymernans , I think you're holding it wrong. 🔥

Very possible! :-)

Nice reduction. It looks like INLINEASM_BR needs to be a barrier to hoisting/sinking in more places.

@bwendling
Copy link

Should we mark INLINEASM_BR as "isBarrier" in include/llvm/Target/Target.td?

@nickdesaulniers
Copy link
Member

I tried

diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td
index aab5376db453..7ec6db9fc4f3 100644
--- a/llvm/include/llvm/Target/Target.td
+++ b/llvm/include/llvm/Target/Target.td
@@ -1021,6 +1021,7 @@ def INLINEASM_BR : StandardPseudoInstruction {
   let hasSideEffects = 1;
   // Despite potentially branching, this instruction is intentionally _not_
   // marked as a terminator or a branch.
+  let isBarrier = 1;
 }
 def CFI_INSTRUCTION : StandardPseudoInstruction {
   let OutOperandList = (outs);

with a quick boot test (not looking at the output), but it failed in the same way. 😞

@nickdesaulniers
Copy link
Member

ToT llvm-reduce was crashing for me, so used bugpoint.

#!/usr/bin/env sh
OUT=$(llc -O2 $1 -print-after=machine-sink -stop-after=machine-sink -o /dev/null  2>&1)
echo "$OUT" | grep -FB1 'INLINEASM_BR &".pushsection .smp_locks,\22a\22\0A.balign 4\0A.long 671f - .\0A.popsection\0A671:\0A\09lock; subl $1, $0; je ${2:l}" [sideeffect] [mayload] [maystore] [attdialect], $0:[mem:m], %7:gr64, 1, $noreg, 24, $noreg, $1:[imm], 1, $2:[imm], blockaddress(@klist_dec_and_del, %ir-block.5), $3:[clobber], implicit-def early-clobber $df, $4:[clobber], implicit-def early-clobber $fpsw, $5:[clobber], implicit-def early-clobber $eflags, !13' | \
  not grep -F '%0:gr64 = nuw ADD64ri8 %7:gr64(tied-def 0), 24, implicit-def dead $eflags'

# interesting.sh

so "grep for the lone INLINEASM_BR then look back one line for that ADD64ri8."

$ bugpoint -compile-custom -compile-command=./interesting.sh lib/klist.ll
$ llvm-dis bugpoint-reduced-simplified.bc
$ wc -l lib/klist.ll bugpoint-reduced-simplified.ll 
   954 lib/klist.ll
   354 bugpoint-reduced-simplified.ll

I've run that repeatedly through llvm-extract, llvm-reduce, and bugpoint some more for good measure, but can't get the reproducer down below 228 lines. Let me gnaw on this jaw breaker some more.

@nickdesaulniers
Copy link
Member

Making copies of llc in either cases was a better idea for an interesting test that worked better:

#!/usr/bin/env bash
GOOD=$(llc-good -O2 $1 -print-after=machine-sink -stop-after=machine-sink -o /dev/null  2>&1)
BAD=$(llc-bad -O2 $1 -print-after=machine-sink -stop-after=machine-sink -o /dev/null  2>&1)
diff -u <( echo "$GOOD" ) <( echo "$BAD" ) | \
  grep -B1 "INLINEASM_BR" | \
  not grep "ADD64ri8"
$ bugpoint -compile-custom -compile-command=./interesting.sh lib/klist.ll
$ llvm-dis bugpoint-reduced-simplified.bc -o bugpoint-reduced-simplified.ll
$ llvm-reduce --test=interesting.sh bugpoint-reduced-simplified.ll -o reduced.ll

then I manually cleaned up the types and output a little.

$ wc -l reduced.ll                                                                
25 reduced.ll

I've verified my test case passes for 78c69a00a4cf (before latest asm goto change) and fails after. I'll see if I can just fix machine sink, tomorrow.

@nickdesaulniers
Copy link
Member

If I remove the diff added in llvm/lib/CodeGen/MachineSink.cpp in https://reviews.llvm.org/D79794, test passes, all llvm tests pass, 4.4 x86 kernel boots. 😉 cc @jyknight .
https://reviews.llvm.org/D83523

@nickdesaulniers nickdesaulniers added [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) [PATCH] Submitted A patch has been submitted for review and removed [BUG] Untriaged Something isn't working labels Jul 10, 2020
@nickdesaulniers
Copy link
Member

@jyknight made a further fix that I think is preferable: https://reviews.llvm.org/D83708.

jyknight added a commit to llvm/llvm-project that referenced this issue Jul 16, 2020
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 4b0aa57.

Link: ClangBuiltLinux/linux#1085

Differential Revision: https://reviews.llvm.org/D83708
@nickdesaulniers nickdesaulniers added [FIXED][LLVM] 12 This bug was fixed in LLVM 12.0 and removed [PATCH] Submitted A patch has been submitted for review labels Jul 17, 2020
@nickdesaulniers nickdesaulniers added the Needs Backport Should be backported to either linux-stable tree or latest llvm release branch. label Jul 17, 2020
@dileks
Copy link
Collaborator

dileks commented Jul 17, 2020

Good to pick this llvm/llvm-project@60433c6 up for release/11.x?

jyknight added a commit to llvm/llvm-project that referenced this issue Jul 17, 2020
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 4b0aa57.

Link: ClangBuiltLinux/linux#1085

Differential Revision: https://reviews.llvm.org/D83708

(cherry picked from commit 60433c6)
@nickdesaulniers nickdesaulniers added [FIXED][LLVM] 11 This bug was fixed in LLVM 11.0 and removed Needs Backport Should be backported to either linux-stable tree or latest llvm release branch. labels Jul 17, 2020
@nickdesaulniers
Copy link
Member

Just noting that this also appears to fix a regression reporting internally for ppc64 in mm/memcontrol.c.

@dileks
Copy link
Collaborator

dileks commented Jul 18, 2020

Great news, it's in release/11.x :-).

arichardson pushed a commit to arichardson/llvm-project that referenced this issue Mar 21, 2021
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 4b0aa57.

Link: ClangBuiltLinux/linux#1085

Differential Revision: https://reviews.llvm.org/D83708
ajohnson-uoregon pushed a commit to ajohnson-uoregon/clang-rewrite-only that referenced this issue Jul 17, 2022
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 d80e429.

Link: ClangBuiltLinux/linux#1085

Differential Revision: https://reviews.llvm.org/D83708

(cherry picked from commit 3eec260)
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
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 4b0aa5724feaa89a9538dcab97e018110b0e4bc3.

Link: ClangBuiltLinux/linux#1085

Differential Revision: https://reviews.llvm.org/D83708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 asm goto related to the implementation of asm goto [BUG] llvm (main) A bug in an unreleased version of LLVM (this label is appropriate for regressions) [FIXED][LLVM] 11 This bug was fixed in LLVM 11.0 [FIXED][LLVM] 12 This bug was fixed in LLVM 12.0
Projects
None yet
Development

No branches or pull requests

5 participants