[clang] [clang] Emit @llvm.assume when we know the streaming mode of the function (PR #121917)
Sander de Smalen via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 04:05:41 PST 2025
================
@@ -11335,6 +11335,13 @@ Value *CodeGenFunction::EmitAArch64SMEBuiltinExpr(unsigned BuiltinID,
unsigned SMEAttrs = FPT->getAArch64SMEAttributes();
if (!(SMEAttrs & FunctionType::SME_PStateSMCompatibleMask)) {
bool IsStreaming = SMEAttrs & FunctionType::SME_PStateSMEnabledMask;
+ // Emit the llvm.assume intrinsic so that called functions can use the
+ // streaming mode information discerned here
+ Value *call =
+ Builder.CreateCall(CGM.getIntrinsic(Builtin->LLVMIntrinsic));
+ if (!IsStreaming)
+ call = Builder.CreateNot(call);
+ Builder.CreateIntrinsic(Intrinsic::assume, {}, {call});
----------------
sdesmalen-arm wrote:
Emitting the llvm.assume only for calls to `__arm_in_streaming_mode()` only has any effect if it is followed by a call to a streaming-compatible function.
To make this more useful generically, I think it needs to be emitted before any call from a streaming- or non-streaming function, to a streaming-compatible function. Then the partial-inliner, ipsccp pass, or function specialization pass can use the information to specialize or inline the callee.
https://github.com/llvm/llvm-project/pull/121917
More information about the cfe-commits
mailing list