[PATCH] D52323: Add necessary support for storing code-model to module IR.
cmtice created this revision. cmtice added reviewers: tejohnson, pcc. Herald added subscribers: cfe-commits, dexonsmith, mehdi_amini. Currently the code-model does not get saved in the module IR, so if a code model is specified when compiling with LTO, it gets lost and is not propagated properly to LTO. This patch does what is necessary in the front end to pass the code-model to the module, so that the back end can store it in the Module (see https://reviews.llvm.org/D52322 for the back-end patch). Fixes PR33306. Repository: rC Clang https://reviews.llvm.org/D52323 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGen/codemodels.c Index: test/CodeGen/codemodels.c === --- test/CodeGen/codemodels.c +++ test/CodeGen/codemodels.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOMODEL +// RUN: %clang_cc1 -emit-llvm -mcode-model small %s -o - | FileCheck %s -check-prefix=CHECK-SMALL +// RUN: %clang_cc1 -emit-llvm -mcode-model kernel %s -o - | FileCheck %s -check-prefix=CHECK-KERNEL +// RUN: %clang_cc1 -emit-llvm -mcode-model medium %s -o - | FileCheck %s -check-prefix=CHECK-MEDIUM +// RUN: %clang_cc1 -emit-llvm -mcode-model large %s -o - | FileCheck %s -check-prefix=CHECK-LARGE + +// CHECK-SMALL: !llvm.module.flags = !{{{.*}}} +// CHECK-SMALL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 1} +// CHECK-KERNEL: !llvm.module.flags = !{{{.*}}} +// CHECK-KERNEL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 2} +// CHECK-MEDIUM: !llvm.module.flags = !{{{.*}}} +// CHECK-MEDIUM: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 3} +// CHECK-LARGE: !llvm.module.flags = !{{{.*}}} +// CHECK-LARGE: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 4} +// CHECK-NOMODEL-NOT: Code Model Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -35,6 +35,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/IR/Module.h" #include "llvm/IR/ValueHandle.h" +#include "llvm/Support/CodeGen.h" #include "llvm/Transforms/Utils/SanitizerStats.h" namespace llvm { Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -44,6 +44,7 @@ #include "clang/CodeGen/ConstantInitBuilder.h" #include "clang/Frontend/CodeGenOptions.h" #include "clang/Sema/SemaDiagnostic.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/IR/CallSite.h" @@ -556,6 +557,21 @@ getModule().setPIELevel(static_cast(PLevel)); } + if (getCodeGenOpts().CodeModel.size() > 0) { +unsigned CM = llvm::StringSwitch(getCodeGenOpts().CodeModel) + .Case("tiny", llvm::CodeModel::Tiny) + .Case("small", llvm::CodeModel::Small) + .Case("kernel", llvm::CodeModel::Kernel) + .Case("medium", llvm::CodeModel::Medium) + .Case("large", llvm::CodeModel::Large) + .Case("default", ~1u) + .Default(~0u); +if ((CM != ~0u) && (CM != ~1u)) { + llvm::CodeModel::Model codeModel = static_cast(CM); + getModule().setCodeModel(codeModel); +} + } + if (CodeGenOpts.NoPLT) getModule().setRtLibUseGOT(); Index: test/CodeGen/codemodels.c === --- test/CodeGen/codemodels.c +++ test/CodeGen/codemodels.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOMODEL +// RUN: %clang_cc1 -emit-llvm -mcode-model small %s -o - | FileCheck %s -check-prefix=CHECK-SMALL +// RUN: %clang_cc1 -emit-llvm -mcode-model kernel %s -o - | FileCheck %s -check-prefix=CHECK-KERNEL +// RUN: %clang_cc1 -emit-llvm -mcode-model medium %s -o - | FileCheck %s -check-prefix=CHECK-MEDIUM +// RUN: %clang_cc1 -emit-llvm -mcode-model large %s -o - | FileCheck %s -check-prefix=CHECK-LARGE + +// CHECK-SMALL: !llvm.module.flags = !{{{.*}}} +// CHECK-SMALL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 1} +// CHECK-KERNEL: !llvm.module.flags = !{{{.*}}} +// CHECK-KERNEL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 2} +// CHECK-MEDIUM: !llvm.module.flags = !{{{.*}}} +// CHECK-MEDIUM: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 3} +// CHECK-LARGE: !llvm.module.flags = !{{{.*}}} +// CHECK-LARGE: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 4} +// CHECK-NOMODEL-NOT: Code Model Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -35,6 +35,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/IR/Module.h" #include "llvm/IR/ValueHandle.h" +#include "llvm/Support/CodeGen.h" #include "llvm/Transforms/Utils/SanitizerStats.h" namespace llvm { Index
[PATCH] D52323: Add necessary support for storing code-model to module IR.
cmtice marked an inline comment as done. cmtice added inline comments. Comment at: lib/CodeGen/CodeGenModule.cpp:569 + .Default(~0u); +if ((CM != ~0u) && (CM != ~1u)) { + llvm::CodeModel::Model codeModel = static_cast(CM); tejohnson wrote: > Can you simplify by using a single constant for both of these (since handling > the same)? I just realized .Case("default") is not a valid case, so I will remove that and there will only be 1 constant. Comment at: test/CodeGen/codemodels.c:2 +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOMODEL +// RUN: %clang_cc1 -emit-llvm -mcode-model small %s -o - | FileCheck %s -check-prefix=CHECK-SMALL +// RUN: %clang_cc1 -emit-llvm -mcode-model kernel %s -o - | FileCheck %s -check-prefix=CHECK-KERNEL tejohnson wrote: > Might as well check "tiny" and "default" as well for completeness. I will add a check for "tiny". "default" turns out not to be a valid option. Repository: rC Clang https://reviews.llvm.org/D52323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52323: Add necessary support for storing code-model to module IR.
cmtice updated this revision to Diff 166492. cmtice edited the summary of this revision. cmtice added a comment. Move include statement from CodeGenModule.h to CodeGenModule.cpp Remove incorrect "default" case statement. Add test for "tiny" code model. https://reviews.llvm.org/D52323 Files: lib/CodeGen/CodeGenModule.cpp test/CodeGen/codemodels.c Index: test/CodeGen/codemodels.c === --- test/CodeGen/codemodels.c +++ test/CodeGen/codemodels.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOMODEL +// RUN: %clang_cc1 -emit-llvm -mcode-model tiny %s -o - | FileCheck %s -check-prefix=CHECK-TINY +// RUN: %clang_cc1 -emit-llvm -mcode-model small %s -o - | FileCheck %s -check-prefix=CHECK-SMALL +// RUN: %clang_cc1 -emit-llvm -mcode-model kernel %s -o - | FileCheck %s -check-prefix=CHECK-KERNEL +// RUN: %clang_cc1 -emit-llvm -mcode-model medium %s -o - | FileCheck %s -check-prefix=CHECK-MEDIUM +// RUN: %clang_cc1 -emit-llvm -mcode-model large %s -o - | FileCheck %s -check-prefix=CHECK-LARGE + +// CHECK-TINY: !llvm.module.flags = !{{{.*}}} +// CHECK-TINY: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 0} +// CHECK-SMALL: !llvm.module.flags = !{{{.*}}} +// CHECK-SMALL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 1} +// CHECK-KERNEL: !llvm.module.flags = !{{{.*}}} +// CHECK-KERNEL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 2} +// CHECK-MEDIUM: !llvm.module.flags = !{{{.*}}} +// CHECK-MEDIUM: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 3} +// CHECK-LARGE: !llvm.module.flags = !{{{.*}}} +// CHECK-LARGE: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 4} +// CHECK-NOMODEL-NOT: Code Model Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -44,6 +44,7 @@ #include "clang/CodeGen/ConstantInitBuilder.h" #include "clang/Frontend/CodeGenOptions.h" #include "clang/Sema/SemaDiagnostic.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/IR/CallSite.h" @@ -53,6 +54,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/ProfileData/InstrProfReader.h" +#include "llvm/Support/CodeGen.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MD5.h" @@ -556,6 +558,20 @@ getModule().setPIELevel(static_cast(PLevel)); } + if (getCodeGenOpts().CodeModel.size() > 0) { +unsigned CM = llvm::StringSwitch(getCodeGenOpts().CodeModel) + .Case("tiny", llvm::CodeModel::Tiny) + .Case("small", llvm::CodeModel::Small) + .Case("kernel", llvm::CodeModel::Kernel) + .Case("medium", llvm::CodeModel::Medium) + .Case("large", llvm::CodeModel::Large) + .Default(~0u); +if (CM != ~0u) { + llvm::CodeModel::Model codeModel = static_cast(CM); + getModule().setCodeModel(codeModel); +} + } + if (CodeGenOpts.NoPLT) getModule().setRtLibUseGOT(); Index: test/CodeGen/codemodels.c === --- test/CodeGen/codemodels.c +++ test/CodeGen/codemodels.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NOMODEL +// RUN: %clang_cc1 -emit-llvm -mcode-model tiny %s -o - | FileCheck %s -check-prefix=CHECK-TINY +// RUN: %clang_cc1 -emit-llvm -mcode-model small %s -o - | FileCheck %s -check-prefix=CHECK-SMALL +// RUN: %clang_cc1 -emit-llvm -mcode-model kernel %s -o - | FileCheck %s -check-prefix=CHECK-KERNEL +// RUN: %clang_cc1 -emit-llvm -mcode-model medium %s -o - | FileCheck %s -check-prefix=CHECK-MEDIUM +// RUN: %clang_cc1 -emit-llvm -mcode-model large %s -o - | FileCheck %s -check-prefix=CHECK-LARGE + +// CHECK-TINY: !llvm.module.flags = !{{{.*}}} +// CHECK-TINY: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 0} +// CHECK-SMALL: !llvm.module.flags = !{{{.*}}} +// CHECK-SMALL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 1} +// CHECK-KERNEL: !llvm.module.flags = !{{{.*}}} +// CHECK-KERNEL: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 2} +// CHECK-MEDIUM: !llvm.module.flags = !{{{.*}}} +// CHECK-MEDIUM: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 3} +// CHECK-LARGE: !llvm.module.flags = !{{{.*}}} +// CHECK-LARGE: !{{[0-9]+}} = !{i32 1, !"Code Model", i32 4} +// CHECK-NOMODEL-NOT: Code Model Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -44,6 +44,7 @@ #include "clang/CodeGen/ConstantInitBuilder.h" #include "clang/Frontend/CodeGenOptions.h" #include "clang/Sema/SemaDiagnostic.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/IR/CallSite.h" @@ -53,6 +5
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice created this revision. cmtice added a reviewer: pcc. Herald added a subscriber: cfe-commits. Currently LLVM CFI tries to use an implicit blacklist file, currently in /usr/lib64/clang//share. If the file is not there, LLVM happily continues, which causes CFI to add checks to files/functions that are known to fail, generating binaries that fail. This CL causes LLVM to die (I hope) if it can't find these implicit blacklist files. Repository: rC Clang https://reviews.llvm.org/D46403 Files: SanitizerArgs.cpp Index: SanitizerArgs.cpp === --- SanitizerArgs.cpp +++ SanitizerArgs.cpp @@ -115,6 +115,8 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: SanitizerArgs.cpp === --- SanitizerArgs.cpp +++ SanitizerArgs.cpp @@ -115,6 +115,8 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice updated this revision to Diff 145073. cmtice added a comment. Tried to upload the diff from the correct location. https://reviews.llvm.org/D46403 Files: lib/Driver/SanitizerArgs.cpp Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,8 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,8 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice added a comment. Ok, I'll work on making this CFI-specific and adding a test case. https://reviews.llvm.org/D46403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice updated this revision to Diff 145243. cmtice added a comment. Updated the error to only occur for CFI blacklist, and added test case. https://reviews.llvm.org/D46403 Files: lib/Driver/SanitizerArgs.cpp test/Driver/fsanitize-blacklist.c Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,8 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,8 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice updated this revision to Diff 145266. cmtice added a comment. Added comment to change in source code. https://reviews.llvm.org/D46403 Files: lib/Driver/SanitizerArgs.cpp test/Driver/fsanitize-blacklist.c Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,10 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + // If cfi_blacklist.txt cannot be found in the resource dir, driver + // should fail. + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,10 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + // If cfi_blacklist.txt cannot be found in the resource dir, driver + // should fail. + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice added a comment. vsk: Are you asking me to put together a cfi blacklist to ship in the resource directory in the default install as part of this code review? Or is that something you want to see in a different code reivew? https://reviews.llvm.org/D46403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice updated this revision to Diff 145524. cmtice added a comment. Fix test failure that my previous changes caused. https://reviews.llvm.org/D46403 Files: lib/Driver/SanitizerArgs.cpp test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt test/Driver/fsanitize-blacklist.c test/Frontend/dependency-gen.c Index: test/Frontend/dependency-gen.c === --- test/Frontend/dependency-gen.c +++ test/Frontend/dependency-gen.c @@ -21,7 +21,7 @@ // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s // CHECK-SIX: {{ }}x.h // RUN: echo "fun:foo" > %t.blacklist -// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s // CHECK-SEVEN: .blacklist // CHECK-SEVEN: {{ }}x.h #ifndef INCLUDE_FLAG_TEST Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt === --- test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt +++ test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt @@ -0,0 +1,19 @@ +[cfi-unrelated-cast] +# The specification of std::get_temporary_buffer mandates a cast to +# uninitialized T* (libstdc++, libc++, MSVC stdlib). +fun:_ZSt20get_temporary_buffer* +fun:_ZNSt3__120get_temporary_buffer* +fun:*get_temporary_buffer@.*@std@@* + +# STL address-of magic (libstdc++, libc++). +fun:*__addressof* +fun:_ZNSt3__19addressof* + +# Windows C++ stdlib headers that contain bad unrelated casts. +src:*xmemory0 +src:*xstddef + +# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++). +# This ctor is used by std::make_shared and needs to cast to uninitialized T* +# in order to call std::allocator_traits::construct. +fun:_ZNSt23_Sp_counted_ptr_inplace* Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,10 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + // If cfi_blacklist.txt cannot be found in the resource dir, driver + // should fail. + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: test/Frontend/dependency-gen.c === --- test/Frontend/dependency-gen.c +++ test/Frontend/dependency-gen.c @@ -21,7 +21,7 @@ // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s // CHECK-SIX: {{ }}x.h // RUN: echo "fun:foo" > %t.blacklist -// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s // CHECK-SEVEN: .blacklist // CHECK-SEVEN: {{ }}x.h #ifndef INCLUDE_FLAG_TEST Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt === ---
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice added a comment. I'm not sure if I have commit access or not; Peter was working with me on trying to commit the change. https://reviews.llvm.org/D46403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice updated this revision to Diff 145537. cmtice added a comment. Make -resource-dir point to correct directory, in test case; move cfi_blacklist.txt file to 'share' subdirectory in test resource dir. https://reviews.llvm.org/D46403 Files: lib/Driver/SanitizerArgs.cpp test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt test/Driver/fsanitize-blacklist.c test/Frontend/dependency-gen.c Index: test/Frontend/dependency-gen.c === --- test/Frontend/dependency-gen.c +++ test/Frontend/dependency-gen.c @@ -21,7 +21,7 @@ // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s // CHECK-SIX: {{ }}x.h // RUN: echo "fun:foo" > %t.blacklist -// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s // CHECK-SEVEN: .blacklist // CHECK-SEVEN: {{ }}x.h #ifndef INCLUDE_FLAG_TEST Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt === --- test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt +++ test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt @@ -0,0 +1,19 @@ +[cfi-unrelated-cast] +# The specification of std::get_temporary_buffer mandates a cast to +# uninitialized T* (libstdc++, libc++, MSVC stdlib). +fun:_ZSt20get_temporary_buffer* +fun:_ZNSt3__120get_temporary_buffer* +fun:*get_temporary_buffer@.*@std@@* + +# STL address-of magic (libstdc++, libc++). +fun:*__addressof* +fun:_ZNSt3__19addressof* + +# Windows C++ stdlib headers that contain bad unrelated casts. +src:*xmemory0 +src:*xstddef + +# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++). +# This ctor is used by std::make_shared and needs to cast to uninitialized T* +# in order to call std::allocator_traits::construct. +fun:_ZNSt23_Sp_counted_ptr_inplace* Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,10 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + // If cfi_blacklist.txt cannot be found in the resource dir, driver + // should fail. + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: test/Frontend/dependency-gen.c === --- test/Frontend/dependency-gen.c +++ test/Frontend/dependency-gen.c @@ -21,7 +21,7 @@ // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s // CHECK-SIX: {{ }}x.h // RUN: echo "fun:foo" > %t.blacklist -// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s // CHECK-SEVEN: .blacklist // CHECK-SEVEN: {{ }}x.h #ifndef INCLUDE_FLAG_TEST Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: test/Drive
[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
cmtice updated this revision to Diff 145540. cmtice added a comment. Make cfi_blacklist.txt be an empty file. https://reviews.llvm.org/D46403 Files: lib/Driver/SanitizerArgs.cpp test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt test/Driver/fsanitize-blacklist.c test/Frontend/dependency-gen.c Index: test/Frontend/dependency-gen.c === --- test/Frontend/dependency-gen.c +++ test/Frontend/dependency-gen.c @@ -21,7 +21,7 @@ // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s // CHECK-SIX: {{ }}x.h // RUN: echo "fun:foo" > %t.blacklist -// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s // CHECK-SEVEN: .blacklist // CHECK-SEVEN: {{ }}x.h #ifndef INCLUDE_FLAG_TEST Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,10 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + // If cfi_blacklist.txt cannot be found in the resource dir, driver + // should fail. + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } Index: test/Frontend/dependency-gen.c === --- test/Frontend/dependency-gen.c +++ test/Frontend/dependency-gen.c @@ -21,7 +21,7 @@ // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s // CHECK-SIX: {{ }}x.h // RUN: echo "fun:foo" > %t.blacklist -// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s // CHECK-SEVEN: .blacklist // CHECK-SEVEN: {{ }}x.h #ifndef INCLUDE_FLAG_TEST Index: test/Driver/fsanitize-blacklist.c === --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -62,4 +62,8 @@ // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second // CHECK-ONLY_FIRST-DISABLED-NOT: good +// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail. +// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST +// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt' + // DELIMITERS: {{^ *"}} Index: lib/Driver/SanitizerArgs.cpp === --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -115,6 +115,10 @@ llvm::sys::path::append(Path, "share", BL.File); if (llvm::sys::fs::exists(Path)) BlacklistFiles.push_back(Path.str()); +else if (BL.Mask == CFI) + // If cfi_blacklist.txt cannot be found in the resource dir, driver + // should fail. + D.Diag(clang::diag::err_drv_no_such_file) << Path; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`
cmtice added a comment. This commit is causing some of our builds to fail with these errors: clang/lib/Sema/SemaOpenMP.cpp:11372:9: error: unused variable 'D' [-Werror,-Wunused-variable] Expr *D = nullptr; ^ clang/lib/Sema/SemaOpenMP.cpp:11373:9: error: unused variable 'CE' [-Werror,-Wunused-variable] Expr *CE = nullptr; ^ 2 errors generated. Would you please fix this? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116637/new/ https://reviews.llvm.org/D116637 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`
cmtice added a comment. When building/running third_party/llvm/llvm-project/clang/test/OpenMP/atomic_messages.c and third_party/llvm/llvm-project/clang/test/OpenMP/atomic_ast_print.cpp, we get use-of-uninitialized-variable error messages: SUMMARY: MemorySanitizer: use-of-uninitialized-value third_party/llvm/llvm-project/clang/lib/Sema/SemaOpenMP.cpp:11214:40 in (anonymous namespace)::OpenMPAtomicCompareChecker::checkType((anonymous namespace)::OpenMPAtomicCompareChecker::ErrorInfoTy&) const::$_57::operator()(clang::Expr const*, llvm::omp::OMPAtomicCompareOp, bool) const Exiting You should probably look into this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116637/new/ https://reviews.llvm.org/D116637 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141105: [OpenMP] Add support for '--offload-arch=native' to OpenMP offloading
cmtice added a comment. Just a heads up: This commit is causing our bootstrap build to fail (your new openmp-system-arch.c test is failing in our stage1 compiler). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141105/new/ https://reviews.llvm.org/D141105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays
cmtice added a comment. I did some testing and verified that this commit is causing some of the Sanitizer issues we are seeing. Is there any chance of a revert? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126864/new/ https://reviews.llvm.org/D126864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice created this revision. cmtice added a reviewer: dblaikie. Herald added subscribers: cfe-commits, fedor.sergeev, aprantl. Herald added a project: clang. Want to decouple setting the DWARF version from enabling/disabling generation of debug info. This adds a new flag '-fdebug-default-version=N' that sets the version of DWARF to be generated, but does not turn on/off debug info generation. Repository: rC Clang https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/CodeGen/debug-default-version.c Index: clang/test/CodeGen/debug-default-version.c === --- /dev/null +++ clang/test/CodeGen/debug-default-version.c @@ -0,0 +1,47 @@ +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,VER4 + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-apple-macosx10.11 -fdebug-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-apple-darwin14 -g -fdebug-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 + +// RUN: %clang -target powerpc-unknown-openbsd -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target powerpc-unknown-freebsd -g -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target i386-pc-solaris -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW + +int main (void) { + return 0; +} + +// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} + +// NOCODEVIEW-NOT: !"CodeView" + +// VER2: !{i32 2, !"Dwarf Version", i32 2} +// VER3: !{i32 2, !"Dwarf Version", i32 3} +// VER4: !{i32 2, !"Dwarf Version", i32 4} +// VER5: !{i32 2, !"Dwarf Version", i32 5} + +// NODWARF-NOT: !"Dwarf Version" +// CODEVIEW: !{i32 2, !"CodeView", i32 1} +// NOCODEVIEW-NOT: !"CodeView" +// NODWARF-NOT: !"Dwarf Version" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice marked 3 inline comments as done. cmtice added inline comments. Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3246-3247 DWARFVersion = ExplicitVersion; } + else if (DefaultDWARFVersion != 0) +DWARFVersion = DefaultDWARFVersion; dblaikie wrote: > dblaikie wrote: > > Looks like this should be on a single line to conform to LLVM convention > > (though might just be phabricator doing something weird) > > > > If you can run clang-format over the change (not over the whole file) it > > should fix up issues like this. (there's various clang-format editor > > integrations - there's some google-internal documentation at > > go/clang-format that'll explain how to setup an auto-save hook that'll > > clang-format the changed lines so all your C++ code in the LLVM repository > > conforms to LLVM's coding conventions (well, those that can be expressed by > > clang-format)) > Oh, there's also clang/tools/clang-format/git-clang-format for formatting > anything in a git revision range. Ok, will do. Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3247-3248 } + else if (DefaultDWARFVersion != 0) +DWARFVersion = DefaultDWARFVersion; dblaikie wrote: > Hmm, actually - why is this case necessary/what does it cover? I was hoping > the case you added inside the "if (EmitDwarf)" case above would be all that > was required (& the call to ParseDebugDefaultVersion would go inside there at > the use, to reduce the variable scope/keep the code closer together). This covers the case where you are setting the default dwarf version without actually turning on/off debug info at all (there's no -gdwarf or -g option, so EmitDwarf is false). Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6173-6175 +unsigned DefaultDwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args); +DwarfVersion = DefaultDwarfVersion ? DefaultDwarfVersion + :getToolChain().GetDefaultDwarfVersion(); dblaikie wrote: > Some clang-formatting required, but also could probably be written as: > > if (DwarfVersion == 0) > DwarfVersion = ParseDebugDefaultVersion(...); > > if (DwarfVersion == 0) > DwarfVersion = getToolChain().GetDefaultDwarfVersion(); > > To make these more symmetric? Ok will do. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 22. cmtice added a comment. Made requested formatting changes. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/CodeGen/debug-default-version.c Index: clang/test/CodeGen/debug-default-version.c === --- /dev/null +++ clang/test/CodeGen/debug-default-version.c @@ -0,0 +1,47 @@ +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,VER4 + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-apple-macosx10.11 -fdebug-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-apple-darwin14 -g -fdebug-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 + +// RUN: %clang -target powerpc-unknown-openbsd -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target powerpc-unknown-freebsd -g -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target i386-pc-solaris -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW + +int main (void) { + return 0; +} + +// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} + +// NOCODEVIEW-NOT: !"CodeView" + +// VER2: !{i32 2, !"Dwarf Version", i32 2} +// VER3: !{i32 2, !"Dwarf Version", i32 3} +// VER4: !{i32 2, !"Dwarf Version", i32 4} +// VER5: !{i32 2, !"Dwarf Version", i32 5} + +// NODWARF-NOT: !"Dwarf Version" +// CODEVIEW: !{i32 2, !"CodeView", i32 1} +// NOCODEVIEW-NOT: !"CodeView" +// NODWARF-NOT: !"Dwarf Version" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getAsInteger(10, Value) +
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 227910. cmtice marked 9 inline comments as done. cmtice added a comment. Made requested changes: - renamed option to be dwarf-specific - fixed spelling & blank line issues - only set version if emit-dwarf is true - move test to Driver directory I *think* I got it all done... CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/CodeGen/debug-default-version.c Index: clang/test/CodeGen/debug-default-version.c === --- /dev/null +++ clang/test/CodeGen/debug-default-version.c @@ -0,0 +1,47 @@ +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,VER4 + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-apple-macosx10.11 -fdebug-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-apple-darwin14 -g -fdebug-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 + +// RUN: %clang -target powerpc-unknown-openbsd -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target powerpc-unknown-freebsd -g -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target i386-pc-solaris -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW + +int main (void) { + return 0; +} + +// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} + +// NOCODEVIEW-NOT: !"CodeView" + +// VER2: !{i32 2, !"Dwarf Version", i32 2} +// VER3: !{i32 2, !"Dwarf Version", i32 3} +// VER4: !{i32 2, !"Dwarf Version", i32 4} +// VER5: !{i32 2, !"Dwarf Version", i32 5} + +// NODWARF-NOT: !"Dwarf Version" +// CODEVIEW: !{i32 2, !"CodeView", i32 1} +// NOCODEVIEW-NOT: !"CodeView" +// NODWARF-NOT: !"Dwarf Version" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, +
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 227940. cmtice added a comment. Try uploading correct diff file? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/CodeGen/debug-default-version.c Index: clang/test/CodeGen/debug-default-version.c === --- /dev/null +++ clang/test/CodeGen/debug-default-version.c @@ -0,0 +1,47 @@ +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,VER4 + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target x86_64-apple-macosx10.11 -fdebug-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER5 +// RUN: %clang -target x86_64-apple-darwin14 -g -fdebug-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=VER4 + +// RUN: %clang -target powerpc-unknown-openbsd -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target powerpc-unknown-freebsd -g -fdebug-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target i386-pc-solaris -fdebug-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW + +int main (void) { + return 0; +} + +// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} + +// NOCODEVIEW-NOT: !"CodeView" + +// VER2: !{i32 2, !"Dwarf Version", i32 2} +// VER3: !{i32 2, !"Dwarf Version", i32 3} +// VER4: !{i32 2, !"Dwarf Version", i32 4} +// VER5: !{i32 2, !"Dwarf Version", i32 5} + +// NODWARF-NOT: !"Dwarf Version" +// CODEVIEW: !{i32 2, !"CodeView", i32 1} +// NOCODEVIEW-NOT: !"CodeView" +// NODWARF-NOT: !"Dwarf Version" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getAsInteger(10, Value) +
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice added a comment. Hmmm...I'm having upload issues. Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3250 // -gline-directives-only supported only for the DWARF debug info. if (DWARFVersion == 0 && DebugInfoKind == codegenoptions::DebugDirectivesOnly) DebugInfoKind = codegenoptions::NoDebugInfo; dblaikie wrote: > probinson wrote: > > After setting DWARFVersion above, when nothing was requested, this looks > > peculiar. Is `DWARFVersion == 0` a proxy for `-gcodeview` ? > Yep, DWARFVersion shouldn't be set when none was requested - see discussion > above between myself & @cmtice - that should leave this code fine/correct. DWARFVersion is (will be) only set when the debug info kind is DWARF, i.e. when EmitDwarf is True. I apologize for the confusion -- David Blaikie and I has some misunderstandings about the original implementation intent. DWARFVersion == 0 ought only to result in codeview being generated/used if the user specified -g and codeview is the default debug format for the platform. Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6174 +DwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args); + if (DwarfVersion == 0) dblaikie wrote: > probinson wrote: > > I have to say, this sequence is a whole lot easier to follow than what's up > > in RenderDebugOptions. It would be nice if they were both so easy to > > understand. > > > > Although it makes me wonder, does `-fdebug-default-version` go unclaimed > > here if there's a `-gdwarf-2` on the command line? > Once the "else if (DefaultDWARFVersion != 0)" clause is removed, and the > ParseDebugDefaultVersion call is sunk down into the "if (EmitDwarf)" case - > hopefully that'll simplify the RenderDebugOptions code enough to be > reasonable? > > I think the complication there is that "-g" can imply CodeView if nothing > explicitly requests DWARF & the target is windows, whereas there's no support > for that kind of CV fallback here? So some of that might be inherent. > > & agreed - worth testing that -fdebug-default-version doesn't get a -Wunused > warning if someone says "-fdebug-default-version 4 -gdwarf-2". @cmtice is > that tested? You might be able to add -Werror to the existing test case's RUN > lines to demonstrate that no such warnings are produced? The thought is that if the user actually chose a specific dwarf version, e.g. -gdwarf-2, then that value should override the general default, specified with -fdebug-default-version (soon to be -fdwarf-default-version). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 227942. cmtice added a comment. re-try upload again. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/dwarf-default-version.c Index: clang/test/Driver/dwarf-default-version.c === --- /dev/null +++ clang/test/Driver/dwarf-default-version.c @@ -0,0 +1,47 @@ +// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdwarf-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdwarf-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdwarf-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-apple-macosx10.11 -fdwarf-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -target x86_64-apple-darwin14 -g -fdwarf-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF4 + +// RUN: %clang -target powerpc-unknown-openbsd -fdwarf-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target powerpc-unknown-freebsd -g -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target i386-pc-solaris -fdwarf-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -target i686-pc-windows-msvc -fdwarf-default-version=2 -gdwarf -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -target i686-pc-windows-msvc -fdwarf-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + +int main (void) { + return 0; +} + +// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} + +// NOCODEVIEW-NOT: !"CodeView" + +// DWARF2: !{i32 2, !"Dwarf Version", i32 2} +// DWARF3: !{i32 2, !"Dwarf Version", i32 3} +// DWARF4: !{i32 2, !"Dwarf Version", i32 4} +// DWARF5: !{i32 2, !"Dwarf Version", i32 5} + +// NODWARF-NOT: !"Dwarf Version" +// CODEVIEW: !{i32 2, !"CodeView", i32 1} +// NOCODEVIEW-NOT: !"CodeView" +// NODWARF-NOT: !"Dwarf Version" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDwarfDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDwarfDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdwarf_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getA
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice added a comment. Ok, I think the upload was correct this time. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice added a comment. dblaikie: The code, as written, parses the dwarf default version flag, whether or not DWARFVersion is 0, i.e. whether or not a -gdwarf-N flag was passed. It only USES the value if there's no overriding value. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice added a comment. For the record, I double-checked and if we use the flag and don't check for it (i.e. if we move the parsing inside the EmitDwarf is True block) then -Werror does indeed complain about an unused command line argument. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 227954. cmtice added a comment. Make second call to ParseDwarfDefaultVersion unconditional (to match the first and avoid errors with -Werror). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/dwarf-default-version.c Index: clang/test/Driver/dwarf-default-version.c === --- /dev/null +++ clang/test/Driver/dwarf-default-version.c @@ -0,0 +1,47 @@ +// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=4 -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -fdwarf-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -fdwarf-default-version=2 -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=5 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -target x86_64-linux-gnu -gdwarf -fdwarf-default-version=2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-linux-gnu -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -target x86_64-apple-macosx10.11 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-apple-macosx10.11 -fdwarf-default-version=5 -g -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -target x86_64-apple-darwin14 -g -fdwarf-default-version=4 -S -emit-llvm -o - %s -isysroot %t | FileCheck %s --check-prefix=DWARF4 + +// RUN: %clang -target powerpc-unknown-openbsd -fdwarf-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target powerpc-unknown-freebsd -g -fdwarf-default-version=4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -target i386-pc-solaris -fdwarf-default-version=4 -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -target i686-pc-windows-msvc -fdwarf-default-version=2 -gdwarf -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -target i686-pc-windows-msvc -fdwarf-default-version=4 -gdwarf -gcodeview -S -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + +int main (void) { + return 0; +} + +// NODEBUGINFO-NOT: !llvm.dbg.cu = !{!0} + +// NOCODEVIEW-NOT: !"CodeView" + +// DWARF2: !{i32 2, !"Dwarf Version", i32 2} +// DWARF3: !{i32 2, !"Dwarf Version", i32 3} +// DWARF4: !{i32 2, !"Dwarf Version", i32 4} +// DWARF5: !{i32 2, !"Dwarf Version", i32 5} + +// NODWARF-NOT: !"Dwarf Version" +// CODEVIEW: !{i32 2, !"CodeView", i32 1} +// NOCODEVIEW-NOT: !"CodeView" +// NODWARF-NOT: !"Dwarf Version" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDwarfDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDwarfDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdwarf_default_version)
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice marked an inline comment as done. cmtice added a comment. Yes, I will change the flag name back to debug-default-version, and add help text mentioning dwarf. I'm in the process of trying to re-do the test cases as required (I'm a bit new to this so it's taking me a bit to figure this out). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 227977. cmtice added a comment. Rename flag to -fdebug-default-version; add help text, mentioning DWARF. Update tests to use -### and add assembler tests. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/debug-default-version.c Index: clang/test/Driver/debug-default-version.c === --- /dev/null +++ clang/test/Driver/debug-default-version.c @@ -0,0 +1,67 @@ +// RUN: %clang -### -c -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -target x86_64-linux-gnu -fdebug-default-version=4 -S -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -### -target x86_64-apple-macosx10.11 -fdebug-default-version=5 -g -S -o - %s -isysroot %t 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -target x86_64-apple-darwin14 -g -fdebug-default-version=4 -S -o - %s -isysroot %t 2>&1 | FileCheck %s --check-prefix=DWARF4 + +// RUN: %clang -### -target powerpc-unknown-openbsd -fdebug-default-version=4 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -target powerpc-unknown-freebsd -g -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -target i386-pc-solaris -fdebug-default-version=4 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -### -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -### -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + + +// Do Assembler testing most of the same test cases as those above. + +// RUN: %clang -### -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +// RUN: %clang -### -c -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -target x86_64-linux-gnu -gdwarf-5 -x assembler -c -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +// The -isysroot is used as a hack to avoid LIT messing with the SDKROOT +// environment variable which indirecty overrides the version in the target +// triple used here. +// RUN: %clang -### -target x86_64-apple-macosx10.11 -fdebug-default-version=5 -g -x assembler -c -o - %s -isysroot %t 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -target x86_64-apple-darwin14 -g -fdebug-default-version=4 -x assembler -c -o - %s -isysroot %t 2>&1 | FileCheck %s --check-prefix=DWARF4 + +// RUN: %clang -### -target powerpc-unknown-openbsd -fdebug-default-version=4 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -target powerpc-unknown-freebsd -g -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -target i386-pc-solaris -fdebug-default-version=4 -g -x assembler -c -o - %s
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 228115. cmtice added a comment. Remove period from help text. Fix tests. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/debug-default-version.c Index: clang/test/Driver/debug-default-version.c === --- /dev/null +++ clang/test/Driver/debug-default-version.c @@ -0,0 +1,45 @@ +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -S -o - %s | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + + +// Do Assembler testing most of the same test cases as those above. + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -x assembler -c -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +int main (void) { + return 0; +} + +// NOCODEVIEW-NOT: "-gcodeview" +// CODEVIEW: "-gcodeview" + +// NODEBUGINFO-NOT: "-debug-info-kind=" + +// DWARF2: "-dwarf-version=2" +// DWARF3: "-dwarf-version=3" +// DWARF4: "-dwarf-version=4" +// DWARF5: "-dwarf-version=5" + +// NOCODEVIEW-NOT: "-gcodeview" +// NODWARF4-NOT: "-dwarf-version=4" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getAsInteger(10, Value) + || Value > 5 + || Value < 2) +TC.getDriver().Diag(diag::err_drv_invalid_int_value) +<< A->getAsString(Args)
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 228130. cmtice added a comment. Fix NODEBUGINFO-NOT test. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/debug-default-version.c Index: clang/test/Driver/debug-default-version.c === --- /dev/null +++ clang/test/Driver/debug-default-version.c @@ -0,0 +1,45 @@ +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + + +// Do Assembler testing most of the same test cases as those above. + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -x assembler -c -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +int main (void) { + return 0; +} + +// NOCODEVIEW-NOT: "-gcodeview" +// CODEVIEW: "-gcodeview" + +// NODEBUGINFO-NOT: -debug-info-kind= + +// DWARF2: "-dwarf-version=2" +// DWARF3: "-dwarf-version=3" +// DWARF4: "-dwarf-version=4" +// DWARF5: "-dwarf-version=5" + +// NOCODEVIEW-NOT: "-gcodeview" +// NODWARF4-NOT: "-dwarf-version=4" Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getAsInteger(10, Value) + || Value > 5 + || Value < 2) +TC.getDriver().Diag(diag::err_drv_invalid_int_value) +<< A->getAsString(Args) << A->g
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 228144. cmtice added a comment. Remove quotes from -NOT tests. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/debug-default-version.c Index: clang/test/Driver/debug-default-version.c === --- /dev/null +++ clang/test/Driver/debug-default-version.c @@ -0,0 +1,45 @@ +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, of you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + + +// Do Assembler testing most of the same test cases as those above. + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -x assembler -c -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +int main (void) { + return 0; +} + +// NOCODEVIEW-NOT: -gcodeview +// CODEVIEW: "-gcodeview" + +// NODEBUGINFO-NOT: -debug-info-kind= + +// DWARF2: "-dwarf-version=2" +// DWARF3: "-dwarf-version=3" +// DWARF4: "-dwarf-version=4" +// DWARF5: "-dwarf-version=5" + +// NOCODEVIEW-NOT: -gcodeview +// NODWARF4-NOT: -dwarf-version=4 Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getAsInteger(10, Value) + || Value > 5 + || Value < 2) +TC.getDriver().Diag(diag::err_drv_invalid_int_value) +<< A->getAsString(Args) << A->ge
[PATCH] D69822: [clang] Add new -fdebug-default-version flag.
cmtice updated this revision to Diff 228250. cmtice added a comment. Fix small typo in comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69822/new/ https://reviews.llvm.org/D69822 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/test/Driver/debug-default-version.c Index: clang/test/Driver/debug-default-version.c === --- /dev/null +++ clang/test/Driver/debug-default-version.c @@ -0,0 +1,45 @@ +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -S -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf -fdebug-default-version=2 -S -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -S -o - %s 2>&1 | FileCheck %s --check-prefixes=NODEBUGINFO,NODWARF4 + +// Check which debug info formats we use on Windows. By default, in an MSVC +// environment, we should use codeview. You can enable dwarf, which implicitly +// disables codeview, or you can explicitly ask for both if you don't know how +// the app will be debugged. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=2 -gdwarf -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF2,NOCODEVIEW +// Explicitly request both. +// RUN: %clang -### -Werror -target i686-pc-windows-msvc -fdebug-default-version=4 -gdwarf -gcodeview -S -o - %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=DWARF4,CODEVIEW + + +// Do Assembler testing most of the same test cases as those above. + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=4 -gdwarf-2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF2 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-3 -fdebug-default-version=4 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF3 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-4 -fdebug-default-version=2 -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF4 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -gdwarf-5 -x assembler -c -fdebug-default-version=2 -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 +// RUN: %clang -### -Werror -target x86_64-linux-gnu -fdebug-default-version=5 -g -x assembler -c -o - %s 2>&1 | FileCheck %s --check-prefix=DWARF5 + +int main (void) { + return 0; +} + +// NOCODEVIEW-NOT: -gcodeview +// CODEVIEW: "-gcodeview" + +// NODEBUGINFO-NOT: -debug-info-kind= + +// DWARF2: "-dwarf-version=2" +// DWARF3: "-dwarf-version=3" +// DWARF4: "-dwarf-version=4" +// DWARF5: "-dwarf-version=5" + +// NOCODEVIEW-NOT: -gcodeview +// NODWARF4-NOT: -dwarf-version=4 Index: clang/lib/Driver/ToolChains/CommonArgs.h === --- clang/lib/Driver/ToolChains/CommonArgs.h +++ clang/lib/Driver/ToolChains/CommonArgs.h @@ -68,6 +68,9 @@ unsigned ParseFunctionAlignment(const ToolChain &TC, const llvm::opt::ArgList &Args); +unsigned ParseDebugDefaultVersion(const ToolChain &TC, + const llvm::opt::ArgList &Args); + void AddAssemblerKPIC(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs); Index: clang/lib/Driver/ToolChains/CommonArgs.cpp === --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1138,6 +1138,22 @@ return Value ? llvm::Log2_32_Ceil(std::min(Value, 65536u)) : Value; } +unsigned tools::ParseDebugDefaultVersion(const ToolChain &TC, + const ArgList &Args) { + const Arg *A = Args.getLastArg(options::OPT_fdebug_default_version); + + if (!A) +return 0; + + unsigned Value = 0; + if (StringRef(A->getValue()).getAsInteger(10, Value) + || Value > 5 + || Value < 2) +TC.getDriver().Diag(diag::err_drv_invalid_int_value) +<< A->getAsString(Args) << A->getVa
[PATCH] D149650: Give NullabilityKind a printing operator<
cmtice added a comment. This is breaking some of our tests. I will give the author a reproducible test case. I am going to revert this while waiting for a fix. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149650/new/ https://reviews.llvm.org/D149650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D116542: [OpenMP] Add a flag for embedding a file into the module
cmtice added a comment. This change introduces a circular dependency: BitcodeWriters now depends on TransformUtils, but TransformUtils also depends on BitcodeWriters. This appears to be a layering violation. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116542/new/ https://reviews.llvm.org/D116542 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits