Merge remote-tracking branch 'origin/master' into llvm16-2

This commit is contained in:
Martin Kinkelin 2023-08-12 14:37:01 +02:00
commit 81ea49db13
401 changed files with 9115 additions and 8336 deletions

View file

@ -232,9 +232,13 @@ LinkageWithCOMDAT DtoLinkage(Dsymbol *sym) {
if (hasWeakUDA(sym)) {
linkage = LLGlobalValue::WeakAnyLinkage;
} else {
// Function (incl. delegate) literals are emitted into each referencing
// compilation unit, so use linkonce_odr for all lambdas and all global
// variables they define.
/* Function (incl. delegate) literals are emitted into each referencing
* compilation unit, so use internal linkage for all lambdas and all global
* variables they define.
* This makes sure these symbols don't accidentally collide when linking
* object files compiled by different compiler invocations (lambda mangles
* aren't stable - see https://issues.dlang.org/show_bug.cgi?id=23722).
*/
auto potentialLambda = sym;
if (auto vd = sym->isVarDeclaration()) {
if (vd->isDataseg())
@ -242,7 +246,7 @@ LinkageWithCOMDAT DtoLinkage(Dsymbol *sym) {
}
if (potentialLambda->isFuncLiteralDeclaration()) {
linkage = LLGlobalValue::LinkOnceODRLinkage;
linkage = LLGlobalValue::InternalLinkage;
} else if (sym->isInstantiated()) {
linkage = templateLinkage;
}
@ -309,8 +313,9 @@ void setVisibility(Dsymbol *sym, llvm::GlobalObject *obj) {
} else {
if (sym->isExport()) {
obj->setVisibility(LLGlobalValue::DefaultVisibility); // overrides @hidden
} else if (!hasHiddenUDA) {
} else if (!obj->hasLocalLinkage() && !hasHiddenUDA) {
// Hide with -fvisibility=hidden, or linkonce_odr etc.
// Note that symbols with local linkage cannot be hidden (LLVM assertion).
// The Apple linker warns about hidden linkonce_odr symbols from object
// files compiled with -linkonce-templates being folded with *public*
// weak_odr symbols from non-linkonce-templates code (e.g., Phobos), so
@ -397,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*/);
}
////////////////////////////////////////////////////////////////////////////////
@ -419,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*/);
}
@ -527,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;
}
@ -565,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));
}
}