Skip to content

Conversation

@pvelesko
Copy link
Contributor

@pvelesko pvelesko commented Jul 25, 2025

Code was assigning the same merge block to multiple headers. Added a fails as follows before the fix:

[3/4] Running the LLVM-SPIRV regression tests
llvm-lit: /space/pvelesko/.local/lib/python3.10/site-packages/lit/llvm/config.py:502: note: using clang: /space/pvelesko/install/llvm/21.0-upstream/bin/clang
FAIL: LLVM_SPIRV :: OpLoopMerge_mergeBlock.ll (1 of 918)
******************** TEST 'LLVM_SPIRV :: OpLoopMerge_mergeBlock.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 5: /space/pvelesko/SPIRV-LLVM-Translator/build/tools/llvm-spirv/llvm-spirv /space/pvelesko/SPIRV-LLVM-Translator/test/../mergeBlock.bc -o /space/pvelesko/SPIRV-LLVM-Translator/build/test/test_output/Output/OpLoopMerge_mergeBlock.ll.tmp.spv
+ /space/pvelesko/SPIRV-LLVM-Translator/build/tools/llvm-spirv/llvm-spirv /space/pvelesko/SPIRV-LLVM-Translator/test/../mergeBlock.bc -o /space/pvelesko/SPIRV-LLVM-Translator/build/test/test_output/Output/OpLoopMerge_mergeBlock.ll.tmp.spv
RUN: at line 6: /usr/local/bin/spirv-val /space/pvelesko/SPIRV-LLVM-Translator/build/test/test_output/Output/OpLoopMerge_mergeBlock.ll.tmp.spv
+ /usr/local/bin/spirv-val /space/pvelesko/SPIRV-LLVM-Translator/build/test/test_output/Output/OpLoopMerge_mergeBlock.ll.tmp.spv
error: line 111: Block '46[%_Z11round_robiniiiPViS0__exit_loopexit]' is already a merge block for another header
  %_Z15gpu_round_robiniiiPViS0_ = OpFunction %void None %32

#3277 should be merged first as this test will trigger that error before hitting merge block error.

DominatorTree DomTree(*Fun);
LoopInfo LI(DomTree);
for (const auto *LoopObj : LI.getLoopsInPreorder()) {
// Find the innermost loop that contains the current basic block
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Find the innermost loop that contains the current basic block
// Find the innermost loop that contains the current basic block.

; This test verifies that OpLoopMerge instructions properly assign unique merge blocks
; and don't create conflicts where the same block is used as a merge block for multiple loops.

; RUN: llvm-spirv %S/mergeBlock.bc -o %t.spv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the test contents in plain text in this file and call llvm-as from here.

Copy link
Contributor

@YixingZhang007 YixingZhang007 Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these binary file should be removed from the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the same for the other .bc file.


; RUN: llvm-spirv --to-text %t.spv -o - | FileCheck %s --check-prefix=CHECK-SPIRV-TEXT
; CHECK-SPIRV-TEXT: LoopMerge
; CHECK-SPIRV-TEXT: BranchConditional No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add newline at end of file.


; RUN: llvm-spirv --to-text %t.spv -o - | FileCheck %s --check-prefix=CHECK-SPIRV-TEXT
; CHECK-SPIRV-TEXT: LoopMerge
; CHECK-SPIRV-TEXT: BranchConditional No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add NEXT to verify that LoopMerge is immediately preceding?

Suggested change
; CHECK-SPIRV-TEXT: BranchConditional
; CHECK-SPIRV-TEXT-NEXT: BranchConditional


; RUN: llvm-spirv --to-text %t.spv -o - | FileCheck %s --check-prefix=CHECK-SPIRV-TEXT
; CHECK-SPIRV-TEXT: LoopMerge
; CHECK-SPIRV-TEXT: BranchConditional No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add newline at end of file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the same for the other .bc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants