2017-08-02 08:28:10 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=generic | FileCheck %s
|
2014-12-12 23:09:58 +08:00
|
|
|
; Both functions should produce the same code. The presence of debug values
|
|
|
|
; should not affect the scheduling strategy.
|
|
|
|
; Generated from:
|
|
|
|
; char argc;
|
|
|
|
; class C {
|
|
|
|
; public:
|
|
|
|
; int test(char ,char ,char ,...);
|
|
|
|
; };
|
|
|
|
; void foo() {
|
|
|
|
; C c;
|
|
|
|
; char lc = argc;
|
|
|
|
; c.test(0,argc,0,lc);
|
|
|
|
; c.test(0,argc,0,lc);
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; with
|
|
|
|
; clang -O2 -c test.cpp -emit-llvm -S
|
|
|
|
; clang -O2 -c test.cpp -emit-llvm -S -g
|
|
|
|
;
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
source_filename = "test/CodeGen/X86/misched-code-difference-with-debug.ll"
|
2014-12-12 23:09:58 +08:00
|
|
|
|
|
|
|
%class.C = type { i8 }
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
@argc = global i8 0, align 1, !dbg !0
|
2014-12-12 23:09:58 +08:00
|
|
|
|
|
|
|
declare i32 @test_function(%class.C*, i8 signext, i8 signext, i8 signext, ...)
|
|
|
|
; CHECK-LABEL: test_without_debug
|
|
|
|
; CHECK: movl [[A:%[a-z]+]], [[B:%[a-z]+]]
|
|
|
|
; CHECK-NEXT: movl [[A]], [[C:%[a-z]+]]
|
2016-12-22 08:45:21 +08:00
|
|
|
|
2014-12-12 23:09:58 +08:00
|
|
|
define void @test_without_debug() {
|
|
|
|
entry:
|
|
|
|
%c = alloca %class.C, align 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i8, i8* @argc, align 1
|
2014-12-12 23:09:58 +08:00
|
|
|
%conv = sext i8 %0 to i32
|
[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 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %0, i8 signext 0, i32 %conv)
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i8, i8* @argc, align 1
|
[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
|
|
|
%call2 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %1, i8 signext 0, i32 %conv)
|
2014-12-12 23:09:58 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
; CHECK-LABEL: test_with_debug
|
|
|
|
; CHECK: movl [[A]], [[B]]
|
|
|
|
; CHECK-NEXT: movl [[A]], [[C]]
|
2016-12-22 08:45:21 +08:00
|
|
|
|
|
|
|
define void @test_with_debug() !dbg !17 {
|
2014-12-12 23:09:58 +08:00
|
|
|
entry:
|
|
|
|
%c = alloca %class.C, align 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i8, i8* @argc, align 1
|
2016-12-22 08:45:21 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !22, metadata !23), !dbg !24
|
2014-12-12 23:09:58 +08:00
|
|
|
%conv = sext i8 %0 to i32
|
2016-12-22 08:45:21 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata %class.C* %c, i64 0, metadata !21, metadata !25), !dbg !24
|
[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 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %0, i8 signext 0, i32 %conv)
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i8, i8* @argc, align 1
|
2016-12-22 08:45:21 +08:00
|
|
|
call void @llvm.dbg.value(metadata %class.C* %c, i64 0, metadata !21, metadata !25), !dbg !24
|
[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
|
|
|
%call2 = call i32 (%class.C*, i8, i8, i8, ...) @test_function(%class.C* %c, i8 signext 0, i8 signext %1, i8 signext 0, i32 %conv)
|
2014-12-12 23:09:58 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-12-22 08:45:21 +08:00
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
|
|
|
|
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #0
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readnone }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!4}
|
|
|
|
!llvm.module.flags = !{!15, !16}
|
2014-12-12 23:09:58 +08:00
|
|
|
|
2017-08-31 02:06:51 +08:00
|
|
|
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
2016-12-22 08:45:21 +08:00
|
|
|
!1 = !DIGlobalVariable(name: "argc", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
|
|
|
|
!2 = !DIFile(filename: "test.cpp", directory: "")
|
|
|
|
!3 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
|
|
|
|
!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !6, globals: !14, imports: !5)
|
|
|
|
!5 = !{}
|
|
|
|
!6 = !{!7}
|
|
|
|
!7 = !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !2, line: 2, size: 8, align: 8, elements: !8, identifier: "_ZTS1C")
|
|
|
|
!8 = !{!9}
|
|
|
|
!9 = !DISubprogram(name: "test", scope: !7, file: !2, type: !10, isLocal: false, isDefinition: false, isOptimized: false)
|
|
|
|
!10 = !DISubroutineType(types: !11)
|
|
|
|
!11 = !{!12, !13, !3, !3, !3, null}
|
|
|
|
!12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
|
|
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64, flags: DIFlagArtificial)
|
|
|
|
!14 = !{!0}
|
|
|
|
!15 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!16 = !{i32 2, !"Debug Info Version", i32 3}
|
[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
|
|
|
!17 = distinct !DISubprogram(name: "test_with_debug", linkageName: "test_with_debug", scope: !2, file: !2, line: 6, type: !18, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !4, retainedNodes: !20)
|
2016-12-22 08:45:21 +08:00
|
|
|
!18 = !DISubroutineType(types: !19)
|
|
|
|
!19 = !{null}
|
|
|
|
!20 = !{!21, !22}
|
|
|
|
!21 = !DILocalVariable(name: "c", scope: !17, file: !2, line: 7, type: !7)
|
|
|
|
!22 = !DILocalVariable(name: "lc", scope: !17, file: !2, line: 8, type: !3)
|
|
|
|
!23 = !DIExpression()
|
|
|
|
!24 = !DILocation(line: 0, scope: !17)
|
|
|
|
!25 = !DIExpression(DW_OP_deref)
|
2014-12-12 23:09:58 +08:00
|
|
|
|