Skip to content

SCEV Stack overflow during Thin-LTO link #49293

@omartijn

Description

@omartijn
Bugzilla Link 49949
Version unspecified
OS Linux
CC @dwblaikie,@erikolofsson,@smithp35,@yuanfang-chen

Extended Description

Linking a large application built as RelWithDebInfo and ThinLTO enabled leads to a stack overflow in the 12.0 RCs. This is a regression from 11.0, which works.

It eventually fails in ValueTracking.cpp, in the computeKnownBitsFromAssume function, while calling Known.getBitWidth(). I can print Known from lldb just fine, but calling the getBitWidth member function fails with an "address access protected" error. The stack trace at this point shows 13026 entries, which looks like a stack overflow.

The 25 top-most stack frames:

  • thread #​15, name = 'ld.lld', stop reason = signal SIGSEGV: address access protected (fault address: 0x7fff6a9f4fe8)
    • frame #​0: 0x000000000510da71 ld.lldcomputeKnownBitsFromAssume(V=0x00007ffe4f728c20, Known=0x00007fff6a9f7760, Depth=5, Q=0x00007fff6a9f7148)::Query const&) at ValueTracking.cpp:662:29 frame #​1: 0x00000000050f9cf6 ld.lldcomputeKnownBits(V=0x00007ffe4f728c20, DemandedElts=0x00007fff6a9f6be0, Known=0x00007fff6a9f7760, Depth=5, Q=0x00007fff6a9f7148)::Query const&) at ValueTracking.cpp:1898:3
      frame #​2: 0x00000000050f921e ld.lldcomputeKnownBits(V=0x00007ffe4f728c20, Known=0x00007fff6a9f7760, Depth=5, Q=0x00007fff6a9f7148)::Query const&) at ValueTracking.cpp:217:3 frame #​3: 0x000000000510c6a9 ld.lldcomputeKnownBitsFromOperator(I=0x00007ffe4f728b38, DemandedElts=0x00007fff6a9f79a0, Known=0x00007fff6a9f87d8, Depth=2, Q=0x00007fff6a9f8c10)::Query const&) at
      deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main
      ValueTracking.cpp:1479:9
      frame #​4: 0x00000000050f9c72 ld.lldcomputeKnownBits(V=0x00007ffe4f728b38, DemandedElts=0x00007fff6a9f79a0, Known=0x00007fff6a9f87d8, Depth=2, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:1886:5 frame #​5: 0x00000000050f921e ld.lldcomputeKnownBits(V=0x00007ffe4f728b38, Known=0x00007fff6a9f87d8, Depth=2, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:217:3
      frame #​6: 0x000000000510bab2 ld.lldcomputeKnownBitsFromOperator(I=0x00007ffe4f728c20, DemandedElts=0x00007fff6a9f8ad0, Known=0x00007fff6a9f87d8, Depth=1, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:1279:5 frame #​7: 0x00000000050f9c72 ld.lldcomputeKnownBits(V=0x00007ffe4f728c20, DemandedElts=0x00007fff6a9f8ad0, Known=0x00007fff6a9f87d8, Depth=1, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:1886:5
      frame #​8: 0x0000000005109ef1 ld.lldComputeNumSignBitsImpl(V=0x00007ffe4f728c20, DemandedElts=0x00007fff6a9f8ad0, Depth=1, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:2978:3 frame #​9: 0x0000000005108e7b ld.lldComputeNumSignBits(V=0x00007ffe4f728c20, DemandedElts=0x00007fff6a9f8ad0, Depth=1, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:2652:21
      frame #​10: 0x00000000050fbdb4 ld.lldComputeNumSignBits(V=0x00007ffe4f728c20, Depth=1, Q=0x00007fff6a9f8c10)::Query const&) at ValueTracking.cpp:389:10 frame #​11: 0x0000000005109bb1 ld.lldComputeNumSignBitsImpl(V=0x00007ffe4f728b38, DemandedElts=0x00007fff6a9f8e90, Depth=0, Q=0x00007fff6a9f8f08)::Query const&) at ValueTracking.cpp:2901:18
      frame #​12: 0x0000000005108e7b ld.lldComputeNumSignBits(V=0x00007ffe4f728b38, DemandedElts=0x00007fff6a9f8e90, Depth=0, Q=0x00007fff6a9f8f08)::Query const&) at ValueTracking.cpp:2652:21 frame #​13: 0x00000000050fbdb4 ld.lldComputeNumSignBits(V=0x00007ffe4f728b38, Depth=0, Q=0x00007fff6a9f8f08)::Query const&) at ValueTracking.cpp:389:10
      frame #​14: 0x00000000050fbcff ld.lldllvm::ComputeNumSignBits(V=0x00007ffe4f728b38, DL=0x00007fff49aafad0, Depth=0, AC=0x00007ffe4dc03958, CxtI=0x0000000000000000, DT=0x00007ffe4d49e948, UseInstrInfo=true) at ValueTracking.cpp:396:10 frame #​15: 0x0000000005020edc ld.lldllvm::ScalarEvolution::getRangeRef(this=0x00007fff49bc9d48, S=0x00007ffe531cbcb0, SignHint=HINT_RANGE_SIGNED) at ScalarEvolution.cpp:5854:21
      frame #​16: 0x0000000003e2ed61 ld.lldllvm::ScalarEvolution::getSignedRange(this=0x00007fff49bc9d48, S=0x00007ffe531cbcb0) at ScalarEvolution.h:868:12 frame #&#8203;17: 0x0000000005014e4f ld.lldStrengthenNoWrapFlags(SE=0x00007fff49bc9d48, Type=scAddExpr, Ops=const llvm::ArrayRef<const llvm::SCEV *> @ 0x00007fff6a9f9e60, Flags=FlagNUW) at ScalarEvolution.cpp:2262:34
      frame #​18: 0x0000000005013631 ld.lldllvm::ScalarEvolution::getAddExpr(this=0x00007fff6a9fa7d8, Ops=const llvm::ArrayRef<const llvm::SCEV *> @ 0x00007fff6a9f9ea0)::$_0::operator()(llvm::ArrayRef<llvm::SCEV const*>) const at ScalarEvolution.cpp:2324:12 frame #&#8203;19: 0x000000000500b015 ld.lldllvm::ScalarEvolution::getAddExpr(this=0x00007fff49bc9d48, Ops=0x00007fff6a9fa890, OrigFlags=FlagNUW, Depth=0) at ScalarEvolution.cpp:2674:34
      frame #​20: 0x00000000020c3747 ld.lldllvm::ScalarEvolution::getAddExpr(this=0x00007fff49bc9d48, LHS=0x00007ffe531cbcb0, RHS=0x00007ffe4d158920, Flags=FlagNUW, Depth=0) at ScalarEvolution.h:527:12 frame #&#8203;21: 0x00000000050153c7 ld.lldllvm::ScalarEvolution::getGEPExpr(this=0x00007fff49bc9d48, GEP=0x00007ffe4f728c20, IndexExprs=0x00007fff6a9faa08) at ScalarEvolution.cpp:3469:10
      frame #​22: 0x000000000501ebcd ld.lldllvm::ScalarEvolution::createNodeForGEP(this=0x00007fff49bc9d48, GEP=0x00007ffe4f728c20) at ScalarEvolution.cpp:5521:10 frame #&#8203;23: 0x0000000005019642 ld.lldllvm::ScalarEvolution::createSCEV(this=0x00007fff49bc9d48, V=0x00007ffe4f728c20) at ScalarEvolution.cpp:6733:12
      frame #​24: 0x00000000050154b1 ld.lld`llvm::ScalarEvolution::getSCEV(this=0x00007fff49bc9d48, V=0x00007ffe4f728c20) at ScalarEvolution.cpp:3873:9

This was build from fa0971b

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions