Go to the documentation of this file.
27 #define DEBUG_TYPE "loweremutls"
38 bool runOnModule(
Module &
M)
override;
41 static void copyLinkageVisibility(
Module &
M,
48 to->setComdat(
M.getOrInsertComdat(
to->getName()));
58 "Add __emutls_[vt]. variables for emultated TLS model",
false,
63 bool LowerEmuTLS::runOnModule(
Module &M) {
67 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
72 if (!
TM.useEmulatedTLS())
77 for (
const auto &
G :
M.globals()) {
78 if (
G.isThreadLocal())
81 for (
const auto G : TlsVars)
82 Changed |= addEmuTlsVar(M,
G);
90 std::string EmuTlsVarName = (
"__emutls_v." + GV->
getName()).str();
102 const ConstantInt *InitIntValue = dyn_cast<ConstantInt>(InitValue);
105 if (isa<ConstantAggregateZero>(InitValue) ||
106 (InitIntValue && InitIntValue->
isZero()))
118 PointerType::getUnqual(InitValue->
getType()) : VoidPtrType;
119 Type *ElementTypes[4] = {WordType, WordType, VoidPtrType, InitPtrType};
121 StructType *EmuTlsVarType = StructType::create(ElementTypeArray);
122 EmuTlsVar = cast<GlobalVariable>(
123 M.getOrInsertGlobal(EmuTlsVarName, EmuTlsVarType));
124 copyLinkageVisibility(
M, GV, EmuTlsVar);
131 Align GVAlignment =
DL.getValueOrABITypeAlignment(GV->
getAlign(), GVType);
136 std::string EmuTlsTmplName = (
"__emutls_t." + GV->
getName()).str();
137 EmuTlsTmplVar = dyn_cast_or_null<GlobalVariable>(
138 M.getOrInsertGlobal(EmuTlsTmplName, GVType));
139 assert(EmuTlsTmplVar &&
"Failed to create emualted TLS initializer");
143 copyLinkageVisibility(
M, GV, EmuTlsTmplVar);
150 EmuTlsTmplVar ? EmuTlsTmplVar : NullPtr};
155 std::max(
DL.getABITypeAlign(WordType),
DL.getABITypeAlign(VoidPtrType));
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void setConstant(bool Val)
LinkageTypes getLinkage() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
The instances of the Type class are immutable: once they are created, they are never changed.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
bool hasInitializer() const
Definitions have initializers, declarations don't.
This is the shared class of boolean and integer constants.
ModulePass * createLowerEmuTLSPass()
LowerEmuTLS - This pass generates __emutls_[vt].xyz variables for all TLS variables for the emulated ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
(vector float) vec_cmpeq(*A, *B) C
const Comdat * getComdat() const
Class to represent integer types.
void initializeLowerEmuTLSPass(PassRegistry &)
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
VisibilityTypes getVisibility() const
This is an important class for using LLVM in a threaded context.
Class to represent pointers.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
A Module instance is used to store all the information related to an LLVM module.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent struct types.
Type * getType() const
All values are typed, get the type of this value.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
INITIALIZE_PASS(LowerEmuTLS, DEBUG_TYPE, "Add __emutls_[vt]. variables for emultated TLS model", false, false) ModulePass *llvm
StringRef getName() const
Return a constant reference to the value's name.
Should compile to something r4 addze r3 instead we get
uint64_t value() const
This is a hole in the type system and should not be abused.
Type * getValueType() const
const char LLVMTargetMachineRef TM
void setAlignment(MaybeAlign Align)
SelectionKind getSelectionKind() const
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...