diff options
| author | Yonghong Song <yhs@fb.com> | 2019-11-22 08:45:37 -0800 |
|---|---|---|
| committer | Yonghong Song <yhs@fb.com> | 2019-12-22 18:28:50 -0800 |
| commit | e3d8ee35e4adca664a9149536e0f0b3b0ceaeaeb (patch) | |
| tree | ded82c55a7ed0ed13f581caa8742bd25337832f9 /clang/test/CodeGen | |
| parent | fb53396c49493e3dfd51bb75ca822bd9896210f6 (diff) | |
| download | bcm5719-llvm-e3d8ee35e4adca664a9149536e0f0b3b0ceaeaeb.tar.gz bcm5719-llvm-e3d8ee35e4adca664a9149536e0f0b3b0ceaeaeb.zip | |
reland "[DebugInfo] Support to emit debugInfo for extern variables"
Commit d77ae1552fc21a9f3877f3ed7e13d631f517c825
("[DebugInfo] Support to emit debugInfo for extern variables")
added deebugInfo for extern variables for BPF target.
The commit is reverted by 891e25b02d760d0de18c7d46947913b3166047e7
as the committed tests using %clang instead of %clang_cc1 causing
test failed in certain scenarios as reported by Reid Kleckner.
This patch fixed the tests by using %clang_cc1.
Differential Revision: https://reviews.llvm.org/D71818
Diffstat (limited to 'clang/test/CodeGen')
| -rw-r--r-- | clang/test/CodeGen/debug-info-extern-basic.c | 26 | ||||
| -rw-r--r-- | clang/test/CodeGen/debug-info-extern-duplicate.c | 10 | ||||
| -rw-r--r-- | clang/test/CodeGen/debug-info-extern-multi.c | 22 | ||||
| -rw-r--r-- | clang/test/CodeGen/debug-info-extern-unused.c | 26 |
4 files changed, 84 insertions, 0 deletions
diff --git a/clang/test/CodeGen/debug-info-extern-basic.c b/clang/test/CodeGen/debug-info-extern-basic.c new file mode 100644 index 00000000000..e2c90842fff --- /dev/null +++ b/clang/test/CodeGen/debug-info-extern-basic.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu -emit-llvm %s -o - | FileCheck %s + +extern char ch; +int test() { + return ch; +} + +int test2() { + extern char ch2; + return ch2; +} + +extern int (*foo)(int); +int test3() { + return foo(0); +} + +// CHECK: distinct !DIGlobalVariable(name: "ch",{{.*}} type: ![[CHART:[0-9]+]], isLocal: false, isDefinition: false +// CHECK: distinct !DIGlobalVariable(name: "ch2",{{.*}} type: ![[CHART]], isLocal: false, isDefinition: false +// CHECK: ![[CHART]] = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) + +// CHECK: distinct !DIGlobalVariable(name: "foo",{{.*}} type: ![[FUNC:[0-9]+]], isLocal: false, isDefinition: false) +// CHECK: ![[FUNC]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[SUB:[0-9]+]], size: 64) +// CHECK: ![[SUB]] = !DISubroutineType(types: ![[TYPES:[0-9]+]]) +// CHECK: ![[TYPES]] = !{![[BASET:[0-9]+]], ![[BASET]]} +// CHECK: ![[BASET]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) diff --git a/clang/test/CodeGen/debug-info-extern-duplicate.c b/clang/test/CodeGen/debug-info-extern-duplicate.c new file mode 100644 index 00000000000..1c6d86f4cc0 --- /dev/null +++ b/clang/test/CodeGen/debug-info-extern-duplicate.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu -emit-llvm %s -o - | FileCheck %s + +extern char ch; +extern char ch; +int test() { + return ch; +} + +// CHECK: distinct !DIGlobalVariable(name: "ch",{{.*}} type: ![[T:[0-9]+]], isLocal: false, isDefinition: false +// CHECK-NOT: distinct !DIGlobalVariable(name: "ch" diff --git a/clang/test/CodeGen/debug-info-extern-multi.c b/clang/test/CodeGen/debug-info-extern-multi.c new file mode 100644 index 00000000000..6a9021d382b --- /dev/null +++ b/clang/test/CodeGen/debug-info-extern-multi.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu -emit-llvm %s -o - | FileCheck %s + +extern char ch; +int test() { + extern short sh; + return ch + sh; +} + +extern char (*foo)(char); +int test2() { + return foo(0) + ch; +} + +// CHECK: distinct !DIGlobalVariable(name: "ch",{{.*}} type: ![[Tch:[0-9]+]], isLocal: false, isDefinition: false +// CHECK: distinct !DIGlobalVariable(name: "sh",{{.*}} type: ![[Tsh:[0-9]+]], isLocal: false, isDefinition: false +// CHECK: ![[Tsh]] = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed) + +// CHECK: distinct !DIGlobalVariable(name: "foo",{{.*}} type: ![[Tptr:[0-9]+]], isLocal: false, isDefinition: false +// ![[Tptr]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[Tsub:[0-9]+]], size: 64) +// ![[Tsub]] = !DISubroutineType(types: ![[Tproto:[0-9]+]]) +// ![[Tproto]] = !{![[Tch]], ![[Tch]]} +// CHECK: ![[Tch]] = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) diff --git a/clang/test/CodeGen/debug-info-extern-unused.c b/clang/test/CodeGen/debug-info-extern-unused.c new file mode 100644 index 00000000000..8b89eaab27e --- /dev/null +++ b/clang/test/CodeGen/debug-info-extern-unused.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu -emit-llvm %s -o - | FileCheck %s + +extern char ch; +int test() { + return 0; +} + +int test2() { + extern char ch2; + return 0; +} + +extern int (*foo)(int); +int test3() { + return 0; +} + +int test4() { + extern int (*foo2)(int); + return 0; +} + +// CHECK-NOT: distinct !DIGlobalVariable(name: "ch" +// CHECK-NOT: distinct !DIGlobalVariable(name: "ch2" +// CHECK-NOT: distinct !DIGlobalVariable(name: "foo" +// CHECK-NOT: distinct !DIGlobalVariable(name: "foo2" |

