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

LLVM ERROR: sleb128 and uleb128 expressions must be absolute #64826

Closed
jroelofs opened this issue Aug 19, 2023 · 2 comments · Fixed by #94004
Closed

LLVM ERROR: sleb128 and uleb128 expressions must be absolute #64826

jroelofs opened this issue Aug 19, 2023 · 2 comments · Fixed by #94004
Labels
llvm:SelectionDAG SelectionDAGISel as well regression

Comments

@jroelofs
Copy link
Contributor

$ cat <<EOF > rdar113994760.ll
source_filename = "rdar113994760.ll"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx"

define swiftcc void @"$s4main11call_foobaryyF"() personality ptr @__gcc_personality_v0 {
entry:
  %swifterror = alloca swifterror ptr, align 8
  invoke swiftcc void null(i64 0, ptr null, ptr swifterror %swifterror)
          to label %.noexc unwind label %tsan_cleanup

.noexc:                                           ; preds = %entry
  ret void

tsan_cleanup:                                     ; preds = %entry
  %cleanup.lpad = landingpad { ptr, i32 }
          cleanup
  resume { ptr, i32 } zeroinitializer
}

declare i32 @__gcc_personality_v0(...)

EOF
$ ./build/bin/llc rdar113994760.ll -filetype=obj -o out
LLVM ERROR: sleb128 and uleb128 expressions must be absolute
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./build/bin/llc rdar113994760.ll -filetype=obj -o out
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  llc                      0x0000000105f11d60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  llc                      0x0000000105f12134 SignalHandler(int) + 188
2  libsystem_platform.dylib 0x00000001a87e1a84 _sigtramp + 56
3  libsystem_pthread.dylib  0x00000001a87b2c28 pthread_kill + 288
4  libsystem_c.dylib        0x00000001a86c1b28 abort + 180
5  llc                      0x0000000105e98e48 llvm::report_fatal_error(llvm::Twine const&, bool) + 328
6  llc                      0x0000000105e98d00 llvm::report_fatal_error(llvm::Twine const&, bool) + 0
7  llc                      0x0000000105a79690 llvm::MCAssembler::relaxBoundaryAlign(llvm::MCAsmLayout&, llvm::MCBoundaryAlignFragment&) + 0
8  llc                      0x0000000105a79d64 llvm::MCAssembler::layoutSectionOnce(llvm::MCAsmLayout&, llvm::MCSection&) + 72
9  llc                      0x0000000105a78ecc llvm::MCAssembler::layoutOnce(llvm::MCAsmLayout&) + 112
10 llc                      0x0000000105a78a88 llvm::MCAssembler::layout(llvm::MCAsmLayout&) + 404
11 llc                      0x0000000105a78ffc llvm::MCAssembler::Finish() + 64
12 llc                      0x0000000105a976a8 (anonymous namespace)::MCMachOStreamer::finishImpl() + 644
13 llc                      0x000000010554014c llvm::AsmPrinter::doFinalization(llvm::Module&) + 3232
14 llc                      0x00000001059fe330 llvm::FPPassManager::doFinalization(llvm::Module&) + 76
15 llc                      0x00000001059fa568 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 960
16 llc                      0x0000000104d2d6e8 main + 6100
17 dyld                     0x00000001a8457f28 start + 2236
Abort trap: 6

rdar://113994760

This regression happened sometime between clang-15 and clang-16. Bisection points at 648ce3d:

commit 648ce3d358560c0f60340fcf28ad2563d213eca2
Author: James Y Knight <jyknight@google.com>
Date:   Fri Jan 6 13:26:03 2023 -0500

    Cleanup unwind table emission code a bit.
    
    This change removes the `tidyLandingPads` function, which previously
    had a few responsibilities:
    
    1. Dealing with the deletion of an invoke, after MachineFunction lowering.
    2. Dealing with the deletion of a landing pad BB, after MachineFunction lowering.
    3. Cleaning up the type-id list generated by `MachineFunction::addLandingPad`.
    
    Case 3 has been fixed in the generator, and the others are now handled
    during table emission.
    
    This change also removes `MachineFunction`'s `addCatchTypeInfo`,
    `addFilterTypeInfo`, and `addCleanup` helper fns, as they had a single
    caller, and being outlined didn't make it simpler.
    
    Finally, as calling `tidyLandingPads` was effectively the only thing
    `DwarfCFIExceptionBase` did, that class has been eliminated.

