[llvm] [GlobalIsel][NFC] Harden MachineIRBuilder (PR #75465)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 03:32:03 PST 2023
https://github.com/tschuett created https://github.com/llvm/llvm-project/pull/75465
Protective measures against https://github.com/llvm/llvm-project/pull/74502
>From 802b68734c9ddb4361a4353706ac0fd37f113b86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Sch=C3=BCtt?= <schuett at gmail.com>
Date: Thu, 14 Dec 2023 12:28:14 +0100
Subject: [PATCH] [GlobalIsel][NFC] Harden MachineIRBuilder
Protective measures against https://github.com/llvm/llvm-project/pull/74502
---
llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 80e9c08e850b68..1bb9a3c6161dd7 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -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);
@@ -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);
More information about the llvm-commits
mailing list