[Lldb-commits] [lldb] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)
@@ -6380,7 +6380,71 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst &I) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + // icmp eq/ne X, (zext/sext (icmp eq/ne X, C)) + ICmpInst::Predicate Pred1, Pred2; const APInt *C; + Instruction *ExtI; + if (match(&I, m_c_ICmp(Pred1, m_Value(X), + m_CombineAnd(m_Instruction(ExtI), + m_ZExtOrSExt(m_ICmp(Pred2, m_Deferred(X), + m_APInt(C))) { dtcxzyw wrote: Sorry, I accidentally dropped the checks in 70a70fb44d0e628a1cf485e1767ada3eaaa26b0f. https://github.com/llvm/llvm-project/pull/65852 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts, assert(Op.getResNo() == 0 && "We only compute knownbits for the difference here."); -// TODO: Compute influence of the carry operand. -if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY) - break; +// With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in. +KnownBits Borrow(1); +if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY) { + Borrow = computeKnownBits(Op.getOperand(2), DemandedElts, Depth + 1); + // Borrow has bit width 1 + Borrow = Borrow.zextOrTrunc(1); nikic wrote: There are no zero-bit integers in SDAG (or IR). The use of zextOrTrunc in the comment probably dates back to the time when APInt did not allow zext/sext/trunc to the original bit width. https://github.com/llvm/llvm-project/pull/67788 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/65852 >From d9d8bcbb98e8f5aecb9733329389d61a489bd731 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Sat, 9 Sep 2023 23:07:29 +0800 Subject: [PATCH 1/9] [InstCombine] Simplify the pattern `a ne/eq (zext (a ne/eq c))` --- .../InstCombine/InstCombineCompares.cpp | 62 ++ .../test/Transforms/InstCombine/icmp-range.ll | 181 ++ 2 files changed, 243 insertions(+) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 9fdc46fec631679..837b8e6d2619989 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -6309,7 +6309,69 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst &I) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + ICmpInst::Predicate Pred1, Pred2; const APInt *C; + // icmp eq/ne X, (zext (icmp eq/ne X, C)) + if (match(&I, m_c_ICmp(Pred1, m_Value(X), + m_ZExt(m_ICmp(Pred2, m_Deferred(X), m_APInt(C) && + ICmpInst::isEquality(Pred1) && ICmpInst::isEquality(Pred2)) { +if (C->isZero()) { + if (Pred2 == ICmpInst::ICMP_EQ) { +// icmp eq X, (zext (icmp eq X, 0)) --> false +// icmp ne X, (zext (icmp eq X, 0)) --> true +return replaceInstUsesWith( +I, +Constant::getIntegerValue( +I.getType(), +APInt(1U, static_cast(Pred1 == ICmpInst::ICMP_NE; + } else { +// icmp eq X, (zext (icmp ne X, 0)) --> icmp ult X, 2 +// icmp ne X, (zext (icmp ne X, 0)) --> icmp ugt X, 1 +return ICmpInst::Create( +Instruction::ICmp, +Pred1 == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGT + : ICmpInst::ICMP_ULT, +X, +Constant::getIntegerValue( +X->getType(), APInt(X->getType()->getScalarSizeInBits(), +Pred1 == ICmpInst::ICMP_NE ? 1 : 2))); + } +} else if (C->isOne()) { + if (Pred2 == ICmpInst::ICMP_NE) { +// icmp eq X, (zext (icmp ne X, 1)) --> false +// icmp ne X, (zext (icmp ne X, 1)) --> true +return replaceInstUsesWith( +I, +Constant::getIntegerValue( +I.getType(), +APInt(1U, static_cast(Pred1 == ICmpInst::ICMP_NE; + } else { +// icmp eq X, (zext (icmp eq X, 1)) --> icmp ult X, 2 +// icmp ne X, (zext (icmp eq X, 1)) --> icmp ugt X, 1 +return ICmpInst::Create( +Instruction::ICmp, +Pred1 == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGT + : ICmpInst::ICMP_ULT, +X, +Constant::getIntegerValue( +X->getType(), APInt(X->getType()->getScalarSizeInBits(), +Pred1 == ICmpInst::ICMP_NE ? 1 : 2))); + } +} else { + // C != 0 && C != 1 + // icmp eq X, (zext (icmp eq X, C)) --> icmp eq X, 0 + // icmp eq X, (zext (icmp ne X, C)) --> icmp eq X, 1 + // icmp ne X, (zext (icmp eq X, C)) --> icmp ne X, 0 + // icmp ne X, (zext (icmp ne X, C)) --> icmp ne X, 1 + return ICmpInst::Create( + Instruction::ICmp, Pred1, X, + Constant::getIntegerValue( + X->getType(), + APInt(X->getType()->getScalarSizeInBits(), +static_cast(Pred2 == ICmpInst::ICMP_NE; +} + } + if (match(I.getOperand(0), m_c_Add(m_ZExt(m_Value(X)), m_SExt(m_Value(Y && match(I.getOperand(1), m_APInt(C)) && X->getType()->isIntOrIntVectorTy(1) && diff --git a/llvm/test/Transforms/InstCombine/icmp-range.ll b/llvm/test/Transforms/InstCombine/icmp-range.ll index 4281e09cb0309c8..15424fce33fdeea 100644 --- a/llvm/test/Transforms/InstCombine/icmp-range.ll +++ b/llvm/test/Transforms/InstCombine/icmp-range.ll @@ -1034,6 +1034,187 @@ define i1 @icmp_ne_bool_1(ptr %ptr) { ret i1 %cmp } +define i1 @icmp_ne_zext_eq_zero(i32 %a) { +; CHECK-LABEL: @icmp_ne_zext_eq_zero( +; CHECK-NEXT:ret i1 true +; + %cmp = icmp eq i32 %a, 0 + %conv = zext i1 %cmp to i32 + %cmp1 = icmp ne i32 %conv, %a + ret i1 %cmp1 +} + +define i1 @icmp_ne_zext_ne_zero(i32 %a) { +; CHECK-LABEL: @icmp_ne_zext_ne_zero( +; CHECK-NEXT:[[CMP1:%.*]] = icmp ugt i32 [[A:%.*]], 1 +; CHECK-NEXT:ret i1 [[CMP1]] +; + %cmp = icmp ne i32 %a, 0 + %conv = zext i1 %cmp to i32 + %cmp1 = icmp ne i32 %conv, %a + ret i1 %cmp1 +} + +define i1 @icmp_eq_zext_eq_zero(i32 %a) { +; CHECK-LABEL: @icmp_eq_zext_eq_zero( +; CHECK-NEXT:ret i1 false +; + %cmp = icmp eq i32 %a, 0 + %conv = zext i1 %cmp to i32 + %cmp1 = icmp eq i32 %conv, %a + ret i1 %cmp1 +} + +define i1 @icmp_eq_zext_ne_zero(i32 %
[Lldb-commits] [lldb] [InstCombine] Simplify the pattern `a ne/eq (zext/sext (a ne/eq c))` (PR #65852)
https://github.com/dtcxzyw updated https://github.com/llvm/llvm-project/pull/65852 >From d9d8bcbb98e8f5aecb9733329389d61a489bd731 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Sat, 9 Sep 2023 23:07:29 +0800 Subject: [PATCH 1/9] [InstCombine] Simplify the pattern `a ne/eq (zext (a ne/eq c))` --- .../InstCombine/InstCombineCompares.cpp | 62 ++ .../test/Transforms/InstCombine/icmp-range.ll | 181 ++ 2 files changed, 243 insertions(+) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 9fdc46fec631679..837b8e6d2619989 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -6309,7 +6309,69 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst &I) { Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) return BinaryOperator::CreateOr(Builder.CreateIsNull(X), Y); + ICmpInst::Predicate Pred1, Pred2; const APInt *C; + // icmp eq/ne X, (zext (icmp eq/ne X, C)) + if (match(&I, m_c_ICmp(Pred1, m_Value(X), + m_ZExt(m_ICmp(Pred2, m_Deferred(X), m_APInt(C) && + ICmpInst::isEquality(Pred1) && ICmpInst::isEquality(Pred2)) { +if (C->isZero()) { + if (Pred2 == ICmpInst::ICMP_EQ) { +// icmp eq X, (zext (icmp eq X, 0)) --> false +// icmp ne X, (zext (icmp eq X, 0)) --> true +return replaceInstUsesWith( +I, +Constant::getIntegerValue( +I.getType(), +APInt(1U, static_cast(Pred1 == ICmpInst::ICMP_NE; + } else { +// icmp eq X, (zext (icmp ne X, 0)) --> icmp ult X, 2 +// icmp ne X, (zext (icmp ne X, 0)) --> icmp ugt X, 1 +return ICmpInst::Create( +Instruction::ICmp, +Pred1 == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGT + : ICmpInst::ICMP_ULT, +X, +Constant::getIntegerValue( +X->getType(), APInt(X->getType()->getScalarSizeInBits(), +Pred1 == ICmpInst::ICMP_NE ? 1 : 2))); + } +} else if (C->isOne()) { + if (Pred2 == ICmpInst::ICMP_NE) { +// icmp eq X, (zext (icmp ne X, 1)) --> false +// icmp ne X, (zext (icmp ne X, 1)) --> true +return replaceInstUsesWith( +I, +Constant::getIntegerValue( +I.getType(), +APInt(1U, static_cast(Pred1 == ICmpInst::ICMP_NE; + } else { +// icmp eq X, (zext (icmp eq X, 1)) --> icmp ult X, 2 +// icmp ne X, (zext (icmp eq X, 1)) --> icmp ugt X, 1 +return ICmpInst::Create( +Instruction::ICmp, +Pred1 == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGT + : ICmpInst::ICMP_ULT, +X, +Constant::getIntegerValue( +X->getType(), APInt(X->getType()->getScalarSizeInBits(), +Pred1 == ICmpInst::ICMP_NE ? 1 : 2))); + } +} else { + // C != 0 && C != 1 + // icmp eq X, (zext (icmp eq X, C)) --> icmp eq X, 0 + // icmp eq X, (zext (icmp ne X, C)) --> icmp eq X, 1 + // icmp ne X, (zext (icmp eq X, C)) --> icmp ne X, 0 + // icmp ne X, (zext (icmp ne X, C)) --> icmp ne X, 1 + return ICmpInst::Create( + Instruction::ICmp, Pred1, X, + Constant::getIntegerValue( + X->getType(), + APInt(X->getType()->getScalarSizeInBits(), +static_cast(Pred2 == ICmpInst::ICMP_NE; +} + } + if (match(I.getOperand(0), m_c_Add(m_ZExt(m_Value(X)), m_SExt(m_Value(Y && match(I.getOperand(1), m_APInt(C)) && X->getType()->isIntOrIntVectorTy(1) && diff --git a/llvm/test/Transforms/InstCombine/icmp-range.ll b/llvm/test/Transforms/InstCombine/icmp-range.ll index 4281e09cb0309c8..15424fce33fdeea 100644 --- a/llvm/test/Transforms/InstCombine/icmp-range.ll +++ b/llvm/test/Transforms/InstCombine/icmp-range.ll @@ -1034,6 +1034,187 @@ define i1 @icmp_ne_bool_1(ptr %ptr) { ret i1 %cmp } +define i1 @icmp_ne_zext_eq_zero(i32 %a) { +; CHECK-LABEL: @icmp_ne_zext_eq_zero( +; CHECK-NEXT:ret i1 true +; + %cmp = icmp eq i32 %a, 0 + %conv = zext i1 %cmp to i32 + %cmp1 = icmp ne i32 %conv, %a + ret i1 %cmp1 +} + +define i1 @icmp_ne_zext_ne_zero(i32 %a) { +; CHECK-LABEL: @icmp_ne_zext_ne_zero( +; CHECK-NEXT:[[CMP1:%.*]] = icmp ugt i32 [[A:%.*]], 1 +; CHECK-NEXT:ret i1 [[CMP1]] +; + %cmp = icmp ne i32 %a, 0 + %conv = zext i1 %cmp to i32 + %cmp1 = icmp ne i32 %conv, %a + ret i1 %cmp1 +} + +define i1 @icmp_eq_zext_eq_zero(i32 %a) { +; CHECK-LABEL: @icmp_eq_zext_eq_zero( +; CHECK-NEXT:ret i1 false +; + %cmp = icmp eq i32 %a, 0 + %conv = zext i1 %cmp to i32 + %cmp1 = icmp eq i32 %conv, %a + ret i1 %cmp1 +} + +define i1 @icmp_eq_zext_ne_zero(i32 %
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
https://github.com/junior-jl updated https://github.com/llvm/llvm-project/pull/67019 From c2396253b9584af9eabe1e67ed922f5f5f0e879c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= Date: Thu, 21 Sep 2023 11:12:58 -0300 Subject: [PATCH 1/2] [lldb] add stop-at-user-entry option to process launch [lldb] add command start [lldb] add stop-at-main option to process launch Revert "[lldb] add command start" This reverts commit 11270775865a8415e00b4d899703f84717344967. [lldb] remove shell modification | make bp one-shot add GetUserEntryPointName method | changed bp creating method use clang-format change option description | using set for entrypoint names use SetVector | change comments style replace const char* by StringRef | change if statements to return early --- lldb/include/lldb/Target/Language.h | 20 ++-- .../Commands/CommandOptionsProcessLaunch.cpp | 48 ++- lldb/source/Commands/Options.td | 4 ++ .../Language/CPlusPlus/CPlusPlusLanguage.h| 6 ++- .../Plugins/Language/ObjC/ObjCLanguage.h | 2 + .../ObjCPlusPlus/ObjCPlusPlusLanguage.h | 2 + 6 files changed, 73 insertions(+), 9 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index a6b9ccaf31b3c42..cf781fc0e8dd5ee 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -95,21 +95,24 @@ class Language : public PluginInterface { class EitherTypeScavenger : public TypeScavenger { public: EitherTypeScavenger() : TypeScavenger() { - for (std::shared_ptr scavenger : { std::shared_ptr(new ScavengerTypes())... }) { + for (std::shared_ptr scavenger : + {std::shared_ptr(new ScavengerTypes())...}) { if (scavenger) m_scavengers.push_back(scavenger); } } + protected: bool Find_Impl(ExecutionContextScope *exe_scope, const char *key, ResultSet &results) override { const bool append = false; - for (auto& scavenger : m_scavengers) { + for (auto &scavenger : m_scavengers) { if (scavenger && scavenger->Find(exe_scope, key, results, append)) return true; } return false; } + private: std::vector> m_scavengers; }; @@ -118,22 +121,25 @@ class Language : public PluginInterface { class UnionTypeScavenger : public TypeScavenger { public: UnionTypeScavenger() : TypeScavenger() { - for (std::shared_ptr scavenger : { std::shared_ptr(new ScavengerTypes())... }) { + for (std::shared_ptr scavenger : + {std::shared_ptr(new ScavengerTypes())...}) { if (scavenger) m_scavengers.push_back(scavenger); } } + protected: bool Find_Impl(ExecutionContextScope *exe_scope, const char *key, ResultSet &results) override { const bool append = true; bool success = false; - for (auto& scavenger : m_scavengers) { + for (auto &scavenger : m_scavengers) { if (scavenger) success = scavenger->Find(exe_scope, key, results, append) || success; } return success; } + private: std::vector> m_scavengers; }; @@ -160,6 +166,10 @@ class Language : public PluginInterface { virtual lldb::LanguageType GetLanguageType() const = 0; + // Implement this function to return the user-defined entry point name + // for the language + virtual llvm::StringRef GetUserEntryPointName() const { return {}; } + virtual bool IsTopLevelFunction(Function &function); virtual bool IsSourceFile(llvm::StringRef file_path) const = 0; @@ -232,7 +242,7 @@ class Language : public PluginInterface { // a match. But we wouldn't want this to match AnotherA::my_function. The // user is specifying a truncated path, not a truncated set of characters. // This function does a language-aware comparison for those purposes. - virtual bool DemangledNameContainsPath(llvm::StringRef path, + virtual bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const; // if a language has a custom format for printing variable declarations that diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp index 85ad8ff5e07132c..2645b7bdd8c4ae6 100644 --- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp +++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp @@ -8,6 +8,7 @@ #include "CommandOptionsProcessLaunch.h" +#include "lldb/Core/Module.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/OptionParser.h" @@ -15,11 +16,13 @@ #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandOptionArgumentTable.h" #include "lldb/Interpreter/OptionArgParser.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ExecutionContext.h" +#inclu
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
junior-jl wrote: > > Hi, @medismailben. I changed the code with your suggestions. Can you take a > > look if the early exits are correct before I commit, please? > > ```c++ > > case 'm': // Stop at user entry point > > { > > TargetSP target_sp = > > execution_context ? execution_context->GetTargetSP() : TargetSP(); > > ModuleSP main_module_sp = target_sp->GetExecutableModule(); > > FileSpecList shared_lib_filter; > > shared_lib_filter.Append(main_module_sp->GetFileSpec()); > > llvm::SetVector, > > std::unordered_set> entryPointNamesSet; > > for (LanguageType lang_type : Language::GetSupportedLanguages()) { > > Language *lang = Language::FindPlugin(lang_type); > > if (!lang) { > > error.SetErrorString("Language not found\n"); > > break; > > } > > std::string entryPointName = lang->GetUserEntryPointName().str(); > > if (!entryPointName.empty()) > > entryPointNamesSet.insert(entryPointName); > > } > > if (entryPointNamesSet.empty()) { > > error.SetErrorString("No entry point name found\n"); > > break; > > } > > BreakpointSP bp_sp = target_sp->CreateBreakpoint( > > &shared_lib_filter, > > nullptr, // containingSourceFiles > > entryPointNamesSet.takeVector(), > > eFunctionNameTypeFull, // func_name_type_mask > > eLanguageTypeUnknown,// language > > 0, // offset > > eLazyBoolNo, // skip_prologue > > false, // internal > > false// hardware > > ); > > if (!bp_sp) { > > error.SetErrorString("Breakpoint creation failed.\n"); > > break; > > } > > bp_sp->SetOneShot(true); > > break; > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Also, thank you for the reminder of changing the description of the PR. > > Done :) > > This code in this switch statement should go into Target.h/Target.cpp as > something like: > > ``` > lldb::BreakpointSP Target::CreateBreakpointAtUserEntry(); > ``` > > Then the code in this switch just calls that function. Then we can expose > this through the SBTarget API as well. Done! ✅ https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -782,7 +824,7 @@ void Target::ApplyNameToBreakpoints(BreakpointName &bp_name) { void Target::GetBreakpointNames(std::vector &names) { names.clear(); - for (const auto& bp_name_entry : m_breakpoint_names) { + for (const auto &bp_name_entry : m_breakpoint_names) { medismailben wrote: All the formatting below seems unrelated to your PR, probably because you ran `clang-format` on the whole file. We try to avoid this because is overwrites the file history with the actual explanations of what previous contributors changes, with your commit which is not related. If you want to reformat the rest of the file, that should be done in a separate commit and you should add the commit hash to the [.git-blame-ignore-revs](https://github.com/llvm/llvm-project/blob/main/.git-blame-ignore-revs) file. Now, if you want to address this, you can do the following: 0. Save your current branch in case things go wrong with git: ``` $ git checkout -b stop-at-user-entry-formatted ``` 1. Un-do commit without deleting your work. ``` $ git reset HEAD~1 ``` 2. Add only changes related to the PR (skip all the formatting changes). ``` $ git add -p . ``` 3. Make sure the changes that are staged don't contain reformatting changes. ``` $ git status $ git commit -v ``` 4. Discard the formatting changes. ``` $ git reset --hard HEAD ``` If you want to format specifically what you changed in your commit, you should run: ``` $ git clang-format HEAD~ $ git add -u $ git commit --amend --no-edit ``` Make sure you don't have any other unstaged changes before doing this, otherwise, they'll be merged with the formatting changes. Let me know if you need help or have any questions. https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: https://github.com/medismailben edited https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)
https://github.com/davidstone created https://github.com/llvm/llvm-project/pull/67930 None >From a52da2e5889f14bcc36ae4263518a49e1e85c244 Mon Sep 17 00:00:00 2001 From: David Stone Date: Sun, 1 Oct 2023 12:02:48 -0600 Subject: [PATCH] [clang][Modules] Move `ASTSourceDescriptor` into its own file --- .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++ clang/include/clang/Basic/Module.h| 26 -- clang/lib/AST/ExternalASTSource.cpp | 2 +- clang/lib/Basic/ASTSourceDescriptor.cpp | 33 clang/lib/Basic/CMakeLists.txt| 1 + clang/lib/Basic/Module.cpp| 15 -- clang/lib/CodeGen/CGDebugInfo.h | 3 +- clang/lib/Serialization/ASTReader.cpp | 1 + .../Plugins/ExpressionParser/Clang/ASTUtils.h | 8 ++- .../Clang/ClangExternalASTSourceCallbacks.cpp | 1 + .../Clang/ClangExternalASTSourceCallbacks.h | 8 ++- 11 files changed, 105 insertions(+), 45 deletions(-) create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h b/clang/include/clang/Basic/ASTSourceDescriptor.h new file mode 100644 index 000..175e0551db76562 --- /dev/null +++ b/clang/include/clang/Basic/ASTSourceDescriptor.h @@ -0,0 +1,52 @@ +//===- ASTSourceDescriptor.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +/// \file +/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules +/// and precompiled header files +// +//===--===// + +#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H +#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H + +#include "clang/Basic/Module.h" +#include "llvm/ADT/StringRef.h" +#include +#include + +namespace clang { + +/// Abstracts clang modules and precompiled header files and holds +/// everything needed to generate debug info for an imported module +/// or PCH. +class ASTSourceDescriptor { + StringRef PCHModuleName; + StringRef Path; + StringRef ASTFile; + ASTFileSignature Signature; + Module *ClangModule = nullptr; + +public: + ASTSourceDescriptor() = default; + ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile, + ASTFileSignature Signature) + : PCHModuleName(std::move(Name)), Path(std::move(Path)), +ASTFile(std::move(ASTFile)), Signature(Signature) {} + ASTSourceDescriptor(Module &M); + + std::string getModuleName() const; + StringRef getPath() const { return Path; } + StringRef getASTFile() const { return ASTFile; } + ASTFileSignature getSignature() const { return Signature; } + Module *getModuleOrNull() const { return ClangModule; } +}; + +} // namespace clang + +#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 676fd372493a3aa..60381472bbd4e59 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -850,32 +850,6 @@ class VisibleModuleSet { unsigned Generation = 0; }; -/// Abstracts clang modules and precompiled header files and holds -/// everything needed to generate debug info for an imported module -/// or PCH. -class ASTSourceDescriptor { - StringRef PCHModuleName; - StringRef Path; - StringRef ASTFile; - ASTFileSignature Signature; - Module *ClangModule = nullptr; - -public: - ASTSourceDescriptor() = default; - ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile, - ASTFileSignature Signature) - : PCHModuleName(std::move(Name)), Path(std::move(Path)), -ASTFile(std::move(ASTFile)), Signature(Signature) {} - ASTSourceDescriptor(Module &M); - - std::string getModuleName() const; - StringRef getPath() const { return Path; } - StringRef getASTFile() const { return ASTFile; } - ASTFileSignature getSignature() const { return Signature; } - Module *getModuleOrNull() const { return ClangModule; } -}; - - } // namespace clang #endif // LLVM_CLANG_BASIC_MODULE_H diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp index 090ef02aa4224d6..00bc6b4b919abf7 100644 --- a/clang/lib/AST/ExternalASTSource.cpp +++ b/clang/lib/AST/ExternalASTSource.cpp @@ -15,10 +15,10 @@ #include "clang/AST/ExternalASTSource.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclarationName.h" +#include "clang/Basic/ASTSourceDescriptor.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" -#include "clang/Basic/Module.h" #include "c
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
https://github.com/junior-jl updated https://github.com/llvm/llvm-project/pull/67019 From c2396253b9584af9eabe1e67ed922f5f5f0e879c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= Date: Thu, 21 Sep 2023 11:12:58 -0300 Subject: [PATCH 1/2] [lldb] add stop-at-user-entry option to process launch [lldb] add command start [lldb] add stop-at-main option to process launch Revert "[lldb] add command start" This reverts commit 11270775865a8415e00b4d899703f84717344967. [lldb] remove shell modification | make bp one-shot add GetUserEntryPointName method | changed bp creating method use clang-format change option description | using set for entrypoint names use SetVector | change comments style replace const char* by StringRef | change if statements to return early --- lldb/include/lldb/Target/Language.h | 20 ++-- .../Commands/CommandOptionsProcessLaunch.cpp | 48 ++- lldb/source/Commands/Options.td | 4 ++ .../Language/CPlusPlus/CPlusPlusLanguage.h| 6 ++- .../Plugins/Language/ObjC/ObjCLanguage.h | 2 + .../ObjCPlusPlus/ObjCPlusPlusLanguage.h | 2 + 6 files changed, 73 insertions(+), 9 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index a6b9ccaf31b3c42..cf781fc0e8dd5ee 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -95,21 +95,24 @@ class Language : public PluginInterface { class EitherTypeScavenger : public TypeScavenger { public: EitherTypeScavenger() : TypeScavenger() { - for (std::shared_ptr scavenger : { std::shared_ptr(new ScavengerTypes())... }) { + for (std::shared_ptr scavenger : + {std::shared_ptr(new ScavengerTypes())...}) { if (scavenger) m_scavengers.push_back(scavenger); } } + protected: bool Find_Impl(ExecutionContextScope *exe_scope, const char *key, ResultSet &results) override { const bool append = false; - for (auto& scavenger : m_scavengers) { + for (auto &scavenger : m_scavengers) { if (scavenger && scavenger->Find(exe_scope, key, results, append)) return true; } return false; } + private: std::vector> m_scavengers; }; @@ -118,22 +121,25 @@ class Language : public PluginInterface { class UnionTypeScavenger : public TypeScavenger { public: UnionTypeScavenger() : TypeScavenger() { - for (std::shared_ptr scavenger : { std::shared_ptr(new ScavengerTypes())... }) { + for (std::shared_ptr scavenger : + {std::shared_ptr(new ScavengerTypes())...}) { if (scavenger) m_scavengers.push_back(scavenger); } } + protected: bool Find_Impl(ExecutionContextScope *exe_scope, const char *key, ResultSet &results) override { const bool append = true; bool success = false; - for (auto& scavenger : m_scavengers) { + for (auto &scavenger : m_scavengers) { if (scavenger) success = scavenger->Find(exe_scope, key, results, append) || success; } return success; } + private: std::vector> m_scavengers; }; @@ -160,6 +166,10 @@ class Language : public PluginInterface { virtual lldb::LanguageType GetLanguageType() const = 0; + // Implement this function to return the user-defined entry point name + // for the language + virtual llvm::StringRef GetUserEntryPointName() const { return {}; } + virtual bool IsTopLevelFunction(Function &function); virtual bool IsSourceFile(llvm::StringRef file_path) const = 0; @@ -232,7 +242,7 @@ class Language : public PluginInterface { // a match. But we wouldn't want this to match AnotherA::my_function. The // user is specifying a truncated path, not a truncated set of characters. // This function does a language-aware comparison for those purposes. - virtual bool DemangledNameContainsPath(llvm::StringRef path, + virtual bool DemangledNameContainsPath(llvm::StringRef path, ConstString demangled) const; // if a language has a custom format for printing variable declarations that diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp index 85ad8ff5e07132c..2645b7bdd8c4ae6 100644 --- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp +++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp @@ -8,6 +8,7 @@ #include "CommandOptionsProcessLaunch.h" +#include "lldb/Core/Module.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/OptionParser.h" @@ -15,11 +16,13 @@ #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandOptionArgumentTable.h" #include "lldb/Interpreter/OptionArgParser.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ExecutionContext.h" +#inclu
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
@@ -782,7 +824,7 @@ void Target::ApplyNameToBreakpoints(BreakpointName &bp_name) { void Target::GetBreakpointNames(std::vector &names) { names.clear(); - for (const auto& bp_name_entry : m_breakpoint_names) { + for (const auto &bp_name_entry : m_breakpoint_names) { junior-jl wrote: I was wondering if that was a problem, thank you for clarifying and for the step-by-step! Should I squash the two commits again? https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -782,7 +824,7 @@ void Target::ApplyNameToBreakpoints(BreakpointName &bp_name) { void Target::GetBreakpointNames(std::vector &names) { names.clear(); - for (const auto& bp_name_entry : m_breakpoint_names) { + for (const auto &bp_name_entry : m_breakpoint_names) { medismailben wrote: > Should I squash the two commits again? You can if you want. https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
https://github.com/junior-jl edited https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
=?utf-8?q?Jos=C3=A9?= L. Junior Message-ID: In-Reply-To: https://github.com/medismailben approved this pull request. https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: medismailben wrote: I think you're good for the implementing however it would be nice to add a shell test to make sure it works well and it doesn't break in the future. https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: medismailben wrote: You can use `lldb/test/Shell/Commands/command-thread-select.test` as an example to write your own test. https://github.com/llvm/llvm-project/pull/67019 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)
@@ -85,6 +85,18 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW, return KnownOut; } +KnownBits KnownBits::computeForSubBorrow(const KnownBits &LHS, KnownBits RHS, + const KnownBits &Borrow) { + assert(Borrow.getBitWidth() == 1 && "Borrow must be 1-bit"); + + // LHS - RHS = LHS + ~RHS + 1 + // Carry 1 - Borrow in ::computeForAddCarry + std::swap(RHS.Zero, RHS.One); + return ::computeForAddCarry(LHS, RHS, + /*CarryZero*/ Borrow.One.getBoolValue(), + /*CarryOne*/ Borrow.Zero.getBoolValue()); shafik wrote: To be consistent with [bugprone-argument-comment](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html) https://github.com/llvm/llvm-project/pull/67788 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/67788 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc++] Implement ranges::contains_subrange (PR #66963)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/66963 >From 5a2c930770cf548c5e3f3451e76b48cb067e6762 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 13 Sep 2023 14:26:01 -0700 Subject: [PATCH 1/5] [libc++] Implement ranges::contains_subrange --- libcxx/include/CMakeLists.txt | 1 + .../__algorithm/ranges_contains_subrange.h| 145 + libcxx/include/algorithm | 14 + ...obust_against_copying_projections.pass.cpp | 4 + .../ranges.contains_subrange.pass.cpp | 293 ++ .../niebloid.compile.pass.cpp | 3 + 6 files changed, 460 insertions(+) create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h create mode 100644 libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 2ec755236dbaee2..b096259f85f6ac8 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -104,6 +104,7 @@ set(files __algorithm/ranges_any_of.h __algorithm/ranges_binary_search.h __algorithm/ranges_clamp.h + __algorithm/ranges_contains_subrange.h __algorithm/ranges_copy.h __algorithm/ranges_copy_backward.h __algorithm/ranges_copy_if.h diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h new file mode 100644 index 000..16de6c29cb2a1a4 --- /dev/null +++ b/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -0,0 +1,145 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H +#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H + +#include <__algorithm/ranges_starts_with.h> +#include <__config> +#include <__functional/identity.h> +#include <__functional/ranges_operations.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/projected.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { +namespace __contains_subrange { +struct __fn { + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred, +class _Proj1, +class _Proj2, +class _Offset> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2, + _Offset __offset) { +if (__offset < 0) + return false; +else { + for (; __offset >= 0; __offset--, __first1++) { +auto result = ranges::starts_with( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +std::ref(__pred), +std::ref(__proj1), +std::ref(__proj2)); +if (result) + return true; + } + return false; +} + } + + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred = ranges::equal_to, +class _Proj1 = identity, +class _Proj2 = identity> +requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred __pred = {}, + _Proj1 __proj1 = {}, + _Proj2 __proj2 = {}) const { +auto __n1 = ranges::distance(__first1, __last1); +auto __n2 = ranges::distance(__first2, __last2); +auto __offset = __n1 - __n2; + +return __contains_subrange_fn_impl( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +__pred, +__proj1, +__proj2, +std::move(__offset)); + } + + template +requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { +auto __n1 = 0; +auto __n2 = 0; + +if cons
[Lldb-commits] [lldb] [libc++] Implement ranges::contains_subrange (PR #66963)
https://github.com/ZijunZhaoCCK converted_to_draft https://github.com/llvm/llvm-project/pull/66963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits