[PATCH] D148692: Fix uninitialized class members

LuoYuanke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 07:38:36 PDT 2023


LuoYuanke added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/ReachingDefAnalysis.h:90
   /// The first instruction in each basic block is 0.
-  int CurInstr;
+  int CurInstr = -1;
 
----------------
It seems in `ReachingDefAnalysis::enterBasicBlock()` `CurInstr` is reset to 0, so I wonder if it is better to initialized to 0.


================
Comment at: llvm/lib/CodeGen/IfConversion.cpp:200
 
-    bool PreRegAlloc;
-    bool MadeChange;
+    bool PreRegAlloc = false;
+    bool MadeChange = false;
----------------
In test/CodeGen/AArch64/O3-pipeline.ll, this pass runs before the register allocation pass, so set it true may be better.


================
Comment at: llvm/lib/CodeGen/ShrinkWrap.cpp:141
   /// Current opcode for frame setup.
-  unsigned FrameSetupOpcode;
+  unsigned FrameSetupOpcode = 0;
 
----------------
Set `~0u`?  See https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/TargetInstrInfo.h#L101.


================
Comment at: llvm/lib/CodeGen/ShrinkWrap.cpp:144
   /// Current opcode for frame destroy.
-  unsigned FrameDestroyOpcode;
+  unsigned FrameDestroyOpcode = 0;
 
----------------
Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148692



More information about the llvm-commits mailing list