Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Show First 20 Lines • Show All 666 Lines • ▼ Show 20 Lines | auto *var = new llvm::GlobalVariable( | ||||
addrSpace); | addrSpace); | ||||
if (op.getUnnamedAddr().hasValue()) | if (op.getUnnamedAddr().hasValue()) | ||||
var->setUnnamedAddr(convertUnnamedAddrToLLVM(*op.getUnnamedAddr())); | var->setUnnamedAddr(convertUnnamedAddrToLLVM(*op.getUnnamedAddr())); | ||||
if (op.getSection().hasValue()) | if (op.getSection().hasValue()) | ||||
var->setSection(*op.getSection()); | var->setSection(*op.getSection()); | ||||
auto TargetTriple = llvm::Triple(llvmModule->getTargetTriple()); | |||||
if (var->isWeakForLinker() && !var->hasCommonLinkage() && | |||||
TargetTriple.isOSBinFormatCOFF()) { | |||||
rnk: Use `supportsCOMDAT` instead of `isOSBinFormatCOFF` to cover Linux. Linux linkonce_odr… | |||||
mnadeemAuthorUnsubmitted According to https://llvm.org/docs/LangRef.html#linkage-types variables with ODR linkage should have equivalent data, which maps to Comdat::ExactMatch, right? but ELF only supports any and nodeduplicate. Would it be correct to set Comdat::Any for ODR linkages? mnadeem: According to https://llvm.org/docs/LangRef.html#linkage-types variables with ODR linkage should… | |||||
rnkUnsubmitted Not Done ReplyInline ActionsFunctions are not generally bit for bit identical between TUs, even when they have equivalent definitions, so ExactMatch can't normally be used. Any is the normal behavior, and would match what you currently get on other platforms. In theory, ExactMatch could be applied to certain kinds of readonly data, but in practice, I have never observed MSVC use this setting. rnk: Functions are not generally bit for bit identical between TUs, even when they have equivalent… | |||||
mnadeemAuthorUnsubmitted
Updated to use supportsCOMDAT. Btw this code block only deals with mlir::LLVM::GlobalOp which dont include functions. mnadeem: > Use supportsCOMDAT instead of isOSBinFormatCOFF to cover Linux. Linux linkonce_odr functions… | |||||
auto *C = llvmModule->getOrInsertComdat(var->getName()); | |||||
if (!var->isInterposable()) | |||||
C->setSelectionKind(llvm::Comdat::ExactMatch); | |||||
var->setComdat(C); | |||||
} | |||||
addRuntimePreemptionSpecifier(op.getDsoLocal(), var); | addRuntimePreemptionSpecifier(op.getDsoLocal(), var); | ||||
Optional<uint64_t> alignment = op.getAlignment(); | Optional<uint64_t> alignment = op.getAlignment(); | ||||
if (alignment.hasValue()) | if (alignment.hasValue()) | ||||
var->setAlignment(llvm::MaybeAlign(alignment.getValue())); | var->setAlignment(llvm::MaybeAlign(alignment.getValue())); | ||||
globalsMapping.try_emplace(op, var); | globalsMapping.try_emplace(op, var); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 490 Lines • Show Last 20 Lines |
Use supportsCOMDAT instead of isOSBinFormatCOFF to cover Linux. Linux linkonce_odr functions should also have comdats.