Subzero: Fix inappropriate use of nullptr. When lowering of a couple of atomic intrinsics down to a loop structure, a FakeUse on the memory address's base variable is created. However, if the memory address is a global constant, there is no base variable. So check for that and don't create a FakeUse if there is none. BUG= none TEST=synchronization_sync (scons test) R=jvoung@chromium.org Review URL: https://codereview.chromium.org/1023673007
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp index 84333b4..e99516b 100644 --- a/src/IceTargetLoweringX8632.cpp +++ b/src/IceTargetLoweringX8632.cpp
@@ -3450,8 +3450,9 @@ Context.insert(InstFakeUse::create(Func, T_ebx)); Context.insert(InstFakeUse::create(Func, T_ecx)); } - // The address base is also reused in the loop. - Context.insert(InstFakeUse::create(Func, Addr->getBase())); + // The address base (if any) is also reused in the loop. + if (Variable *Base = Addr->getBase()) + Context.insert(InstFakeUse::create(Func, Base)); Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); _mov(DestLo, T_eax); @@ -3476,8 +3477,9 @@ if (Variable *ValVar = llvm::dyn_cast<Variable>(Val)) { Context.insert(InstFakeUse::create(Func, ValVar)); } - // The address base is also reused in the loop. - Context.insert(InstFakeUse::create(Func, Addr->getBase())); + // The address base (if any) is also reused in the loop. + if (Variable *Base = Addr->getBase()) + Context.insert(InstFakeUse::create(Func, Base)); _mov(Dest, T_eax); }