[llvm] [clang] [Offload] Initial support for registering offloading entries on COFF targets (PR #72697)
Johannes Doerfert via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 20 12:37:26 PST 2023
================
@@ -62,35 +63,51 @@ void offloading::emitOffloadingEntry(Module &M, Constant *Addr, StringRef Name,
M.getDataLayout().getDefaultGlobalsAddressSpace());
// The entry has to be created in the section the linker expects it to be.
- Entry->setSection(SectionName);
+ if (Triple.isOSBinFormatCOFF())
+ Entry->setSection((SectionName + "$OE").str());
+ else
+ Entry->setSection(SectionName);
Entry->setAlignment(Align(1));
}
std::pair<GlobalVariable *, GlobalVariable *>
offloading::getOffloadEntryArray(Module &M, StringRef SectionName) {
- auto *EntriesB =
- new GlobalVariable(M, ArrayType::get(getEntryTy(M), 0),
- /*isConstant=*/true, GlobalValue::ExternalLinkage,
- /*Initializer=*/nullptr, "__start_" + SectionName);
+ llvm::Triple Triple(M.getTargetTriple());
+
+ auto *ZeroInitilaizer =
+ ConstantAggregateZero::get(ArrayType::get(getEntryTy(M), 0u));
+ auto *EntryInit = Triple.isOSBinFormatCOFF() ? ZeroInitilaizer : nullptr;
+ auto *EntryType = Triple.isOSBinFormatCOFF()
+ ? ZeroInitilaizer->getType()
+ : ArrayType::get(getEntryTy(M), 0);
----------------
jdoerfert wrote:
I don't see why we need the ternary here, aren't both options the same?
https://github.com/llvm/llvm-project/pull/72697
More information about the cfe-commits
mailing list