[PATCH] D108745: [asan] Fixed a runtime crash.

Kirill Stoimenov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 17:29:54 PDT 2021


kstoimenov created this revision.
Herald added subscribers: pengfei, hiraditya.
kstoimenov requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Looks like the NoRegister has some effect on the final code that is generated. My guess is that some optimization kicks in at the end?

When I use -S to dump the assemly I get the correct version with 'shrq    $3, %r8':
__asan_check_store4_rn129:

  movq    %r9, %r8
  shrq    $3, %r8
  movsbl  2147450880(%r8), %r8d

But, when I disassemble the final binary I get RAX in stead of R8 <https://reviews.llvm.org/source/libcxx/>:
000000000041f253 <__asan_check_store4_rn129>:
41f253:       4d 89 c8                mov    %r9,%r8
41f256:       48 c1 e8 03             shr    $0x3,%rax
41f25a:       45 0f be 80 00 80 ff    movsbl 0x7fff8000(%r8),%r8d


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108745

Files:
  llvm/lib/Target/X86/X86MCInstLower.cpp


Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===================================================================
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1370,12 +1370,12 @@
       STI);
   OutStreamer->emitInstruction(MCInstBuilder(X86::SHR64ri)
                                    .addReg(X86::R8)
-                                   .addReg(X86::NoRegister)
+                                   .addReg(X86::R8)
                                    .addImm(MappingScale),
                                STI);
   if (OrShadowOffset) {
     OutStreamer->emitInstruction(MCInstBuilder(X86::OR64ri32)
-                                     .addReg(X86::NoRegister)
+                                     .addReg(X86::R8)
                                      .addReg(X86::R8)
                                      .addImm(ShadowBase),
                                  STI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108745.368785.patch
Type: text/x-patch
Size: 921 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210826/cc5dea14/attachment.bin>


More information about the llvm-commits mailing list