Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Last active November 19, 2015 01:30
Show Gist options
  • Save alexcrichton/ce1a275616a0eefdab36 to your computer and use it in GitHub Desktop.
Save alexcrichton/ce1a275616a0eefdab36 to your computer and use it in GitHub Desktop.
target triple = "x86_64-pc-windows-msvc"
%TY = type { i8*, i64, i64 }
declare i32 @__C_specific_handler(...)
declare void @f1(%TY*)
declare void @f2()
declare void @f3(i64*)
define void @main() personality i32 (...)* @__C_specific_handler !dbg !1 {
entry-block:
%0 = alloca %TY
call void @f1(%TY* %0)
invoke void @f2()
to label %normal unwind label %bad
normal:
ret void
bad:
%cleanuppad = cleanuppad []
call void @f4(%TY* %0)
cleanupret %cleanuppad unwind to caller
}
define void @f4(%TY*) {
entry-block:
%1 = getelementptr %TY, %TY* %0, i64 0, i32 1, !dbg !7
call void @f3(i64* %1)
ret void
}
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DISubprogram(name: "main", linkageName: "_ZN19backtrace_debuginfo4mainE", scope: !3, file: !2, line: 1, type: !4, isLocal: true, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, templateParams: !6, variables: !6)
!2 = !DIFile(filename: "src/test/run-pass/backtrace-debuginfo.rs", directory: "C:\5Cmsys64\5Chome\5Cale\5Crust3")
!3 = !DINamespace(name: "backtrace_debuginfo", scope: null)
!4 = !DISubroutineType(types: !5)
!5 = !{null}
!6 = !{}
!7 = !DILocation(line: 467, scope: !8)
!8 = distinct !DILexicalBlock(scope: !10, file: !9, line: 465, column: 23)
!9 = !DIFile(filename: "src/liballoc\5Craw_vec.rs", directory: "C:\5Cmsys64\5Chome\5Cale\5Crust3")
!10 = distinct !DISubprogram(name: "drop", linkageName: "_ZN19backtrace_debuginfo7raw_vec14RawVec<T>.Drop4dropE", scope: !11, file: !9, line: 465, type: !13, isLocal: true, isDefinition: true, scopeLine: 465, flags: DIFlagPrototyped, isOptimized: false, templateParams: !6, variables: !6)
!11 = !DINamespace(name: "RawVec<T>.Drop", scope: !12)
!12 = !DINamespace(name: "raw_vec", scope: !3)
!13 = !DISubroutineType(types: !14)
!14 = !{null, !15}
!15 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&mut alloc::raw_vec::RawVec<u8>", baseType: !"{struct 0807d7f44fa1df99/2e4<{u8},>}", size: 64, align: 64)
@alexcrichton
Copy link
Author

$ opt test.ll -o /dev/null
$ opt test.ll -o /dev/null -O2
!dbg attachment points at wrong subprogram for function
!1 = distinct !DISubprogram(name: "main", linkageName: "_ZN19backtrace_debuginfo4mainE", scope: !3, file: !2, line: 1, type: !4, isLocal: true, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, templateParams: !6, variables: !6)
void ()* @main
  %1 = getelementptr %TY, %TY* %0, i64 0, i32 1, !dbg !7
!7 = !DILocation(line: 467, scope: !8)
!8 = distinct !DILexicalBlock(scope: !10, file: !9, line: 465, column: 23)
!10 = distinct !DISubprogram(name: "drop", linkageName: "_ZN19backtrace_debuginfo7raw_vec14RawVec<T>.Drop4dropE", scope: !11, file: !9, line: 465, type: !13, isLocal: true, isDefinition: true, scopeLine: 465, flags: DIFlagPrototyped, isOptimized: false, templateParams: !6, variables: !6)
LLVM ERROR: Broken function found, compilation aborted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment