llvm.org GIT mirror llvm / 52f8d91
Don't crash when compiling inline assembler containing .file directives. Removing the assertion is safe to do because any module level inline assembly is always emitted first via AsmPrinter::doInitialization(). http://reviews.llvm.org/D16101 rdar://22690666 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263033 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 4 years ago
2 changed file(s) with 68 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
343343 }
344344 assert(!FileName.empty());
345345 if (FileNumber == 0) {
346 FileNumber = SourceIdMap.size() + 1;
347 assert((MCDwarfFiles.empty() || FileNumber == MCDwarfFiles.size()) &&
348 "Don't mix autonumbered and explicit numbered line table usage");
346 // File numbers start with 1 and/or after any file numbers
347 // allocated by inline-assembler .file directives.
348 FileNumber = MCDwarfFiles.empty() ? 1 : MCDwarfFiles.size();
349349 SmallString<256> Buffer;
350350 auto IterBool = SourceIdMap.insert(
351351 std::make_pair((Directory + Twine('\0') + FileName).toStringRef(Buffer),
0 ; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s
1
2 ; Generated from:
3 ; asm(
4 ; ".file 1 \"A.asm\"\n"
5 ; ".file 2 \"B.asm\"\n"
6 ; ".loc 1 111\n"
7 ; ".text\n"
8 ; ".globl _bar\n"
9 ; "_bar:\n"
10 ; ".loc 2 222\n"
11 ; "\tret\n"
12 ; );
13 ;
14 ; void bar();
15 ;
16 ; void foo() {
17 ; bar();
18 ; }
19
20 ; CHECK: .file 1 "A.asm"
21 ; CHECK: .file 2 "B.asm"
22 ; CHECK: .loc 1 111
23 ; CHECK: .loc 2 222
24 ; CHECK: .file 3 "test.c"
25 ; CHECK: .loc 3 14 0
26
27 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
28 target triple = "x86_64-apple-macosx"
29
30 module asm ".file 1 \22A.asm\22"
31 module asm ".file 2 \22B.asm\22"
32 module asm ".loc 1 111"
33 module asm ".text"
34 module asm ".globl _bar"
35 module asm "_bar:"
36 module asm ".loc 2 222"
37 module asm "\09ret"
38
39 ; Function Attrs: nounwind ssp uwtable
40 define void @foo() !dbg !4 {
41 entry:
42 call void (...) @bar(), !dbg !11
43 ret void, !dbg !12
44 }
45
46 declare void @bar(...)
47
48 !llvm.dbg.cu = !{!0}
49 !llvm.module.flags = !{!7, !8, !9}
50 !llvm.ident = !{!10}
51
52 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 256963)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
53 !1 = !DIFile(filename: "test.c", directory: "/Volumes/Data/radar/22690666")
54 !2 = !{}
55 !3 = !{!4}
56 !4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 14, type: !5, isLocal: false, isDefinition: true, scopeLine: 14, isOptimized: false, variables: !2)
57 !5 = !DISubroutineType(types: !6)
58 !6 = !{null}
59 !7 = !{i32 2, !"Dwarf Version", i32 2}
60 !8 = !{i32 2, !"Debug Info Version", i32 3}
61 !9 = !{i32 1, !"PIC Level", i32 2}
62 !10 = !{!"clang version 3.8.0 (trunk 256963)"}
63 !11 = !DILocation(line: 15, column: 3, scope: !4)
64 !12 = !DILocation(line: 16, column: 1, scope: !4)