[PATCH] D77837: [llvm][NFC] Style fixes in Inliner.cpp
David Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 17:39:25 PDT 2020
davidxl added inline comments.
================
Comment at: llvm/lib/Transforms/IPO/Inliner.cpp:630
- int InlineHistoryID;
+ int InlineHistoryID = -1;
if (!IsTriviallyDead) {
----------------
mtrofin wrote:
> dblaikie wrote:
> > Generally I'm in favor of not adding unneeded (in the sense that if the program is working as intended it won't read uninitialized values) - that way tools like MSan and the like can find bugs in this code if the program isn't working as intended.
> >
> > Looks like that's the case here - InlineHistoryID is only used under the same condition (IsTriviallyDead) it's initialized. (also Clang has warnings for this too, in addition to the runtime checks)
> My worry is maintainability - initializing is local, while making sure that code evolution doesn't lead to uninitialized value propagating isn't.
>
>
This is a good point. It is ok to initialize it to illegal value that can be caught by assertions or can consistently crash the program. Here is not the case: -1 is actually a valid value to indicate a state, so it is not a good idea to initialize it to it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77837/new/
https://reviews.llvm.org/D77837
More information about the llvm-commits
mailing list