@@ -40,7 +40,7 @@ enum OffloadEntryKindFlag : uint32_t {
40
40
41
41
IntegerType *getSizeTTy (Module &M) {
42
42
LLVMContext &C = M.getContext ();
43
- switch (M.getDataLayout ().getPointerTypeSize (Type::getInt8PtrTy (C))) {
43
+ switch (M.getDataLayout ().getPointerTypeSize (PointerType::getUnqual (C))) {
44
44
case 4u :
45
45
return Type::getInt32Ty (C);
46
46
case 8u :
@@ -60,9 +60,10 @@ StructType *getEntryTy(Module &M) {
60
60
LLVMContext &C = M.getContext ();
61
61
StructType *EntryTy = StructType::getTypeByName (C, " __tgt_offload_entry" );
62
62
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));
66
67
return EntryTy;
67
68
}
68
69
@@ -80,9 +81,9 @@ StructType *getDeviceImageTy(Module &M) {
80
81
LLVMContext &C = M.getContext ();
81
82
StructType *ImageTy = StructType::getTypeByName (C, " __tgt_device_image" );
82
83
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));
86
87
return ImageTy;
87
88
}
88
89
@@ -284,17 +285,17 @@ StructType *getFatbinWrapperTy(Module &M) {
284
285
LLVMContext &C = M.getContext ();
285
286
StructType *FatbinTy = StructType::getTypeByName (C, " fatbin_wrapper" );
286
287
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));
290
291
return FatbinTy;
291
292
}
292
293
293
294
// / Embed the image \p Image into the module \p M so it can be found by the
294
295
// / runtime.
295
296
GlobalVariable *createFatbinDesc (Module &M, ArrayRef<char > Image, bool IsHIP) {
296
297
LLVMContext &C = M.getContext ();
297
- llvm::Type *Int8PtrTy = Type::getInt8PtrTy (C);
298
+ llvm::Type *Int8PtrTy = PointerType::getUnqual (C);
298
299
llvm::Triple Triple = llvm::Triple (M.getTargetTriple ());
299
300
300
301
// Create the global string containing the fatbinary.
@@ -315,7 +316,7 @@ GlobalVariable *createFatbinDesc(Module &M, ArrayRef<char> Image, bool IsHIP) {
315
316
ConstantInt::get (Type::getInt32Ty (C), IsHIP ? HIPFatMagic : CudaFatMagic),
316
317
ConstantInt::get (Type::getInt32Ty (C), 1 ),
317
318
ConstantExpr::getPointerBitCastOrAddrSpaceCast (Fatbin, Int8PtrTy),
318
- ConstantPointerNull::get (Type::getInt8PtrTy (C))};
319
+ ConstantPointerNull::get (PointerType::getUnqual (C))};
319
320
320
321
Constant *FatbinInitializer =
321
322
ConstantStruct::get (getFatbinWrapperTy (M), FatbinWrapper);
@@ -529,21 +530,21 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
529
530
DtorFunc->setSection (" .text.startup" );
530
531
531
532
// 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),
534
535
/* isVarArg*/ false );
535
536
FunctionCallee RegFatbin = M.getOrInsertFunction (
536
537
IsHIP ? " __hipRegisterFatBinary" : " __cudaRegisterFatBinary" , RegFatTy);
537
538
// 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 );
541
542
FunctionCallee RegFatbinEnd =
542
543
M.getOrInsertFunction (" __cudaRegisterFatBinaryEnd" , RegFatEndTy);
543
544
// 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 );
547
548
FunctionCallee UnregFatbin = M.getOrInsertFunction (
548
549
IsHIP ? " __hipUnregisterFatBinary" : " __cudaUnregisterFatBinary" ,
549
550
UnregFatTy);
@@ -554,19 +555,19 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
554
555
FunctionCallee AtExit = M.getOrInsertFunction (" atexit" , AtExitTy);
555
556
556
557
auto *BinaryHandleGlobal = new llvm::GlobalVariable (
557
- M, Type::getInt8PtrTy (C)->getPointerTo (), false ,
558
+ M, PointerType::getUnqual (C)->getPointerTo (), false ,
558
559
llvm::GlobalValue::InternalLinkage,
559
- llvm::ConstantPointerNull::get (Type::getInt8PtrTy (C)->getPointerTo ()),
560
+ llvm::ConstantPointerNull::get (PointerType::getUnqual (C)->getPointerTo ()),
560
561
IsHIP ? " .hip.binary_handle" : " .cuda.binary_handle" );
561
562
562
563
// Create the constructor to register this image with the runtime.
563
564
IRBuilder<> CtorBuilder (BasicBlock::Create (C, " entry" , CtorFunc));
564
565
CallInst *Handle = CtorBuilder.CreateCall (
565
566
RegFatbin, ConstantExpr::getPointerBitCastOrAddrSpaceCast (
566
- FatbinDesc, Type::getInt8PtrTy (C)));
567
+ FatbinDesc, PointerType::getUnqual (C)));
567
568
CtorBuilder.CreateAlignedStore (
568
569
Handle , BinaryHandleGlobal,
569
- Align (M.getDataLayout ().getPointerTypeSize (Type::getInt8PtrTy (C))));
570
+ Align (M.getDataLayout ().getPointerTypeSize (PointerType::getUnqual (C))));
570
571
CtorBuilder.CreateCall (createRegisterGlobalsFunction (M, IsHIP), Handle );
571
572
if (!IsHIP)
572
573
CtorBuilder.CreateCall (RegFatbinEnd, Handle );
@@ -578,8 +579,8 @@ void createRegisterFatbinFunction(Module &M, GlobalVariable *FatbinDesc,
578
579
// `atexit()` intead.
579
580
IRBuilder<> DtorBuilder (BasicBlock::Create (C, " entry" , DtorFunc));
580
581
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))));
583
584
DtorBuilder.CreateCall (UnregFatbin, BinaryHandle);
584
585
DtorBuilder.CreateRetVoid ();
585
586
0 commit comments