[PATCH] D32868: [globalisel][tablegen] Fix nullptr dereferences when getVRegDef() is called on a phys reg.
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 15:25:12 PDT 2017
dsanders added inline comments.
================
Comment at: test/TableGen/GlobalISelEmitter.td:141-142
// CHECK-NEXT: return false;
-// CHECK-NEXT: MachineInstr &MI1 = *MRI.getVRegDef(MI0.getOperand(1).getReg());
-// CHECK-NEXT: if (MI1.getNumOperands() < 3)
+// CHECK-NEXT: MachineInstr *MI1 = MRI.getVRegDef(MI0->getOperand(1).getReg());
+// CHECK-NEXT: if (!MI1 || MI1->getNumOperands() < 3)
// CHECK-NEXT: return false;
----------------
There's only a couple of them in the test at the moment but here's one of the getVRegDef's.
getVRegDef() returns a pointer to the MI that def's the register or nullptr otherwise. Previously, we unconditionally dereferenced it which caused a nullptr dereference when the register was live-in but now we check for the nullptr first.
https://reviews.llvm.org/D32868
More information about the llvm-commits
mailing list