jroelofs referenced this issue Aug 19, 2023
This change removes the `tidyLandingPads` function, which previously
had a few responsibilities:

1. Dealing with the deletion of an invoke, after MachineFunction lowering.
2. Dealing with the deletion of a landing pad BB, after MachineFunction lowering.
3. Cleaning up the type-id list generated by `MachineFunction::addLandingPad`.

Case 3 has been fixed in the generator, and the others are now handled
during table emission.

This change also removes `MachineFunction`'s `addCatchTypeInfo`,
`addFilterTypeInfo`, and `addCleanup` helper fns, as they had a single
caller, and being outlined didn't make it simpler.

Finally, as calling `tidyLandingPads` was effectively the only thing
`DwarfCFIExceptionBase` did, that class has been eliminated.
@MaskRay
Copy link
Member

MaskRay commented Aug 19, 2023

llc -mtriple=x86_64-apple-macosx rdar113994760.ll (default -filetype=asm) suggests that Ltmp1 is not defined, therefore the subtraction in .uleb128 Ltmp1-Ltmp0 cannot be folded to a constant, leading to this assembler error.

@EugeneZelenko EugeneZelenko added mc Machine (object) code and removed new issue labels Aug 19, 2023
@MaskRay MaskRay added llvm:codegen and removed mc Machine (object) code labels Aug 19, 2023
@jyknight
Copy link
Member

(Note, I'm mostly unavailable this week.)

From a glance, looks like SelectionDAGBuilder::lowerInvokable isn't updating Result.second after the call to lowerEndEH, which results in the SwiftErrorVal-handling code in SelectionDAGBuilder::LowerCallTo to reset the DAG root, thus forgetting to include the EH_LABEL DAG node it was supposed to have added.

It doesn't look like I changed that, so I dunno why it broke only from my change.

jroelofs added a commit to swiftlang/llvm-project that referenced this issue Aug 25, 2023
jroelofs added a commit to swiftlang/llvm-project that referenced this issue Aug 25, 2023
bnbarham pushed a commit to bnbarham/llvm-project that referenced this issue May 20, 2024
This reverts commit 648ce3d.

rdar://113994760
llvm#64826
(cherry picked from commit 1c7f71c)
jroelofs added a commit to jroelofs/llvm-project that referenced this issue May 31, 2024
lowerInvokeable wasn't updating the returned chain after emitting the
lowerEndEH, which caused SwiftErrorVal-handling code to re-set the DAG root,
and thus accidentally skip the EH_LABEL node it was supposed to have addeed.
After fixing that, a few places needed to be adjusted that assume the specific
shape of the returned DAG.

Fixes: llvm#64826
Fixes: rdar://113994760
bnbarham pushed a commit to swiftlang/llvm-project that referenced this issue Jun 5, 2024
This reverts commit 648ce3d.

rdar://113994760
llvm#64826
(cherry picked from commit 1c7f71c)
jroelofs added a commit that referenced this issue Jun 14, 2024
…60 (#94004)

lowerInvokeable wasn't updating the returned chain after emitting the
lowerEndEH, which caused SwiftErrorVal-handling code to re-set the DAG
root, and thus accidentally skip the EH_LABEL node it was supposed to
have addeed. After fixing that, a few places needed to be adjusted that
assume the specific shape of the returned DAG.

Fixes: #64826
Fixes: rdar://113994760
@EugeneZelenko EugeneZelenko added llvm:SelectionDAG SelectionDAGISel as well and removed llvm:codegen labels Jun 14, 2024
EthanLuisMcDonough pushed a commit to EthanLuisMcDonough/llvm-project that referenced this issue Aug 13, 2024
…60 (llvm#94004)

lowerInvokeable wasn't updating the returned chain after emitting the
lowerEndEH, which caused SwiftErrorVal-handling code to re-set the DAG
root, and thus accidentally skip the EH_LABEL node it was supposed to
have addeed. After fixing that, a few places needed to be adjusted that
assume the specific shape of the returned DAG.

Fixes: llvm#64826
Fixes: rdar://113994760
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:SelectionDAG SelectionDAGISel as well regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants