Skip to content

Commit 5d3ded9

Browse files
committed
Remove legacy LL[Maybe]Align
1 parent f6702cf commit 5d3ded9

File tree

15 files changed

+29
-32
lines changed

15 files changed

+29
-32
lines changed

gen/abi/x86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ struct X86TargetABI : TargetABI {
266266
#else
267267
// Keep alignment for LLVM 13+, to prevent invalid `movaps` etc.,
268268
// but limit to 4 (required according to runnable/ldc_cabi1.d).
269-
auto align4 = LLAlign(4);
269+
auto align4 = llvm::Align(4);
270270
if (arg->attrs.getAlignment().
271271
#if LDC_LLVM_VER >= 1500
272272
value_or

gen/coverage.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ void emitCoverageLinecountInc(const Loc &loc) {
4444
// Do an atomic increment, so this works when multiple threads are executed.
4545
gIR->ir->CreateAtomicRMW(llvm::AtomicRMWInst::Add, ptr, DtoConstUint(1),
4646
#if LDC_LLVM_VER >= 1300
47-
LLAlign(4),
47+
llvm::Align(4),
4848
#endif
4949
llvm::AtomicOrdering::Monotonic);
5050
break;
5151
case opts::CoverageIncrement::nonatomic: {
5252
// Do a non-atomic increment, user is responsible for correct results with
5353
// multithreaded execution
54-
llvm::LoadInst *load = gIR->ir->CreateAlignedLoad(i32Type, ptr, LLAlign(4));
54+
llvm::LoadInst *load =
55+
gIR->ir->CreateAlignedLoad(i32Type, ptr, llvm::Align(4));
5556
llvm::StoreInst *store = gIR->ir->CreateAlignedStore(
56-
gIR->ir->CreateAdd(load, DtoConstUint(1)), ptr, LLAlign(4));
57+
gIR->ir->CreateAdd(load, DtoConstUint(1)), ptr, llvm::Align(4));
5758
// add !nontemporal attribute, to inform the optimizer that caching is not
5859
// needed
5960
llvm::MDNode *node = llvm::MDNode::get(
@@ -66,7 +67,7 @@ void emitCoverageLinecountInc(const Loc &loc) {
6667
// Do a boolean set, avoiding a memory read (blocking) and threading issues
6768
// at the cost of not "counting"
6869
llvm::StoreInst *store =
69-
gIR->ir->CreateAlignedStore(DtoConstUint(1), ptr, LLAlign(4));
70+
gIR->ir->CreateAlignedStore(DtoConstUint(1), ptr, llvm::Align(4));
7071
// add !nontemporal attribute, to inform the optimizer that caching is not
7172
// needed
7273
llvm::MDNode *node = llvm::MDNode::get(

gen/dvalue.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ DBitFieldLValue::DBitFieldLValue(Type *t, LLValue *ptr, BitFieldDeclaration *bf)
180180
DRValue *DBitFieldLValue::getRVal() {
181181
const auto sizeInBits = intType->getBitWidth();
182182
const auto ptr = DtoBitCast(val, getPtrToType(intType));
183-
LLValue *v = gIR->ir->CreateAlignedLoad(intType, ptr, LLMaybeAlign(1));
183+
LLValue *v = gIR->ir->CreateAlignedLoad(intType, ptr, llvm::MaybeAlign(1));
184184

185185
if (bf->type->isunsigned()) {
186186
if (auto n = bf->bitOffset)
@@ -208,7 +208,8 @@ void DBitFieldLValue::store(LLValue *value) {
208208

209209
const auto mask =
210210
llvm::APInt::getLowBitsSet(intType->getBitWidth(), bf->fieldWidth);
211-
const auto oldVal = gIR->ir->CreateAlignedLoad(intType, ptr, LLMaybeAlign(1));
211+
const auto oldVal =
212+
gIR->ir->CreateAlignedLoad(intType, ptr, llvm::MaybeAlign(1));
212213
const auto maskedOldVal =
213214
gIR->ir->CreateAnd(oldVal, ~(mask << bf->bitOffset));
214215

@@ -218,7 +219,7 @@ void DBitFieldLValue::store(LLValue *value) {
218219
bfVal = gIR->ir->CreateShl(bfVal, n);
219220

220221
const auto newVal = gIR->ir->CreateOr(maskedOldVal, bfVal);
221-
gIR->ir->CreateAlignedStore(newVal, ptr, LLMaybeAlign(1));
222+
gIR->ir->CreateAlignedStore(newVal, ptr, llvm::MaybeAlign(1));
222223
}
223224

224225
DDcomputeLValue::DDcomputeLValue(Type *t, llvm::Type * llt, LLValue *v) : DLValue(t, v) {

gen/irstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ IRState::setGlobalVarInitializer(LLGlobalVariable *&globalVar,
147147
module, initializer->getType(), globalVar->isConstant(),
148148
globalVar->getLinkage(), nullptr, "", nullptr,
149149
globalVar->getThreadLocalMode());
150-
globalHelperVar->setAlignment(LLMaybeAlign(globalVar->getAlignment()));
150+
globalHelperVar->setAlignment(llvm::MaybeAlign(globalVar->getAlignment()));
151151
globalHelperVar->setComdat(globalVar->getComdat());
152152
globalHelperVar->setDLLStorageClass(globalVar->getDLLStorageClass());
153153
globalHelperVar->setSection(globalVar->getSection());

gen/llvm.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ using llvm::APFloat;
3535
using llvm::APInt;
3636
using llvm::IRBuilder;
3737

38-
#define LLAlign llvm::Align
39-
#define LLMaybeAlign llvm::MaybeAlign
40-
4138
#define GET_INTRINSIC_DECL(_X) \
4239
(llvm::Intrinsic::getDeclaration(&gIR->module, llvm::Intrinsic::_X))
4340

gen/llvmhelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ llvm::AllocaInst *DtoArrayAlloca(Type *type, unsigned arraysize,
191191
lltype, gIR->module.getDataLayout().getAllocaAddrSpace(),
192192
DtoConstUint(arraysize), name, gIR->topallocapoint());
193193
if (auto alignment = DtoAlignment(type)) {
194-
ai->setAlignment(LLAlign(alignment));
194+
ai->setAlignment(llvm::Align(alignment));
195195
}
196196
return ai;
197197
}
@@ -202,7 +202,7 @@ llvm::AllocaInst *DtoRawAlloca(LLType *lltype, size_t alignment,
202202
lltype, gIR->module.getDataLayout().getAllocaAddrSpace(), name,
203203
gIR->topallocapoint());
204204
if (alignment) {
205-
ai->setAlignment(LLAlign(alignment));
205+
ai->setAlignment(llvm::Align(alignment));
206206
}
207207
return ai;
208208
}

gen/passes/SimplifyDRuntimeCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
6060
/// expects that the size has type 'intptr_t' and Dst/Src are pointers.
6161
Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
6262
unsigned Align, IRBuilder<> &B) {
63-
auto A = LLMaybeAlign(Align);
63+
auto A = llvm::MaybeAlign(Align);
6464
return B.CreateMemCpy(CastToCStr(Dst, B), A, CastToCStr(Src, B), A, Len,
6565
false);
6666
}

gen/rttibuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void RTTIBuilder::push_void_array(llvm::Constant *CI, Type *valtype,
8686
auto G = new LLGlobalVariable(gIR->module, CI->getType(), true, lwc.first, CI,
8787
initname.peekChars());
8888
setLinkage(lwc, G);
89-
G->setAlignment(LLMaybeAlign(DtoAlignment(valtype)));
89+
G->setAlignment(llvm::MaybeAlign(DtoAlignment(valtype)));
9090

9191
push_void_array(getTypeAllocSize(CI->getType()), G);
9292
}
@@ -112,7 +112,7 @@ void RTTIBuilder::push_array(llvm::Constant *CI, uint64_t dim, Type *valtype,
112112
auto G = new LLGlobalVariable(gIR->module, CI->getType(), true, lwc.first, CI,
113113
initname.peekChars());
114114
setLinkage(lwc, G);
115-
G->setAlignment(LLMaybeAlign(DtoAlignment(valtype)));
115+
G->setAlignment(llvm::MaybeAlign(DtoAlignment(valtype)));
116116

117117
push_array(dim, DtoBitCast(G, DtoType(valtype->pointerTo())));
118118
}

gen/tocall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
415415
llvm::StoreInst *ret = p->ir->CreateStore(val, ptr);
416416
ret->setAtomic(llvm::AtomicOrdering(atomicOrdering));
417417
if (auto alignment = getTypeAllocSize(val->getType())) {
418-
ret->setAlignment(LLAlign(alignment));
418+
ret->setAlignment(llvm::Align(alignment));
419419
}
420420
return true;
421421
}
@@ -449,7 +449,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
449449

450450
llvm::LoadInst *load = p->ir->CreateLoad(loadedType, ptr);
451451
if (auto alignment = getTypeAllocSize(loadedType)) {
452-
load->setAlignment(LLAlign(alignment));
452+
load->setAlignment(llvm::Align(alignment));
453453
}
454454
load->setAtomic(llvm::AtomicOrdering(atomicOrdering));
455455
llvm::Value *val = load;

gen/toconstelem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class ToConstElemVisitor : public Visitor {
443443
auto globalVar = new llvm::GlobalVariable(
444444
p->module, DtoType(se->type), false,
445445
llvm::GlobalValue::InternalLinkage, nullptr, ".structliteral");
446-
globalVar->setAlignment(LLMaybeAlign(DtoAlignment(se->type)));
446+
globalVar->setAlignment(llvm::MaybeAlign(DtoAlignment(se->type)));
447447

448448
p->setStructLiteralConstant(se, globalVar);
449449
llvm::Constant *constValue = toConstElem(se, p);

0 commit comments

Comments
 (0)