Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
ConstantInt *i =
mdconst::extract<ConstantInt>(MMO.getRanges()->getOperand(0));
if (i->getIntegerType()->getBitWidth() !=
MMO.getMemoryType().getScalarSizeInBits()) {
ValTy.getScalarType().getSizeInBits()) {
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
ValTy.getScalarType().getSizeInBits()) {
MMO.getMemoryType().getScalarSizeInBits()) {

This should continue to permit the extending load case to use range metadata. Verifying the result type is trickier since we need to account for valid extending loads

Copy link
Contributor

Choose a reason for hiding this comment

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

The change to use the memory type got lost

report("range is incompatible with the result type", MI);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
!0 = !{i24 0, i24 1048575}
!1 = !{!"omnipotent char", !2}
!2 = !{!"Simple C/C++ TBAA"}
!3 = !{i32 0, i32 1048575}
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't touch the input IR. However this makes me realize we are violating the principle that we shouldn't touch the underlying IR in codegen. I guess global metadata constants could be an exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I do not understand how to resolve the comment, this test started to fail because i24 range is used on i32 value, I have forked this range with i32 to make the test pass, should I change this test or should I change the check? Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it depends how we want to handle extending loads. As written, I think we should leave the test for now. However that means you need to adjust from checking the result memory type, to the memory type in the MachineMemOperand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, thank you!

...

# Make sure range metadata is not preserved when widening loads, but
Expand Down Expand Up @@ -67,7 +68,7 @@ body: |
; SI-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load (s32), !tbaa !1, addrspace 1)
; SI-NEXT: $vgpr0 = COPY [[LOAD]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_LOAD %0 :: (load (s24), align 4, addrspace 1, !range !0, !tbaa !1)
%1:_(s32) = G_LOAD %0 :: (load (s24), align 4, addrspace 1, !range !3, !tbaa !1)
$vgpr0 = COPY %1

...
Expand Down
4 changes: 1 addition & 3 deletions llvm/test/MachineVerifier/test_g_incompatible_range.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: not --crash llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=none %s -filetype=null 2>&1 | FileCheck %s
# RUN: not --crash llc -o - -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=none %s 2>&1 | FileCheck %s
--- |
define void @mismatched_range_type() {
ret void
Expand All @@ -21,10 +21,8 @@ body: |
; CHECK: Bad machine code: range is incompatible with the result type
%3:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1)

; CHECK: Bad machine code: range is incompatible with the result type
%4:_(p0) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1)

; CHECK: Bad machine code: range is incompatible with the result type
%5:_(<2 x p0>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1)

$vgpr0_vgpr1 = COPY %3
Expand Down
Loading