[llvm] Fix dangling IPOAmendableCB function_ref. (PR #120698)
Haojian Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 00:06:01 PST 2025
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/120698
>From 92735cc31a5613ce4f0a5917fba2937bf650de0d Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
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 a8ee3cd531e490..28bce7b906652f 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<bool(const Function &F)>;
+ using IPOAmendableCBTy = std::function<bool(const Function &F)>;
IPOAmendableCBTy IPOAmendableCB;
};
More information about the llvm-commits
mailing list