From 92735cc31a5613ce4f0a5917fba2937bf650de0d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 20 Dec 2024 09:42:56 +0100 Subject: [PATCH] Fix dangling IPOAmendableCB function_ref. A temporary lambda is assigned to a llvm::function_ref, this lambda is destroyed at the end of the full expression, any use of the function_ref afterwards is undefined behavior. --- llvm/include/llvm/Transforms/IPO/Attributor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index a8ee3cd531e49..28bce7b906652 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1478,7 +1478,7 @@ struct AttributorConfig { /// The name of the pass running the attributor, used to emit remarks. const char *PassName = nullptr; - using IPOAmendableCBTy = function_ref; + using IPOAmendableCBTy = std::function; IPOAmendableCBTy IPOAmendableCB; };