Skip to content

Commit 26616c6

Browse files
author
Thorsten Schütt
authored
[GlobalIsel][NFC] Harden MachineIRBuilder (#75465)
Protective measures against #74502
1 parent b7f50e1 commit 26616c6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
314314
assert(EltTy.getScalarSizeInBits() == Val.getBitWidth() &&
315315
"creating constant with the wrong size");
316316

317-
if (Ty.isVector()) {
317+
assert(!Ty.isScalableVector() &&
318+
"unexpected scalable vector in buildConstant");
319+
320+
if (Ty.isFixedVector()) {
318321
auto Const = buildInstr(TargetOpcode::G_CONSTANT)
319322
.addDef(getMRI()->createGenericVirtualRegister(EltTy))
320323
.addCImm(&Val);
@@ -347,7 +350,10 @@ MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
347350

348351
assert(!Ty.isPointer() && "invalid operand type");
349352

350-
if (Ty.isVector()) {
353+
assert(!Ty.isScalableVector() &&
354+
"unexpected scalable vector in buildFConstant");
355+
356+
if (Ty.isFixedVector()) {
351357
auto Const = buildInstr(TargetOpcode::G_FCONSTANT)
352358
.addDef(getMRI()->createGenericVirtualRegister(EltTy))
353359
.addFPImm(&Val);

0 commit comments

Comments
 (0)