[PATCH] D158939: Protect against null dereferences

Wang, Xin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 02:40:42 PDT 2023


XinWang10 added inline comments.


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7071
+  for (Instruction *I : TrueInstrs) {
+    assert(TrueBranch != nullptr && "TrueBranch must be initialized");
     I->moveBefore(TrueBranch);
----------------
This may be useless, we don't init TrueBranch only when TrueInstrs.size()==0.


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7074
+  }
+  for (Instruction *I : FalseInstrs) {
+    assert(FalseBranch != nullptr && "FalseBranch must be initialized");
----------------
Ditto.


================
Comment at: llvm/lib/TableGen/TGParser.cpp:585
+    if (!is_contained(UnsolvedArgNames, ArgName)) {
+      assert(ArgName != nullptr && "ArgName must be initialized");
       return Error(Loc, "We can only specify the template argument '" +
----------------
I see ArgumentInit just have 2 kinds, so ArgName could always be inited.


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:5967
+    // Call DAG->ComputeNumSignBits(Src, DemandedSrcElts, 0U) may return 0
+    assert(NumBitsPerSrcElt != 0 && "Modulo by zero");
     assert((NumBitsPerElt % NumBitsPerSrcElt) == 0 && "Unexpected extension");
----------------
I find this is mostly called by combine*, I think the type could be legal here, so will not be 0 here? Otherwise we could crash.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158939/new/

https://reviews.llvm.org/D158939



More information about the llvm-commits mailing list