Skip to content

Commit 5d3ded9

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

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);

gen/toir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void write_struct_literal(Loc loc, LLValue *mem, StructDeclaration *sd,
164164

165165
IF_LOG Logger::cout() << "merged IR value: " << *val << '\n';
166166
gIR->ir->CreateAlignedStore(val, DtoBitCast(ptr, getPtrToType(intType)),
167-
LLMaybeAlign(1));
167+
llvm::MaybeAlign(1));
168168
offset += group.sizeInBytes;
169169

170170
i += group.bitFields.size() - 1; // skip the other bit fields of the group

gen/tollvm.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ void DtoMemSet(LLValue *dst, LLValue *val, LLValue *nbytes, unsigned align) {
402402

403403
dst = DtoBitCast(dst, VoidPtrTy);
404404

405-
gIR->ir->CreateMemSet(dst, val, nbytes, LLMaybeAlign(align), false /*isVolatile*/);
405+
gIR->ir->CreateMemSet(dst, val, nbytes, llvm::MaybeAlign(align),
406+
false /*isVolatile*/);
406407
}
407408

408409
////////////////////////////////////////////////////////////////////////////////
@@ -424,7 +425,7 @@ void DtoMemCpy(LLValue *dst, LLValue *src, LLValue *nbytes, unsigned align) {
424425
dst = DtoBitCast(dst, VoidPtrTy);
425426
src = DtoBitCast(src, VoidPtrTy);
426427

427-
auto A = LLMaybeAlign(align);
428+
auto A = llvm::MaybeAlign(align);
428429
gIR->ir->CreateMemCpy(dst, A, src, A, nbytes, false /*isVolatile*/);
429430
}
430431

@@ -532,7 +533,7 @@ LLValue *DtoLoad(DLValue *src, const char *name) {
532533
LLValue *DtoAlignedLoad(LLType *type, LLValue *src, const char *name) {
533534
llvm::LoadInst *ld = DtoLoadImpl(type, src, name);
534535
if (auto alignment = getABITypeAlign(ld->getType())) {
535-
ld->setAlignment(LLAlign(alignment));
536+
ld->setAlignment(llvm::Align(alignment));
536537
}
537538
return ld;
538539
}
@@ -570,7 +571,7 @@ void DtoAlignedStore(LLValue *src, LLValue *dst) {
570571
"Should store bools as i8 instead of i1.");
571572
llvm::StoreInst *st = gIR->ir->CreateStore(src, dst);
572573
if (auto alignment = getABITypeAlign(src->getType())) {
573-
st->setAlignment(LLAlign(alignment));
574+
st->setAlignment(llvm::Align(alignment));
574575
}
575576
}
576577

ir/iraggr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ LLConstant *IrAggr::getInitSymbol(bool define) {
8787
irMangle, isConstant, false, useDLLImport());
8888
}
8989

90-
initGlobal->setAlignment(LLMaybeAlign(DtoAlignment(type)));
90+
initGlobal->setAlignment(llvm::MaybeAlign(DtoAlignment(type)));
9191

9292
init = initGlobal;
9393

ir/irvar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void IrGlobal::declare() {
114114
// Set the alignment (it is important not to use type->alignsize because
115115
// VarDeclarations can have an align() attribute independent of the type
116116
// as well).
117-
gvar->setAlignment(LLMaybeAlign(DtoAlignment(V)));
117+
gvar->setAlignment(llvm::MaybeAlign(DtoAlignment(V)));
118118

119119
applyVarDeclUDAs(V, gvar);
120120

runtime/jit-rt/cpp-so/bind.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
#include "valueparser.h"
2020

21-
#define LLAlign llvm::Align
22-
#define LLMaybeAlign llvm::MaybeAlign
23-
2421
namespace {
2522
enum { SmallParamsCount = 5 };
2623

@@ -75,15 +72,15 @@ allocParam(llvm::IRBuilder<> &builder, llvm::Type &srcType,
7572
auto elemType = srcType.getPointerElementType();
7673
auto stackArg = builder.CreateAlloca(elemType);
7774
if (auto alignment = layout.getABITypeAlignment(elemType))
78-
stackArg->setAlignment(LLAlign(alignment));
75+
stackArg->setAlignment(llvm::Align(alignment));
7976
auto init =
8077
parseInitializer(layout, *elemType, param.data, errHandler, override);
8178
builder.CreateStore(init, stackArg);
8279
return stackArg;
8380
}
8481
auto stackArg = builder.CreateAlloca(&srcType);
8582
if (auto alignment = layout.getABITypeAlignment(&srcType))
86-
stackArg->setAlignment(LLAlign(alignment));
83+
stackArg->setAlignment(llvm::Align(alignment));
8784
auto init =
8885
parseInitializer(layout, srcType, param.data, errHandler, override);
8986
builder.CreateStore(init, stackArg);

0 commit comments

Comments
 (0)