@@ -551,14 +551,6 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
551551 CurFn->addFnAttr (" min-legal-vector-width" ,
552552 llvm::utostr (LargestVectorWidth));
553553
554- // Add vscale_range attribute if appropriate.
555- std::optional<std::pair<unsigned , unsigned >> VScaleRange =
556- getContext ().getTargetInfo ().getVScaleRange (getLangOpts ());
557- if (VScaleRange) {
558- CurFn->addFnAttr (llvm::Attribute::getWithVScaleRangeArgs (
559- getLLVMContext (), VScaleRange->first , VScaleRange->second ));
560- }
561-
562554 // If we generated an unreachable return block, delete it now.
563555 if (ReturnBlock.isValid () && ReturnBlock.getBlock ()->use_empty ()) {
564556 Builder.ClearInsertionPoint ();
@@ -1110,6 +1102,15 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
11101102 if (FD && FD->isMain ())
11111103 Fn->removeFnAttr (" zero-call-used-regs" );
11121104
1105+ // Add vscale_range attribute if appropriate.
1106+ std::optional<std::pair<unsigned , unsigned >> VScaleRange =
1107+ getContext ().getTargetInfo ().getVScaleRange (
1108+ getLangOpts (), FD ? IsArmStreamingFunction (FD, true ) : false );
1109+ if (VScaleRange) {
1110+ CurFn->addFnAttr (llvm::Attribute::getWithVScaleRangeArgs (
1111+ getLLVMContext (), VScaleRange->first , VScaleRange->second ));
1112+ }
1113+
11131114 llvm::BasicBlock *EntryBB = createBasicBlock (" entry" , CurFn);
11141115
11151116 // Create a marker to make it easy to insert allocas into the entryblock
0 commit comments