Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: lib/Transforms/NaCl/ExpandTls.cpp

Issue 1151093004: Changes from 3.7 merge to files not in upstream (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/Transforms/NaCl/ExpandTls.cpp
diff --git a/lib/Transforms/NaCl/ExpandTls.cpp b/lib/Transforms/NaCl/ExpandTls.cpp
index fc7db7c0ba1cba3e72e2b6e4624941b4e70f79f4..ada9a4aa6d2c464cb97611998c1f85e2164be3c5 100644
--- a/lib/Transforms/NaCl/ExpandTls.cpp
+++ b/lib/Transforms/NaCl/ExpandTls.cpp
@@ -116,7 +116,7 @@ static void addVarToTlsTemplate(PassState *State,
State->DL.getTypeAllocSize(TlsVar->getType()->getElementType());
}
-static PointerType *buildTlsTemplate(Module &M, std::vector<VarInfo> *TlsVars) {
+static StructType *buildTlsTemplate(Module &M, std::vector<VarInfo> *TlsVars) {
std::vector<Type*> FieldBssTypes;
std::vector<Type*> FieldInitTypes;
std::vector<Constant*> FieldInitValues;
@@ -203,11 +203,13 @@ static PointerType *buildTlsTemplate(Module &M, std::vector<VarInfo> *TlsVars) {
TemplateDataVar->setName(StartSymbol);
Constant *TdataEnd = ConstantExpr::getGetElementPtr(
+ InitTemplateType,
TemplateDataVar,
ConstantInt::get(M.getContext(), APInt(32, 1)));
setGlobalVariableValue(M, "__tls_template_tdata_end", TdataEnd);
Constant *TotalEnd = ConstantExpr::getGetElementPtr(
+ TemplateType,
ConstantExpr::getBitCast(TemplateDataVar, TemplatePtrType),
ConstantInt::get(M.getContext(), APInt(32, 1)));
setGlobalVariableValue(M, "__tls_template_end", TotalEnd);
@@ -221,11 +223,11 @@ static PointerType *buildTlsTemplate(Module &M, std::vector<VarInfo> *TlsVars) {
setGlobalVariableValue(M, AlignmentSymbol, AlignmentVar);
AlignmentVar->setName(AlignmentSymbol);
- return TemplatePtrType;
+ return TemplateType;
}
static void rewriteTlsVars(Module &M, std::vector<VarInfo> *TlsVars,
- PointerType *TemplatePtrType) {
+ StructType *TemplateType) {
// Set up the intrinsic that reads the thread pointer.
Function *ReadTpFunc = Intrinsic::getDeclaration(&M, Intrinsic::nacl_read_tp);
@@ -237,8 +239,8 @@ static void rewriteTlsVars(Module &M, std::vector<VarInfo> *TlsVars,
Use *U = &*Var->use_begin();
Instruction *InsertPt = PhiSafeInsertPt(U);
Value *RawThreadPtr = CallInst::Create(ReadTpFunc, "tls_raw", InsertPt);
- Value *TypedThreadPtr = new BitCastInst(RawThreadPtr, TemplatePtrType,
- "tls_struct", InsertPt);
+ Value *TypedThreadPtr = new BitCastInst(
+ RawThreadPtr, TemplateType->getPointerTo(), "tls_struct", InsertPt);
SmallVector<Value*, 3> Indexes;
// We use -1 because we use the x86-style TLS layout in which
// the TLS data is stored at addresses below the thread pointer.
@@ -254,8 +256,8 @@ static void rewriteTlsVars(Module &M, std::vector<VarInfo> *TlsVars,
M.getContext(), APInt(32, VarInfo->IsBss ? 1 : 0)));
Indexes.push_back(ConstantInt::get(
M.getContext(), APInt(32, VarInfo->TemplateIndex)));
- Value *TlsField = GetElementPtrInst::Create(TypedThreadPtr, Indexes,
- "field", InsertPt);
+ Value *TlsField = GetElementPtrInst::Create(
+ TemplateType, TypedThreadPtr, Indexes, "field", InsertPt);
PhiSafeReplaceUses(U, TlsField);
}
VarInfo->TlsVar->eraseFromParent();
@@ -321,8 +323,8 @@ bool ExpandTls::runOnModule(Module &M) {
delete Pass;
std::vector<VarInfo> TlsVars;
- PointerType *TemplatePtrType = buildTlsTemplate(M, &TlsVars);
- rewriteTlsVars(M, &TlsVars, TemplatePtrType);
+ StructType *TemplateType = buildTlsTemplate(M, &TlsVars);
+ rewriteTlsVars(M, &TlsVars, TemplateType);
defineTlsLayoutFunctions(M);

Powered by Google App Engine
This is Rietveld 408576698