<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 5, 2014 at 6:37 PM, Kevin Qin <span dir="ltr"><<a href="mailto:kevinqindev@gmail.com" target="_blank">kevinqindev@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This commit make trunk broken. Please have a look.</div></blockquote><div><br></div><div>This was already reverted. =)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>In file included from /home/kevin/llvm_trunk/llvm/include/llvm/Support/CrashRecoveryContext.h:15:0,</div>
<div> from /home/kevin/llvm_trunk/llvm/lib/Support/CrashRecoveryContext.cpp:10:</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h: In instantiation of ‘static Ret llvm::function_ref<Ret()>::callback_fn(void*) [with Callable = llvm::CrashRecoveryContext::RunSafely(void (*)(void*), void*)::__lambda0; Ret = void]’:</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:105:53: required from ‘llvm::function_ref<Ret()>::function_ref(Callable&&) [with Callable = llvm::CrashRecoveryContext::RunSafely(void (*)(void*), void*)::__lambda0; Ret = void]’</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/Support/CrashRecoveryContext.h:82:45: required from here</div><div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:98:51: error: ‘void*’ is not a pointer-to-object type</div>
<div> return reinterpret_cast<Callable&>(*callable)();</div><div> ^</div><div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:98:51: error: return-statement with a value, in function returning 'void' [-fpermissive]</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h: In instantiation of ‘static Ret llvm::function_ref<Ret()>::callback_fn(void*) [with Callable = llvm::CrashRecoveryContext::RunSafelyOnThread(void (*)(void*), void*, unsigned int)::__lambda1; Ret = void]’:</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:105:53: required from ‘llvm::function_ref<Ret()>::function_ref(Callable&&) [with Callable = llvm::CrashRecoveryContext::RunSafelyOnThread(void (*)(void*), void*, unsigned int)::__lambda1; Ret = void]’</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/Support/CrashRecoveryContext.h:93:73: required from here</div><div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:98:51: error: ‘void*’ is not a pointer-to-object type</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:98:51: error: return-statement with a value, in function returning 'void' [-fpermissive]</div><div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h: In instantiation of ‘static Ret llvm::function_ref<Ret()>::callback_fn(void*) [with Callable = llvm::function_ref<void()>&; Ret = void]’:</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:105:53: required from ‘llvm::function_ref<Ret()>::function_ref(Callable&&) [with Callable = llvm::function_ref<void()>&; Ret = void]’</div>
<div>/home/kevin/llvm_trunk/llvm/lib/Support/CrashRecoveryContext.cpp:346:47: required from here</div><div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:98:51: error: ‘void*’ is not a pointer-to-object type</div>
<div>/home/kevin/llvm_trunk/llvm/include/llvm/ADT/STLExtras.h:98:51: error: return-statement with a value, in function returning 'void' [-fpermissive]</div><div>make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/CrashRecoveryContext.cpp.o] Error 1</div>
<div>make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-06 9:01 GMT+08:00 Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@metafoo.co.uk</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon May 5 20:01:29 2014<br>
New Revision: 208025<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=208025&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=208025&view=rev</a><br>
Log:<br>
Add llvm::function_ref (and a couple of uses of it), representing a type-erased reference to a callable object.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/ADT/STLExtras.h<br>
llvm/trunk/include/llvm/Support/CrashRecoveryContext.h<br>
llvm/trunk/include/llvm/Transforms/Utils/CtorUtils.h<br>
llvm/trunk/lib/Support/CrashRecoveryContext.cpp<br>
llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp<br>
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp<br>
llvm/trunk/lib/Transforms/Utils/CtorUtils.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/STLExtras.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Mon May 5 20:01:29 2014<br>
@@ -55,6 +55,131 @@ struct greater_ptr : public std::binary_<br>
}<br>
};<br>
<br>
+/// An efficient, type-erasing, non-owning reference to a callable. This is<br>
+/// intended for use as the type of a function parameter that is not used<br>
+/// after the function in question returns.<br>
+///<br>
+/// This class does not own the callable, so it is not in general safe to store<br>
+/// a function_ref.<br>
+template<typename Fn> class function_ref;<br>
+<br>
+#if LLVM_HAS_VARIADIC_TEMPLATES<br>
+<br>
+template<typename Ret, typename ...Params><br>
+class function_ref<Ret(Params...)> {<br>
+ Ret (*callback)(void *callable, Params ...params);<br>
+ void *callable;<br>
+<br>
+ template<typename Callable><br>
+ static Ret callback_fn(void *callable, Params ...params) {<br>
+ return reinterpret_cast<Callable&>(*callable)(<br>
+ std::forward<Params>(params)...);<br>
+ }<br>
+<br>
+public:<br>
+ template<typename Callable><br>
+ function_ref(Callable &&callable)<br>
+ : callback(callback_fn<Callable>),<br>
+ callable(reinterpret_cast<void *>(&callable)) {}<br>
+ Ret operator()(Params ...params) const {<br>
+ return callback(callable, std::forward<Params>(params)...);<br>
+ }<br>
+};<br>
+<br>
+#else<br>
+<br>
+template<typename Ret><br>
+class function_ref<Ret()> {<br>
+ Ret (*callback)(void *callable);<br>
+ void *callable;<br>
+<br>
+ template<typename Callable><br>
+ static Ret callback_fn(void *callable) {<br>
+ return reinterpret_cast<Callable&>(*callable)();<br>
+ }<br>
+<br>
+public:<br>
+ template<typename Callable><br>
+ function_ref(Callable &&callable)<br>
+ : callback(callback_fn<Callable>),<br>
+ callable(reinterpret_cast<void *>(&callable)) {}<br>
+ Ret operator()() const { return callback(callable); }<br>
+};<br>
+<br>
+template<typename Ret, typename Param1><br>
+class function_ref<Ret(Param1)> {<br>
+ Ret (*callback)(void *callable, Param1 param1);<br>
+ void *callable;<br>
+<br>
+ template<typename Callable><br>
+ static Ret callback_fn(void *callable, Param1 param1) {<br>
+ return reinterpret_cast<Callable&>(*callable)(<br>
+ std::forward<Param1>(param1));<br>
+ }<br>
+<br>
+public:<br>
+ template<typename Callable><br>
+ function_ref(Callable &&callable)<br>
+ : callback(callback_fn<Callable>),<br>
+ callable(reinterpret_cast<void *>(&callable)) {}<br>
+ Ret operator()(Param1 param1) {<br>
+ return callback(callable, std::forward<Param1>(param1));<br>
+ }<br>
+};<br>
+<br>
+template<typename Ret, typename Param1, typename Param2><br>
+class function_ref<Ret(Param1, Param2)> {<br>
+ Ret (*callback)(void *callable, Param1 param1, Param2 param2);<br>
+ void *callable;<br>
+<br>
+ template<typename Callable><br>
+ static Ret callback_fn(void *callable, Param1 param1, Param2 param2) {<br>
+ return reinterpret_cast<Callable&>(*callable)(<br>
+ std::forward<Param1>(param1),<br>
+ std::forward<Param2>(param2));<br>
+ }<br>
+<br>
+public:<br>
+ template<typename Callable><br>
+ function_ref(Callable &&callable)<br>
+ : callback(callback_fn<Callable>),<br>
+ callable(reinterpret_cast<void *>(&callable)) {}<br>
+ Ret operator()(Param1 param1, Param2 param2) {<br>
+ return callback(callable,<br>
+ std::forward<Param1>(param1),<br>
+ std::forward<Param2>(param2));<br>
+ }<br>
+};<br>
+<br>
+template<typename Ret, typename Param1, typename Param2, typename Param3><br>
+class function_ref<Ret(Param1, Param2, Param3)> {<br>
+ Ret (*callback)(void *callable, Param1 param1, Param2 param2, Param3 param3);<br>
+ void *callable;<br>
+<br>
+ template<typename Callable><br>
+ static Ret callback_fn(void *callable, Param1 param1, Param2 param2,<br>
+ Param3 param3) {<br>
+ return reinterpret_cast<Callable&>(*callable)(<br>
+ std::forward<Param1>(param1),<br>
+ std::forward<Param2>(param2),<br>
+ std::forward<Param3>(param3));<br>
+ }<br>
+<br>
+public:<br>
+ template<typename Callable><br>
+ function_ref(Callable &&callable)<br>
+ : callback(callback_fn<Callable>),<br>
+ callable(reinterpret_cast<void *>(&callable)) {}<br>
+ Ret operator()(Param1 param1, Param2 param2, Param3 param3) {<br>
+ return callback(callable,<br>
+ std::forward<Param1>(param1),<br>
+ std::forward<Param2>(param2),<br>
+ std::forward<Param3>(param3));<br>
+ }<br>
+};<br>
+<br>
+#endif<br>
+<br>
// deleter - Very very very simple method that is used to invoke operator<br>
// delete on something. It is used like this:<br>
//<br>
<br>
Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/CrashRecoveryContext.h (original)<br>
+++ llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Mon May 5 20:01:29 2014<br>
@@ -12,11 +12,13 @@<br>
<br>
#include <string><br>
<br>
+#include "llvm/ADT/STLExtras.h"<br>
+<br>
namespace llvm {<br>
class StringRef;<br>
<br>
class CrashRecoveryContextCleanup;<br>
-<br>
+<br>
/// \brief Crash recovery helper object.<br>
///<br>
/// This class implements support for running operations in a safe context so<br>
@@ -46,21 +48,10 @@ class CrashRecoveryContext {<br>
void *Impl;<br>
CrashRecoveryContextCleanup *head;<br>
<br>
- /// An adaptor to convert an arbitrary functor into a void(void*), void* pair.<br>
- template<typename T> struct FunctorAdaptor {<br>
- T Fn;<br>
- static void invoke(void *Data) {<br>
- return static_cast<FunctorAdaptor<T>*>(Data)->Fn();<br>
- }<br>
- typedef void Callback(void*);<br>
- Callback *fn() { return &invoke; }<br>
- void *arg() { return this; }<br>
- };<br>
-<br>
public:<br>
CrashRecoveryContext() : Impl(nullptr), head(nullptr) {}<br>
~CrashRecoveryContext();<br>
-<br>
+<br>
void registerCleanup(CrashRecoveryContextCleanup *cleanup);<br>
void unregisterCleanup(CrashRecoveryContextCleanup *cleanup);<br>
<br>
@@ -86,11 +77,9 @@ public:<br>
/// make as little assumptions as possible about the program state when<br>
/// RunSafely has returned false. Clients can use getBacktrace() to retrieve<br>
/// the backtrace of the crash on failures.<br>
- bool RunSafely(void (*Fn)(void*), void *UserData);<br>
- template<typename Functor><br>
- bool RunSafely(Functor Fn) {<br>
- FunctorAdaptor<Functor> Adaptor = { Fn };<br>
- return RunSafely(Adaptor.fn(), Adaptor.arg());<br>
+ bool RunSafely(function_ref<void()> Fn);<br>
+ bool RunSafely(void (*Fn)(void*), void *UserData) {<br>
+ return RunSafely([&]() { Fn(UserData); });<br>
}<br>
<br>
/// \brief Execute the provide callback function (with the given arguments) in<br>
@@ -98,12 +87,10 @@ public:<br>
/// requested stack size).<br>
///<br>
/// See RunSafely() and llvm_execute_on_thread().<br>
+ bool RunSafelyOnThread(function_ref<void()>, unsigned RequestedStackSize = 0);<br>
bool RunSafelyOnThread(void (*Fn)(void*), void *UserData,<br>
- unsigned RequestedStackSize = 0);<br>
- template<typename Functor><br>
- bool RunSafelyOnThread(Functor Fn, unsigned RequestedStackSize = 0) {<br>
- FunctorAdaptor<Functor> Adaptor = { Fn };<br>
- return RunSafelyOnThread(Adaptor.fn(), Adaptor.arg(), RequestedStackSize);<br>
+ unsigned RequestedStackSize = 0) {<br>
+ return RunSafelyOnThread([&]() { Fn(UserData); }, RequestedStackSize);<br>
}<br>
<br>
/// \brief Explicitly trigger a crash recovery in the current process, and<br>
<br>
Modified: llvm/trunk/include/llvm/Transforms/Utils/CtorUtils.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/CtorUtils.h?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/CtorUtils.h?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Transforms/Utils/CtorUtils.h (original)<br>
+++ llvm/trunk/include/llvm/Transforms/Utils/CtorUtils.h Mon May 5 20:01:29 2014<br>
@@ -14,8 +14,7 @@<br>
#ifndef LLVM_TRANSFORMS_UTILS_CTOR_UTILS_H<br>
#define LLVM_TRANSFORMS_UTILS_CTOR_UTILS_H<br>
<br>
-#include <functional><br>
-#include <vector><br>
+#include "llvm/ADT/STLExtras.h"<br>
<br>
namespace llvm {<br>
<br>
@@ -23,12 +22,10 @@ class GlobalVariable;<br>
class Function;<br>
class Module;<br>
<br>
-typedef bool (*ShouldRemoveCtor)(void *, Function *);<br>
-<br>
/// Call "ShouldRemove" for every entry in M's global_ctor list and remove the<br>
/// entries for which it returns true. Return true if anything changed.<br>
-bool optimizeGlobalCtorsList(Module &M, ShouldRemoveCtor ShouldRemove,<br>
- void *Context);<br>
+bool optimizeGlobalCtorsList(Module &M,<br>
+ function_ref<bool(Function *)> ShouldRemove);<br>
<br>
} // End llvm namespace<br>
<br>
<br>
Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/CrashRecoveryContext.cpp (original)<br>
+++ llvm/trunk/lib/Support/CrashRecoveryContext.cpp Mon May 5 20:01:29 2014<br>
@@ -301,7 +301,7 @@ void CrashRecoveryContext::Disable() {<br>
<br>
#endif<br>
<br>
-bool CrashRecoveryContext::RunSafely(void (*Fn)(void*), void *UserData) {<br>
+bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) {<br>
// If crash recovery is disabled, do nothing.<br>
if (gCrashRecoveryEnabled) {<br>
assert(!Impl && "Crash recovery context already initialized!");<br>
@@ -313,7 +313,7 @@ bool CrashRecoveryContext::RunSafely(voi<br>
}<br>
}<br>
<br>
- Fn(UserData);<br>
+ Fn();<br>
return true;<br>
}<br>
<br>
@@ -334,8 +334,7 @@ const std::string &CrashRecoveryContext:<br>
<br>
namespace {<br>
struct RunSafelyOnThreadInfo {<br>
- void (*Fn)(void*);<br>
- void *Data;<br>
+ function_ref<void()> Fn;<br>
CrashRecoveryContext *CRC;<br>
bool Result;<br>
};<br>
@@ -344,11 +343,11 @@ struct RunSafelyOnThreadInfo {<br>
static void RunSafelyOnThread_Dispatch(void *UserData) {<br>
RunSafelyOnThreadInfo *Info =<br>
reinterpret_cast<RunSafelyOnThreadInfo*>(UserData);<br>
- Info->Result = Info->CRC->RunSafely(Info->Fn, Info->Data);<br>
+ Info->Result = Info->CRC->RunSafely(Info->Fn);<br>
}<br>
-bool CrashRecoveryContext::RunSafelyOnThread(void (*Fn)(void*), void *UserData,<br>
+bool CrashRecoveryContext::RunSafelyOnThread(function_ref<void()> Fn,<br>
unsigned RequestedStackSize) {<br>
- RunSafelyOnThreadInfo Info = { Fn, UserData, this, false };<br>
+ RunSafelyOnThreadInfo Info = { Fn, this, false };<br>
llvm_execute_on_thread(RunSafelyOnThread_Dispatch, &Info, RequestedStackSize);<br>
if (CrashRecoveryContextImpl *CRC = (CrashRecoveryContextImpl *)Impl)<br>
CRC->setSwitchedThread();<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp Mon May 5 20:01:29 2014<br>
@@ -54,16 +54,16 @@ namespace {<br>
<br>
bool RemoveUnusedGlobalValue(GlobalValue &GV);<br>
};<br>
+}<br>
<br>
/// Returns true if F contains only a single "ret" instruction.<br>
-bool isEmptyFunction(void *Context, Function *F) {<br>
+static bool isEmptyFunction(Function *F) {<br>
BasicBlock &Entry = F->getEntryBlock();<br>
if (Entry.size() != 1 || !isa<ReturnInst>(Entry.front()))<br>
return false;<br>
ReturnInst &RI = cast<ReturnInst>(Entry.front());<br>
return RI.getReturnValue() == NULL;<br>
}<br>
-}<br>
<br>
char GlobalDCE::ID = 0;<br>
INITIALIZE_PASS(GlobalDCE, "globaldce",<br>
@@ -75,7 +75,7 @@ bool GlobalDCE::runOnModule(Module &M) {<br>
bool Changed = false;<br>
<br>
// Remove empty functions from the global ctors list.<br>
- Changed |= optimizeGlobalCtorsList(M, isEmptyFunction, nullptr);<br>
+ Changed |= optimizeGlobalCtorsList(M, isEmptyFunction);<br>
<br>
// Loop over the module, adding globals which are obviously necessary.<br>
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon May 5 20:01:29 2014<br>
@@ -3022,10 +3022,9 @@ bool GlobalOpt::runOnModule(Module &M) {<br>
LocalChange |= OptimizeFunctions(M);<br>
<br>
// Optimize global_ctors list.<br>
- LocalChange |= optimizeGlobalCtorsList(M, [](void *C, Function *F) -> bool {<br>
- GlobalOpt *self = static_cast<GlobalOpt *>(C);<br>
- return EvaluateStaticConstructor(F, self->DL, self->TLI);<br>
- }, this);<br>
+ LocalChange |= optimizeGlobalCtorsList(M, [&](Function *F) {<br>
+ return EvaluateStaticConstructor(F, DL, TLI);<br>
+ });<br>
<br>
// Optimize non-address-taken globals.<br>
LocalChange |= OptimizeGlobalVars(M);<br>
<br>
Modified: llvm/trunk/lib/Transforms/Utils/CtorUtils.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CtorUtils.cpp?rev=208025&r1=208024&r2=208025&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CtorUtils.cpp?rev=208025&r1=208024&r2=208025&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Utils/CtorUtils.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Utils/CtorUtils.cpp Mon May 5 20:01:29 2014<br>
@@ -132,8 +132,8 @@ GlobalVariable *findGlobalCtors(Module &<br>
<br>
/// Call "ShouldRemove" for every entry in M's global_ctor list and remove the<br>
/// entries for which it returns true. Return true if anything changed.<br>
-bool optimizeGlobalCtorsList(Module &M, ShouldRemoveCtor ShouldRemove,<br>
- void *Context) {<br>
+bool optimizeGlobalCtorsList(Module &M,<br>
+ function_ref<bool(Function *)> ShouldRemove) {<br>
GlobalVariable *GlobalCtors = findGlobalCtors(M);<br>
if (!GlobalCtors)<br>
return false;<br>
@@ -163,7 +163,7 @@ bool optimizeGlobalCtorsList(Module &M,<br>
continue;<br>
<br>
// If we can evaluate the ctor at compile time, do.<br>
- if (ShouldRemove(Context, F)) {<br>
+ if (ShouldRemove(F)) {<br>
Ctors.erase(Ctors.begin() + i);<br>
MadeChange = true;<br>
--i;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Best Regards,<div><br></div><div>Kevin Qin</div></div>
</font></span></div>
</blockquote></div><br></div></div>