[PATCH] D157616: [ExtendLifetimes][2/4] Implement fake.use intrinsic in LLVM to extend the lifetime of operands

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 06:50:09 PDT 2023


StephenTozer created this revision.
StephenTozer added reviewers: dblaikie, aprantl, echristo.
StephenTozer added a project: debug-info.
Herald added subscribers: jdoerfert, pengfei, javed.absar, hiraditya, MatzeB.
Herald added a project: All.
StephenTozer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is part of a set of patches that add an `-fextend-lifetimes` flag to clang, which extends the lifetimes of local variables and parameters for improved debuggability. In addition to that flag, the patch series adds a new function attribute to disable the post-RA scheduler (which is applied by `-fextend-lifetimes`), a pragma to selectively disable `-fextend-lifetimes`, and an `-fextend-this-ptr` flag which functions as `-fextend-lifetimes` for `this` pointers only. All changes and tests in these patches were written by @wolfgangp, though I will be managing these reviews and addressing any comments raised. Discussion on the approach of this patch series as a whole should be directed to the 3rd patch, D157613 <https://reviews.llvm.org/D157613>, in order to simplify review.

---

This particular patch implements a new intrinsic instruction in LLVM, `llvm.fake.use` in IR and `FAKE_USE` in MIR, that takes a single operand and has no effect other than "using" its operand, to ensure that its operand remains live until after the fake use. This patch does not emit fake uses anywhere; the next patch in this sequence causes them to be emitted from the clang frontend, such that for each variable (or `this`) a fake.use operand is inserted at the end of that variable's scope, using that variable's value. This patch covers everything post-frontend, which is largely just the basic plumbing for a new intrinsic/instruction, along with a few steps to preserve the fake uses through optimizations (such as moving them ahead of a tail call).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157616

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/PtrUseVisitor.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/Analysis.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
  llvm/lib/CodeGen/MachineCSE.cpp
  llvm/lib/CodeGen/MachineScheduler.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/X86/X86FloatingPoint.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/CloneFunction.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
  llvm/test/CodeGen/Generic/fake-use-constprop.ll
  llvm/test/CodeGen/Generic/fake-use-tailcall.ll
  llvm/test/CodeGen/MIR/X86/fake-use-phi.mir
  llvm/test/CodeGen/MIR/X86/fake-use-scheduler.mir
  llvm/test/CodeGen/MIR/X86/fake-use-tailcall.mir
  llvm/test/CodeGen/MIR/X86/fake-use-zero-length.mir
  llvm/test/CodeGen/X86/fake-use-escape.ll
  llvm/test/CodeGen/X86/fake-use-hpfloat.ll
  llvm/test/CodeGen/X86/fake-use-ld.ll
  llvm/test/CodeGen/X86/fake-use-simple-tail-call.ll
  llvm/test/CodeGen/X86/fake-use-split-ret.ll
  llvm/test/CodeGen/X86/fake-use-sroa.ll
  llvm/test/CodeGen/X86/fake-use-suppress-load.ll
  llvm/test/CodeGen/X86/fake-use-vector.ll
  llvm/test/CodeGen/X86/fake-use-vector2.ll
  llvm/test/DebugInfo/X86/Inputs/check-fake-use.py
  llvm/test/DebugInfo/X86/fake-use.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157616.549015.patch
Type: text/x-patch
Size: 75475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/f9324757/attachment-0001.bin>


More information about the llvm-commits mailing list