@@ -2937,12 +2937,21 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
2937
2937
&getTarget().getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
2938
2938
BuiltinID = mutateLongDoubleBuiltin(BuiltinID);
2939
2939
2940
- // If the builtin has been declared explicitly with an assembler label,
2941
- // disable the specialized emitting below. Ideally we should communicate the
2942
- // rename in IR, or at least avoid generating the intrinsic calls that are
2943
- // likely to get lowered to the renamed library functions.
2944
- const unsigned BuiltinIDIfNoAsmLabel =
2945
- FD->hasAttr<AsmLabelAttr>() ? 0 : BuiltinID;
2940
+ const unsigned BuiltinIDIfEmitIntrinsics = [&] {
2941
+ // If the builtin has been declared explicitly with an assembler label,
2942
+ // disable the specialized emitting below. Ideally we should communicate the
2943
+ // rename in IR, or at least avoid generating the intrinsic calls that are
2944
+ // likely to get lowered to the renamed library functions.
2945
+ if (FD->hasAttr<AsmLabelAttr>())
2946
+ return 0U;
2947
+
2948
+ // If the target requests not to use intrinsics for a builtin, disable the
2949
+ // specialized emitting below.
2950
+ if (!getTargetHooks().shouldUseIntrinsicsForBuiltin(BuiltinID))
2951
+ return 0U;
2952
+
2953
+ return BuiltinID;
2954
+ }();
2946
2955
2947
2956
std::optional<bool> ErrnoOverriden;
2948
2957
// ErrnoOverriden is true if math-errno is overriden via the
@@ -3035,7 +3044,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
3035
3044
ConstWithoutErrnoOrExceptions && ErrnoOverridenToFalseWithOpt;
3036
3045
}
3037
3046
if (GenerateIntrinsics) {
3038
- switch (BuiltinIDIfNoAsmLabel ) {
3047
+ switch (BuiltinIDIfEmitIntrinsics ) {
3039
3048
case Builtin::BIacos:
3040
3049
case Builtin::BIacosf:
3041
3050
case Builtin::BIacosl:
@@ -3515,7 +3524,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
3515
3524
}
3516
3525
};
3517
3526
3518
- switch (BuiltinIDIfNoAsmLabel ) {
3527
+ switch (BuiltinIDIfEmitIntrinsics ) {
3519
3528
default: break;
3520
3529
case Builtin::BI__builtin___CFStringMakeConstantString:
3521
3530
case Builtin::BI__builtin___NSStringMakeConstantString:
@@ -3645,7 +3654,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
3645
3654
case Builtin::BI__builtin_ctzl:
3646
3655
case Builtin::BI__builtin_ctzll:
3647
3656
case Builtin::BI__builtin_ctzg: {
3648
- bool HasFallback = BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_ctzg &&
3657
+ bool HasFallback = BuiltinIDIfEmitIntrinsics == Builtin::BI__builtin_ctzg &&
3649
3658
E->getNumArgs() > 1;
3650
3659
3651
3660
Value *ArgValue =
@@ -3677,7 +3686,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
3677
3686
case Builtin::BI__builtin_clzl:
3678
3687
case Builtin::BI__builtin_clzll:
3679
3688
case Builtin::BI__builtin_clzg: {
3680
- bool HasFallback = BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_clzg &&
3689
+ bool HasFallback = BuiltinIDIfEmitIntrinsics == Builtin::BI__builtin_clzg &&
3681
3690
E->getNumArgs() > 1;
3682
3691
3683
3692
Value *ArgValue =
@@ -4347,7 +4356,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
4347
4356
Ty = VecTy->getElementType();
4348
4357
bool IsSigned = Ty->isSignedIntegerType();
4349
4358
unsigned Opc;
4350
- if (BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_elementwise_add_sat)
4359
+ if (BuiltinIDIfEmitIntrinsics == Builtin::BI__builtin_elementwise_add_sat)
4351
4360
Opc = IsSigned ? llvm::Intrinsic::sadd_sat : llvm::Intrinsic::uadd_sat;
4352
4361
else
4353
4362
Opc = IsSigned ? llvm::Intrinsic::ssub_sat : llvm::Intrinsic::usub_sat;
0 commit comments