是否可以在GCC / Clang上强制进行尾部调用优化? [英] Is it possible to force tail call optimization on GCC/Clang?

查看:68
本文介绍了是否可以在GCC / Clang上强制进行尾部调用优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试尽可能多地使用C编写函数式程序。
我知道像GCC / Clang这样的好的编译器会默默地进行尾部调用优化,但这并不能保证。是否可以在编译器上强制进行尾调用优化? (当然,只有在结束时才调用它)

I'm trying to write a program in functional style with C as much as possible. I know fine compilers like GCC/Clang do tail call optimization silently, but it's not guaranteed. Is there any option to force tail call optimization on the compilers? (Of course when only it's called at the end of itself)

推荐答案

Clang根本没有做任何优化。有LLVM通行证 tailcallelim 可以完成您想要的操作(但不能保证)。您可以使用 opt 单独运行它。

Clang is not doing any optimisations at all. There is an LLVM pass tailcallelim which may do what you want (but it is not guaranteed). You can run it separately with opt.

这篇关于是否可以在GCC / Clang上强制进行尾部调用优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