Remove legacy LL[Maybe]Align

This commit is contained in:
Martin Kinkelin 2023-07-29 01:58:14 +02:00
parent f6702cfbf5
commit 5d3ded9eeb
15 changed files with 29 additions and 32 deletions

View file

@ -266,7 +266,7 @@ struct X86TargetABI : TargetABI {
#else
// Keep alignment for LLVM 13+, to prevent invalid `movaps` etc.,
// but limit to 4 (required according to runnable/ldc_cabi1.d).
auto align4 = LLAlign(4);
auto align4 = llvm::Align(4);
if (arg->attrs.getAlignment().
#if LDC_LLVM_VER >= 1500
value_or

View file

@ -44,16 +44,17 @@ void emitCoverageLinecountInc(const Loc &loc) {
// Do an atomic increment, so this works when multiple threads are executed.
gIR->ir->CreateAtomicRMW(llvm::AtomicRMWInst::Add, ptr, DtoConstUint(1),
#if LDC_LLVM_VER >= 1300
LLAlign(4),
llvm::Align(4),
#endif
llvm::AtomicOrdering::Monotonic);
break;
case opts::CoverageIncrement::nonatomic: {
// Do a non-atomic increment, user is responsible for correct results with
// multithreaded execution
llvm::LoadInst *load = gIR->ir->CreateAlignedLoad(i32Type, ptr, LLAlign(4));
llvm::LoadInst *load =
gIR->ir->CreateAlignedLoad(i32Type, ptr, llvm::Align(4));
llvm::StoreInst *store = gIR->ir->CreateAlignedStore(
gIR->ir->CreateAdd(load, DtoConstUint(1)), ptr, LLAlign(4));
gIR->ir->CreateAdd(load, DtoConstUint(1)), ptr, llvm::Align(4));
// add !nontemporal attribute, to inform the optimizer that caching is not
// needed
llvm::MDNode *node = llvm::MDNode::get(
@ -66,7 +67,7 @@ void emitCoverageLinecountInc(const Loc &loc) {
// Do a boolean set, avoiding a memory read (blocking) and threading issues
// at the cost of not "counting"
llvm::StoreInst *store =
gIR->ir->CreateAlignedStore(DtoConstUint(1), ptr, LLAlign(4));
gIR->ir->CreateAlignedStore(DtoConstUint(1), ptr, llvm::Align(4));
// add !nontemporal attribute, to inform the optimizer that caching is not
// needed
llvm::MDNode *node = llvm::MDNode::get(

View file

@ -180,7 +180,7 @@ DBitFieldLValue::DBitFieldLValue(Type *t, LLValue *ptr, BitFieldDeclaration *bf)
DRValue *DBitFieldLValue::getRVal() {
const auto sizeInBits = intType->getBitWidth();
const auto ptr = DtoBitCast(val, getPtrToType(intType));
LLValue *v = gIR->ir->CreateAlignedLoad(intType, ptr, LLMaybeAlign(1));
LLValue *v = gIR->ir->CreateAlignedLoad(intType, ptr, llvm::MaybeAlign(1));
if (bf->type->isunsigned()) {
if (auto n = bf->bitOffset)
@ -208,7 +208,8 @@ void DBitFieldLValue::store(LLValue *value) {
const auto mask =
llvm::APInt::getLowBitsSet(intType->getBitWidth(), bf->fieldWidth);
const auto oldVal = gIR->ir->CreateAlignedLoad(intType, ptr, LLMaybeAlign(1));
const auto oldVal =
gIR->ir->CreateAlignedLoad(intType, ptr, llvm::MaybeAlign(1));
const auto maskedOldVal =
gIR->ir->CreateAnd(oldVal, ~(mask << bf->bitOffset));
@ -218,7 +219,7 @@ void DBitFieldLValue::store(LLValue *value) {
bfVal = gIR->ir->CreateShl(bfVal, n);
const auto newVal = gIR->ir->CreateOr(maskedOldVal, bfVal);
gIR->ir->CreateAlignedStore(newVal, ptr, LLMaybeAlign(1));
gIR->ir->CreateAlignedStore(newVal, ptr, llvm::MaybeAlign(1));
}
DDcomputeLValue::DDcomputeLValue(Type *t, llvm::Type * llt, LLValue *v) : DLValue(t, v) {

View file

@ -147,7 +147,7 @@ IRState::setGlobalVarInitializer(LLGlobalVariable *&globalVar,
module, initializer->getType(), globalVar->isConstant(),
globalVar->getLinkage(), nullptr, "", nullptr,
globalVar->getThreadLocalMode());
globalHelperVar->setAlignment(LLMaybeAlign(globalVar->getAlignment()));
globalHelperVar->setAlignment(llvm::MaybeAlign(globalVar->getAlignment()));
globalHelperVar->setComdat(globalVar->getComdat());
globalHelperVar->setDLLStorageClass(globalVar->getDLLStorageClass());
globalHelperVar->setSection(globalVar->getSection());

View file

@ -35,9 +35,6 @@ using llvm::APFloat;
using llvm::APInt;
using llvm::IRBuilder;
#define LLAlign llvm::Align
#define LLMaybeAlign llvm::MaybeAlign
#define GET_INTRINSIC_DECL(_X) \
(llvm::Intrinsic::getDeclaration(&gIR->module, llvm::Intrinsic::_X))

View file

@ -191,7 +191,7 @@ llvm::AllocaInst *DtoArrayAlloca(Type *type, unsigned arraysize,
lltype, gIR->module.getDataLayout().getAllocaAddrSpace(),
DtoConstUint(arraysize), name, gIR->topallocapoint());
if (auto alignment = DtoAlignment(type)) {
ai->setAlignment(LLAlign(alignment));
ai->setAlignment(llvm::Align(alignment));
}
return ai;
}
@ -202,7 +202,7 @@ llvm::AllocaInst *DtoRawAlloca(LLType *lltype, size_t alignment,
lltype, gIR->module.getDataLayout().getAllocaAddrSpace(), name,
gIR->topallocapoint());
if (alignment) {
ai->setAlignment(LLAlign(alignment));
ai->setAlignment(llvm::Align(alignment));
}
return ai;
}

View file

@ -60,7 +60,7 @@ Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
/// expects that the size has type 'intptr_t' and Dst/Src are pointers.
Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
unsigned Align, IRBuilder<> &B) {
auto A = LLMaybeAlign(Align);
auto A = llvm::MaybeAlign(Align);
return B.CreateMemCpy(CastToCStr(Dst, B), A, CastToCStr(Src, B), A, Len,
false);
}

View file

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

View file

@ -415,7 +415,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
llvm::StoreInst *ret = p->ir->CreateStore(val, ptr);
ret->setAtomic(llvm::AtomicOrdering(atomicOrdering));
if (auto alignment = getTypeAllocSize(val->getType())) {
ret->setAlignment(LLAlign(alignment));
ret->setAlignment(llvm::Align(alignment));
}
return true;
}
@ -449,7 +449,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
llvm::LoadInst *load = p->ir->CreateLoad(loadedType, ptr);
if (auto alignment = getTypeAllocSize(loadedType)) {
load->setAlignment(LLAlign(alignment));
load->setAlignment(llvm::Align(alignment));
}
load->setAtomic(llvm::AtomicOrdering(atomicOrdering));
llvm::Value *val = load;

View file

@ -443,7 +443,7 @@ public:
auto globalVar = new llvm::GlobalVariable(
p->module, DtoType(se->type), false,
llvm::GlobalValue::InternalLinkage, nullptr, ".structliteral");
globalVar->setAlignment(LLMaybeAlign(DtoAlignment(se->type)));
globalVar->setAlignment(llvm::MaybeAlign(DtoAlignment(se->type)));
p->setStructLiteralConstant(se, globalVar);
llvm::Constant *constValue = toConstElem(se, p);

View file

@ -164,7 +164,7 @@ static void write_struct_literal(Loc loc, LLValue *mem, StructDeclaration *sd,
IF_LOG Logger::cout() << "merged IR value: " << *val << '\n';
gIR->ir->CreateAlignedStore(val, DtoBitCast(ptr, getPtrToType(intType)),
LLMaybeAlign(1));
llvm::MaybeAlign(1));
offset += group.sizeInBytes;
i += group.bitFields.size() - 1; // skip the other bit fields of the group

View file

@ -402,7 +402,8 @@ void DtoMemSet(LLValue *dst, LLValue *val, LLValue *nbytes, unsigned align) {
dst = DtoBitCast(dst, VoidPtrTy);
gIR->ir->CreateMemSet(dst, val, nbytes, LLMaybeAlign(align), false /*isVolatile*/);
gIR->ir->CreateMemSet(dst, val, nbytes, llvm::MaybeAlign(align),
false /*isVolatile*/);
}
////////////////////////////////////////////////////////////////////////////////
@ -424,7 +425,7 @@ void DtoMemCpy(LLValue *dst, LLValue *src, LLValue *nbytes, unsigned align) {
dst = DtoBitCast(dst, VoidPtrTy);
src = DtoBitCast(src, VoidPtrTy);
auto A = LLMaybeAlign(align);
auto A = llvm::MaybeAlign(align);
gIR->ir->CreateMemCpy(dst, A, src, A, nbytes, false /*isVolatile*/);
}
@ -532,7 +533,7 @@ LLValue *DtoLoad(DLValue *src, const char *name) {
LLValue *DtoAlignedLoad(LLType *type, LLValue *src, const char *name) {
llvm::LoadInst *ld = DtoLoadImpl(type, src, name);
if (auto alignment = getABITypeAlign(ld->getType())) {
ld->setAlignment(LLAlign(alignment));
ld->setAlignment(llvm::Align(alignment));
}
return ld;
}
@ -570,7 +571,7 @@ void DtoAlignedStore(LLValue *src, LLValue *dst) {
"Should store bools as i8 instead of i1.");
llvm::StoreInst *st = gIR->ir->CreateStore(src, dst);
if (auto alignment = getABITypeAlign(src->getType())) {
st->setAlignment(LLAlign(alignment));
st->setAlignment(llvm::Align(alignment));
}
}

View file

@ -87,7 +87,7 @@ LLConstant *IrAggr::getInitSymbol(bool define) {
irMangle, isConstant, false, useDLLImport());
}
initGlobal->setAlignment(LLMaybeAlign(DtoAlignment(type)));
initGlobal->setAlignment(llvm::MaybeAlign(DtoAlignment(type)));
init = initGlobal;

View file

@ -114,7 +114,7 @@ void IrGlobal::declare() {
// Set the alignment (it is important not to use type->alignsize because
// VarDeclarations can have an align() attribute independent of the type
// as well).
gvar->setAlignment(LLMaybeAlign(DtoAlignment(V)));
gvar->setAlignment(llvm::MaybeAlign(DtoAlignment(V)));
applyVarDeclUDAs(V, gvar);

View file

@ -18,9 +18,6 @@
#include "valueparser.h"
#define LLAlign llvm::Align
#define LLMaybeAlign llvm::MaybeAlign
namespace {
enum { SmallParamsCount = 5 };
@ -75,7 +72,7 @@ allocParam(llvm::IRBuilder<> &builder, llvm::Type &srcType,
auto elemType = srcType.getPointerElementType();
auto stackArg = builder.CreateAlloca(elemType);
if (auto alignment = layout.getABITypeAlignment(elemType))
stackArg->setAlignment(LLAlign(alignment));
stackArg->setAlignment(llvm::Align(alignment));
auto init =
parseInitializer(layout, *elemType, param.data, errHandler, override);
builder.CreateStore(init, stackArg);
@ -83,7 +80,7 @@ allocParam(llvm::IRBuilder<> &builder, llvm::Type &srcType,
}
auto stackArg = builder.CreateAlloca(&srcType);
if (auto alignment = layout.getABITypeAlignment(&srcType))
stackArg->setAlignment(LLAlign(alignment));
stackArg->setAlignment(llvm::Align(alignment));
auto init =
parseInitializer(layout, srcType, param.data, errHandler, override);
builder.CreateStore(init, stackArg);