Skip to content

Commit 40d9cd8

Browse files
committed
[NFC] Give IRGenModule Exclusive Ownership of an LLVMContext Object
1 parent 9dcd2b5 commit 40d9cd8

15 files changed

+60
-53
lines changed

lib/IRGen/GenArchetype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ withOpaqueTypeGenericArgs(IRGenFunction &IGF,
435435
}
436436
types.push_back(args.back()->getType());
437437
});
438-
auto bufTy = llvm::StructType::get(IGF.IGM.LLVMContext, types);
438+
auto bufTy = llvm::StructType::get(IGF.IGM.getLLVMContext(), types);
439439
alloca = IGF.createAlloca(bufTy, IGF.IGM.getPointerAlignment());
440440
allocaSize = IGF.IGM.getPointerSize() * args.size();
441441
IGF.Builder.CreateLifetimeStart(alloca, allocaSize);

lib/IRGen/GenBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ if (Builtin.ID == BuiltinValueKind::id) { \
657657
// If the type is floating-point, then we need to bitcast to integer.
658658
auto valueTy = origValueTy;
659659
if (valueTy->isFloatingPointTy()) {
660-
valueTy = llvm::IntegerType::get(IGF.IGM.LLVMContext,
660+
valueTy = llvm::IntegerType::get(IGF.IGM.getLLVMContext(),
661661
valueTy->getPrimitiveSizeInBits());
662662
}
663663

lib/IRGen/GenCall.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void addDereferenceableAttributeToBuilder(IRGenModule &IGM,
100100
// dynamic-layout aggregates.
101101
if (auto fixedTI = dyn_cast<FixedTypeInfo>(&ti)) {
102102
b.addAttribute(
103-
llvm::Attribute::getWithDereferenceableBytes(IGM.LLVMContext,
103+
llvm::Attribute::getWithDereferenceableBytes(IGM.getLLVMContext(),
104104
fixedTI->getFixedSize().getValue()));
105105
}
106106
}
@@ -116,7 +116,7 @@ static void addIndirectValueParameterAttributes(IRGenModule &IGM,
116116
// The parameter must reference dereferenceable memory of the type.
117117
addDereferenceableAttributeToBuilder(IGM, b, ti);
118118

119-
attrs = attrs.addAttributes(IGM.LLVMContext,
119+
attrs = attrs.addAttributes(IGM.getLLVMContext(),
120120
argIndex + llvm::AttributeList::FirstArgIndex, b);
121121
}
122122

@@ -132,7 +132,7 @@ static void addInoutParameterAttributes(IRGenModule &IGM,
132132
// The inout must reference dereferenceable memory of the type.
133133
addDereferenceableAttributeToBuilder(IGM, b, ti);
134134

135-
attrs = attrs.addAttributes(IGM.LLVMContext,
135+
attrs = attrs.addAttributes(IGM.getLLVMContext(),
136136
argIndex + llvm::AttributeList::FirstArgIndex, b);
137137
}
138138

@@ -169,7 +169,7 @@ static void addIndirectResultAttributes(IRGenModule &IGM,
169169
b.addAttribute(llvm::Attribute::NoCapture);
170170
if (allowSRet)
171171
b.addAttribute(llvm::Attribute::StructRet);
172-
attrs = attrs.addAttributes(IGM.LLVMContext,
172+
attrs = attrs.addAttributes(IGM.getLLVMContext(),
173173
paramIndex + llvm::AttributeList::FirstArgIndex,
174174
b);
175175
}
@@ -178,7 +178,7 @@ void IRGenModule::addSwiftSelfAttributes(llvm::AttributeList &attrs,
178178
unsigned argIndex) {
179179
llvm::AttrBuilder b;
180180
b.addAttribute(llvm::Attribute::SwiftSelf);
181-
attrs = attrs.addAttributes(this->LLVMContext,
181+
attrs = attrs.addAttributes(this->getLLVMContext(),
182182
argIndex + llvm::AttributeList::FirstArgIndex, b);
183183
}
184184

@@ -199,7 +199,7 @@ void IRGenModule::addSwiftErrorAttributes(llvm::AttributeList &attrs,
199199
b.addDereferenceableAttr(getPointerSize().getValue());
200200

201201
auto attrIndex = argIndex + llvm::AttributeList::FirstArgIndex;
202-
attrs = attrs.addAttributes(this->LLVMContext, attrIndex, b);
202+
attrs = attrs.addAttributes(this->getLLVMContext(), attrIndex, b);
203203
}
204204

205205
void irgen::addByvalArgumentAttributes(IRGenModule &IGM,
@@ -208,8 +208,8 @@ void irgen::addByvalArgumentAttributes(IRGenModule &IGM,
208208
llvm::AttrBuilder b;
209209
b.addAttribute(llvm::Attribute::ByVal);
210210
b.addAttribute(llvm::Attribute::getWithAlignment(
211-
IGM.LLVMContext, llvm::Align(align.getValue())));
212-
attrs = attrs.addAttributes(IGM.LLVMContext,
211+
IGM.getLLVMContext(), llvm::Align(align.getValue())));
212+
attrs = attrs.addAttributes(IGM.getLLVMContext(),
213213
argIndex + llvm::AttributeList::FirstArgIndex, b);
214214
}
215215

@@ -220,7 +220,7 @@ void irgen::addExtendAttribute(IRGenModule &IGM, llvm::AttributeList &attrs,
220220
b.addAttribute(llvm::Attribute::SExt);
221221
else
222222
b.addAttribute(llvm::Attribute::ZExt);
223-
attrs = attrs.addAttributes(IGM.LLVMContext, index, b);
223+
attrs = attrs.addAttributes(IGM.getLLVMContext(), index, b);
224224
}
225225

226226
namespace swift {
@@ -2841,7 +2841,7 @@ void CallEmission::setArgs(Explosion &original, bool isOutlined,
28412841
void CallEmission::addAttribute(unsigned index,
28422842
llvm::Attribute::AttrKind attr) {
28432843
auto &attrs = CurCallee.getMutableAttributes();
2844-
attrs = attrs.addAttribute(IGF.IGM.LLVMContext, index, attr);
2844+
attrs = attrs.addAttribute(IGF.IGM.getLLVMContext(), index, attr);
28452845
}
28462846

28472847
/// Initialize an Explosion with the parameters of the current

lib/IRGen/GenConstant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ llvm::Constant *irgen::emitConstantInt(IRGenModule &IGM,
5353
assert(width.isFixedWidth() && "impossible width value");
5454
}
5555

56-
return llvm::ConstantInt::get(IGM.LLVMContext, value);
56+
return llvm::ConstantInt::get(IGM.getLLVMContext(), value);
5757
}
5858

5959
llvm::Constant *irgen::emitConstantFP(IRGenModule &IGM, FloatLiteralInst *FLI) {
60-
return llvm::ConstantFP::get(IGM.LLVMContext, FLI->getValue());
60+
return llvm::ConstantFP::get(IGM.getLLVMContext(), FLI->getValue());
6161
}
6262

6363
llvm::Constant *irgen::emitAddrOfConstantString(IRGenModule &IGM,

lib/IRGen/GenCoverage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void IRGenModule::emitCoverageMapping() {
8080
size_t CurrentSize, PrevSize = FilenamesSize;
8181

8282
// Now we need to build up the list of function records.
83-
llvm::LLVMContext &Ctx = LLVMContext;
83+
llvm::LLVMContext &Ctx = getLLVMContext();
8484
auto *Int32Ty = llvm::Type::getInt32Ty(Ctx);
8585

8686
llvm::Type *FunctionRecordTypes[] = {

lib/IRGen/GenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4440,7 +4440,7 @@ llvm::Constant *IRGenModule::getAddrOfGlobalUTF16String(StringRef utf8) {
44404440
*toPtr = 0;
44414441
ArrayRef<llvm::UTF16> utf16(&buffer[0], utf16Length + 1);
44424442

4443-
auto init = llvm::ConstantDataArray::get(LLVMContext, utf16);
4443+
auto init = llvm::ConstantDataArray::get(getLLVMContext(), utf16);
44444444
auto global = new llvm::GlobalVariable(Module, init->getType(), true,
44454445
llvm::GlobalValue::PrivateLinkage,
44464446
init);

lib/IRGen/GenFunc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ void irgen::emitBlockHeader(IRGenFunction &IGF,
18091809

18101810
const clang::ASTContext &ASTContext = IGF.IGM.getClangASTContext();
18111811
llvm::IntegerType *UnsignedLongTy =
1812-
llvm::IntegerType::get(IGF.IGM.LLVMContext,
1812+
llvm::IntegerType::get(IGF.IGM.getLLVMContext(),
18131813
ASTContext.getTypeSize(ASTContext.UnsignedLongTy));
18141814
descriptorFields.addInt(UnsignedLongTy, 0);
18151815
descriptorFields.addInt(UnsignedLongTy,

lib/IRGen/GenHeap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,8 +1239,8 @@ llvm::Constant *IRGenModule::getFixLifetimeFn() {
12391239
llvm::Attribute::NoInline);
12401240

12411241
// Give the function an empty body.
1242-
auto entry = llvm::BasicBlock::Create(LLVMContext, "", fixLifetime);
1243-
llvm::ReturnInst::Create(LLVMContext, entry);
1242+
auto entry = llvm::BasicBlock::Create(getLLVMContext(), "", fixLifetime);
1243+
llvm::ReturnInst::Create(getLLVMContext(), entry);
12441244

12451245
FixLifetimeFn = fixLifetime;
12461246
return fixLifetime;

lib/IRGen/GenIntegerLiteral.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class IntegerLiteralTypeInfo :
127127
llvm::StructType *IRGenModule::getIntegerLiteralTy() {
128128
if (!IntegerLiteralTy) {
129129
IntegerLiteralTy =
130-
llvm::StructType::create(LLVMContext, {
130+
llvm::StructType::create(getLLVMContext(), {
131131
SizeTy->getPointerTo(),
132132
SizeTy
133133
}, "swift.int_literal");

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3430,7 +3430,7 @@ void IRGenFunction::setInvariantLoad(llvm::LoadInst *load) {
34303430
void IRGenFunction::setDereferenceableLoad(llvm::LoadInst *load,
34313431
unsigned size) {
34323432
auto sizeConstant = llvm::ConstantInt::get(IGM.Int64Ty, size);
3433-
auto sizeNode = llvm::MDNode::get(IGM.LLVMContext,
3433+
auto sizeNode = llvm::MDNode::get(IGM.getLLVMContext(),
34343434
llvm::ConstantAsMetadata::get(sizeConstant));
34353435
load->setMetadata(IGM.DereferenceableID, sizeNode);
34363436
}

0 commit comments

Comments
 (0)