203 lines · plain
1# RUN: llvm-mc -triple=x86_64-windows -filetype=obj < %s -o %t.obj2# RUN: llvm-objdump --no-print-imm-hex -d %t.obj | FileCheck %s --check-prefix=ASM3# RUN: llvm-pdbutil dump -symbols %t.obj | FileCheck %s --check-prefix=CODEVIEW4 5# C source to generate the assembly:6# volatile int unlikely_cond = 0;7# extern void __declspec(noreturn) abort();8# __forceinline void f() {9# if (unlikely_cond)10# abort();11# }12# void g() {13# unlikely_cond = 0;14# f();15# unlikely_cond = 0;16# }17 18# This test is interesting because the inlined instructions are discontiguous.19# LLVM's block layout algorithms will put the 'abort' call last, as it is20# considered highly unlikely to execute. This is similar to what it does for21# calls to __asan_report*, for which it is very important to have an accurate22# stack trace.23 24# ASM: 0000000000000000 <g>:25# ASM-NEXT: 0: 48 83 ec 28 subq $40, %rsp26# ASM-NEXT: 4: c7 05 fc ff ff ff 00 00 00 00 movl $0, -4(%rip)27# Begin inline loc (matches cv_loc below)28# ASM-NEXT: e: 83 3d ff ff ff ff 00 cmpl $0, -1(%rip)29# ASM-NEXT: 15: 75 0f jne 0x26 <g+0x26>30# End inline loc31# ASM-NEXT: 17: c7 05 fc ff ff ff 00 00 00 00 movl $0, -4(%rip)32# ASM-NEXT: 21: 48 83 c4 28 addq $40, %rsp33# ASM-NEXT: 25: c3 retq34# Begin inline loc (matches cv_loc below)35# ASM-NEXT: 26: e8 00 00 00 00 callq 0x2b <g+0x2b>36# ASM-NEXT: 2b: 0f 0b ud237# End inline loc38 39# CODEVIEW: S_INLINESITE [size = 24]40# CODEVIEW-NEXT: inlinee = 0x1002 (f), parent = 0, end = 041# CODEVIEW-NEXT: 0B2E code 0xE (+0xE) line 1 (+1)42# CODEVIEW-NEXT: 0409 code end 0x17 (+0x9)43# CODEVIEW-NEXT: 0B2F code 0x26 (+0xF) line 2 (+1)44# CODEVIEW-NEXT: 0407 code end 0x2D (+0x7)45 46 .text47 .globl g48g: # @g49.Lfunc_begin0:50 .cv_func_id 051 .cv_file 1 "C:\\src\\llvm\\build\\t.cpp"52 .cv_loc 0 1 7 0 is_stmt 0 # t.cpp:7:053.seh_proc g54 subq $40, %rsp55 .seh_stackalloc 4056 .seh_endprologue57 .cv_loc 0 1 8 17 # t.cpp:8:1758 movl $0, unlikely_cond(%rip)59 .cv_inline_site_id 1 within 0 inlined_at 1 9 360 .cv_loc 1 1 4 7 # t.cpp:4:761 cmpl $0, unlikely_cond(%rip)62 jne .LBB0_163 .cv_loc 0 1 10 17 # t.cpp:10:1764 movl $0, unlikely_cond(%rip)65 .seh_startepilogue66 .cv_loc 0 1 11 1 # t.cpp:11:167 addq $40, %rsp68 .seh_endepilogue69 retq70 71.LBB0_1: # %if.then.i72 .cv_loc 1 1 5 5 # t.cpp:5:573 callq abort74 ud275.Lfunc_end0:76 .seh_handlerdata77 .text78 .seh_endproc79 80 .bss81 .globl unlikely_cond # @unlikely_cond82 .p2align 283unlikely_cond:84 .long 0 # 0x085 86 .section .debug$S,"dr"87 .p2align 288 .long 4 # Debug section magic89 .long 246 # Inlinee lines subsection90 .long .Ltmp9-.Ltmp8 # Subsection size91.Ltmp8:92 .long 0 # Inlinee lines signature93 94 # Inlined function f starts at t.cpp:395 .long 4098 # Type index of inlined function96 .long 0 # Offset into filechecksum table97 .long 3 # Starting line number98.Ltmp9:99 .p2align 2100 .long 241 # Symbol subsection for g101 .long .Ltmp11-.Ltmp10 # Subsection size102.Ltmp10:103 .short .Ltmp13-.Ltmp12 # Record length104.Ltmp12:105 .short 4423 # Record kind: S_GPROC32_ID106 .long 0 # PtrParent107 .long 0 # PtrEnd108 .long 0 # PtrNext109 .long .Lfunc_end0-g # Code size110 .long 0 # Offset after prologue111 .long 0 # Offset before epilogue112 .long 4099 # Function type index113 .secrel32 g # Function section relative address114 .secidx g # Function section index115 .byte 0 # Flags116 .asciz "g" # Function name117.Ltmp13:118 .short .Ltmp15-.Ltmp14 # Record length119.Ltmp14:120 .short 4429 # Record kind: S_INLINESITE121 .long 0 # PtrParent122 .long 0 # PtrEnd123 .long 4098 # Inlinee type index124 .cv_inline_linetable 1 1 3 .Lfunc_begin0 .Lfunc_end0125.Ltmp15:126 .short 2 # Record length127 .short 4430 # Record kind: S_INLINESITE_END128 .short 2 # Record length129 .short 4431 # Record kind: S_PROC_ID_END130.Ltmp11:131 .p2align 2132 .cv_linetable 0, g, .Lfunc_end0133 .long 241 # Symbol subsection for globals134 .long .Ltmp17-.Ltmp16 # Subsection size135.Ltmp16:136 .short .Ltmp19-.Ltmp18 # Record length137.Ltmp18:138 .short 4365 # Record kind: S_GDATA32139 .long 4100 # Type140 .secrel32 unlikely_cond # DataOffset141 .secidx unlikely_cond # Segment142 .asciz "unlikely_cond" # Name143.Ltmp19:144.Ltmp17:145 .p2align 2146 .cv_filechecksums # File index to string table offset subsection147 .cv_stringtable # String table148 .section .debug$T,"dr"149 .p2align 2150 .long 4 # Debug section magic151 # ArgList (0x1000) {152 # TypeLeafKind: LF_ARGLIST (0x1201)153 # NumArgs: 0154 # Arguments [155 # ]156 # }157 .byte 0x06, 0x00, 0x01, 0x12158 .byte 0x00, 0x00, 0x00, 0x00159 # Procedure (0x1001) {160 # TypeLeafKind: LF_PROCEDURE (0x1008)161 # ReturnType: void (0x3)162 # CallingConvention: NearC (0x0)163 # FunctionOptions [ (0x0)164 # ]165 # NumParameters: 0166 # ArgListType: () (0x1000)167 # }168 .byte 0x0e, 0x00, 0x08, 0x10169 .byte 0x03, 0x00, 0x00, 0x00170 .byte 0x00, 0x00, 0x00, 0x00171 .byte 0x00, 0x10, 0x00, 0x00172 # FuncId (0x1002) {173 # TypeLeafKind: LF_FUNC_ID (0x1601)174 # ParentScope: 0x0175 # FunctionType: void () (0x1001)176 # Name: f177 # }178 .byte 0x0e, 0x00, 0x01, 0x16179 .byte 0x00, 0x00, 0x00, 0x00180 .byte 0x01, 0x10, 0x00, 0x00181 .byte 0x66, 0x00, 0xf2, 0xf1182 # FuncId (0x1003) {183 # TypeLeafKind: LF_FUNC_ID (0x1601)184 # ParentScope: 0x0185 # FunctionType: void () (0x1001)186 # Name: g187 # }188 .byte 0x0e, 0x00, 0x01, 0x16189 .byte 0x00, 0x00, 0x00, 0x00190 .byte 0x01, 0x10, 0x00, 0x00191 .byte 0x67, 0x00, 0xf2, 0xf1192 # Modifier (0x1004) {193 # TypeLeafKind: LF_MODIFIER (0x1001)194 # ModifiedType: int (0x74)195 # Modifiers [ (0x2)196 # Volatile (0x2)197 # ]198 # }199 .byte 0x0a, 0x00, 0x01, 0x10200 .byte 0x74, 0x00, 0x00, 0x00201 .byte 0x02, 0x00, 0xf2, 0xf1202 203