[PATCH] D48676: [Local] Teach insertReplacementDbgValues basic integer/pointer conversions

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 17:07:15 PDT 2018


vsk marked an inline comment as done.
vsk added a comment.

I'm double-checking the DWARF for sign extension. Here is what I see in the stage2 llc binary:

  0x00754923:                     DW_TAG_inlined_subroutine
                                    DW_AT_abstract_origin	(0x0000000000751e3a "_ZL28isPotentialBlockedMemCpyPairii")
                                    DW_AT_ranges [... snip]
                                    DW_AT_call_file	("/Users/vsk/src/llvm.org-master/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp")
                                    DW_AT_call_line	(546)
  
  0x00754930:                       DW_TAG_formal_parameter
                                      DW_AT_location	(0x00186529
                                         [0x00000000000008a4,  0x00000000000008bb): DW_OP_reg2 RCX, DW_OP_piece 0x2, DW_OP_breg2 RCX+0, DW_OP_constu 0xffff, DW_OP_and, DW_OP_constu 0xf, DW_OP_shr, DW_OP_lit0, DW_OP_not, DW_OP_mul, DW_OP_stack_value, DW_OP_piece 0x2
                                         [0x00000000000008fe,  0x0000000000000906): DW_OP_reg2 RCX, DW_OP_piece 0x2, DW_OP_breg2 RCX+0, DW_OP_constu 0xffff, DW_OP_and, DW_OP_constu 0xf, DW_OP_shr, DW_OP_lit0, DW_OP_not, DW_OP_mul, DW_OP_stack_value, DW_OP_piece 0x2
                                         [0x000000000000096e,  0x0000000000000971): DW_OP_reg2 RCX, DW_OP_piece 0x2, DW_OP_breg2 RCX+0, DW_OP_constu 0xffff, DW_OP_and, DW_OP_constu 0xf, DW_OP_shr, DW_OP_lit0, DW_OP_not, DW_OP_mul, DW_OP_stack_value, DW_OP_piece 0x2)
                                      DW_AT_abstract_origin	(0x0000000000751e4b "LdOpcode")

This shows that the DIExpression is lowered correctly, I think. The variable "LdOpcode" is an "int" in the source, but some optimization has us using only its lower 16 bits. Unfortunately, lldb doesn't accept this variable description:

  ~/src/builds/llvm.org-master-RA-stage2 (0) $ lldb -- ./bin/llc /Users/vsk/src/llvm.org-master/llvm/test/CodeGen/X86/avoid-sfb-overlaps.ll -mtriple=x86_64-linux -o -
  (lldb) b isPotentialBlockedMemCpyPair
  Breakpoint 1: where = llc`(anonymous namespace)::X86AvoidSFBPass::runOnMachineFunction(llvm::MachineFunction&) + 1188 [inlined] isPotentialBlockedMemCpyPair(int, int) at X86AvoidStoreForwardingBlocks.cpp:546, address = 0x0000000100078cb4
  ...
  Process 24842 stopped
  * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
      frame #0: 0x0000000100078cb4 llc`(anonymous namespace)::X86AvoidSFBPass::runOnMachineFunction(llvm::MachineFunction&) [inlined] isPotentialBlockedMemCpyPair(LdOpcode=<unavailable>, StOpcode=<unavailable>) at X86AvoidStoreForwardingBlocks.cpp:162 [opt]
     159  }
     160
     161  static bool isPotentialBlockedMemCpyPair(int LdOpcode, int StOpcode) {
  -> 162    switch (LdOpcode) {
   
  (lldb) p LdOpcode
  error: Couldn't materialize: couldn't get the value of variable LdOpcode: DW_OP_piece for offset 2 but top of stack is of size 8
  error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

Here is what the DWARF4 standard says:

  The DW_OP_piece operation takes a single operand, which is an unsigned LEB128 number. The number describes the size in bytes of the piece of the object referenced by the preceding simple location description. If the piece is located in a register, but does not occupy the entire register, the placement of the piece within that register is defined by the ABI.

With this patch, LLVM emits `DW_OP_reg2 RCX, DW_OP_piece 0x2`. LLDB should know to interpret this as the low 16 bits of %rcx. We'll have to teach it.


https://reviews.llvm.org/D48676





More information about the llvm-commits mailing list