Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Side by Side Diff: src/IceInstX8632.cpp

Issue 1435283003: Subzero: Fix a crash in mem operand dumping. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (getBase()) 182 if (getBase())
183 Str << "+"; 183 Str << "+";
184 if (getShift() > 0) 184 if (getShift() > 0)
185 Str << (1u << getShift()) << "*"; 185 Str << (1u << getShift()) << "*";
186 if (Func) 186 if (Func)
187 getIndex()->dump(Func); 187 getIndex()->dump(Func);
188 else 188 else
189 getIndex()->dump(Str); 189 getIndex()->dump(Str);
190 Dumped = true; 190 Dumped = true;
191 } 191 }
192 if (Disp) {
193 if (Disp > 0)
194 Str << "+";
195 Str << Disp;
196 Dumped = true;
197 }
192 // Pretty-print the Offset. 198 // Pretty-print the Offset.
193 bool OffsetIsZero = false; 199 bool OffsetIsZero = false;
194 bool OffsetIsNegative = false; 200 bool OffsetIsNegative = false;
195 if (getOffset() == 0 && Disp == 0) { 201 if (getOffset() == nullptr) {
196 OffsetIsZero = true; 202 OffsetIsZero = true;
197 } else if (getOffset() == 0 && Disp != 0) {
198 OffsetIsZero = (Disp == 0);
199 OffsetIsNegative = (Disp < 0);
200 } else if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) { 203 } else if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) {
201 OffsetIsZero = (CI->getValue() + Disp == 0); 204 OffsetIsZero = (CI->getValue() == 0);
202 OffsetIsNegative = (static_cast<int32_t>(CI->getValue()) + Disp < 0); 205 OffsetIsNegative = (static_cast<int32_t>(CI->getValue()) < 0);
203 } else { 206 } else {
204 assert(llvm::isa<ConstantRelocatable>(getOffset()) && Disp == 0); 207 assert(llvm::isa<ConstantRelocatable>(getOffset()));
205 } 208 }
206 if (Dumped) { 209 if (Dumped) {
207 if (!OffsetIsZero) { // Suppress if Offset is known to be 0 210 if (!OffsetIsZero) { // Suppress if Offset is known to be 0
208 if (!OffsetIsNegative) // Suppress if Offset is known to be negative 211 if (!OffsetIsNegative) // Suppress if Offset is known to be negative
209 Str << "+"; 212 Str << "+";
210 getOffset()->dump(Func, Str); 213 getOffset()->dump(Func, Str);
211 } 214 }
212 } else { 215 } else {
213 // There is only the offset. 216 // There is only the offset.
214 getOffset()->dump(Func, Str); 217 getOffset()->dump(Func, Str);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 Var->dump(Func); 317 Var->dump(Func);
315 else 318 else
316 Var->dump(Str); 319 Var->dump(Str);
317 Str << ")"; 320 Str << ")";
318 } 321 }
319 322
320 } // namespace X86Internal 323 } // namespace X86Internal
321 } // end of namespace Ice 324 } // end of namespace Ice
322 325
323 X86INSTS_DEFINE_STATIC_DATA(TargetX8632) 326 X86INSTS_DEFINE_STATIC_DATA(TargetX8632)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698