[Lldb-commits] [lldb] [lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (PR #112307)

2024-10-15 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse approved this pull request.

LGTM, there are a couple of scenarios here which come close to needing to 
store-and-pass-around `BasicBlock::iterator`s to encode a position correctly, 
but in all these situations it's correct to just call `getIterator`.

https://github.com/llvm/llvm-project/pull/112307
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (PR #112307)

2024-10-15 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse edited 
https://github.com/llvm/llvm-project/pull/112307
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (PR #112307)

2024-10-15 Thread Jeremy Morse via lldb-commits


@@ -514,7 +513,8 @@ bool 
IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
m_CFStringCreateWithBytes, CFSCWB_arguments,
"CFStringCreateWithBytes",
llvm::cast(
-   m_entry_instruction_finder.GetValue(function)));
+   m_entry_instruction_finder.GetValue(function))
+   ->getIterator());

jmorse wrote:

Similar story to above, `FindEntryInstruction` uses a debug-intrinsic skipping 
function, so there's no need to pass around the iterator as a position.

https://github.com/llvm/llvm-project/pull/112307
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (PR #112307)

2024-10-15 Thread Jeremy Morse via lldb-commits


@@ -378,8 +378,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function 
&llvm_function) {
 
 Constant *initializer = result_global->getInitializer();
 
-StoreInst *synthesized_store =
-new StoreInst(initializer, new_result_global, first_entry_instruction);
+StoreInst *synthesized_store = new StoreInst(
+initializer, new_result_global, 
first_entry_instruction->getIterator());

jmorse wrote:

This is one of the more interesting use cases -- `first_entry_instruction` is 
initialized from the start of a block and in the "RemoveDIs" model there's 
ambiguity over whether the insert position is before-or-after debug records at 
the start of the block. However, because you're using `getFirstNonPHIOrDbg` the 
intention is clearly to insert after any debug records and this code is 
achieving that.

(No change needed)

https://github.com/llvm/llvm-project/pull/112307
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-02-03 Thread Jeremy Morse via lldb-commits

jmorse wrote:

NB, I'm looking less likely to have time for this soon; if you're able to add 
some coverage to the unit tests (there'll be somewhere using those DIBuilder 
APIs that can duplicated to use iterator insertion instead), it'll speed things 
up.

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-02-04 Thread Jeremy Morse via lldb-commits

jmorse wrote:

Indeed, that's a pattern we've seen elsewhere in the instruction APIs -- you 
can select whether you want an instruction inserted into a block or not by 
whether you pass an instruction pointer or nullptr in. However, without a 
common "no-such-location" instruction iterator (or by making the argument 
std::optional) we can't replicate that with the new APIs.

For things like the instruction constructor APIs we've used overloads, and 
forced users who don't want instruction insertion to call a function without an 
insertion location argument. Here, we'd have a `insertDbgValueIntrinsic` 
function without the InsertBefore argument for users to call -- that would 
preserve the generality, however it wouldn't solve your backwards-compatibility 
objectives. If that's the case, there might be nothing we can do about that 
here.

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-24 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse created 
https://github.com/llvm/llvm-project/pull/124287

As part of the "RemoveDIs" work to eliminate debug intrinsics, we're replacing 
methods that use Instruction*'s as positions with iterators. A number of these 
(such as getFirstNonPHIOrDbg) are sufficiently infrequently used that we can 
just replace the pointer-returning version with an iterator-returning version, 
hopefully without much/any disruption.

Thus this patch has getFirstNonPHIOrDbg and getFirstNonPHIOrDbgOrLifetime 
return an iterator, and updates all call-sites. There are no concerns about the 
iterators returned being converted to Instruction*'s and losing the debug-info 
bit: because the methods skip debug intrinsics, the iterator head bit is always 
false anyway.

>From 3d2aa2734d6cb49c43565e3ac8584ba8130fe302 Mon Sep 17 00:00:00 2001
From: Jeremy Morse 
Date: Thu, 23 Jan 2025 12:24:14 +
Subject: [PATCH] [NFC][DebugInfo] Make some block-start-position methods
 return iterators

As part of the "RemoveDIs" work to eliminate debug intrinsics, we're
replacing methods that use Instruction*'s as positions with iterators. A
number of these (such as getFirstNonPHIOrDbg) are sufficiently infrequently
used that we can just replace the pointer-returning version with an
iterator-returning version, hopefully without much/any disruption.

Thus this patch has getFirstNonPHIOrDbg and getFirstNonPHIOrDbgOrLifetime
return an iterator, and updates all call-sites. There are no concerns about
the iterators returned being converted to Instruction*'s and losing the
debug-info bit: because the methods skip debug intrinsics, the iterator
head bit is always false anyway.
---
 .../ExpressionParser/Clang/IRForTarget.cpp|  6 ++--
 llvm/include/llvm/IR/BasicBlock.h | 18 ++--
 llvm/lib/CodeGen/CodeGenPrepare.cpp   |  2 +-
 llvm/lib/IR/BasicBlock.cpp| 28 +--
 .../AArch64/AArch64TargetTransformInfo.cpp|  2 +-
 .../Target/AMDGPU/SIAnnotateControlFlow.cpp   |  4 +--
 llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp  |  2 +-
 llvm/lib/Transforms/Coroutines/CoroFrame.cpp  |  5 ++--
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  2 +-
 llvm/lib/Transforms/IPO/IROutliner.cpp|  2 +-
 llvm/lib/Transforms/IPO/SCCP.cpp  |  4 +--
 llvm/lib/Transforms/IPO/SampleProfile.cpp |  2 +-
 .../InstCombineLoadStoreAlloca.cpp|  4 +--
 .../Transforms/Scalar/CallSiteSplitting.cpp   |  2 +-
 .../Transforms/Scalar/SimpleLoopUnswitch.cpp  |  2 +-
 llvm/lib/Transforms/Utils/CodeMoverUtils.cpp  |  2 +-
 llvm/lib/Transforms/Utils/IRNormalizer.cpp|  2 +-
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp |  4 +--
 .../Frontend/OpenMPIRBuilderTest.cpp  | 24 ++--
 19 files changed, 67 insertions(+), 50 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 6c728f34474898..a414ad652448e9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -66,7 +66,7 @@ static llvm::Value *FindEntryInstruction(llvm::Function 
*function) {
   if (function->empty())
 return nullptr;
 
-  return function->getEntryBlock().getFirstNonPHIOrDbg();
+  return &*function->getEntryBlock().getFirstNonPHIOrDbg();
 }
 
 IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
@@ -361,7 +361,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function 
&llvm_function) {
 // there's nothing to put into its equivalent persistent variable.
 
 BasicBlock &entry_block(llvm_function.getEntryBlock());
-Instruction *first_entry_instruction(entry_block.getFirstNonPHIOrDbg());
+Instruction *first_entry_instruction(&*entry_block.getFirstNonPHIOrDbg());
 
 if (!first_entry_instruction)
   return false;
@@ -1505,7 +1505,7 @@ bool IRForTarget::ReplaceVariables(Function 
&llvm_function) {
   LLDB_LOG(log, "Arg: \"{0}\"", PrintValue(argument));
 
   BasicBlock &entry_block(llvm_function.getEntryBlock());
-  Instruction *FirstEntryInstruction(entry_block.getFirstNonPHIOrDbg());
+  Instruction *FirstEntryInstruction(&*entry_block.getFirstNonPHIOrDbg());
 
   if (!FirstEntryInstruction) {
 m_error_stream.Printf("Internal error [IRForTarget]: Couldn't find the "
diff --git a/llvm/include/llvm/IR/BasicBlock.h 
b/llvm/include/llvm/IR/BasicBlock.h
index e22fe1e7e7dc8f..5df4dcecebc878 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -299,22 +299,20 @@ class BasicBlock final : public Value, // Basic blocks 
are data objects also
   /// Returns a pointer to the first instruction in this block that is not a
   /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp
   /// is true.
-  const Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) const;
-  Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = tr

[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse updated 
https://github.com/llvm/llvm-project/pull/124287

>From 3d2aa2734d6cb49c43565e3ac8584ba8130fe302 Mon Sep 17 00:00:00 2001
From: Jeremy Morse 
Date: Thu, 23 Jan 2025 12:24:14 +
Subject: [PATCH 1/2] [NFC][DebugInfo] Make some block-start-position methods
 return iterators

As part of the "RemoveDIs" work to eliminate debug intrinsics, we're
replacing methods that use Instruction*'s as positions with iterators. A
number of these (such as getFirstNonPHIOrDbg) are sufficiently infrequently
used that we can just replace the pointer-returning version with an
iterator-returning version, hopefully without much/any disruption.

Thus this patch has getFirstNonPHIOrDbg and getFirstNonPHIOrDbgOrLifetime
return an iterator, and updates all call-sites. There are no concerns about
the iterators returned being converted to Instruction*'s and losing the
debug-info bit: because the methods skip debug intrinsics, the iterator
head bit is always false anyway.
---
 .../ExpressionParser/Clang/IRForTarget.cpp|  6 ++--
 llvm/include/llvm/IR/BasicBlock.h | 18 ++--
 llvm/lib/CodeGen/CodeGenPrepare.cpp   |  2 +-
 llvm/lib/IR/BasicBlock.cpp| 28 +--
 .../AArch64/AArch64TargetTransformInfo.cpp|  2 +-
 .../Target/AMDGPU/SIAnnotateControlFlow.cpp   |  4 +--
 llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp  |  2 +-
 llvm/lib/Transforms/Coroutines/CoroFrame.cpp  |  5 ++--
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  2 +-
 llvm/lib/Transforms/IPO/IROutliner.cpp|  2 +-
 llvm/lib/Transforms/IPO/SCCP.cpp  |  4 +--
 llvm/lib/Transforms/IPO/SampleProfile.cpp |  2 +-
 .../InstCombineLoadStoreAlloca.cpp|  4 +--
 .../Transforms/Scalar/CallSiteSplitting.cpp   |  2 +-
 .../Transforms/Scalar/SimpleLoopUnswitch.cpp  |  2 +-
 llvm/lib/Transforms/Utils/CodeMoverUtils.cpp  |  2 +-
 llvm/lib/Transforms/Utils/IRNormalizer.cpp|  2 +-
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp |  4 +--
 .../Frontend/OpenMPIRBuilderTest.cpp  | 24 ++--
 19 files changed, 67 insertions(+), 50 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 6c728f34474898..a414ad652448e9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -66,7 +66,7 @@ static llvm::Value *FindEntryInstruction(llvm::Function 
*function) {
   if (function->empty())
 return nullptr;
 
-  return function->getEntryBlock().getFirstNonPHIOrDbg();
+  return &*function->getEntryBlock().getFirstNonPHIOrDbg();
 }
 
 IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
@@ -361,7 +361,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function 
&llvm_function) {
 // there's nothing to put into its equivalent persistent variable.
 
 BasicBlock &entry_block(llvm_function.getEntryBlock());
-Instruction *first_entry_instruction(entry_block.getFirstNonPHIOrDbg());
+Instruction *first_entry_instruction(&*entry_block.getFirstNonPHIOrDbg());
 
 if (!first_entry_instruction)
   return false;
@@ -1505,7 +1505,7 @@ bool IRForTarget::ReplaceVariables(Function 
&llvm_function) {
   LLDB_LOG(log, "Arg: \"{0}\"", PrintValue(argument));
 
   BasicBlock &entry_block(llvm_function.getEntryBlock());
-  Instruction *FirstEntryInstruction(entry_block.getFirstNonPHIOrDbg());
+  Instruction *FirstEntryInstruction(&*entry_block.getFirstNonPHIOrDbg());
 
   if (!FirstEntryInstruction) {
 m_error_stream.Printf("Internal error [IRForTarget]: Couldn't find the "
diff --git a/llvm/include/llvm/IR/BasicBlock.h 
b/llvm/include/llvm/IR/BasicBlock.h
index e22fe1e7e7dc8f..5df4dcecebc878 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -299,22 +299,20 @@ class BasicBlock final : public Value, // Basic blocks 
are data objects also
   /// Returns a pointer to the first instruction in this block that is not a
   /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp
   /// is true.
-  const Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) const;
-  Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) {
-return const_cast(
-static_cast(this)->getFirstNonPHIOrDbg(
-SkipPseudoOp));
+  InstListType::const_iterator getFirstNonPHIOrDbg(bool SkipPseudoOp = true) 
const;
+  InstListType::iterator getFirstNonPHIOrDbg(bool SkipPseudoOp = true) {
+return static_cast(this)->getFirstNonPHIOrDbg(
+SkipPseudoOp).getNonConst();
   }
 
   /// Returns a pointer to the first instruction in this block that is not a
   /// PHINode, a debug intrinsic, or a lifetime intrinsic, or any pseudo
   /// operation if \c SkipPseudoOp is true.
-  const Instruction *
+  InstListType::const_iterator
   getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp = true) const;

[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse edited 
https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits


@@ -1656,7 +1656,8 @@ static Value 
*emitSetAndGetSwiftErrorValueAround(Instruction *Call,
 Builder.SetInsertPoint(Call->getNextNode());
   } else {
 auto Invoke = cast(Call);
-Builder.SetInsertPoint(Invoke->getNormalDest()->getFirstNonPHIOrDbg());
+BasicBlock::iterator It = Invoke->getNormalDest()->getFirstNonPHIOrDbg();
+Builder.SetInsertPoint(It);

jmorse wrote:

Looks like it isn't, removing

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse commented:

Adjusted two call sites, see comments on the others. I've also added an extra 
unwrap to CoroSplit.cpp due to it not compiling -- this is going to be reworked 
in #124288 anyway.

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits


@@ -448,6 +455,9 @@ BasicBlock::const_iterator 
BasicBlock::getFirstNonPHIOrDbgOrAlloca() const {
   ++InsertPt;
 }
   }
+
+  // Signal that this comes after any debug records.
+  InsertPt.setHeadBit(false);

jmorse wrote:

The other two call-sites always generate iterators with a false head bit 
anyway, but there's a path from `getFirstNonPHIIt` to this line without 
InsertPt being assigned a different iterator. `getFirstNonPHIIt` will set the 
head bit, therefore we have to explicitly clear it here to ensure the position 
is "after" any debug records.

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse updated 
https://github.com/llvm/llvm-project/pull/124287

>From 3d2aa2734d6cb49c43565e3ac8584ba8130fe302 Mon Sep 17 00:00:00 2001
From: Jeremy Morse 
Date: Thu, 23 Jan 2025 12:24:14 +
Subject: [PATCH 1/3] [NFC][DebugInfo] Make some block-start-position methods
 return iterators

As part of the "RemoveDIs" work to eliminate debug intrinsics, we're
replacing methods that use Instruction*'s as positions with iterators. A
number of these (such as getFirstNonPHIOrDbg) are sufficiently infrequently
used that we can just replace the pointer-returning version with an
iterator-returning version, hopefully without much/any disruption.

Thus this patch has getFirstNonPHIOrDbg and getFirstNonPHIOrDbgOrLifetime
return an iterator, and updates all call-sites. There are no concerns about
the iterators returned being converted to Instruction*'s and losing the
debug-info bit: because the methods skip debug intrinsics, the iterator
head bit is always false anyway.
---
 .../ExpressionParser/Clang/IRForTarget.cpp|  6 ++--
 llvm/include/llvm/IR/BasicBlock.h | 18 ++--
 llvm/lib/CodeGen/CodeGenPrepare.cpp   |  2 +-
 llvm/lib/IR/BasicBlock.cpp| 28 +--
 .../AArch64/AArch64TargetTransformInfo.cpp|  2 +-
 .../Target/AMDGPU/SIAnnotateControlFlow.cpp   |  4 +--
 llvm/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp  |  2 +-
 llvm/lib/Transforms/Coroutines/CoroFrame.cpp  |  5 ++--
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  2 +-
 llvm/lib/Transforms/IPO/IROutliner.cpp|  2 +-
 llvm/lib/Transforms/IPO/SCCP.cpp  |  4 +--
 llvm/lib/Transforms/IPO/SampleProfile.cpp |  2 +-
 .../InstCombineLoadStoreAlloca.cpp|  4 +--
 .../Transforms/Scalar/CallSiteSplitting.cpp   |  2 +-
 .../Transforms/Scalar/SimpleLoopUnswitch.cpp  |  2 +-
 llvm/lib/Transforms/Utils/CodeMoverUtils.cpp  |  2 +-
 llvm/lib/Transforms/Utils/IRNormalizer.cpp|  2 +-
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp |  4 +--
 .../Frontend/OpenMPIRBuilderTest.cpp  | 24 ++--
 19 files changed, 67 insertions(+), 50 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 6c728f34474898..a414ad652448e9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -66,7 +66,7 @@ static llvm::Value *FindEntryInstruction(llvm::Function 
*function) {
   if (function->empty())
 return nullptr;
 
-  return function->getEntryBlock().getFirstNonPHIOrDbg();
+  return &*function->getEntryBlock().getFirstNonPHIOrDbg();
 }
 
 IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
@@ -361,7 +361,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function 
&llvm_function) {
 // there's nothing to put into its equivalent persistent variable.
 
 BasicBlock &entry_block(llvm_function.getEntryBlock());
-Instruction *first_entry_instruction(entry_block.getFirstNonPHIOrDbg());
+Instruction *first_entry_instruction(&*entry_block.getFirstNonPHIOrDbg());
 
 if (!first_entry_instruction)
   return false;
@@ -1505,7 +1505,7 @@ bool IRForTarget::ReplaceVariables(Function 
&llvm_function) {
   LLDB_LOG(log, "Arg: \"{0}\"", PrintValue(argument));
 
   BasicBlock &entry_block(llvm_function.getEntryBlock());
-  Instruction *FirstEntryInstruction(entry_block.getFirstNonPHIOrDbg());
+  Instruction *FirstEntryInstruction(&*entry_block.getFirstNonPHIOrDbg());
 
   if (!FirstEntryInstruction) {
 m_error_stream.Printf("Internal error [IRForTarget]: Couldn't find the "
diff --git a/llvm/include/llvm/IR/BasicBlock.h 
b/llvm/include/llvm/IR/BasicBlock.h
index e22fe1e7e7dc8f..5df4dcecebc878 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -299,22 +299,20 @@ class BasicBlock final : public Value, // Basic blocks 
are data objects also
   /// Returns a pointer to the first instruction in this block that is not a
   /// PHINode or a debug intrinsic, or any pseudo operation if \c SkipPseudoOp
   /// is true.
-  const Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) const;
-  Instruction *getFirstNonPHIOrDbg(bool SkipPseudoOp = true) {
-return const_cast(
-static_cast(this)->getFirstNonPHIOrDbg(
-SkipPseudoOp));
+  InstListType::const_iterator getFirstNonPHIOrDbg(bool SkipPseudoOp = true) 
const;
+  InstListType::iterator getFirstNonPHIOrDbg(bool SkipPseudoOp = true) {
+return static_cast(this)->getFirstNonPHIOrDbg(
+SkipPseudoOp).getNonConst();
   }
 
   /// Returns a pointer to the first instruction in this block that is not a
   /// PHINode, a debug intrinsic, or a lifetime intrinsic, or any pseudo
   /// operation if \c SkipPseudoOp is true.
-  const Instruction *
+  InstListType::const_iterator
   getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp = true) const;

[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-27 Thread Jeremy Morse via lldb-commits

https://github.com/jmorse closed 
https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-28 Thread Jeremy Morse via lldb-commits

jmorse wrote:

Ooooff, yeah we missed that. I think (90% confident) that overloading the 
relevant DIBuilder methods with iterator-taking versions should work fine, and 
we should be able to pick that into llvm20 before rc1, we'll look at it 
momentarily.

(In theory downstream compatibility isn't a strong LLVM concern (?), but I 
think it'd be easy to support and ease transitions).

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [NFC][DebugInfo] Make some block-start-position methods return iterators (PR #124287)

2025-01-28 Thread Jeremy Morse via lldb-commits

jmorse wrote:

Prototype here 
https://github.com/jmorse/llvm-project/commit/8e68a722e0e2925f042cd6479f8b86578ba3042d
 , is that the sort of thing that would be useful? It's lacking unit test 
coverage right now.

https://github.com/llvm/llvm-project/pull/124287
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits