llvm-project/llvm/test/Transforms/CodeGenPrepare
Guozhi Wei 6d20937c29 [CodeGenPrepare] Delete intrinsic call to llvm.assume to enable more tailcall
The attached test case is simplified from tcmalloc. Both function calls should be optimized as tailcall. But llvm can only optimize the first call. The second call can't be optimized because function dupRetToEnableTailCallOpts failed to duplicate ret into block case2.

There 2 problems blocked the duplication:

  1 Intrinsic call llvm.assume is not handled by dupRetToEnableTailCallOpts.
  2 The control flow is more complex than expected, dupRetToEnableTailCallOpts can only duplicate ret into its predecessor, but here we have an intermediate block between call and ret.

The solutions:

  1 Since CodeGenPrepare is already at the end of LLVM IR phase, we can simply delete the intrinsic call to llvm.assume.
  2 A general solution to the complex control flow is hard, but for this case, after exit2 is duplicated into case1, exit2 is the only successor of exit1 and exit1 is the only predecessor of exit2, so they can be combined through eliminateFallThrough. But this function is called too late, there is no more dupRetToEnableTailCallOpts after it. We can add an earlier call to eliminateFallThrough to solve it.

Differential Revision: https://reviews.llvm.org/D76539
2020-03-31 11:55:51 -07:00
..
AArch64 Recommit "[PatternMatch] Match XOR variant of unsigned-add overflow check." 2020-02-23 18:33:18 +00:00
AMDGPU [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
ARM Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
Mips Revert "Temporarily Revert "Add basic loop fusion pass."" 2019-04-17 04:52:47 +00:00
NVPTX Revert "Temporarily Revert "Add basic loop fusion pass."" 2019-04-17 04:52:47 +00:00
PowerPC [CodeGen] Fix the computation of the alignment of split stores. 2020-02-12 10:37:30 +01:00
SPARC [TargetLower] Update shouldFormOverflowOp check if math is used. 2020-02-19 11:28:33 +01:00
X86 [CodeGenPrepare] Delete intrinsic call to llvm.assume to enable more tailcall 2020-03-31 11:55:51 -07:00
dom-tree.ll [CodeGenPrepare][test] Add REQUIRES to two tests after D73754 2020-02-02 09:53:17 -08:00
sink-shift-and-trunc.ll [CodeGenPrepare] Fix use-after-free 2019-08-16 23:10:34 +00:00
skip-merging-case-block.ll [CodeGenPrepare][test] Add REQUIRES to two tests after D73754 2020-02-02 09:53:17 -08:00