27 #define DEBUG_TYPE "loweremutls" 38 bool runOnModule(
Module &M)
override;
41 static void copyLinkageVisibility(
Module &M,
57 "Add __emutls_[vt]. variables for emultated TLS model",
false,
62 bool LowerEmuTLS::runOnModule(
Module &M) {
66 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
71 if (!
TM.useEmulatedTLS())
77 if (
G.isThreadLocal())
80 for (
const auto G : TlsVars)
81 Changed |= addEmuTlsVar(M,
G);
89 std::string EmuTlsVarName = (
"__emutls_v." + GV->
getName()).str();
104 if (isa<ConstantAggregateZero>(InitValue) ||
105 (InitIntValue && InitIntValue->
isZero()))
118 Type *ElementTypes[4] = {WordType, WordType, VoidPtrType, InitPtrType};
121 EmuTlsVar = cast<GlobalVariable>(
123 copyLinkageVisibility(M, GV, EmuTlsVar);
140 std::string EmuTlsTmplName = (
"__emutls_t." + GV->
getName()).str();
141 EmuTlsTmplVar = dyn_cast_or_null<GlobalVariable>(
143 assert(EmuTlsTmplVar &&
"Failed to create emualted TLS initializer");
147 copyLinkageVisibility(M, GV, EmuTlsTmplVar);
154 NullPtr, EmuTlsTmplVar ? EmuTlsTmplVar : NullPtr
void setVisibility(VisibilityTypes V)
unsigned getAlignment() const
A parsed version of the target data layout string in and methods for querying it. ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
void initializeLowerEmuTLSPass(PassRegistry &)
void setAlignment(unsigned Align)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
Type * getType() const
All values are typed, get the type of this value.
void setComdat(Comdat *C)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LinkageTypes getLinkage() const
Class to represent pointers.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
VisibilityTypes getVisibility() const
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
This is an important base class in LLVM.
static Constant * get(StructType *T, ArrayRef< Constant *> V)
Class to represent integer types.
void setConstant(bool Val)
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
ModulePass * createLowerEmuTLSPass()
LowerEmuTLS - This pass generates __emutls_[vt].xyz variables for all TLS variables for the emulated ...
INITIALIZE_PASS(LowerEmuTLS, DEBUG_TYPE, "Add __emutls_[vt]. variables for emultated TLS model", false, false) ModulePass *llvm
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
void setSelectionKind(SelectionKind Val)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void setLinkage(LinkageTypes LT)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
const Comdat * getComdat() const
Constant * getOrInsertGlobal(StringRef Name, Type *Ty, function_ref< GlobalVariable *()> CreateGlobalCallback)
Look up the specified global in the module symbol table.
StringRef getName() const
Return a constant reference to the value's name.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
bool hasInitializer() const
Definitions have initializers, declarations don't.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Primary interface to the complete machine description for the target machine.
iterator_range< global_iterator > globals()
This file describes how to lower LLVM code to machine code.
SelectionKind getSelectionKind() const