<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[AMDGPU][FixIrreducible][UnifyLoopExits] Support callbr with inline-asm (#149308)</title>
<updated>2025-10-30T13:22:42+00:00</updated>
<author>
<name>Robert Imschweiler</name>
<email>robert.imschweiler@amd.com</email>
</author>
<published>2025-10-30T13:22:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=89540114a72594dbf71fbe728ba6c6d1deecfa03'/>
<id>89540114a72594dbf71fbe728ba6c6d1deecfa03</id>
<content type='text'>
First batch of changes to add support for inline-asm callbr for the
AMDGPU backend.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
First batch of changes to add support for inline-asm callbr for the
AMDGPU backend.</pre>
</div>
</content>
</entry>
<entry>
<title>[BasicBlockUtils] Add BasicBlock printer (#163066)</title>
<updated>2025-10-22T15:47:14+00:00</updated>
<author>
<name>Robert Imschweiler</name>
<email>robert.imschweiler@amd.com</email>
</author>
<published>2025-10-22T15:47:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6fca1381189065bf363257d5bc626f4f11e91a7f'/>
<id>6fca1381189065bf363257d5bc626f4f11e91a7f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Reland [BasicBlockUtils] Handle funclets when detaching EH pad blocks (#159379)</title>
<updated>2025-09-20T00:00:17+00:00</updated>
<author>
<name>Gábor Spaits</name>
<email>gaborspaits1@gmail.com</email>
</author>
<published>2025-09-20T00:00:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0a47e8c2fc337b8dc5dac1778c7a46c3219e157c'/>
<id>0a47e8c2fc337b8dc5dac1778c7a46c3219e157c</id>
<content type='text'>
Fixes #148052 .

Last PR did not account for the scenario, when more than one instruction
used the `catchpad` label.
In that case I have deleted uses, which were already "choosen to be
iterated over" by the early increment iterator. This issue was not
visible in normal release build on x86, but luckily later on the address
sanitizer build it has found it on the buildbot.

Here is the diff from the last version of this PR: #158435
```diff
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 91e245e5e8f5..1dd8cb4ee584 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -106,7 +106,8 @@ void llvm::detachDeadBlocks(ArrayRef&lt;BasicBlock *&gt; BBs,
       // first block, the we would have possible cleanupret and catchret
       // instructions with poison arguments, which wouldn't be valid.
       if (isa&lt;FuncletPadInst&gt;(I)) {
-        for (User *User : make_early_inc_range(I.users())) {
+        SmallPtrSet&lt;BasicBlock *, 4&gt; UniqueEHRetBlocksToDelete;
+        for (User *User : I.users()) {
           Instruction *ReturnInstr = dyn_cast&lt;Instruction&gt;(User);
           // If we have a cleanupret or catchret block, replace it with just an
           // unreachable. The other alternative, that may use a catchpad is a
@@ -114,33 +115,12 @@ void llvm::detachDeadBlocks(ArrayRef&lt;BasicBlock *&gt; BBs,
           if (isa&lt;CatchReturnInst&gt;(ReturnInstr) ||
               isa&lt;CleanupReturnInst&gt;(ReturnInstr)) {
             BasicBlock *ReturnInstrBB = ReturnInstr-&gt;getParent();
-            // This catchret or catchpad basic block is detached now. Let the
-            // successors know it.
-            // This basic block also may have some predecessors too. For
-            // example the following LLVM-IR is valid:
-            //
-            //   [cleanuppad_block]
-            //            |
-            //    [regular_block]
-            //            |
-            //   [cleanupret_block]
-            //
-            // The IR after the cleanup will look like this:
-            //
-            //   [cleanuppad_block]
-            //            |
-            //    [regular_block]
-            //            |
-            //     [unreachable]
-            //
-            // So regular_block will lead to an unreachable block, which is also
-            // valid. There is no need to replace regular_block with unreachable
-            // in this context now.
-            // On the other hand, the cleanupret/catchret block's successors
-            // need to know about the deletion of their predecessors.
-            emptyAndDetachBlock(ReturnInstrBB, Updates, KeepOneInputPHIs);
+            UniqueEHRetBlocksToDelete.insert(ReturnInstrBB);
           }
         }
+        for (BasicBlock *EHRetBB :
+             make_early_inc_range(UniqueEHRetBlocksToDelete))
+          emptyAndDetachBlock(EHRetBB, Updates, KeepOneInputPHIs);
       }
     }
```</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #148052 .

Last PR did not account for the scenario, when more than one instruction
used the `catchpad` label.
In that case I have deleted uses, which were already "choosen to be
iterated over" by the early increment iterator. This issue was not
visible in normal release build on x86, but luckily later on the address
sanitizer build it has found it on the buildbot.

Here is the diff from the last version of this PR: #158435
```diff
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 91e245e5e8f5..1dd8cb4ee584 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -106,7 +106,8 @@ void llvm::detachDeadBlocks(ArrayRef&lt;BasicBlock *&gt; BBs,
       // first block, the we would have possible cleanupret and catchret
       // instructions with poison arguments, which wouldn't be valid.
       if (isa&lt;FuncletPadInst&gt;(I)) {
-        for (User *User : make_early_inc_range(I.users())) {
+        SmallPtrSet&lt;BasicBlock *, 4&gt; UniqueEHRetBlocksToDelete;
+        for (User *User : I.users()) {
           Instruction *ReturnInstr = dyn_cast&lt;Instruction&gt;(User);
           // If we have a cleanupret or catchret block, replace it with just an
           // unreachable. The other alternative, that may use a catchpad is a
@@ -114,33 +115,12 @@ void llvm::detachDeadBlocks(ArrayRef&lt;BasicBlock *&gt; BBs,
           if (isa&lt;CatchReturnInst&gt;(ReturnInstr) ||
               isa&lt;CleanupReturnInst&gt;(ReturnInstr)) {
             BasicBlock *ReturnInstrBB = ReturnInstr-&gt;getParent();
-            // This catchret or catchpad basic block is detached now. Let the
-            // successors know it.
-            // This basic block also may have some predecessors too. For
-            // example the following LLVM-IR is valid:
-            //
-            //   [cleanuppad_block]
-            //            |
-            //    [regular_block]
-            //            |
-            //   [cleanupret_block]
-            //
-            // The IR after the cleanup will look like this:
-            //
-            //   [cleanuppad_block]
-            //            |
-            //    [regular_block]
-            //            |
-            //     [unreachable]
-            //
-            // So regular_block will lead to an unreachable block, which is also
-            // valid. There is no need to replace regular_block with unreachable
-            // in this context now.
-            // On the other hand, the cleanupret/catchret block's successors
-            // need to know about the deletion of their predecessors.
-            emptyAndDetachBlock(ReturnInstrBB, Updates, KeepOneInputPHIs);
+            UniqueEHRetBlocksToDelete.insert(ReturnInstrBB);
           }
         }
+        for (BasicBlock *EHRetBB :
+             make_early_inc_range(UniqueEHRetBlocksToDelete))
+          emptyAndDetachBlock(EHRetBB, Updates, KeepOneInputPHIs);
       }
     }
```</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Reland "[BasicBlockUtils] Handle funclets when detaching EH p… (#159292)</title>
<updated>2025-09-17T09:44:17+00:00</updated>
<author>
<name>Gábor Spaits</name>
<email>gaborspaits1@gmail.com</email>
</author>
<published>2025-09-17T09:44:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=88c64f76ed2ca226da99b99f60d316b1519fc7d8'/>
<id>88c64f76ed2ca226da99b99f60d316b1519fc7d8</id>
<content type='text'>
…ad blocks" (#158435)"

This reverts commit 41cef78227eb909181cb9360099b2d92de8d649f.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
…ad blocks" (#158435)"

This reverts commit 41cef78227eb909181cb9360099b2d92de8d649f.</pre>
</div>
</content>
</entry>
<entry>
<title>Reland "[BasicBlockUtils] Handle funclets when detaching EH pad blocks" (#158435)</title>
<updated>2025-09-17T07:47:29+00:00</updated>
<author>
<name>Gábor Spaits</name>
<email>gaborspaits1@gmail.com</email>
</author>
<published>2025-09-17T07:47:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=41cef78227eb909181cb9360099b2d92de8d649f'/>
<id>41cef78227eb909181cb9360099b2d92de8d649f</id>
<content type='text'>
When removing EH Pad blocks, the value defined by them becomes poison. These poison values are then used by `catchret` and `cleanupret`, which is invalid. This commit replaces those unreachable `catchret` and `cleanupret` instructions with `unreachable`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When removing EH Pad blocks, the value defined by them becomes poison. These poison values are then used by `catchret` and `cleanupret`, which is invalid. This commit replaces those unreachable `catchret` and `cleanupret` instructions with `unreachable`.
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[BasicBlockUtils] Handle funclets when detaching EH pad blocks" (#158364)</title>
<updated>2025-09-14T19:58:48+00:00</updated>
<author>
<name>Arthur Eubanks</name>
<email>aeubanks@google.com</email>
</author>
<published>2025-09-14T19:58:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b30c29c89381f87562edc34c7813cbd310d1d4b0'/>
<id>b30c29c89381f87562edc34c7813cbd310d1d4b0</id>
<content type='text'>
Reverts llvm/llvm-project#157363

Causes crashes, see
https://github.com/llvm/llvm-project/pull/157363#issuecomment-3286783238</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverts llvm/llvm-project#157363

Causes crashes, see
https://github.com/llvm/llvm-project/pull/157363#issuecomment-3286783238</pre>
</div>
</content>
</entry>
<entry>
<title>[BasicBlockUtils] Handle funclets when detaching EH pad blocks (#157363)</title>
<updated>2025-09-11T20:52:16+00:00</updated>
<author>
<name>Gábor Spaits</name>
<email>gaborspaits1@gmail.com</email>
</author>
<published>2025-09-11T20:52:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=43561ad204329667954d5ce1e632e09335f0ab12'/>
<id>43561ad204329667954d5ce1e632e09335f0ab12</id>
<content type='text'>
Fixes #148052 .

When removing EH Pad blocks, the value defined by them becomes poison. These poison values are then used by `catchret` and `cleanupret`, which is invalid. This commit replaces those unreachable `catchret` and `cleanupret` instructions with `unreachable`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #148052 .

When removing EH Pad blocks, the value defined by them becomes poison. These poison values are then used by `catchret` and `cleanupret`, which is invalid. This commit replaces those unreachable `catchret` and `cleanupret` instructions with `unreachable`.</pre>
</div>
</content>
</entry>
<entry>
<title>[RemoveDIs][NFC] Clean up BasicBlockUtils now intrinsics are gone (#154326)</title>
<updated>2025-08-20T09:03:44+00:00</updated>
<author>
<name>Orlando Cazalet-Hyams</name>
<email>orlando.hyams@sony.com</email>
</author>
<published>2025-08-20T09:03:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6c9352530aca94693c5184b566553621435f1e5c'/>
<id>6c9352530aca94693c5184b566553621435f1e5c</id>
<content type='text'>
A couple of minor readability changes now that we're not supporting both
intrinsics and records.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A couple of minor readability changes now that we're not supporting both
intrinsics and records.</pre>
</div>
</content>
</entry>
<entry>
<title>[RemoveDIs] Resolve RemoveRedundantDbgInstrs fwd scan FIXME (#144718)</title>
<updated>2025-06-24T12:09:49+00:00</updated>
<author>
<name>Orlando Cazalet-Hyams</name>
<email>orlando.hyams@sony.com</email>
</author>
<published>2025-06-24T12:09:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=352baa386c10ef62ef190023e5b6a3434e84dc1f'/>
<id>352baa386c10ef62ef190023e5b6a3434e84dc1f</id>
<content type='text'>
These FIXMEs were added to keep the dbg_record implementation identical to the
dbg intrinsic versions, which have since been removed. I don't think there's any
reason for the old behaviour; my understanding is it was a minor bug no one got
round to fixing.

I've upgraded the test to be written with dbg_records while I'm here.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These FIXMEs were added to keep the dbg_record implementation identical to the
dbg intrinsic versions, which have since been removed. I don't think there's any
reason for the old behaviour; my understanding is it was a minor bug no one got
round to fixing.

I've upgraded the test to be written with dbg_records while I'm here.</pre>
</div>
</content>
</entry>
<entry>
<title>[llvm] Remove unused includes (NFC) (#144293)</title>
<updated>2025-06-16T15:59:18+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-06-16T15:59:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=05cd32adb7ce2354563814ab6e0b818f2ed6fa26'/>
<id>05cd32adb7ce2354563814ab6e0b818f2ed6fa26</id>
<content type='text'>
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.</pre>
</div>
</content>
</entry>
</feed>
