r362113 - [Docs] Modernize references to macOS
Author: jryans Date: Thu May 30 09:46:22 2019 New Revision: 362113 URL: http://llvm.org/viewvc/llvm-project?rev=362113&view=rev Log: [Docs] Modernize references to macOS Summary: This updates all places in documentation that refer to "Mac OS X", "OS X", etc. to instead use the modern name "macOS" when no specific version number is mentioned. If a specific version is mentioned, this attempts to use the OS name at the time of that version: * Mac OS X for 10.0 - 10.7 * OS X for 10.8 - 10.11 * macOS for 10.12 - present Reviewers: JDevlieghere Subscribers: mgorny, christof, arphaman, cfe-commits, lldb-commits, libcxx-commits, llvm-commits Tags: #clang, #lldb, #libc, #llvm Differential Revision: https://reviews.llvm.org/D62654 Modified: cfe/trunk/docs/AddressSanitizer.rst cfe/trunk/docs/AutomaticReferenceCounting.rst cfe/trunk/docs/ClangCommandLineReference.rst cfe/trunk/docs/CommandGuide/clang.rst cfe/trunk/docs/LeakSanitizer.rst cfe/trunk/docs/Modules.rst cfe/trunk/docs/SafeStack.rst cfe/trunk/docs/UndefinedBehaviorSanitizer.rst cfe/trunk/docs/UsersManual.rst cfe/trunk/docs/analyzer/checkers.rst cfe/trunk/docs/analyzer/developer-docs/DebugChecks.rst Modified: cfe/trunk/docs/AddressSanitizer.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AddressSanitizer.rst?rev=362113&r1=362112&r2=362113&view=diff == --- cfe/trunk/docs/AddressSanitizer.rst (original) +++ cfe/trunk/docs/AddressSanitizer.rst Thu May 30 09:46:22 2019 @@ -119,7 +119,7 @@ force disabled by setting ``ASAN_OPTIONS #1 0x7f7ddabcac4d in __libc_start_main ??:0 ... -Note that on OS X you may need to run ``dsymutil`` on your binary to have the +Note that on macOS you may need to run ``dsymutil`` on your binary to have the file\:line info in the AddressSanitizer reports. Additional Checks @@ -134,14 +134,14 @@ globals defined in another translation u you should set environment variable ``ASAN_OPTIONS=check_initialization_order=1``. -Note that this option is not supported on OS X. +Note that this option is not supported on macOS. Memory leak detection - For more information on leak detector in AddressSanitizer, see :doc:`LeakSanitizer`. The leak detection is turned on by default on Linux, -and can be enabled using ``ASAN_OPTIONS=detect_leaks=1`` on OS X; +and can be enabled using ``ASAN_OPTIONS=detect_leaks=1`` on macOS; however, it is not yet supported on other platforms. Issue Suppression @@ -273,7 +273,7 @@ Supported Platforms AddressSanitizer is supported on: * Linux i386/x86\_64 (tested on Ubuntu 12.04) -* OS X 10.7 - 10.11 (i386/x86\_64) +* macOS 10.7 - 10.11 (i386/x86\_64) * iOS Simulator * Android ARM * NetBSD i386/x86\_64 Modified: cfe/trunk/docs/AutomaticReferenceCounting.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AutomaticReferenceCounting.rst?rev=362113&r1=362112&r2=362113&view=diff == --- cfe/trunk/docs/AutomaticReferenceCounting.rst (original) +++ cfe/trunk/docs/AutomaticReferenceCounting.rst Thu May 30 09:46:22 2019 @@ -268,7 +268,7 @@ ARC's semantics and restrictions. * There must be reliable conventions for whether and when "ownership" is passed between caller and callee, for both arguments and return values. Objective-C methods follow such a convention very reliably, at least for -system libraries on Mac OS X, and functions always pass objects at +0. The +system libraries on macOS, and functions always pass objects at +0. The C-based APIs for Core Foundation objects, on the other hand, have much more varied transfer semantics. Modified: cfe/trunk/docs/ClangCommandLineReference.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=362113&r1=362112&r2=362113&view=diff == --- cfe/trunk/docs/ClangCommandLineReference.rst (original) +++ cfe/trunk/docs/ClangCommandLineReference.rst Thu May 30 09:46:22 2019 @@ -2218,7 +2218,7 @@ Generate branches with extended addressa .. option:: -mmacosx-version-min=, -mmacos-version-min= -Set Mac OS X deployment target +Set macOS deployment target .. option:: -mmcu= Modified: cfe/trunk/docs/CommandGuide/clang.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=362113&r1=362112&r2=362113&view=diff == --- cfe/trunk/docs/CommandGuide/clang.rst (original) +++ cfe/trunk/docs/CommandGuide/clang.rst Thu May 30 09:46:22 2019 @@ -316,7 +316,7 @@ number of cross compilers, or may only s .. option:: -mmacosx-version-min= - When building for Mac OS X, specify the minimum version supported by your + When building for macOS, specify the minimum vers
[libunwind] r362113 - [Docs] Modernize references to macOS
Author: jryans Date: Thu May 30 09:46:22 2019 New Revision: 362113 URL: http://llvm.org/viewvc/llvm-project?rev=362113&view=rev Log: [Docs] Modernize references to macOS Summary: This updates all places in documentation that refer to "Mac OS X", "OS X", etc. to instead use the modern name "macOS" when no specific version number is mentioned. If a specific version is mentioned, this attempts to use the OS name at the time of that version: * Mac OS X for 10.0 - 10.7 * OS X for 10.8 - 10.11 * macOS for 10.12 - present Reviewers: JDevlieghere Subscribers: mgorny, christof, arphaman, cfe-commits, lldb-commits, libcxx-commits, llvm-commits Tags: #clang, #lldb, #libc, #llvm Differential Revision: https://reviews.llvm.org/D62654 Modified: libunwind/trunk/docs/index.rst Modified: libunwind/trunk/docs/index.rst URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/index.rst?rev=362113&r1=362112&r2=362113&view=diff == --- libunwind/trunk/docs/index.rst (original) +++ libunwind/trunk/docs/index.rst Thu May 30 09:46:22 2019 @@ -50,7 +50,7 @@ FreeBSD i386, x86_64, ARM64 Cl iOS ARM ClangSjLj LinuxARM Clang, GCC EHABI Linuxi386, x86_64, ARM64 Clang, GCC DWARF CFI -Mac OS X i386, x86_64 Clang, GCC DWARF CFI +macOSi386, x86_64 Clang, GCC DWARF CFI NetBSD x86_64 Clang, GCC DWARF CFI Windows i386, x86_64, ARM, ARM64 ClangDWARF CFI ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Attach DW_AT_const_value to static data-member definitions if available (PR #72730)
https://github.com/jryans commented: Overall this looks good, thanks! I think we may want to add a test to check that the output DWARF has a const value in the expected place, since consumers are relying on it. https://github.com/llvm/llvm-project/pull/72730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Attach DW_AT_const_value to static data-member definitions if available (PR #72730)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/72730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Attach DW_AT_const_value to static data-member definitions if available (PR #72730)
@@ -5503,11 +5516,17 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, } AppendAddressSpaceXDeref(AddressSpace, Expr); +llvm::DIExpression *E = nullptr; +if (Expr.empty()) { + if (auto const *InitVal = evaluateConstantInitializer(D)) +E = createConstantValueExpression(D, *InitVal); +} else jryans wrote: I believe code style says this else block should use braces because the if block has them. https://github.com/llvm/llvm-project/pull/72730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Attach DW_AT_const_value to static data-member definitions if available (PR #72730)
https://github.com/jryans approved this pull request. > This patch makes sure we encode the constant in a `DIExpression` on > definitions, which is tested. And we have tests for ensuring that > `DW_OP_constu` expressions get turned into `DW_AT_const_value`s (I know of at > least `llvm/test/DebugInfo/Generic/dwarf5-debug-info-static-member.ll`) Ah okay, then with that in mind, I think the test changes here are likely enough to merge. 🙂 https://github.com/llvm/llvm-project/pull/72730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][DebugInfo] Revert to attaching DW_AT_const_value on static member declarations (PR #73626)
https://github.com/jryans approved this pull request. Thanks, seems like a fine temporary measure to me! 😄 https://github.com/llvm/llvm-project/pull/73626 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ecade80 - [clang][Darwin] Try to guess the SDK root with xcrun when unspecified
Author: Caleb Zulawski Date: 2023-01-18T18:20:59Z New Revision: ecade80d93960ad01d8665db02c23841e055a80f URL: https://github.com/llvm/llvm-project/commit/ecade80d93960ad01d8665db02c23841e055a80f DIFF: https://github.com/llvm/llvm-project/commit/ecade80d93960ad01d8665db02c23841e055a80f.diff LOG: [clang][Darwin] Try to guess the SDK root with xcrun when unspecified Picking up from https://reviews.llvm.org/D109460 Reviewed By: ldionne Differential Revision: https://reviews.llvm.org/D136315 Added: clang/test/Driver/darwin-sdk-detect.c Modified: clang/docs/UsersManual.rst clang/lib/Driver/ToolChains/Darwin.cpp Removed: diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 7dd8ecb5fcc4d..e0030d24c23b1 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3824,6 +3824,20 @@ backend. Operating System Features and Limitations - +Apple +^ + +On Apple platforms, the standard headers and libraries are not provided by +the base system and are instead part of the Xcode SDK application. The location +of the SDK is determined any of the following ways: + +- If passed to Clang, the ``-isysroot`` option specifies the path to the SDK. + +- If the sysroot isn't provided, the ``SDKROOT`` environment variable is checked. + This variable is set by various Xcode tools. + +- Otherwise, Clang uses Xcode's ``xcrun`` tool to find the SDK. + Windows ^^^ diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 9f95c962ee9aa..03c28c14a0ecb 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -18,15 +18,22 @@ #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "clang/Driver/SanitizerArgs.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Option/ArgList.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/TargetParser.h" #include "llvm/Support/Threading.h" #include "llvm/Support/VirtualFileSystem.h" #include // ::getenv +#include // std::unique_ptr using namespace clang::driver; using namespace clang::driver::tools; @@ -2078,21 +2085,89 @@ std::optional parseSDKSettings(llvm::vfs::FileSystem &VFS, void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { const OptTable &Opts = getDriver().getOpts(); - // Support allowing the SDKROOT environment variable used by xcrun and other - // Xcode tools to define the default sysroot, by making it the default for - // isysroot. + // On Apple platforms, standard headers and libraries are not provided with + // the base system (e.g. in /usr/{include,lib}). Instead, they are provided + // in various SDKs for the diff erent Apple platforms. Clang needs to know + // where that SDK lives, and there are a couple ways this can be achieved: + // + // (1) If `-isysroot ` is passed explicitly, use that. if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { // Warn if the path does not exist. if (!getVFS().exists(A->getValue())) getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue(); - } else { -if (char *env = ::getenv("SDKROOT")) { - // We only use this value as the default if it is an absolute path, - // exists, and it is not the root path. - if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) && - StringRef(env) != "/") { -Args.append(Args.MakeSeparateArg( -nullptr, Opts.getOption(options::OPT_isysroot), env)); + } + + // (2) If the SDKROOT environment variable is defined and points to a valid + // path, use that. $SDKROOT is set by `xcrun` and other Xcode tools, so + // running `xcrun clang` will work by going through this path. + else if (char *env = ::getenv("SDKROOT")) { +// We only use this value as the default if it is an absolute path, +// exists, and it is not the root path. +if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) && +StringRef(env) != "/") { + Args.append(Args.MakeSeparateArg( + nullptr, Opts.getOption(options::OPT_isysroot), env)); +} + } + + // (3) Otherwise, we try to guess the path of the default SDK by running + // `xcrun --show-sdk-path`. This won't always be correct, but if the + // user wants to use the non-default SDK, they should specify it + // explicitly with methods (1) or (2) above. + else { +llvm::SmallString<64> OutputFile; +llvm::sys::fs::createTemporaryFile("print-sdk-path", "" /* No Suffix */, +
[clang] [IPSCCP] Variable not visible at Og: (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans approved this pull request. Looks good to me, thanks! 😄 Other reviewers had more comments last time around, so probably best to wait for at least one more review before landing. https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [IPSCCP] Variable not visible at Og. (PR #66745)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 241cceb - [Clang][Tooling] Accept preprocessed input files
Author: J. Ryan Stinnett Date: 2023-08-08T12:44:48+01:00 New Revision: 241cceb9af844ef7d7a87124407a04b0a64991fe URL: https://github.com/llvm/llvm-project/commit/241cceb9af844ef7d7a87124407a04b0a64991fe DIFF: https://github.com/llvm/llvm-project/commit/241cceb9af844ef7d7a87124407a04b0a64991fe.diff LOG: [Clang][Tooling] Accept preprocessed input files This restores the tooling library's ability to accept invocations that take a preprocessed file as the primary input. Regressed by https://reviews.llvm.org/D105695 Fixes https://github.com/llvm/llvm-project/issues/63941 Differential Revision: https://reviews.llvm.org/D157011 Added: Modified: clang/lib/Tooling/Tooling.cpp clang/unittests/Tooling/ToolingTest.cpp Removed: diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index 46a784e44b931a..dc82a1f3772dd2 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -147,6 +147,13 @@ getCC1Arguments(DiagnosticsEngine *Diagnostics, if (IsCC1Command(Job) && llvm::all_of(Job.getInputInfos(), IsSrcFile)) CC1Jobs.push_back(&Job); + // If there are no jobs for source files, try checking again for a single job + // with any file type. This accepts a preprocessed file as input. + if (CC1Jobs.empty()) +for (const driver::Command &Job : Jobs) + if (IsCC1Command(Job)) +CC1Jobs.push_back(&Job); + if (CC1Jobs.empty() || (CC1Jobs.size() > 1 && !ignoreExtraCC1Commands(Compilation))) { SmallString<256> error_msg; diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index ebe03fda78f1ef..354af292a54108 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -449,6 +449,13 @@ TEST_F(CommandLineExtractorTest, AcceptSaveTemps) { EXPECT_NE(extractCC1Arguments(Args), nullptr); } +TEST_F(CommandLineExtractorTest, AcceptPreprocessedInputFile) { + addFile("test.i", "int main() {}\n"); + const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0", "-c", +"test.i"}; + EXPECT_NE(extractCC1Arguments(Args), nullptr); +} + TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) { addFile("test.c", "int main() {}\n"); const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0", ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Rename -macosx_version_min to -macosx_version_min (PR #88810)
jryans wrote: Perhaps good to edit the PR title, it mentions the same flag twice at the moment. https://github.com/llvm/llvm-project/pull/88810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Rename -macosx_version_min to -macos_version_min (PR #88810)
https://github.com/jryans commented: AIUI, this is straightforward case of updating tools to use new option names. I suppose there is a chance it triggers failures in e.g. older linkers that don't support the newer names, but I assume on Apple platforms there's less risk of that anyway. Do you happen to know when the new name was first added to the linker? https://github.com/llvm/llvm-project/pull/88810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs][Clang] Resolve DILocalVariables used by DbgRecords (PR #90882)
https://github.com/jryans approved this pull request. https://github.com/llvm/llvm-project/pull/90882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DebugInfo] Use DW_op_bit_piece for structured bindings of bitfields (PR #85665)
jryans wrote: It would be great to add a few notes to document this additional op in the [`DIExpression` list of ops](https://llvm.org/docs/LangRef.html#diexpression). It would be especially good for those added docs to clarify the difference between this and `DW_OP_LLVM_fragment`. (I do understand that this `DW_OP_bit_piece` op is part of standard DWARF, and there are already some standard DWARF ops we use that are missing from those docs already, but even with that in mind ... it would be great to have new docs added for this additional op.) https://github.com/llvm/llvm-project/pull/85665 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RemoveDIs] Print IR with debug records by default (PR #91724)
https://github.com/jryans commented: Overall, your process looks good to me! Thanks for working on this and including such a detailed description. This will surely aid downstream maintainers. 😄 There's one part I did not fully understand. How did you identify the "pre-script fixups"? What's the importance of those changes? I did not seen any mention of that in your PR description. https://github.com/llvm/llvm-project/pull/91724 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RemoveDIs] Print IR with debug records by default (PR #91724)
https://github.com/jryans approved this pull request. Thanks for clarifying the pre-script fixes. With that resolved, this looks good to me. https://github.com/llvm/llvm-project/pull/91724 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
@@ -11,6 +11,22 @@ #include "llvm/IR/DebugInfo.h" using namespace llvm; +#if ENABLE_DEBUGLOC_COVERAGE_TRACKING +DILocAndCoverageTracking::DILocAndCoverageTracking(const DILocation *L) +: TrackingMDNodeRef(const_cast(L)), + Kind(DebugLocKind::Normal) {} + +DebugLoc DebugLoc::getTemporary() { return DebugLoc(DebugLocKind::Temporary); } +DebugLoc DebugLoc::getUnknown() { return DebugLoc(DebugLocKind::Unknown); } +DebugLoc DebugLoc::getLineZero() { return DebugLoc(DebugLocKind::LineZero); } + +#else + jryans wrote: I would maybe remove the blank lines around this `#else`, but perhaps that's just me. https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
@@ -22,6 +23,67 @@ namespace llvm { class LLVMContext; class raw_ostream; class DILocation; + class Function; + +#if ENABLE_DEBUGLOC_COVERAGE_TRACKING + // Used to represent different "kinds" of DebugLoc, expressing that a DebugLoc + // is either ordinary, containing a valid DILocation, or otherwise describing + // the reason why the DebugLoc does not contain a valid DILocation. + enum class DebugLocKind : uint8_t { +// DebugLoc is expected to contain a valid DILocation. +Normal, +// DebugLoc intentionally does not have a valid DILocation; may be for a +// compiler-generated instruction, or an explicitly dropped location. +LineZero, jryans wrote: Hmm, I'd really prefer the name of this case to clearly state the "intentional" aspect. Perhaps `IntentionallyZero`...? Another approach might be to have separate enum values for the different reasons, e.g. `CompilerGenerated`, `ExplicitlyDropped`, and whatever the others might be. Stating these cases very clearly, not just in comments, but also via enum value would appear to be a very valuable capturing of intent to me. (However, maybe it is too much trouble to do so...? Please say that if so.) https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
@@ -2080,6 +2081,10 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) { } if (!DL) { +// FIXME: We could assert that `DL.getKind() != DebugLocKind::Temporary` +// here, or otherwise record any temporary DebugLocs seen to ensure that +// transient compiler-generated instructions aren't leaking their DLs to +// other instructions. jryans wrote: Hmm yes, reporting such cases somehow does seem valuable... though unclear to me which way is best, so perhaps best left as future work for now. https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
https://github.com/jryans commented: Looks good overall, a few comments inline. Thanks for working on this feature, I believe this will be quite useful! 😄 https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -1279,6 +1279,9 @@ void Instruction::swapProfMetadata() { void Instruction::copyMetadata(const Instruction &SrcInst, ArrayRef WL) { + if (WL.empty() || is_contained(WL, LLVMContext::MD_dbg)) +setDebugLoc(SrcInst.getDebugLoc()); jryans wrote: Hmm, I'm wondering why this was necessary and if it may have unrelated consequence beyond this patch stack's feature...? https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -55,6 +73,28 @@ namespace sys { ///specified, the entire frame is printed. void PrintStackTrace(raw_ostream &OS, int Depth = 0); +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +#ifdef NDEBUG +#error DebugLoc origin-tracking should not be enabled in Release builds. +#endif + /// Populates the given array with a stacktrace of the current program, up to jryans wrote: stacktrace -> stack trace https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -50,11 +50,15 @@ class TargetRegisterInfo; class MergePotentialsElt { unsigned Hash; MachineBasicBlock *Block; - DebugLoc BranchDebugLoc; + // We use MDNode rather than DebugLoc here because under certain CMake + // options*, DebugLoc may contain a SmallVector used for introspection + // purposes, which causes errors when stored here. + // *LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING=COVERAGE_AND_ORIGIN jryans wrote: What's the purpose of this line...? https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -253,6 +253,122 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, return true; } +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +void sys::symbolizeAddresses(AddressSet &Addresses, + SymbolizedAddressMap &SymbolizedAddresses) { + assert(!DisableSymbolicationFlag && !getenv(DisableSymbolizationEnv) && + "Debugify origin stacktraces require symbolization to be enabled."); jryans wrote: stacktrace -> stack trace https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -115,6 +138,23 @@ namespace llvm { DebugLocKind getKind() const { return Loc.Kind; } #endif +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +#if !ENABLE_DEBUGLOC_COVERAGE_TRACKING +#error Cannot enable DebugLoc origin-tracking without coverage-tracking! +#endif jryans wrote: Not sure how critical checking this case is... IIUC, CMake options won't let you set such anything anyway, so perhaps remove this? If keeping it, perhaps remove the blank line after this `#endif` here. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -253,6 +253,122 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, return true; } +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +void sys::symbolizeAddresses(AddressSet &Addresses, + SymbolizedAddressMap &SymbolizedAddresses) { + assert(!DisableSymbolicationFlag && !getenv(DisableSymbolizationEnv) && + "Debugify origin stacktraces require symbolization to be enabled."); + + // Convert Set of Addresses to ordered list. + SmallVector AddressList(Addresses.begin(), Addresses.end()); + if (AddressList.empty()) +return; + int NumAddresses = AddressList.size(); + llvm::sort(AddressList); + + // Use llvm-symbolizer tool to symbolize the stack traces. First look for it jryans wrote: It seems like this copies code from `printSymbolizedStackTrace` above...? Can we rework this to share common code instead of duplicating it? https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -48,22 +64,29 @@ namespace llvm { Temporary }; - // Extends TrackingMDNodeRef to also store a DebugLocKind, allowing Debugify - // to ignore intentionally-empty DebugLocs. - class DILocAndCoverageTracking : public TrackingMDNodeRef { + // Extends TrackingMDNodeRef to also store a DebugLocKind and Origin, + // allowing Debugify to ignore intentionally-empty DebugLocs and display the + // code responsible for generating unintentionally-empty DebugLocs. + // Currently we only need to track the Origin of this DILoc when using a + // DebugLoc that is Normal and empty, so only collect the origin stacktrace in jryans wrote: Do you "normal or empty"...? There seem to be two cases below where traces are collected. stacktrace -> stack trace https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
https://github.com/jryans requested changes to this pull request. More exciting work! 😄 Seems roughly sensible, but appears to duplicate some code that can hopefully be shared. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -28,6 +31,11 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/JSON.h" #include +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +// We need the Signals header to operate on stacktraces if we're using DebugLoc jryans wrote: stacktrace -> stack trace https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -487,14 +490,15 @@ def Main(): if bugs_metadata == "DILocation": try: +origin = bug["origin"] action = bug["action"] bb_name = bug["bb-name"] fn_name = bug["fn-name"] instr = bug["instr"] except: skipped_bugs += 1 continue -di_loc_bug = DILocBug(action, bb_name, fn_name, instr) +di_loc_bug = DILocBug(origin, action, bb_name, fn_name, instr) jryans wrote: Maybe move `origin` to the end, which also seems to match the order where its used? https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -487,14 +490,15 @@ def Main(): if bugs_metadata == "DILocation": try: +origin = bug["origin"] action = bug["action"] bb_name = bug["bb-name"] fn_name = bug["fn-name"] instr = bug["instr"] except: skipped_bugs += 1 continue -di_loc_bug = DILocBug(action, bb_name, fn_name, instr) +di_loc_bug = DILocBug(origin, action, bb_name, fn_name, instr) jryans wrote: Ah hmm, that is odd... Okay, seems like you've tried to follow the local (somewhat strange) style. 😄 https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
@@ -22,6 +23,67 @@ namespace llvm { class LLVMContext; class raw_ostream; class DILocation; + class Function; + +#if ENABLE_DEBUGLOC_COVERAGE_TRACKING + // Used to represent different "kinds" of DebugLoc, expressing that a DebugLoc + // is either ordinary, containing a valid DILocation, or otherwise describing + // the reason why the DebugLoc does not contain a valid DILocation. + enum class DebugLocKind : uint8_t { +// DebugLoc is expected to contain a valid DILocation. +Normal, +// DebugLoc intentionally does not have a valid DILocation; may be for a +// compiler-generated instruction, or an explicitly dropped location. +LineZero, jryans wrote: Looking at it another way, I suppose my point is `LineZero` doesn't convey whether it's on purpose, an accident, or some undetermined mix of the two. But really, this case is trying to capture cases where explicit choices were made, so the name should reflect that somehow. https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -115,6 +138,23 @@ namespace llvm { DebugLocKind getKind() const { return Loc.Kind; } #endif +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +#if !ENABLE_DEBUGLOC_COVERAGE_TRACKING +#error Cannot enable DebugLoc origin-tracking without coverage-tracking! +#endif jryans wrote: Hmm, how are environment variables ending up with up confused compiler defines...? Anyway, it's fine to keep, even if highly unlikely to be hit. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -253,6 +253,122 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, return true; } +#if ENABLE_DEBUGLOC_ORIGIN_TRACKING +void sys::symbolizeAddresses(AddressSet &Addresses, + SymbolizedAddressMap &SymbolizedAddresses) { + assert(!DisableSymbolicationFlag && !getenv(DisableSymbolizationEnv) && + "Debugify origin stacktraces require symbolization to be enabled."); + + // Convert Set of Addresses to ordered list. + SmallVector AddressList(Addresses.begin(), Addresses.end()); + if (AddressList.empty()) +return; + int NumAddresses = AddressList.size(); + llvm::sort(AddressList); + + // Use llvm-symbolizer tool to symbolize the stack traces. First look for it jryans wrote: I don't see a need to be so conservative with this particular bit in the `Support` library. `symbolizeAddresses` seems like a useful function that others may want to use as well. So, I'd encourage making that available all the time (removing the `#if` guards) and refactoring to deduplicate shared code here. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 4/5] Track coverage and origins through IRBuilder (PR #108214)
https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/108214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 4/5] Track coverage and origins through IRBuilder (PR #108214)
@@ -90,12 +90,23 @@ class IRBuilderCallbackInserter : public IRBuilderDefaultInserter { /// Common base class shared among various IRBuilders. class IRBuilderBase { /// Pairs of (metadata kind, MDNode *) that should be added to all newly - /// created instructions, like !dbg metadata. + /// created instructions, excluding !dbg metadata, which is stored in the + // StoredDL field. SmallVector, 2> MetadataToCopy; + // The DebugLoc that will be applied to instructions inserted by this builder. + DebugLoc StoredDL; + // Tracks whether we have explicitly set a DebugLoc - valid or empty - in this + // builder, to determine whether to copy StoredDL to inserted instructions. + // We use this bool instead of an optional because we may stil want to copy jryans wrote: stil -> still https://github.com/llvm/llvm-project/pull/108214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 4/5] Track coverage and origins through IRBuilder (PR #108214)
https://github.com/jryans approved this pull request. This part looks good overall, thanks for working on this! 😄 One small note inline below. https://github.com/llvm/llvm-project/pull/108214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
@@ -22,6 +23,67 @@ namespace llvm { class LLVMContext; class raw_ostream; class DILocation; + class Function; + +#if ENABLE_DEBUGLOC_COVERAGE_TRACKING + // Used to represent different "kinds" of DebugLoc, expressing that a DebugLoc + // is either ordinary, containing a valid DILocation, or otherwise describing + // the reason why the DebugLoc does not contain a valid DILocation. + enum class DebugLocKind : uint8_t { +// DebugLoc is expected to contain a valid DILocation. +Normal, +// DebugLoc intentionally does not have a valid DILocation; may be for a +// compiler-generated instruction, or an explicitly dropped location. +LineZero, jryans wrote: Thanks, this new version looks great to me! 😄 https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
https://github.com/jryans approved this pull request. This part looks good to me, thanks for working on this! 😄 https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -1279,6 +1279,9 @@ void Instruction::swapProfMetadata() { void Instruction::copyMetadata(const Instruction &SrcInst, ArrayRef WL) { + if (WL.empty() || is_contained(WL, LLVMContext::MD_dbg)) +setDebugLoc(SrcInst.getDebugLoc()); jryans wrote: Ah okay, thanks, seems reasonable then! https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
@@ -48,22 +64,29 @@ namespace llvm { Temporary }; - // Extends TrackingMDNodeRef to also store a DebugLocKind, allowing Debugify - // to ignore intentionally-empty DebugLocs. - class DILocAndCoverageTracking : public TrackingMDNodeRef { + // Extends TrackingMDNodeRef to also store a DebugLocKind and Origin, + // allowing Debugify to ignore intentionally-empty DebugLocs and display the + // code responsible for generating unintentionally-empty DebugLocs. + // Currently we only need to track the Origin of this DILoc when using a + // DebugLoc that is Normal and empty, so only collect the origin stacktrace in jryans wrote: Ah okay, re-reading it again, I think it makes sense this time. Not quite sure how to best clarify for other readers... Maybe move some of your "Normal" explanation here into the code comment...? https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)
https://github.com/jryans approved this pull request. New docs look good, thanks for working on this! Yes, the value is quite clear indeed. :smile: https://github.com/llvm/llvm-project/pull/107279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DLCov 3/5] Implement DebugLoc origin-tracking (PR #107369)
jryans wrote: IIRC, there are still some open review threads in this PR, mainly related to reducing duplication in the symbolication bits. https://github.com/llvm/llvm-project/pull/107369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits