[cfe-dev] Folding constexpr function calls with constant arguments in non constant expression contexts

Roger Ferrer Ibanez via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 22 01:57:52 PST 2017


Hi all,

maybe this is just a silly question. But I wondered why clang is not attempting to fold calls to constexpr functions in non-constant expression contexts.

Example:  https://godbolt.org/g/KBaMjp just compare "one" vs "two" in the IR

I understand that clang does not have to do this and I'm not saying it should.

But I'd like to know what is the rationale here.
- Is it a C++ Standard issue?, i.e. doing that would trigger some side-effects that would be non-compliant.
- Is it a "separation of concerns" issue?, i.e. let LLVM optimize these cases and improve if it can't.
- Is it a speed issue?, i.e. even if the original AST is preserved for fidelity, computing an associated constant value to it takes time which is precious for some clients.

Or maybe it is something else that didn't occur to me.

Thank you,
Roger
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.



More information about the cfe-dev mailing list