paulkirth added a comment.

As a quick test, I hacked the printer pass to generate an output string, and 
passed that into the remarks emitter. From opt or llc things look as expected. 
There's some additional output, but its limited.

I see a more serious issue when using it from Clang, as the output is truncated 
, as in it only printed up to the first stack slot in my test. Its also all 
bold, which isn't great. I have a feeling that my shortcut is the root cause of 
the truncation, but I haven't tracked down the issue exactly.

Do any other remarks output complex data like this? From what I can see they 
tend to be fairly short…

I also thought about printing each line as a remark, but that seems to get 
noisy pretty fast, since each line would have the `remark <file location>` tag 
plus an `[-Rpass-analysis=stackframe-printer]` at the end.

Example truncated output (each function should have several lines w/ offset 
from SP, alignment, and size):

  $ clang -O1 -Rpass-analysis=stackframe-printer 
llvm/test/CodeGen/X86/stack-frame-printer.ll -c -o /dev/null -mllvm 
-print-stack-frame                        
  
  remark: <unknown>:0:0: 
  # Stack Layout: stackSizeWarning
   [-Rpass-analysis=stackframe-printer]
  remark: <unknown>:0:0: 
  # Stack Layout: cleanup_array
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  
   [-Rpass-analysis=stackframe-printer]
  remark: <unknown>:0:0: 
  # Stack Layout: cleanup_result
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  
   [-Rpass-analysis=stackframe-printer]
  remark: <unknown>:0:0: 
  # Stack Layout: do_work
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  
   [-Rpass-analysis=stackframe-printer]
  remark: <unknown>:0:0: 
  # Stack Layout: gen_array
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  
   [-Rpass-analysis=stackframe-printer]
  remark: <unknown>:0:0: 
  # Stack Layout: caller
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  
   [-Rpass-analysis=stackframe-printer]

Output from llc (which looks more or less as expected):

  $ llc -mcpu=corei7 -O1 -print-stack-frame 
-pass-remarks-analysis=stackframe-printer < 
llvm/test/CodeGen/X86/stack-frame-printer.ll 2>&1 >/dev/null
  
  remark: <unknown>:0:0: 
  # Stack Layout: stackSizeWarning
  Offset            Align     Size      
  [SP-88]           16        80        
      buffer @ frame-diags.c:30
  [SP-168]          16        80        
      buffer2 @ frame-diags.c:33
  
  
  remark: <unknown>:0:0: 
  # Stack Layout: cleanup_array
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  [SP-16]           8         8         
      a @ dot.c:13
  
  
  remark: <unknown>:0:0: 
  # Stack Layout: cleanup_result
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  [SP-16]           8         8         
      res @ dot.c:21
  
  
  remark: <unknown>:0:0: 
  # Stack Layout: do_work
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  [SP-12]           4         4         
      i @ dot.c:55
  [SP-24]           8         8         
      AB @ dot.c:38
  [SP-28]           4         4         
      len @ dot.c:37
  [SP-32]           4         4         
  [SP-40]           8         8         
      out @ dot.c:32
  [SP-48]           8         8         
      B @ dot.c:32
  [SP-56]           8         8         
      A @ dot.c:32
  [SP-60]           4         4         
      sum @ dot.c:54
  
  
  remark: <unknown>:0:0: 
  # Stack Layout: gen_array
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  [SP-12]           4         4         
      i @ dot.c:69
  [SP-16]           4         4         
      size @ dot.c:62
  [SP-24]           8         8         
      res @ dot.c:65
  [SP-32]           8         8         
  
  
  remark: <unknown>:0:0: 
  # Stack Layout: caller
  Offset            Align     Size      
  [SP-8]      Spill 16        8         
  [SP-12]           4         4         
      ret @ dot.c:81
  [SP-16]           4         4         
  [SP-24]           8         8         
      res @ dot.c:80
  [SP-32]           8         8         
      B @ dot.c:79
  [SP-40]           8         8         
      A @ dot.c:78
  [SP-44]           4         4         
      err @ dot.c:83
  [SP-48]           4         4         
      size @ dot.c:77

Are there any thoughts about how to make this work more nicely w/ optimization 
remarks from Clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135488

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to