-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[GlobalISel] Catching inconsistencies in load memory, result, and range metadata type #121247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d18e4f7
b76c3df
b740e22
f935fc6
21d6e71
ab0d2d5
21b9ca8
3a3233f
8026866
80f6486
314a0eb
da70608
4f16afa
f2ddff5
cd6958b
c4f11af
141e4b7
b7601c0
d45d85c
9094137
6e0f428
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1274,6 +1274,24 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { | |
| if (TypeSize::isKnownGT(MMO.getSize().getValue(), | ||
| ValTy.getSizeInBytes())) | ||
| report("load memory size cannot exceed result size", MI); | ||
|
|
||
| if (MMO.getRanges()) { | ||
| auto operandBits = [](const MDOperand &o) -> unsigned { | ||
| ConstantInt *i = mdconst::dyn_extract<ConstantInt>(o); | ||
| if (!i->isNegative()) | ||
| return i->getValue().getActiveBits(); | ||
| APInt reversed(i->getValue()); | ||
|
||
| reversed.negate(); | ||
| return reversed.getActiveBits() + 1; // one more bit for the sign | ||
| }; | ||
| unsigned bitsUsed = | ||
| std::max(operandBits(MMO.getRanges()->getOperand(0)), | ||
| operandBits(MMO.getRanges()->getOperand(1))); | ||
| if (bitsUsed != ValTy.getScalarType().getSizeInBits()) { | ||
| report("range is incompatible with the value it gets assigned to", | ||
parsifal-47 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MI); | ||
| } | ||
| } | ||
| } else if (MI->getOpcode() == TargetOpcode::G_STORE) { | ||
| if (TypeSize::isKnownLT(ValTy.getSizeInBytes(), | ||
| MMO.getSize().getValue())) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # RUN: not --crash llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=none %s -o - | ||
parsifal-47 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | | ||
| define void @range_metadata_sext_i8_signed_range_i64_load_as_v2i32() { | ||
| ret void | ||
| } | ||
|
|
||
| define void @range_metadata_sext_i8_signed_range_i64_load_as_v2i32_extractlo() { | ||
| ret void | ||
| } | ||
|
|
||
| define void @range_metadata_sext_i33_signed_range_i64_load_as_v2i32() { | ||
| ret void | ||
| } | ||
|
|
||
| !0 = !{i64 -4294967295, i64 4294967296} | ||
| !1 = !{i64 -8589934591, i64 8589934592} | ||
|
|
||
| ... | ||
| --- | ||
| name: range_metadata_sext_i33_signed_range_i64_load_as_v2i32 | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| liveins: $vgpr0, $vgpr1 | ||
| %1:_(s32) = COPY $vgpr0 | ||
| %2:_(s32) = COPY $vgpr1 | ||
| %0:_(p1) = G_MERGE_VALUES %1(s32), %2(s32) | ||
| ; CHECK: Bad machine code: range is incompatible with the value it gets assigned to | ||
|
||
| %3:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !1, addrspace 1) | ||
| $vgpr0_vgpr1 = COPY %3 | ||
| SI_RETURN implicit $vgpr0_vgpr1 | ||
| ... | ||
|
|
||
| --- | ||
| name: range_metadata_sext_i8_signed_range_i64_load_as_v2i32_extractlo | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| liveins: $vgpr0, $vgpr1 | ||
| %1:_(s32) = COPY $vgpr0 | ||
| %2:_(s32) = COPY $vgpr1 | ||
| %0:_(p1) = G_MERGE_VALUES %1(s32), %2(s32) | ||
| ; CHECK: Bad machine code: range is incompatible with the value it gets assigned to | ||
| %3:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1) | ||
| %zero:_(s32) = G_CONSTANT i32 0 | ||
| %extract:_(s32) = G_EXTRACT_VECTOR_ELT %3, %zero | ||
| %6:_(s32) = G_SEXT_INREG %zero, 9 | ||
| $vgpr0 = COPY %6 | ||
| SI_RETURN implicit $vgpr0, implicit $vgpr1 | ||
| ... | ||
|
|
||
| --- | ||
| name: range_metadata_sext_i8_signed_range_i64_load_as_v2i32 | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| liveins: $vgpr0, $vgpr1 | ||
| %1:_(s32) = COPY $vgpr0 | ||
| %2:_(s32) = COPY $vgpr1 | ||
| %0:_(p1) = G_MERGE_VALUES %1(s32), %2(s32) | ||
| ; CHECK: Bad machine code: range is incompatible with the value it gets assigned to | ||
| %3:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1) | ||
| %6:_(<2 x s32>) = G_SEXT_INREG %3, 9 | ||
| $vgpr0_vgpr1 = COPY %6 | ||
| SI_RETURN implicit $vgpr0_vgpr1 | ||
| ... | ||
Uh oh!
There was an error while loading. Please reload this page.