@@ -806,30 +806,15 @@ struct SYCLWrapper {
806806 // / \returns Pair of Constants that point at entries content.
807807 std::pair<Constant *, Constant *>
808808 addOffloadEntriesToModule (StringRef Entries) {
809- if (Entries.empty ()) {
810- auto *NullPtr = Constant::getNullValue (PointerType::getUnqual (C));
811- return std::pair<Constant *, Constant *>(NullPtr, NullPtr);
812- }
813-
814- auto *I64Zero = ConstantInt::get (Type::getInt64Ty (C), 0 );
815- auto *I32Zero = ConstantInt::get (Type::getInt32Ty (C), 0 );
816- auto *NullPtr = Constant::getNullValue (PointerType::getUnqual (C));
817-
818809 SmallVector<Constant *> EntriesInits;
819810 std::unique_ptr<MemoryBuffer> MB = MemoryBuffer::getMemBuffer (Entries);
820811 for (line_iterator LI (*MB); !LI.is_at_eof (); ++LI) {
821- Constant *EntryData[] = {
822- ConstantExpr::getNullValue (Type::getInt64Ty (C)),
823- ConstantInt::get (Type::getInt16Ty (C), 1 ),
824- ConstantInt::get (Type::getInt16Ty (C), object::OffloadKind::OFK_SYCL),
825- I32Zero,
826- NullPtr,
827- addStringToModule (*LI, " __sycl_offload_entry_name" ),
828- I64Zero,
829- I64Zero,
830- NullPtr};
831-
832- EntriesInits.push_back (ConstantStruct::get (EntryTy, EntryData));
812+ Constant *C = addStringToModule (*LI, " __sycl_offload_entry_name" );
813+ GlobalVariable *GV =
814+ emitOffloadingEntry (M, /* Kind*/ OffloadKind::OFK_SYCL, C,
815+ /* Name*/ " __sycl_offload_entry_name" , /* Size*/ 0 ,
816+ /* Flags*/ 0 , /* Data*/ 0 );
817+ EntriesInits.push_back (GV);
833818 }
834819
835820 auto *Arr = ConstantArray::get (ArrayType::get (EntryTy, EntriesInits.size ()),
@@ -951,10 +936,10 @@ struct SYCLWrapper {
951936 // /
952937 // / \code
953938 // / __attribute__((visibility("hidden")))
954- // / extern __tgt_offload_entry *__start_offloading_entries0;
955- // / __attribute__((visibility("hidden")))
956- // / extern __tgt_offload_entry *__stop_offloading_entries0;
939+ // / __tgt_offload_entry *__sycl_offload_entries_arr0[];
957940 // / ...
941+ // / __attribute__((visibility("hidden")))
942+ // / __tgt_offload_entry *__sycl_offload_entries_arrN[];
958943 // /
959944 // / __attribute__((visibility("hidden")))
960945 // / extern const char *CompileOptions = "...";
@@ -969,19 +954,18 @@ struct SYCLWrapper {
969954 // /
970955 // / static const __sycl.tgt_device_image Images[] = {
971956 // / {
972- // / Version, // Version
973- // / OffloadKind, // OffloadKind
974- // / Format, // format of the image - SPIRV, LLVMIR
975- // / // bc, etc
976- // TripleString, // Arch
977- // / CompileOptions0, // CompileOptions
978- // / LinkOptions0, // LinkOptions
979- // / Image0, // ImageStart
980- // / Image0 + N, // ImageEnd
981- // / __start_offloading_entries0, // EntriesBegin
982- // / __stop_offloading_entries0, // EntriesEnd
983- // / NULL, // PropertiesBegin
984- // / NULL, // PropertiesEnd
957+ // / Version, // Version
958+ // / OffloadKind, // OffloadKind
959+ // / Format, // Format of the image.
960+ // TripleString, // Arch
961+ // / CompileOptions, // CompileOptions
962+ // / LinkOptions, // LinkOptions
963+ // / Image0, // ImageStart
964+ // / Image0 + IMAGE0_SIZE, // ImageEnd
965+ // / __sycl_offload_entries_arr0, // EntriesBegin
966+ // / __sycl_offload_entries_arr0 + ENTRIES0_SIZE, // EntriesEnd
967+ // / NULL, // PropertiesBegin
968+ // / NULL, // PropertiesEnd
985969 // / },
986970 // / ...
987971 // / };
0 commit comments