|
|
|||
File indexing completed on 2026-05-10 08:44:42
0001 //===- PlaceSafepoints.h - Place GC Safepoints ----------------------------===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // Place garbage collection safepoints at appropriate locations in the IR. This 0010 // does not make relocation semantics or variable liveness explicit. That's 0011 // done by RewriteStatepointsForGC. 0012 // 0013 // Terminology: 0014 // - A call is said to be "parseable" if there is a stack map generated for the 0015 // return PC of the call. A runtime can determine where values listed in the 0016 // deopt arguments and (after RewriteStatepointsForGC) gc arguments are located 0017 // on the stack when the code is suspended inside such a call. Every parse 0018 // point is represented by a call wrapped in an gc.statepoint intrinsic. 0019 // - A "poll" is an explicit check in the generated code to determine if the 0020 // runtime needs the generated code to cooperate by calling a helper routine 0021 // and thus suspending its execution at a known state. The call to the helper 0022 // routine will be parseable. The (gc & runtime specific) logic of a poll is 0023 // assumed to be provided in a function of the name "gc.safepoint_poll". 0024 // 0025 // We aim to insert polls such that running code can quickly be brought to a 0026 // well defined state for inspection by the collector. In the current 0027 // implementation, this is done via the insertion of poll sites at method entry 0028 // and the backedge of most loops. We try to avoid inserting more polls than 0029 // are necessary to ensure a finite period between poll sites. This is not 0030 // because the poll itself is expensive in the generated code; it's not. Polls 0031 // do tend to impact the optimizer itself in negative ways; we'd like to avoid 0032 // perturbing the optimization of the method as much as we can. 0033 // 0034 // We also need to make most call sites parseable. The callee might execute a 0035 // poll (or otherwise be inspected by the GC). If so, the entire stack 0036 // (including the suspended frame of the current method) must be parseable. 0037 // 0038 // This pass will insert: 0039 // - Call parse points ("call safepoints") for any call which may need to 0040 // reach a safepoint during the execution of the callee function. 0041 // - Backedge safepoint polls and entry safepoint polls to ensure that 0042 // executing code reaches a safepoint poll in a finite amount of time. 0043 // 0044 // We do not currently support return statepoints, but adding them would not 0045 // be hard. They are not required for correctness - entry safepoints are an 0046 // alternative - but some GCs may prefer them. Patches welcome. 0047 // 0048 //===----------------------------------------------------------------------===// 0049 0050 #ifndef LLVM_TRANSFORMS_SCALAR_PLACESAFEPOINTS_H 0051 #define LLVM_TRANSFORMS_SCALAR_PLACESAFEPOINTS_H 0052 0053 #include "llvm/IR/PassManager.h" 0054 0055 namespace llvm { 0056 0057 class TargetLibraryInfo; 0058 0059 class PlaceSafepointsPass : public PassInfoMixin<PlaceSafepointsPass> { 0060 public: 0061 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 0062 0063 bool runImpl(Function &F, const TargetLibraryInfo &TLI); 0064 0065 void cleanup() {} 0066 0067 private: 0068 }; 0069 } // namespace llvm 0070 0071 #endif // LLVM_TRANSFORMS_SCALAR_PLACESAFEPOINTS_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|