Skip to content

Commit 0c9093f

Browse files
committed
validate MMO before using it.
1 parent 85b9757 commit 0c9093f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,8 +1735,10 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
17351735
case UNKNOWN:
17361736
llvm_unreachable("Unknown instruction class");
17371737
case S_BUFFER_LOAD_IMM: {
1738+
// If XNACK is enabled, use the constrained opcodes when the first load is
1739+
// under-aligned.
17381740
const MachineMemOperand *MMO = *CI.I->memoperands_begin();
1739-
bool NeedsConstrainedOpc = needsConstrainedOpcode(*STM, MMO, Width);
1741+
bool NeedsConstrainedOpc = MMO && needsConstrainedOpcode(*STM, MMO, Width);
17401742
switch (Width) {
17411743
default:
17421744
return 0;
@@ -1755,8 +1757,10 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
17551757
}
17561758
}
17571759
case S_BUFFER_LOAD_SGPR_IMM: {
1760+
// If XNACK is enabled, use the constrained opcodes when the first load is
1761+
// under-aligned.
17581762
const MachineMemOperand *MMO = *CI.I->memoperands_begin();
1759-
bool NeedsConstrainedOpc = needsConstrainedOpcode(*STM, MMO, Width);
1763+
bool NeedsConstrainedOpc = MMO && needsConstrainedOpcode(*STM, MMO, Width);
17601764
switch (Width) {
17611765
default:
17621766
return 0;
@@ -1778,7 +1782,7 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
17781782
// If XNACK is enabled, use the constrained opcodes when the first load is
17791783
// under-aligned.
17801784
const MachineMemOperand *MMO = *CI.I->memoperands_begin();
1781-
bool NeedsConstrainedOpc = needsConstrainedOpcode(*STM, MMO, Width);
1785+
bool NeedsConstrainedOpc = MMO && needsConstrainedOpcode(*STM, MMO, Width);
17821786
switch (Width) {
17831787
default:
17841788
return 0;

0 commit comments

Comments
 (0)