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

Verifier error if unwinding used in same module as _Unwind_Resume definition with debug info #57469

Closed
nikic opened this issue Aug 31, 2022 · 7 comments · Fixed by llvm/llvm-project-release-prs#141

Comments

@nikic
Copy link
Contributor

nikic commented Aug 31, 2022

; RUN: opt -S -mtriple=x86_64-linux-gnu -dwarfehprepare < %s
define void @_Unwind_Resume(ptr %ptr) !dbg !4 {
  ret void, !dbg !11
}

declare i32 @__gxx_personality_v0(...)
declare void @might_throw()

define void @simple_cleanup_catch() personality ptr @__gxx_personality_v0 !dbg !12 {
  invoke void @might_throw()
          to label %exit unwind label %landingpad, !dbg !15

exit:
  ret void

landingpad:
  %ex = landingpad { ptr, i32 }
      cleanup
  resume { ptr, i32 } %ex
}

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3}

!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 16.0.0 (https://github.com/llvm/llvm-project.git a4c8fb9d1f46f30c66a9ca0dd07c7933f338bb34)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "/app/example.c", directory: "/app")
!2 = !{i32 7, !"Dwarf Version", i32 4}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "_Unwind_Resume", scope: !5, file: !5, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !9)
!5 = !DIFile(filename: "example.c", directory: "/app")
!6 = !DISubroutineType(types: !7)
!7 = !{null, !8}
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
!9 = !{!10}
!10 = !DILocalVariable(name: "exception", arg: 1, scope: !4, file: !5, line: 1, type: !8)
!11 = !DILocation(line: 2, column: 1, scope: !4)
!12 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !13, scopeLine: 4, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
!13 = !DISubroutineType(types: !14)
!14 = !{null}
!15 = !DILocation(line: 6, column: 1, scope: !12)

Results in the following verifier error for the inserted _Unwind_Resume call:

inlinable function call in a function with debug info must have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0
@llvmbot
Copy link
Member

llvmbot commented Aug 31, 2022

@llvm/issue-subscribers-debuginfo

@nikic
Copy link
Contributor Author

nikic commented Aug 31, 2022

What's the right way to fix this? Inlining is clearly not relevant at this point in the pipeline, so should the call just get assigned some kind of dummy debug loc?

@jmorse
Copy link
Member

jmorse commented Aug 31, 2022

What's the right way to fix this? Inlining is clearly not relevant at this point in the pipeline, so should the call just get assigned some kind of dummy debug loc?

I think you're correct, a dummy debug loc is the solution, by creating a DILocation in the functions scope with line number zero. There's precedent here:

// Calls must always have a debug location, or else inlining breaks. So
where SafeStack similarly creates a dummy location. Line zero explicitly signifies "this location was created by the compiler and doesn't mean anything".

@nikic
Copy link
Contributor Author

nikic commented Sep 1, 2022

Candidate patch: https://reviews.llvm.org/D133095

@nikic nikic self-assigned this Sep 1, 2022
@nikic nikic closed this as completed in 5134bd4 Sep 1, 2022
@nikic nikic added this to the LLVM 15.0.1 Release milestone Sep 1, 2022
@nikic nikic moved this to Needs Triage in LLVM Release Status Sep 1, 2022
@nikic
Copy link
Contributor Author

nikic commented Sep 1, 2022

/cherry-pick 5134bd4

@nikic nikic reopened this Sep 1, 2022
@llvmbot
Copy link
Member

llvmbot commented Sep 1, 2022

/branch llvm/llvm-project-release-prs/issue57469

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Sep 1, 2022
…ume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

Fixes llvm/llvm-project#57469.

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

(cherry picked from commit 5134bd4)
@llvmbot
Copy link
Member

llvmbot commented Sep 1, 2022

/pull-request llvm/llvm-project-release-prs#141

@nikic nikic moved this from Needs Triage to Needs Review in LLVM Release Status Sep 1, 2022
nikic added a commit to rust-lang/llvm-project that referenced this issue Sep 2, 2022
…ume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

Fixes llvm#57469.

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

(cherry picked from commit 5134bd4)
@tru tru moved this from Needs Review to Needs Merge in LLVM Release Status Sep 9, 2022
tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Sep 12, 2022
…ume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

Fixes llvm/llvm-project#57469.

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

(cherry picked from commit 5134bd4)
@tru tru moved this from Needs Merge to Done in LLVM Release Status Sep 12, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
…ume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

Fixes llvm/llvm-project#57469.

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

(cherry picked from commit 5134bd432f8c35c87f4c4dc3bb744d396adcab58)
sunfishcode added a commit to sunfishcode/llvm-project that referenced this issue Aug 21, 2024
…d_Resume calls

Similar to the fix for llvm#57469, ensure that the other `_Unwind_Resume` call
emitted by DwarfEHPrepare has a debug location if needed.

This fixes nbdd0121/unwinding#34.
sunfishcode added a commit that referenced this issue Aug 22, 2024
…d_Resume calls (#105513)

Similar to the fix for #57469, ensure that the other `_Unwind_Resume`
call emitted by DwarfEHPrepare has a debug location if needed.

This fixes nbdd0121/unwinding#34.
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Aug 23, 2024
…d_Resume calls (llvm#105513)

Similar to the fix for llvm#57469, ensure that the other `_Unwind_Resume`
call emitted by DwarfEHPrepare has a debug location if needed.

This fixes nbdd0121/unwinding#34.

(cherry picked from commit e76db25)
cjdb pushed a commit to cjdb/llvm-project that referenced this issue Aug 23, 2024
…d_Resume calls (llvm#105513)

Similar to the fix for llvm#57469, ensure that the other `_Unwind_Resume`
call emitted by DwarfEHPrepare has a debug location if needed.

This fixes nbdd0121/unwinding#34.
tru pushed a commit to llvmbot/llvm-project that referenced this issue Aug 26, 2024
…d_Resume calls (llvm#105513)

Similar to the fix for llvm#57469, ensure that the other `_Unwind_Resume`
call emitted by DwarfEHPrepare has a debug location if needed.

This fixes nbdd0121/unwinding#34.

(cherry picked from commit e76db25)
dmpolukhin pushed a commit to dmpolukhin/llvm-project that referenced this issue Sep 2, 2024
…d_Resume calls (llvm#105513)

Similar to the fix for llvm#57469, ensure that the other `_Unwind_Resume`
call emitted by DwarfEHPrepare has a debug location if needed.

This fixes nbdd0121/unwinding#34.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants