@@ -657,8 +657,7 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
657
657
// To support the SYCL 2020 spelling with no propagation, only emit for
658
658
// kernel-or-device when that spelling, fall-back to old behavior.
659
659
if (ReqSubGroup && (IsKernelOrDevice || !ReqSubGroup->isSYCL2020Spelling ())) {
660
- const auto *CE = dyn_cast<ConstantExpr>(ReqSubGroup->getValue ());
661
- assert (CE && " Not an integer constant expression" );
660
+ const auto *CE = cast<ConstantExpr>(ReqSubGroup->getValue ());
662
661
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt ();
663
662
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get (
664
663
Builder.getInt32 (ArgVal->getSExtValue ()))};
@@ -705,32 +704,26 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
705
704
llvm::MDNode::get (Context, AttrMDArgs));
706
705
}
707
706
708
- if (const SYCLIntelNumSimdWorkItemsAttr *A =
709
- FD->getAttr <SYCLIntelNumSimdWorkItemsAttr>()) {
710
- const auto *CE = dyn_cast<ConstantExpr>(A->getValue ());
711
- assert (CE && " Not an integer constant expression" );
707
+ if (const auto *A = FD->getAttr <SYCLIntelNumSimdWorkItemsAttr>()) {
708
+ const auto *CE = cast<ConstantExpr>(A->getValue ());
712
709
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt ();
713
710
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get (
714
711
Builder.getInt32 (ArgVal->getSExtValue ()))};
715
712
Fn->setMetadata (" num_simd_work_items" ,
716
713
llvm::MDNode::get (Context, AttrMDArgs));
717
714
}
718
715
719
- if (const SYCLIntelSchedulerTargetFmaxMhzAttr *A =
720
- FD->getAttr <SYCLIntelSchedulerTargetFmaxMhzAttr>()) {
721
- const auto *CE = dyn_cast<ConstantExpr>(A->getValue ());
722
- assert (CE && " Not an integer constant expression" );
716
+ if (const auto *A = FD->getAttr <SYCLIntelSchedulerTargetFmaxMhzAttr>()) {
717
+ const auto *CE = cast<ConstantExpr>(A->getValue ());
723
718
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt ();
724
719
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get (
725
720
Builder.getInt32 (ArgVal->getSExtValue ()))};
726
721
Fn->setMetadata (" scheduler_target_fmax_mhz" ,
727
722
llvm::MDNode::get (Context, AttrMDArgs));
728
723
}
729
724
730
- if (const SYCLIntelMaxGlobalWorkDimAttr *A =
731
- FD->getAttr <SYCLIntelMaxGlobalWorkDimAttr>()) {
732
- const auto *CE = dyn_cast<ConstantExpr>(A->getValue ());
733
- assert (CE && " Not an integer constant expression" );
725
+ if (const auto *A = FD->getAttr <SYCLIntelMaxGlobalWorkDimAttr>()) {
726
+ const auto *CE = cast<ConstantExpr>(A->getValue ());
734
727
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt ();
735
728
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get (
736
729
Builder.getInt32 (ArgVal->getSExtValue ()))};
@@ -760,12 +753,8 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
760
753
llvm::MDNode::get (Context, AttrMDArgs));
761
754
}
762
755
763
- if (const SYCLIntelNoGlobalWorkOffsetAttr *A =
764
- FD->getAttr <SYCLIntelNoGlobalWorkOffsetAttr>()) {
765
- const Expr *Arg = A->getValue ();
766
- assert (Arg && " Got an unexpected null argument" );
767
- const auto *CE = dyn_cast<ConstantExpr>(Arg);
768
- assert (CE && " Not an integer constant expression" );
756
+ if (const auto *A = FD->getAttr <SYCLIntelNoGlobalWorkOffsetAttr>()) {
757
+ const auto *CE = cast<ConstantExpr>(A->getValue ());
769
758
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt ();
770
759
if (ArgVal->getBoolValue ())
771
760
Fn->setMetadata (" no_global_work_offset" , llvm::MDNode::get (Context, {}));
0 commit comments