[PATCH] D87148: [ImplicitNullCheck] Handle Nonzero faulting pages and complex addressing
Denis Antrushin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 07:29:31 PDT 2020
dantrushin added inline comments.
================
Comment at: llvm/include/llvm/CodeGen/TargetInstrInfo.h:1287
+ std::pair<Register, bool> &BaseRegUsedInConstAddr,
+ std::pair<Register, bool> &IndexRegUsedInConstAddr,
+ const TargetRegisterInfo *TRI,
----------------
These names are confusing. I've been scrolling back and forth for several minutes :)
Why not to pass and name them separately?
================
Comment at: llvm/lib/CodeGen/ImplicitNullChecks.cpp:421
+ Scale != 0 && IndexRegUsedInConstAddr.first &&
+ IndexRegUsedInConstAddr.first != PointerReg;
----------------
Do you really need to check that `BaseRegUsedInConstAddr.first` is not zero?
Would simple `BaseRegUsedInConstAddr.first != PointerReg` work here?
I also found positive names more readable, e.g. `bool BaseRegIsNullChecked = BaseRegUsedInConstAddr.first == PointerReg`
I think it is reasonable to assert `Scale !=0 || IndexRegUsedInConstAddr.first == 0` and remove Scale check.
================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:3680
+
+ auto *BaseOp = &MemI.getOperand(MemRefBegin + X86::AddrBaseReg);
+ if (!BaseOp->isReg()) // Can be an MO_FrameIndex
----------------
Any reason to use `auto *` instead of `auto &` ?
If I read it correctly, `BaseOp` is used to get base register only. Using reference you'd have less characters to type :)
================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:3693
+ Scale = MemI.getOperand(MemRefBegin + X86::AddrScaleAmt).getImm();
+ auto *IndexOp = &MemI.getOperand(MemRefBegin + X86::AddrIndexReg);
+ auto IndexOpReg = IndexOp->getReg();
----------------
ditto. `auto &IndexOp = MI.getOperand()` ?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87148/new/
https://reviews.llvm.org/D87148
More information about the llvm-commits
mailing list