@@ -2739,25 +2739,19 @@ Address CodeGenFunction::EmitFieldSYCLAnnotations(const FieldDecl *D,
2739
2739
assert (SYCLAnnotAttr && " no add_ir_annotations_member attribute" );
2740
2740
llvm::Value *V = Addr.getPointer ();
2741
2741
llvm::Type *VTy = V->getType ();
2742
-
2743
- // llvm.ptr.annotation intrinsic accepts a pointer to integer of any width -
2744
- // don't perform bitcasts if value is integer.
2745
- if (VTy->getPointerElementType ()->isIntegerTy ()) {
2746
- llvm::Function *F = CGM.getIntrinsic (llvm::Intrinsic::ptr_annotation, VTy);
2747
- V = EmitSYCLAnnotationCall (F, V, D->getLocation (), SYCLAnnotAttr);
2748
- return Address::deprecated (V, Addr.getAlignment ());
2749
- }
2750
-
2751
2742
auto *PTy = dyn_cast<llvm::PointerType>(VTy);
2752
2743
unsigned AS = PTy ? PTy->getAddressSpace () : 0 ;
2753
- llvm::PointerType *IntrinTy =
2754
- llvm::PointerType::getWithSamePointeeType (CGM.Int8PtrTy , AS);
2744
+ llvm::Type *IntrType = VTy;
2745
+ if (!VTy->getPointerElementType ()->isIntegerTy ())
2746
+ IntrType = llvm::PointerType::getWithSamePointeeType (CGM.Int8PtrTy , AS);
2755
2747
llvm::Function *F =
2756
- CGM.getIntrinsic (llvm::Intrinsic::ptr_annotation, IntrinTy );
2748
+ CGM.getIntrinsic (llvm::Intrinsic::ptr_annotation, IntrType );
2757
2749
2758
- V = Builder.CreateBitCast (V, IntrinTy);
2750
+ if (VTy != IntrType)
2751
+ V = Builder.CreateBitCast (V, IntrType);
2759
2752
V = EmitSYCLAnnotationCall (F, V, D->getLocation (), SYCLAnnotAttr);
2760
- V = Builder.CreateBitCast (V, VTy);
2753
+ if (VTy != IntrType)
2754
+ V = Builder.CreateBitCast (V, VTy);
2761
2755
return Address (V, Addr.getElementType (), Addr.getAlignment ());
2762
2756
}
2763
2757
0 commit comments