================
@@ -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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to