diff options
author | Yuri Gorshenin <ygorshenin@google.com> | 2014-10-13 11:44:06 +0000 |
---|---|---|
committer | Yuri Gorshenin <ygorshenin@google.com> | 2014-10-13 11:44:06 +0000 |
commit | ab1b88ab59ace17763e5cae2abb4d5908a897b14 (patch) | |
tree | d7b82408e1e64ac50edc35e76b6f6d625d8821da /llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp | |
parent | 3f840a934eaac729e5ce17ddcd8ebb6565018d24 (diff) | |
download | bcm5719-llvm-ab1b88ab59ace17763e5cae2abb4d5908a897b14.tar.gz bcm5719-llvm-ab1b88ab59ace17763e5cae2abb4d5908a897b14.zip |
[asan-asm-instrumentation] Follow-up fixes to r219602: asserts are moved into
function.
llvm-svn: 219610
Diffstat (limited to 'llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp')
-rw-r--r-- | llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp index 1f1a9df10b3..dbc5f281461 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp @@ -39,14 +39,14 @@ static cl::opt<bool> ClAsanInstrumentAssembly( const int64_t MinAllowedDisplacement = std::numeric_limits<int32_t>::min(); const int64_t MaxAllowedDisplacement = std::numeric_limits<int32_t>::max(); -int64_t ApplyBounds(int64_t Displacement) { +int64_t ApplyDisplacementBounds(int64_t Displacement) { return std::max(std::min(MaxAllowedDisplacement, Displacement), MinAllowedDisplacement); } -bool InBounds(int64_t Displacement) { - return Displacement >= MinAllowedDisplacement && - Displacement <= MaxAllowedDisplacement; +void CheckDisplacementBounds(int64_t Displacement) { + assert(Displacement >= MinAllowedDisplacement && + Displacement <= MaxAllowedDisplacement); } bool IsStackReg(unsigned Reg) { return Reg == X86::RSP || Reg == X86::ESP; } @@ -339,7 +339,7 @@ void X86AddressSanitizer::ComputeMemOperandAddress(X86Operand &Op, while (Residue != 0) { const MCConstantExpr *Disp = - MCConstantExpr::Create(ApplyBounds(Residue), Ctx); + MCConstantExpr::Create(ApplyDisplacementBounds(Residue), Ctx); std::unique_ptr<X86Operand> DispOp = X86Operand::CreateMem(0, Disp, Reg, 0, 1, SMLoc(), SMLoc()); EmitLEA(*DispOp, VT, Reg, Out); @@ -362,11 +362,11 @@ X86AddressSanitizer::AddDisplacement(X86Operand &Op, int64_t Displacement, int64_t OrigDisplacement = static_cast<const MCConstantExpr *>(Op.getMemDisp())->getValue(); - assert(InBounds(OrigDisplacement)); + CheckDisplacementBounds(OrigDisplacement); Displacement += OrigDisplacement; - int64_t NewDisplacement = ApplyBounds(Displacement); - assert(InBounds(NewDisplacement)); + int64_t NewDisplacement = ApplyDisplacementBounds(Displacement); + CheckDisplacementBounds(NewDisplacement); *Residue = Displacement - NewDisplacement; const MCExpr *Disp = MCConstantExpr::Create(NewDisplacement, Ctx); |