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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstX8632.cpp
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 817b41d4ec5905dee05624b2a76d906477309968..2c2f09ca83cbee31035af787e4b76a619446bd8a 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -189,19 +189,22 @@ void MachineTraits<TargetX8632>::X86OperandMem::dump(const Cfg *Func,
getIndex()->dump(Str);
Dumped = true;
}
+ if (Disp) {
+ if (Disp > 0)
+ Str << "+";
+ Str << Disp;
+ Dumped = true;
+ }
// Pretty-print the Offset.
bool OffsetIsZero = false;
bool OffsetIsNegative = false;
- if (getOffset() == 0 && Disp == 0) {
+ if (getOffset() == nullptr) {
OffsetIsZero = true;
- } else if (getOffset() == 0 && Disp != 0) {
- OffsetIsZero = (Disp == 0);
- OffsetIsNegative = (Disp < 0);
} else if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) {
- OffsetIsZero = (CI->getValue() + Disp == 0);
- OffsetIsNegative = (static_cast<int32_t>(CI->getValue()) + Disp < 0);
+ OffsetIsZero = (CI->getValue() == 0);
+ OffsetIsNegative = (static_cast<int32_t>(CI->getValue()) < 0);
} else {
- assert(llvm::isa<ConstantRelocatable>(getOffset()) && Disp == 0);
+ assert(llvm::isa<ConstantRelocatable>(getOffset()));
}
if (Dumped) {
if (!OffsetIsZero) { // Suppress if Offset is known to be 0
« 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