[PATCH] D79258: [AutoFDO] Handling must tail calls in indirect call promotion

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 17:16:50 PDT 2020


hoyFB created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
hoyFB edited the summary of this revision.
hoyFB edited the summary of this revision.
hoyFB added reviewers: wenlei, davidxl.

Per the IR convention, a musttail call must precede a ret with an optional bitcast. This was violated by the indirect call promotion optimization which could result an IR like:

  ; <label>:2192:
    br i1 %2198, label %2199, label %2201, !dbg !226012, !prof !229483
  
  ; <label>:2199:                                   ; preds = %2192
    musttail call fastcc void @foo(i8* %2195), !dbg !226012
    br label %2202, !dbg !226012
  
  ; <label>:2201:                                   ; preds = %2192
    musttail call fastcc void %2197(i8* %2195), !dbg !226012
    br label %2202, !dbg !226012
  
  ; <label>:2202:                                   ; preds = %605, %2201, %2199
    ret void, !dbg !229485

This is being fixed in this change where the return statement goes together with the promoted indirect call. The code generated is like:

  ; <label>:2192:
    br i1 %2198, label %2199, label %2201, !dbg !226012, !prof !229483
  
  ; <label>:2199:                                   ; preds = %2192
    musttail call fastcc void @foo(i8* %2195), !dbg !226012
    ret void, !dbg !229485
  
  ; <label>:2201:                                   ; preds = %2192
    musttail call fastcc void %2197(i8* %2195), !dbg !226012
    ret void, !dbg !229485


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79258

Files:
  llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
  llvm/test/Transforms/PGOProfile/indirect_call_promotion_musttail.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79258.261521.patch
Type: text/x-patch
Size: 6716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/b2da9cb4/attachment-0001.bin>


More information about the llvm-commits mailing list