[PATCH] D60942: Emit diagnostic if inline asm "n" constraint isn't an immediate

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 17:23:31 PDT 2019


void added a comment.

In D60942#1500730 <https://reviews.llvm.org/D60942#1500730>, @joerg wrote:

> On the frontend side:
>
> - __builtin_constant_p is not expanded correctly in EvalConstant.cpp when used as part of codegen for -O0. This means that trivially unreachable branches are emitted (e.g. with a BR with a literal false as condition),
> - The constant evaluator has a general problem with overly pessimistic analysis when it comes to possible side effects. Still have to discuss the correct handling with Richard for this.


GCC has this to say about `__builtin_constant_p`'s behavior:

> A return of 0 does not indicate that the value is not a constant, but merely that GCC cannot prove it is a constant with the specified value of the -O option.

When I was modifying our implementation recently, I made it so that if there are no optimizations then we evaluate to `0` in the front-end before code-gen. It might be that those blocks are being emitted, but they should have something like `br i1 false, label %true_bb, label %false_bb` or equivalent.

> On the backend side:
> 
> - The is_constant intrinsic is lowered too late. The prepare-isel pass it is currently part of is run after the last SimplifyCFG pass, so the now-dead basic blocks are never pruned and therefore the asm statements survive.

Is this at `-O0` or all optimization levels?

> All that said, with the discussed generalization from literal 'n' to 'expects immediate', I think this code solves the part of the problem it is meant to solve.

W00T!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60942/new/

https://reviews.llvm.org/D60942





More information about the llvm-commits mailing list