2016-03-22 05:25:01 +08:00
|
|
|
; RUN: llc -filetype=asm -asm-verbose=0 -O0 < %s | FileCheck %s
|
2017-09-12 06:59:45 +08:00
|
|
|
; RUN: llc -filetype=obj -O0 < %s | llvm-dwarfdump -debug-line - | FileCheck %s --check-prefix=INT
|
2014-12-31 06:47:13 +08:00
|
|
|
|
|
|
|
; Check that the assembly output properly handles is_stmt changes. And since
|
|
|
|
; we're testing anyway, check the integrated assembler too.
|
|
|
|
|
|
|
|
; Generated with clang from multiline.c:
|
|
|
|
; void f1();
|
|
|
|
; void f2() {
|
|
|
|
; f1(); f1(); f1();
|
|
|
|
; f1(); f1(); f1();
|
|
|
|
; }
|
|
|
|
|
|
|
|
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 2 0{{$}}
|
2015-01-14 02:17:08 +08:00
|
|
|
; CHECK-NOT: .loc{{ }}
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 3 3 prologue_end{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
; CHECK-NOT: .loc
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 3 9 is_stmt 0{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
; CHECK-NOT: .loc
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 3 15{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
; CHECK-NOT: .loc
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 4 3 is_stmt 1{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
; CHECK-NOT: .loc
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 4 9 is_stmt 0{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
; CHECK-NOT: .loc
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 4 15{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
; CHECK-NOT: .loc
|
2014-12-31 07:33:55 +08:00
|
|
|
; CHECK: .loc 1 5 1 is_stmt 1{{$}}
|
2014-12-31 06:47:13 +08:00
|
|
|
|
|
|
|
; INT: {{^}}Address
|
|
|
|
; INT: -----
|
|
|
|
; INT-NEXT: 2 0 1 0 0 is_stmt{{$}}
|
|
|
|
; INT-NEXT: 3 3 1 0 0 is_stmt prologue_end{{$}}
|
|
|
|
; INT-NEXT: 3 9 1 0 0 {{$}}
|
|
|
|
; INT-NEXT: 3 15 1 0 0 {{$}}
|
|
|
|
; INT-NEXT: 4 3 1 0 0 is_stmt{{$}}
|
|
|
|
; INT-NEXT: 4 9 1 0 0 {{$}}
|
|
|
|
; INT-NEXT: 4 15 1 0 0 {{$}}
|
|
|
|
; INT-NEXT: 5 1 1 0 0 is_stmt{{$}}
|
|
|
|
|
|
|
|
|
|
|
|
; Function Attrs: nounwind uwtable
|
2015-11-06 06:03:56 +08:00
|
|
|
define void @f2() #0 !dbg !4 {
|
2014-12-31 06:47:13 +08:00
|
|
|
entry:
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
call void (...) @f1(), !dbg !11
|
|
|
|
call void (...) @f1(), !dbg !12
|
|
|
|
call void (...) @f1(), !dbg !13
|
|
|
|
call void (...) @f1(), !dbg !14
|
|
|
|
call void (...) @f1(), !dbg !15
|
|
|
|
call void (...) @f1(), !dbg !16
|
2014-12-31 06:47:13 +08:00
|
|
|
ret void, !dbg !17
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @f1(...) #1
|
|
|
|
|
|
|
|
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!8, !9}
|
|
|
|
!llvm.ident = !{!10}
|
|
|
|
|
2016-04-15 23:57:41 +08:00
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 (trunk 225000) (llvm/trunk 224999)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
|
2015-04-30 00:38:44 +08:00
|
|
|
!1 = !DIFile(filename: "multiline.c", directory: "/tmp/dbginfo")
|
2014-12-31 06:47:13 +08:00
|
|
|
!2 = !{}
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!4 = distinct !DISubprogram(name: "f2", line: 2, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, retainedNodes: !2)
|
2015-04-30 00:38:44 +08:00
|
|
|
!5 = !DIFile(filename: "multiline.c", directory: "/tmp/dbginfo")
|
|
|
|
!6 = !DISubroutineType(types: !7)
|
2014-12-31 06:47:13 +08:00
|
|
|
!7 = !{null}
|
|
|
|
!8 = !{i32 2, !"Dwarf Version", i32 4}
|
2015-03-04 01:24:31 +08:00
|
|
|
!9 = !{i32 2, !"Debug Info Version", i32 3}
|
2014-12-31 06:47:13 +08:00
|
|
|
!10 = !{!"clang version 3.6.0 (trunk 225000) (llvm/trunk 224999)"}
|
2015-04-30 00:38:44 +08:00
|
|
|
!11 = !DILocation(line: 3, column: 3, scope: !4)
|
|
|
|
!12 = !DILocation(line: 3, column: 9, scope: !4)
|
|
|
|
!13 = !DILocation(line: 3, column: 15, scope: !4)
|
|
|
|
!14 = !DILocation(line: 4, column: 3, scope: !4)
|
|
|
|
!15 = !DILocation(line: 4, column: 9, scope: !4)
|
|
|
|
!16 = !DILocation(line: 4, column: 15, scope: !4)
|
|
|
|
!17 = !DILocation(line: 5, column: 1, scope: !4)
|