[asan-asm-instrumentation] Fixed memory references which includes %rsp as a base or an index register.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp | ||
---|---|---|
302 ↗ | (On Diff #14450) | I think the common term is "spill". |
707 ↗ | (On Diff #14450) | I wonder if this could be moved to the parent class to reduce code duplication. |
test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s | ||
12 ↗ | (On Diff #14450) | This could be done with 1 lea instruction. |
lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp | ||
---|---|---|
137 ↗ | (On Diff #14577) | this can be coded in 2 lines: |
366 ↗ | (On Diff #14577) | Both of this can be either positive or negative, right? |
test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s | ||
11 ↗ | (On Diff #14577) | Please add tests for borderline cases (i.e. when we require 2 LEAs). |
PTAL
lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp | ||
---|---|---|
137 ↗ | (On Diff #14577) | Done. |
366 ↗ | (On Diff #14577) | Done, but there're no need to check against MinAllowedDisplacement, since Displacement is always non-negative, and OrigDisplacement is always 32-bit signed integer. |
test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s | ||
11 ↗ | (On Diff #14577) | Added border-line test. Not sure that the displacement limits are tested somewhere. Manual tests shows that large displacements (more than 32-bit) are just cut by assembler. |
LGTM w/ some minor comments
compiler-rt tests for this case would be nice, too
lib/Target/X86/AsmParser/X86AsmInstrumentation.cpp | ||
---|---|---|
42 ↗ | (On Diff #14786) | ApplyDisplacementBounds or smth |
366 ↗ | (On Diff #14577) | Ah, then add an assert(Displacement >= 0) instead of the lower bound check, or just leave it like this. Your choice. |
test/Instrumentation/AddressSanitizer/X86/asm_rsp_mem_op.s | ||
11 ↗ | (On Diff #14577) | Nice. |