-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[consteval] The mixed use of 'consteval' and 'constexpr' takes longer time to compile #62947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-c-20 |
@llvm/issue-subscribers-clang-frontend |
CC folks who might know where the main culprit is or may know how the determine it @erichkeane @zygoloid @tbaederr |
I don't have much familiarity with the consteval code, @AaronBallman and @Fznamznon are the two who have been spending the most time doing that lately. |
I don't know if this is helpful, but I ran the example with -ftime-trace and put the .json into speedscope, and interestingly it's not that something is really slower but rather it's simply computed twice. The constexpr case has
The consteval case has
as well as
both taking roughly the same time as the single constexpr case. So really, only EvaluateAsConstantExpr is performed twice which doubles the compile time. |
Seems similar to #61425 |
Agreed, this seems to be a duplicate of #61425. |
I don't think this is a duplicate. #61425 would cover the repeated calls to Presumably the issue here is that the constant evaluator is stepping into |
Oh, thank you for observing that! I've reopened the issue. |
@zygoloid Thanks!
|
IIUC the
where we'd otherwise have two nested The way I think this was supposed to work is that we build the inner call and its |
The reproducer:
Let's run:
time clang++ -std=c++20 -fconstexpr-steps=4294967295 -c Fib.cpp
in my computer it shows:
But if I change
Recursive
intoconsteval
, the result will be:it shows now it takes double times to compile the source.
The text was updated successfully, but these errors were encountered: