@@ -40,7 +40,7 @@ enum OffloadEntryKindFlag : uint32_t {
4040
4141IntegerType *getSizeTTy (Module &M) {
4242 LLVMContext &C = M.getContext ();
43- switch (M.getDataLayout ().getPointerTypeSize (Type::getInt8PtrTy (C))) {
43+ switch (M.getDataLayout ().getPointerTypeSize (PointerType::getUnqual (C))) {
4444 case 4u :
4545 return Type::getInt32Ty (C);
4646 case 8u :
@@ -60,9 +60,10 @@ StructType *getEntryTy(Module &M) {
6060 LLVMContext &C = M.getContext ();
6161 StructType *EntryTy = StructType::getTypeByName (C, " __tgt_offload_entry" );
6262 if (!EntryTy)
63- EntryTy = StructType::create (" __tgt_offload_entry" , Type::getInt8PtrTy (C),
64- Type::getInt8PtrTy (C), getSizeTTy (M),
65- Type::getInt32Ty (C), Type::getInt32Ty (C));
63+ EntryTy =
64+ StructType::create (" __tgt_offload_entry" , PointerType::getUnqual (C),
65+ PointerType::getUnqual (C), getSizeTTy (M),
66+ Type::getInt32Ty (C), Type::getInt32Ty (C));
6667 return EntryTy;
6768}
6869
@@ -80,9 +81,9 @@ StructType *getDeviceImageTy(Module &M) {
8081 LLVMContext &C = M.getContext ();
8182 StructType *ImageTy = StructType::getTypeByName (C, " __tgt_device_image" );
8283 if (!ImageTy)
83- ImageTy = StructType::create (" __tgt_device_image " , Type::getInt8PtrTy (C),
84- Type::getInt8PtrTy (C), getEntryPtrTy (M ),
85- getEntryPtrTy (M));
84+ ImageTy = StructType::create (
85+ " __tgt_device_image " , PointerType::getUnqual (C ),
86+ PointerType::getUnqual (C), getEntryPtrTy (M), getEntryPtrTy (M));
8687 return ImageTy;
8788}
8889
@@ -284,17 +285,17 @@ StructType *getFatbinWrapperTy(Module &M) {
284285 LLVMContext &C = M.getContext ();
285286 StructType *FatbinTy = StructType::getTypeByName (C, " fatbin_wrapper" );
286287 if (!FatbinTy)
287- FatbinTy = StructType::create (" fatbin_wrapper " , Type::getInt32Ty (C),
288- Type::getInt32Ty (C), Type::getInt8PtrTy (C),
289- Type::getInt8PtrTy (C));
288+ FatbinTy = StructType::create (
289+ " fatbin_wrapper " , Type::getInt32Ty (C), Type::getInt32Ty (C),
290+ PointerType::getUnqual (C), PointerType::getUnqual (C));
290291 return FatbinTy;
291292}
292293
293294// / Embed the image \p Image into the module \p M so it can be found by the
294295// / runtime.
295296GlobalVariable *createFatbinDesc (Module &M, ArrayRef<char > Image, bool IsHIP) {
296297 LLVMContext &C = M.getContext ();
297- llvm::Type *Int8PtrTy = Type::getInt8PtrTy (C);
298+ llvm::Type *Int8PtrTy = PointerType::getUnqual (C);
298299 llvm::Triple Triple = llvm::Triple (M.getTargetTriple ());
299300
300301 // Create the global string containing the fatbinary.
@@ -315,7 +316,7 @@ GlobalVariable *createFatbinDesc(Module &M, ArrayRef<char> Image, bool IsHIP) {
315316 ConstantInt::get (Type::getInt32Ty (C), IsHIP ? HIPFatMagic : CudaFatMagic),
316317 ConstantInt::get (Type::getInt32Ty (C), 1 ),
317318 ConstantExpr::getPointerBitCastOrAddrSpaceCast (Fatbin, Int8PtrTy),
318- ConstantPointerNull::get (Type::getInt8PtrTy (C))};
319+ ConstantPointerNull::get (PointerType::getUnqual (C))};
319320
320321 Constant *FatbinInitializer =
321322 ConstantStruct::get (getFatbinWrapperTy (M), FatbinWrapper);
@@ -529,21 +530,21 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
529530 DtorFunc->setSection (" .text.startup" );
530531
531532 // Get the __cudaRegisterFatBinary function declaration.
532- auto *RegFatTy = FunctionType::get (Type::getInt8PtrTy (C)->getPointerTo (),
533- Type::getInt8PtrTy (C),
533+ auto *RegFatTy = FunctionType::get (PointerType::getUnqual (C)->getPointerTo (),
534+ PointerType::getUnqual (C),
534535 /* isVarArg*/ false );
535536 FunctionCallee RegFatbin = M.getOrInsertFunction (
536537 IsHIP ? " __hipRegisterFatBinary" : " __cudaRegisterFatBinary" , RegFatTy);
537538 // Get the __cudaRegisterFatBinaryEnd function declaration.
538- auto *RegFatEndTy = FunctionType::get (Type::getVoidTy (C),
539- Type::getInt8PtrTy (C)->getPointerTo (),
540- /* isVarArg*/ false );
539+ auto *RegFatEndTy = FunctionType::get (
540+ Type::getVoidTy (C), PointerType::getUnqual (C)->getPointerTo (),
541+ /* isVarArg*/ false );
541542 FunctionCallee RegFatbinEnd =
542543 M.getOrInsertFunction (" __cudaRegisterFatBinaryEnd" , RegFatEndTy);
543544 // Get the __cudaUnregisterFatBinary function declaration.
544- auto *UnregFatTy = FunctionType::get (Type::getVoidTy (C),
545- Type::getInt8PtrTy (C)->getPointerTo (),
546- /* isVarArg*/ false );
545+ auto *UnregFatTy = FunctionType::get (
546+ Type::getVoidTy (C), PointerType::getUnqual (C)->getPointerTo (),
547+ /* isVarArg*/ false );
547548 FunctionCallee UnregFatbin = M.getOrInsertFunction (
548549 IsHIP ? " __hipUnregisterFatBinary" : " __cudaUnregisterFatBinary" ,
549550 UnregFatTy);
@@ -554,19 +555,19 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
554555 FunctionCallee AtExit = M.getOrInsertFunction (" atexit" , AtExitTy);
555556
556557 auto *BinaryHandleGlobal = new llvm::GlobalVariable (
557- M, Type::getInt8PtrTy (C)->getPointerTo (), false ,
558+ M, PointerType::getUnqual (C)->getPointerTo (), false ,
558559 llvm::GlobalValue::InternalLinkage,
559- llvm::ConstantPointerNull::get (Type::getInt8PtrTy (C)->getPointerTo ()),
560+ llvm::ConstantPointerNull::get (PointerType::getUnqual (C)->getPointerTo ()),
560561 IsHIP ? " .hip.binary_handle" : " .cuda.binary_handle" );
561562
562563 // Create the constructor to register this image with the runtime.
563564 IRBuilder<> CtorBuilder (BasicBlock::Create (C, " entry" , CtorFunc));
564565 CallInst *Handle = CtorBuilder.CreateCall (
565566 RegFatbin, ConstantExpr::getPointerBitCastOrAddrSpaceCast (
566- FatbinDesc, Type::getInt8PtrTy (C)));
567+ FatbinDesc, PointerType::getUnqual (C)));
567568 CtorBuilder.CreateAlignedStore (
568569 Handle, BinaryHandleGlobal,
569- Align (M.getDataLayout ().getPointerTypeSize (Type::getInt8PtrTy (C))));
570+ Align (M.getDataLayout ().getPointerTypeSize (PointerType::getUnqual (C))));
570571 CtorBuilder.CreateCall (createRegisterGlobalsFunction (M, IsHIP), Handle);
571572 if (!IsHIP)
572573 CtorBuilder.CreateCall (RegFatbinEnd, Handle);
@@ -578,8 +579,8 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
578579 // `atexit()` intead.
579580 IRBuilder<> DtorBuilder (BasicBlock::Create (C, " entry" , DtorFunc));
580581 LoadInst *BinaryHandle = DtorBuilder.CreateAlignedLoad (
581- Type::getInt8PtrTy (C)->getPointerTo (), BinaryHandleGlobal,
582- Align (M.getDataLayout ().getPointerTypeSize (Type::getInt8PtrTy (C))));
582+ PointerType::getUnqual (C)->getPointerTo (), BinaryHandleGlobal,
583+ Align (M.getDataLayout ().getPointerTypeSize (PointerType::getUnqual (C))));
583584 DtorBuilder.CreateCall (UnregFatbin, BinaryHandle);
584585 DtorBuilder.CreateRetVoid ();
585586
0 commit comments