- In X86LowerAMXType.cpp dyn_cast could lead to UserI be nullptr which coud be dref in IRBuilder constructor.
- In AsmPrinter.cpp, doInitialization could make MMI be nullptr if MMIWP->getMMI() is false, then the deref after could be unexpected.
Details
- Reviewers
skan pengfei yubing - Commits
- rG7c6c03ea7110: [NFC] Fix possibly deref nullptr
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
OK, the other two places are in same function, line 432 shows
MMI = MMIWP ? &MMIWP->getMMI() : nullptr;
So MMI could be nullptr, I just add add condition for those could deref this MMI, no func change.
No, if MMI could be nullptr, then it's not a NFC change. If we never crash at this point, assert should be used instead.
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
576 | Why? |
Then I could remove NFC label.
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
576 | Constructor would deref MMI WinException::WinException(AsmPrinter *A) : EHStreamer(A) { // MSVC's EH tables are always composed of 32-bit words. All known 64-bit // platforms use an imagerel32 relocation to refer to symbols. useImageRel32 = (A->getDataLayout().getPointerSizeInBits() == 64); ... const DataLayout &AsmPrinter::getDataLayout() const { return MMI->getModule()->getDataLayout(); } |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
576 | Move this to AsmPrinter::getDataLayout() |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
386 | MMI-> expresses the intention that MMI cannot be nullptr. This assert has very little value. I think we generally don't add it. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
386 | OK, I may mov this to higher level to avoid static analyzer report in another patch. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
386 | Please just don't send patches just to appease static analyzer. Their reports must be analyzed. Low value reports can be turned down/ignored. |
MMI-> expresses the intention that MMI cannot be nullptr. This assert has very little value. I think we generally don't add it.