1 //===- CoroInternal.h - Internal Coroutine interfaces ---------*- C++ -*---===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 // Common definitions/declarations used internally by coroutine lowering passes.
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
12 #define LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
14 #include "llvm/Analysis/TargetTransformInfo.h"
15 #include "llvm/IR/IRBuilder.h"
16 #include "llvm/Transforms/Coroutines/CoroInstr.h"
17 #include "llvm/Transforms/Coroutines/CoroShape.h"
25 bool isSuspendBlock(BasicBlock
*BB
);
26 bool declaresAnyIntrinsic(const Module
&M
);
27 bool declaresIntrinsics(const Module
&M
,
28 const std::initializer_list
<StringRef
>);
29 void replaceCoroFree(CoroIdInst
*CoroId
, bool Elide
);
31 /// Replaces all @llvm.coro.alloc intrinsics calls associated with a given
32 /// call @llvm.coro.id instruction with boolean value false.
33 void suppressCoroAllocs(CoroIdInst
*CoroId
);
34 /// Replaces CoroAllocs with boolean value false.
35 void suppressCoroAllocs(LLVMContext
&Context
,
36 ArrayRef
<CoroAllocInst
*> CoroAllocs
);
38 /// Attempts to rewrite the location operand of debug intrinsics in terms of
39 /// the coroutine frame pointer, folding pointer offsets into the DIExpression
41 /// If the frame pointer is an Argument, store it into an alloca to enhance the
43 void salvageDebugInfo(
44 SmallDenseMap
<Argument
*, AllocaInst
*, 4> &ArgToAllocaMap
,
45 DbgVariableIntrinsic
&DVI
, bool IsEntryPoint
);
46 void salvageDebugInfo(
47 SmallDenseMap
<Argument
*, AllocaInst
*, 4> &ArgToAllocaMap
,
48 DbgVariableRecord
&DVR
, bool UseEntryValue
);
50 // Keeps data and helper functions for lowering coroutine intrinsics.
54 PointerType
*const Int8Ptr
;
55 FunctionType
*const ResumeFnType
;
56 ConstantPointerNull
*const NullPtr
;
58 LowererBase(Module
&M
);
59 CallInst
*makeSubFnCall(Value
*Arg
, int Index
, Instruction
*InsertPt
);
62 bool defaultMaterializable(Instruction
&V
);
63 void normalizeCoroutine(Function
&F
, coro::Shape
&Shape
,
64 TargetTransformInfo
&TTI
);
65 CallInst
*createMustTailCall(DebugLoc Loc
, Function
*MustTailCallFn
,
66 TargetTransformInfo
&TTI
,
67 ArrayRef
<Value
*> Arguments
, IRBuilder
<> &);
68 } // End namespace coro.
69 } // End namespace llvm