[PATCH] D147704: [Inliner] Preserve nonnull from callsites during inlining

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 05:09:24 PDT 2023


xbolva00 created this revision.
Herald added subscribers: ChuanqiXu, haicheng, hiraditya.
Herald added a project: All.
xbolva00 requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

Inliner fails to simplify inlined function based on known callsite attributes

  declare void @h(ptr %p)
  
  define void @f(ptr %p) {
  	call void @g(ptr nonnull %p)
  	ret void
  }
  
  define void @g(ptr %p) {
  	call void @h(ptr %p)
  	ret void
  }

Inliner inlines g into f but we lose extra info that %p was nonnull ptr. Implemented suggested solution, so insert nonnull assumes in Inliner to preserve knowledge.

Fixes https://github.com/llvm/llvm-project/issues/61966#issuecomment-1498360707


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147704

Files:
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Coroutines/ex0.ll
  llvm/test/Transforms/Coroutines/ex1.ll
  llvm/test/Transforms/Coroutines/ex5.ll
  llvm/test/Transforms/FunctionSpecialization/function-specialization-recursive.ll
  llvm/test/Transforms/Inline/assumptions-from-callsite-attrs.ll
  llvm/test/Transforms/Inline/cgscc-cycle.ll
  llvm/test/Transforms/Inline/noalias-calls2.ll
  llvm/test/Transforms/Inline/nonnull.ll
  llvm/test/Transforms/PhaseOrdering/X86/hoist-load-of-baseptr.ll
  llvm/test/Transforms/PhaseOrdering/dae-dce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147704.511376.patch
Type: text/x-patch
Size: 41239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230406/7721b6b8/attachment.bin>


More information about the llvm-commits mailing list