[PATCH] D102978: [WebAssembly] Add TargetInstrInfo::getCalleeOperand

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 25 02:09:37 PDT 2021


djtodoro added inline comments.


================
Comment at: llvm/test/DebugInfo/WebAssembly/call-site.ll:23
+; CHECK:                 DW_AT_name  ("call_indirect")
+; CHECK: 0x00000065:     DW_TAG_GNU_call_site
+
----------------
aheejin wrote:
> djtodoro wrote:
> > why don't we have here an additional CHECK for the register that holds the indirect call (`DW_AT_GNU_call_site_target`)?
> It doesn't have it. Am I doing something wrong? This is the full llvm-dwarfdump output for this file.
> ```
> call-site.o:  file format WASM                                                   
>                                                                                  
> .debug_info contents:                                                            
> 0x00000000: Compile Unit: length = 0x00000068, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x0000006c)
>                                                                                  
> 0x0000000b: DW_TAG_compile_unit                                                  
>               DW_AT_producer  ("clang version 11.0.0")                           
>               DW_AT_language  (DW_LANG_C99)                                      
>               DW_AT_name  ("test.c")                                             
>               DW_AT_stmt_list  (0x00000000)                                      
>               DW_AT_comp_dir  ("/home/llvm-project")                             
>               DW_AT_GNU_pubnames  (true)                                         
>               DW_AT_low_pc  (0x00000000)                                         
>               DW_AT_ranges  (0x00000000                                          
>                  [0x00000002, 0x0000000a)                                        
>                  [0x0000000b, 0x0000001a))                                       
>                                                                                  
> 0x00000026:   DW_TAG_subprogram                                                  
>                 DW_AT_low_pc  (0x00000002)                                       
>                 DW_AT_high_pc  (0x0000000a)                                      
>                 DW_AT_frame_base  (DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value)
>                 DW_AT_GNU_all_call_sites  (true)                                 
>                 DW_AT_name  ("call_direct")                                      
>                 DW_AT_decl_file  ("/home/llvm-project/test.c")                   
>                 DW_AT_decl_line  (3)                                             
>                 DW_AT_external  (true)                                           
>                                                                                  
> 0x0000003d:     DW_TAG_GNU_call_site                                             
>                   DW_AT_abstract_origin  (0x00000047 "foo")                      
>                   DW_AT_low_pc  (0x00000009)                                     
>                                                                                  
> 0x00000046:     NULL                                                             
>                                                                                  
> 0x00000047:   DW_TAG_subprogram                                                  
>                 DW_AT_name  ("foo")                                              
>                 DW_AT_decl_file  ("/home/llvm-project/test.c")                   
>                 DW_AT_decl_line  (30)                                            
>                 DW_AT_declaration  (true)                                        
>                 DW_AT_external  (true)                                           
>                                                                                  
> 0x0000004e:   DW_TAG_subprogram                                                  
>                 DW_AT_low_pc  (0x0000000b)                                       
>                 DW_AT_high_pc  (0x0000001a)                                      
>                 DW_AT_frame_base  (DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value)
>                 DW_AT_GNU_all_call_sites  (true)                                 
>                 DW_AT_name  ("call_indirect")                                    
>                 DW_AT_decl_file  ("/home/llvm-project/test.c")                   
>                 DW_AT_decl_line  (3)                                             
>                 DW_AT_external  (true)                                           
>                                                                                  
> 0x00000065:     DW_TAG_GNU_call_site                                             
>                   DW_AT_low_pc  (0x00000019)                                     
>                                                                                  
> 0x0000006a:     NULL                                                             
>                                                                                  
> 0x0000006b:   NULL
> ```
> 
> It only seems to contain 
> ```
> 0x00000065:     DW_TAG_GNU_call_site                                             
>                   DW_AT_low_pc  (0x00000019)   
> ```
> for the indirect call. I'm not very familiar with dwarf info stuff myself, so please let me know if something is missing. Thanks.
Actually, this is useless call_site debug information, since it does not have the `DW_AT_GNU_call_site_target` attribute (which holds the location of the indirect call).
In this case the call instruction is:

  %6:i32 = CALL_INDIRECT 0, 0, %5:i32, %4:i32, %7:i32, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def $value_stack, implicit $value_stack, debug-location !11; test.c:40:11

And the callee op is `%7:i32`, which is not a physical register, so there is no way to generate `MachineLocation` for it. The WebAssembly indirect calls should be handled differently I guess.

For now, we can do:

         const MachineOperand &CalleeOp = TII->getCalleeOperand(MI);
         if (!CalleeOp.isGlobal() &&
             (!CalleeOp.isReg() || !Register::isPhysicalRegister(CalleeOp.getReg())))
            continue;



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102978/new/

https://reviews.llvm.org/D102978



More information about the llvm-commits mailing list