From d6a47c09c66a2150d849d30ee7e77c2d1ff7c32c Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Mon, 25 Sep 2017 17:11:27 +0300 Subject: [PATCH] [build][debug info] fix gradle 'build' --- llvmDebugInfoC/build.gradle | 61 -------- llvmDebugInfoC/src/demo-common/c/common.c | 67 --------- .../src/demo-common/include/common.h | 39 ----- llvmDebugInfoC/src/demo-generated/c/demo.c | 92 ------------ .../src/demo-local-variable/c/demo.c | 107 -------------- llvmDebugInfoC/src/demo-simple/c/demo.c | 113 --------------- llvmDebugInfoC/src/demo-types/c/demo.c | 137 ------------------ 7 files changed, 616 deletions(-) delete mode 100644 llvmDebugInfoC/src/demo-common/c/common.c delete mode 100644 llvmDebugInfoC/src/demo-common/include/common.h delete mode 100644 llvmDebugInfoC/src/demo-generated/c/demo.c delete mode 100644 llvmDebugInfoC/src/demo-local-variable/c/demo.c delete mode 100644 llvmDebugInfoC/src/demo-simple/c/demo.c delete mode 100644 llvmDebugInfoC/src/demo-types/c/demo.c diff --git a/llvmDebugInfoC/build.gradle b/llvmDebugInfoC/build.gradle index d1ff32c6605..e62964653b7 100644 --- a/llvmDebugInfoC/build.gradle +++ b/llvmDebugInfoC/build.gradle @@ -29,66 +29,5 @@ model { buildable = false } } - - def demoCFlags = ["-g", "-I${llvmDir}/include".toString(), - "-I${projectDir}/src/main/include".toString(), - "-I${projectDir}/src/demo-common/include".toString()] - def demoLdFlagsLinux = ["-L${buildDir}/libs/debugInfo/static".toString(), "-ldebugInfo", - "-L${llvmDir}/lib".toString(), "-Wl,-(", "-lLLVMSupport", "-lLLVMAnalysis", "-lLLVMProfileData", "-lLLVMCore", "-Wl,-)", - "-L/usr/lib/x86_64-linux-gnu", "-L/lib/x86_64-linux-gnu", "-lncurses", "-lz", - "-ldl", "-lpthread"] - def demoLdFlagsMac = ["-L${llvmDir}/lib".toString(), "-lLLVMCore", "-lLLVMSupport", "-lLLVMAnalysis", "-lLLVMProfileData", - "-lncurses", "-lz", "-L${buildDir}/libs/debugInfo/static".toString(), "-ldebugInfo"] - demosimple(NativeExecutableSpec) { - //dependsOn project("debugInfoStaticLibrary") - sources.c.source.srcDirs "src/demo-simple/c", "src/demo-common/c" - binaries.all { - cCompiler.args.addAll(demoCFlags) - if (targetPlatform.operatingSystem.linux) { - linker.args.addAll(demoLdFlagsLinux) - } else { - linker.args.addAll(demoLdFlagsMac) - } - } - } - - demogenerated(NativeExecutableSpec) { - //dependsOn project("debugInfoStaticLibrary") - sources.c.source.srcDirs "src/demo-generated/c", "src/demo-common/c" - binaries.all { - cCompiler.args.addAll(demoCFlags) - if (targetPlatform.operatingSystem.linux) { - linker.args.addAll(demoLdFlagsLinux) - } else { - linker.args.addAll(demoLdFlagsMac) - } - } - } - - demolocalvariable(NativeExecutableSpec) { - //dependsOn project("debugInfoStaticLibrary") - sources.c.source.srcDirs "src/demo-local-variable/c", "src/demo-common/c" - binaries.all { - cCompiler.args.addAll(demoCFlags) - if (targetPlatform.operatingSystem.linux) { - linker.args.addAll(demoLdFlagsLinux) - } else { - linker.args.addAll(demoLdFlagsMac) - } - } - } - - demotypes(NativeExecutableSpec) { - //dependsOn project("debugInfoStaticLibrary") - sources.c.source.srcDirs "src/demo-types/c", "src/demo-common/c" - binaries.all { - cCompiler.args.addAll(demoCFlags) - if (targetPlatform.operatingSystem.linux) { - linker.args.addAll(demoLdFlagsLinux) - } else { - linker.args.addAll(demoLdFlagsMac) - } - } - } } } diff --git a/llvmDebugInfoC/src/demo-common/c/common.c b/llvmDebugInfoC/src/demo-common/c/common.c deleted file mode 100644 index f2ab7388860..00000000000 --- a/llvmDebugInfoC/src/demo-common/c/common.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -codegen g_codegen; - -void -codegen_init() { - g_codegen.module = LLVMModuleCreateWithName("test"); - g_codegen.di_builder = DICreateBuilder(g_codegen.module); - g_codegen.di_compile_unit = DICreateCompilationUnit(g_codegen.di_builder, 4, - "", "", - "konanc", 0, "", 0); - g_codegen.llvm_builder = LLVMCreateBuilderInContext(LLVMGetModuleContext(g_codegen.module)); -} - -void -codegen_destroy() { - DIFinalize(g_codegen.di_builder); - LLVMVerifyModule(g_codegen.module, LLVMPrintMessageAction, NULL); - LLVMDumpModule(g_codegen.module); - LLVMDisposeModule(g_codegen.module); - LLVMShutdown(); -} - - -static LLVMValueRef -create_function(const char* name) { - LLVMTypeRef function_type = LLVMFunctionType(LLVMVoidType(), NULL, 0, 0); - return LLVMAddFunction(g_codegen.module, name, function_type); -} - -void -create_function_with_entry(const char *name, - location loc, - DISubroutineTypeRef subroutine_type, - DISubprogramRef *subprogram) { - LLVMValueRef function = create_function(name); - LLVMBasicBlockRef bb = LLVMAppendBasicBlock(function, "entry"); - *subprogram = DICreateFunction(g_codegen.di_builder, - SCOPE(g_codegen.di_compile_unit), - name, - name, - *loc.file, - loc.line, - subroutine_type, 0, 1, 0); - LLVMPositionBuilderAtEnd(g_codegen.llvm_builder, bb); - DIFunctionAddSubprogram(function, *subprogram); -} - diff --git a/llvmDebugInfoC/src/demo-common/include/common.h b/llvmDebugInfoC/src/demo-common/include/common.h deleted file mode 100644 index bfe0c4730ca..00000000000 --- a/llvmDebugInfoC/src/demo-common/include/common.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __DEMO_COMMON_H__ -#define __DEMO_COMMON_H__ -typedef struct { - LLVMModuleRef module; - DIBuilderRef di_builder; - LLVMBuilderRef llvm_builder; - DICompileUnitRef di_compile_unit; -} codegen; - -typedef struct { - DIFileRef *file; - int line; -} location; - -codegen g_codegen; - -#define SCOPE(x) ((DIScopeOpaqueRef)(x)) -#define TYPE(x) ((DITypeOpaqueRef)(x)) - -void codegen_init(); -void codegen_destroy(); -void create_function_with_entry(const char *, location, DISubroutineTypeRef, DISubprogramRef *); - -#endif diff --git a/llvmDebugInfoC/src/demo-generated/c/demo.c b/llvmDebugInfoC/src/demo-generated/c/demo.c deleted file mode 100644 index 778d1dd5983..00000000000 --- a/llvmDebugInfoC/src/demo-generated/c/demo.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -/** - * this demo produces bitcode for case when several functions generated from one source code. - * e.g. for following source: - * 0:123456789012345678901 - * 1: fun main():Int { - * 2: {foo()}() - * 3: return 0 - * 4: } - * 5 fun foo() {} - * - * we produce following IR (line and column numbers are in parencies) - * fun main$caller$foo(2:4) - * call foo(5:2) - * fun main(1:2) - * call main$caller$foo(2:12) - * return0(3:4) - * fun foo(5:2) - * return(5:14) - */ - -static DIFileRef file; -static DISubroutineTypeRef subroutine_type; - -#define FOO_FUNCTION "foo" -#define MAIN_FUNCTION "main" -#define MAIN_CALLER_FOO_FUNCTION "main$caller$foo" - - -static void -create_foo() { - DISubprogramRef di; - location loc = {&file, 5}; - create_function_with_entry(FOO_FUNCTION, loc, subroutine_type, &di); - LLVMBuilderSetDebugLocation(g_codegen.llvm_builder, 5, 14, SCOPE(di)); - LLVMBuildRetVoid(g_codegen.llvm_builder); -} - -static void -create_main_caller_foo() { - DISubprogramRef di; - location loc = {&file, 2}; - create_function_with_entry(MAIN_CALLER_FOO_FUNCTION, loc, subroutine_type, &di); - LLVMValueRef fn = LLVMGetNamedFunction(g_codegen.module, FOO_FUNCTION); - LLVMBuilderSetDebugLocation(g_codegen.llvm_builder, 5, 2, SCOPE(di)); - LLVMBuildCall(g_codegen.llvm_builder, fn, NULL, 0, ""); - LLVMBuilderResetDebugLocation(g_codegen.llvm_builder); - LLVMBuildRetVoid(g_codegen.llvm_builder); -} - -static void -create_main() { - DISubprogramRef di; - location loc = {&file, 1}; - create_function_with_entry(MAIN_FUNCTION, loc, subroutine_type, &di); - LLVMValueRef fn = LLVMGetNamedFunction(g_codegen.module, MAIN_CALLER_FOO_FUNCTION); - LLVMBuilderSetDebugLocation(g_codegen.llvm_builder, 2, 12, SCOPE(di)); - LLVMBuildCall(g_codegen.llvm_builder, fn, NULL, 0, ""); - LLVMBuilderSetDebugLocation(g_codegen.llvm_builder, 3, 4, SCOPE(di)); - LLVMBuildRetVoid(g_codegen.llvm_builder); -} - - -int -main() { - codegen_init(); - file = DICreateFile(g_codegen.di_builder, "", ""); - subroutine_type = DICreateSubroutineType(g_codegen.di_builder, NULL, 0); - create_foo(); - create_main_caller_foo(); - create_main(); - codegen_destroy(); -} diff --git a/llvmDebugInfoC/src/demo-local-variable/c/demo.c b/llvmDebugInfoC/src/demo-local-variable/c/demo.c deleted file mode 100644 index 3aa8ab392fb..00000000000 --- a/llvmDebugInfoC/src/demo-local-variable/c/demo.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -/** - * 0:b-backend-dwarf:minamoto@unit-703(0)# clang -xc -S -g -emit-llvm -o - - - * "TERMCAP", line 20, col 1, terminal 'SC': Missing separator - * 12345678901234567890 - * 1:int main() { - * 2: int a = 42; - * 3: return a; - * 4:} - * ; ModuleID = '-' - * source_filename = "-" - * target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" - * target triple = "x86_64-apple-macosx10.12.0" - * - * ; Function Attrs: nounwind ssp uwtable - * define i32 @main() #0 !dbg !7 { - * %1 = alloca i32, align 4 - * %2 = alloca i32, align 4 - * store i32 0, i32* %1, align 4 - * call void @llvm.dbg.declare(metadata i32* %2, metadata !12, metadata !13), !dbg !14 - * store i32 42, i32* %2, align 4, !dbg !14 - * %3 = load i32, i32* %2, align 4, !dbg !15 - * ret i32 %3, !dbg !16 - * } - * - * ; Function Attrs: nounwind readnone - * declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - * - * attributes #0 = { nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - * attributes #1 = { nounwind readnone } - * - * !llvm.dbg.cu = !{!0} - * !llvm.module.flags = !{!3, !4, !5} - * !llvm.ident = !{!6} - * - * !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Apple LLVM version 8.1.0 (clang-802.0.36)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) - * !1 = !DIFile(filename: "-", directory: "/Users/minamoto/ws/.git-trees/backend-dwarf") - * !2 = !{} - * !3 = !{i32 2, !"Dwarf Version", i32 4} - * !4 = !{i32 2, !"Debug Info Version", i32 700000003} - * !5 = !{i32 1, !"PIC Level", i32 2} - * !6 = !{!"Apple LLVM version 8.1.0 (clang-802.0.36)"} - * !7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, variables: !2) - * !8 = !DIFile(filename: "", directory: "/Users/minamoto/ws/.git-trees/backend-dwarf") - * !9 = !DISubroutineType(types: !10) - * !10 = !{!11} - * !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) - * !12 = !DILocalVariable(name: "a", scope: !7, file: !8, line: 2, type: !11) - * !13 = !DIExpression() - * !14 = !DILocation(line: 2, column: 7, scope: !7) - * !15 = !DILocation(line: 3, column: 10, scope: !7) - * !16 = !DILocation(line: 3, column: 3, scope: !7) - */ - -static DIFileRef file; -static DISubroutineTypeRef subroutine_type; -static LLVMTypeRef int_type; -static DITypeOpaqueRef di_int_type; - - -static void -create_main() { - DISubprogramRef di; - location loc = {&file, 1}; - create_function_with_entry("main", loc, subroutine_type, &di); - LLVMValueRef address = LLVMBuildAlloca(g_codegen.llvm_builder, int_type, ""); - DILocationRef location = LLVMBuilderSetDebugLocation(g_codegen.llvm_builder, - 2, 1, SCOPE(di)); - DILocalVariableRef variable_a = DICreateAutoVariable(g_codegen.di_builder, SCOPE(di), - "a", file, 2, di_int_type); - DIInsertDeclarationWithEmptyExpression(g_codegen.di_builder, address, variable_a, - location, LLVMGetInsertBlock(g_codegen.llvm_builder)); - LLVMBuildStore(g_codegen.llvm_builder, LLVMConstInt(int_type, 42, 1), address); - LLVMValueRef value = LLVMBuildLoad(g_codegen.llvm_builder, address, ""); - LLVMBuildRet(g_codegen.llvm_builder, value); -} - - -int -main() { - codegen_init(); - file = DICreateFile(g_codegen.di_builder, "", ""); - subroutine_type = DICreateSubroutineType(g_codegen.di_builder, NULL, 0); - int_type = LLVMInt32Type(); - di_int_type = TYPE(DICreateBasicType(g_codegen.di_builder, "int", 32, 4, 0)); - create_main(); - codegen_destroy(); -} diff --git a/llvmDebugInfoC/src/demo-simple/c/demo.c b/llvmDebugInfoC/src/demo-simple/c/demo.c deleted file mode 100644 index 97797537330..00000000000 --- a/llvmDebugInfoC/src/demo-simple/c/demo.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -//clang llvmDebugInfoC/test/demo.c -IllvmDebugInfoC/include/ -Idependencies/all/clang+llvm-3.9.0-darwin-macos/include -c - -//c++ demo.o -Idependencies/all/clang+llvm-3.9.0-darwin-macos/include -Ldependencies/all/clang+llvm-3.9.0-darwin-macos/lib -lLLVMCore -lLLVMSupport -lncurses -o demo - -// -// 0:b-backend-dwarf:minamoto@unit-703(0)# clang -S -xc -emit-llvm -g -o - - -// int foo(int i) { return i; } -// int main() { -// int i = 0; -// return foo(i); -// } -// ; ModuleID = '-' -// source_filename = "-" -// target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" -// target triple = "x86_64-apple-macosx10.12.0" -// -// ; Function Attrs: nounwind ssp uwtable -// define i32 @foo(i32) #0 !dbg !7 { -// %2 = alloca i32, align 4 -// store i32 %0, i32* %2, align 4 -// call void @llvm.dbg.declare(metadata i32* %2, metadata !12, metadata !13), !dbg !14 -// %3 = load i32, i32* %2, align 4, !dbg !15 -// ret i32 %3, !dbg !16 -// } -// -// ; Function Attrs: nounwind readnone -// declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 -// -// ; Function Attrs: nounwind ssp uwtable -// define i32 @main() #0 !dbg !17 { -// %1 = alloca i32, align 4 -// %2 = alloca i32, align 4 -// store i32 0, i32* %1, align 4 -// call void @llvm.dbg.declare(metadata i32* %2, metadata !20, metadata !13), !dbg !21 -// store i32 0, i32* %2, align 4, !dbg !21 -// %3 = load i32, i32* %2, align 4, !dbg !22 -// %4 = call i32 @foo(i32 %3), !dbg !23 -// ret i32 %4, !dbg !24 -// } -// -// attributes #0 = { nounwind ssp uwtable "disable-tail-calls"="false" "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" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3" "unsafe-fp-math"="false" "use-soft-float"="false" } -// attributes #1 = { nounwind readnone } -// -// !llvm.dbg.cu = !{!0} -// !llvm.module.flags = !{!3, !4, !5} -// !llvm.ident = !{!6} -// -// !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Apple LLVM version 8.0.0 (clang-800.0.42.1)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) -// !1 = !DIFile(filename: "-", directory: "/Users/minamoto/ws/.git-trees/backend-dwarf") -// !2 = !{} -// !3 = !{i32 2, !"Dwarf Version", i32 2} -// !4 = !{i32 2, !"Debug Info Version", i32 700000003} -// !5 = !{i32 1, !"PIC Level", i32 2} -// !6 = !{!"Apple LLVM version 8.0.0 (clang-800.0.42.1)"} -// !7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) -// !8 = !DIFile(filename: "", directory: "/Users/minamoto/ws/.git-trees/backend-dwarf") -// !9 = !DISubroutineType(types: !10) -// !10 = !{!11, !11} -// !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -// !12 = !DILocalVariable(name: "i", arg: 1, scope: !7, file: !8, line: 1, type: !11) -// !13 = !DIExpression() -// !14 = !DILocation(line: 1, column: 13, scope: !7) -// !15 = !DILocation(line: 1, column: 25, scope: !7) -// !16 = !DILocation(line: 1, column: 18, scope: !7) -// !17 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 2, type: !18, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, variables: !2) -// !18 = !DISubroutineType(types: !19) -// !19 = !{!11} -// !20 = !DILocalVariable(name: "i", scope: !17, file: !8, line: 3, type: !11) -// !21 = !DILocation(line: 3, column: 7, scope: !17) -// !22 = !DILocation(line: 4, column: 14, scope: !17) -// !23 = !DILocation(line: 4, column: 10, scope: !17) -// !24 = !DILocation(line: 4, column: 3, scope: !17) - -int -main() { - codegen_init(); - DIBasicTypeRef type0 = DICreateBasicType(g_codegen.di_builder, "int", 32, 4, 0); - DISubroutineTypeRef subroutineType = DICreateSubroutineType(g_codegen.di_builder, (DITypeOpaqueRef *)&type0, 1); - const char *functionName = "foo"; - DIFileRef file = DICreateFile(g_codegen.di_builder, "1.kt", "src"); - DISubprogramRef diFunction = DICreateFunction(g_codegen.di_builder, SCOPE(g_codegen.di_compile_unit), functionName, "foo:link", file, 66, subroutineType, 0, 1, 0); - - //function creation. - - LLVMTypeRef intType = LLVMInt32Type(); - LLVMValueRef functionType = LLVMFunctionType(intType, &intType, 1, 0); - LLVMValueRef llvmFunction = LLVMAddFunction(g_codegen.module, functionName, functionType); - DIFunctionAddSubprogram(llvmFunction, diFunction); - LLVMBasicBlockRef bb = LLVMAppendBasicBlock(llvmFunction, "entry"); - LLVMPositionBuilderAtEnd(g_codegen.llvm_builder, bb); - LLVMBuilderSetDebugLocation(g_codegen.llvm_builder, 42, 15, SCOPE(diFunction)); - LLVMValueRef ret = LLVMBuildRet(g_codegen.llvm_builder, LLVMGetParam(llvmFunction, 0)); - codegen_destroy(); - return 0; -} diff --git a/llvmDebugInfoC/src/demo-types/c/demo.c b/llvmDebugInfoC/src/demo-types/c/demo.c deleted file mode 100644 index f9aea39daa1..00000000000 --- a/llvmDebugInfoC/src/demo-types/c/demo.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - /** - * 0:b-debugger-types:minamoto@unit-703(0)# clang -g -xc -emit-llvm -S -o - - - * struct A{ - * int a; - * int b; - * }; - * - * struct A* foo(struct A* a) { - * a->a += 1; - * return a; - * } - * ; ModuleID = '-' - * source_filename = "-" - * target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" - * target triple = "x86_64-apple-macosx10.12.0" - * - * %struct.A = type { i32, i32 } - * - * ; Function Attrs: nounwind ssp uwtable - * define %struct.A* @foo(%struct.A*) #0 !dbg !7 { - * %2 = alloca %struct.A*, align 8 - * store %struct.A* %0, %struct.A** %2, align 8 - * call void @llvm.dbg.declare(metadata %struct.A** %2, metadata !17, metadata !18), !dbg !19 - * %3 = load %struct.A*, %struct.A** %2, align 8, !dbg !20 - * %4 = getelementptr inbounds %struct.A, %struct.A* %3, i32 0, i32 0, !dbg !21 - * %5 = load i32, i32* %4, align 4, !dbg !22 - * %6 = add nsw i32 %5, 1, !dbg !22 - * store i32 %6, i32* %4, align 4, !dbg !22 - * %7 = load %struct.A*, %struct.A** %2, align 8, !dbg !23 - * ret %struct.A* %7, !dbg !24 - * } - * - * ; Function Attrs: nounwind readnone - * declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - * - * attributes #0 = { nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - * attributes #1 = { nounwind readnone } - * - * !llvm.dbg.cu = !{!0} - * !llvm.module.flags = !{!3, !4, !5} - * !llvm.ident = !{!6} - * - * !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Apple LLVM version 8.1.0 (clang-802.0.36)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) - * !1 = !DIFile(filename: "-", directory: "/Users/minamoto/ws/.git-trees/debugger-types") - * !2 = !{} - * !3 = !{i32 2, !"Dwarf Version", i32 4} - * !4 = !{i32 2, !"Debug Info Version", i32 700000003} - * !5 = !{i32 1, !"PIC Level", i32 2} - * !6 = !{!"Apple LLVM version 8.1.0 (clang-802.0.36)"} - * !7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 6, type: !9, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) - * !8 = !DIFile(filename: "", directory: "/Users/minamoto/ws/.git-trees/debugger-types") - * !9 = !DISubroutineType(types: !10) - * !10 = !{!11, !11} - * !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64, align: 64) - * !12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !8, line: 1, size: 64, align: 32, elements: !13) - * !13 = !{!14, !16} - * !14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !8, line: 2, baseType: !15, size: 32, align: 32) - * !15 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) - * !16 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !12, file: !8, line: 3, baseType: !15, size: 32, align: 32, offset: 32) - * !17 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !8, line: 6, type: !11) - * !18 = !DIExpression() - * !19 = !DILocation(line: 6, column: 25, scope: !7) - * !20 = !DILocation(line: 7, column: 2, scope: !7) - * !21 = !DILocation(line: 7, column: 5, scope: !7) - * !22 = !DILocation(line: 7, column: 7, scope: !7) - * !23 = !DILocation(line: 8, column: 9, scope: !7) - * !24 = !DILocation(line: 8, column: 2, scope: !7) - */ -static DIFileRef file; -static DISubroutineTypeRef subroutine_type; -static LLVMTypeRef int_type; - -static void -create_main() { - DISubprogramRef di; - location loc = {&file, 1}; - create_function_with_entry("main", loc, subroutine_type, &di); - LLVMBuildRet(g_codegen.llvm_builder, LLVMConstInt(LLVMInt32Type(), 42, 1)); -} - - -int -main() { - codegen_init(); - DITypeOpaqueRef int_type = TYPE(DICreateBasicType(g_codegen.di_builder, "int", 32, 4, 0)); - DIDerivedTypeRef elements_int_type[2]; - file = DICreateFile(g_codegen.di_builder, "", ""); - DICompositeTypeRef tempA = DICreateReplaceableCompositeType(g_codegen.di_builder, "A", SCOPE(g_codegen.di_compile_unit), file, 2, 0); - elements_int_type[0] = DICreateMemberType( - /* builder = */ g_codegen.di_builder, - /* scope = */ SCOPE(tempA), /* note: here dump points to structure ???*/ - /* name = */ "a", - /* file = */ file, - /* lineNum = */ 3, - /* sizeInBits = */ 32, - /* alignInBits = */ 32, - /* offsetInBits = */ 0, - /* flags = */ 0, - /* type = */ int_type); - elements_int_type[1] = DICreateMemberType( - /* builder = */ g_codegen.di_builder, - /* scope = */ SCOPE(tempA), - /* name = */ "b", - /* file = */ file, - /* lineNum = */ 4, - /* sizeInBits = */ 32, - /* alignInBits = */ 32, - /* offsetInBits = */ 32, - /* flags = */ 0, - /* type = */ int_type); - - DITypeOpaqueRef A_type = TYPE(DICreateStructType( - g_codegen.di_builder, - g_codegen.di_compile_unit, - "A", file, 2, 64, 32, 0, (void *)0, elements_int_type, 2, tempA)); - subroutine_type = DICreateSubroutineType(g_codegen.di_builder, &A_type, 1); - create_main(); - codegen_destroy(); -}