Skip to content

Commit

Permalink
[GlobalIsel][NFC] Harden MachineIRBuilder (#75465)
Browse files Browse the repository at this point in the history
Protective measures against
#74502
  • Loading branch information
Thorsten Schütt authored Dec 14, 2023
1 parent b7f50e1 commit 26616c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
assert(EltTy.getScalarSizeInBits() == Val.getBitWidth() &&
"creating constant with the wrong size");

if (Ty.isVector()) {
assert(!Ty.isScalableVector() &&
"unexpected scalable vector in buildConstant");

if (Ty.isFixedVector()) {
auto Const = buildInstr(TargetOpcode::G_CONSTANT)
.addDef(getMRI()->createGenericVirtualRegister(EltTy))
.addCImm(&Val);
Expand Down Expand Up @@ -347,7 +350,10 @@ MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,

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

if (Ty.isVector()) {
assert(!Ty.isScalableVector() &&
"unexpected scalable vector in buildFConstant");

if (Ty.isFixedVector()) {
auto Const = buildInstr(TargetOpcode::G_FCONSTANT)
.addDef(getMRI()->createGenericVirtualRegister(EltTy))
.addFPImm(&Val);
Expand Down

0 comments on commit 26616c6

Please sign in to comment.