[PATCH] D144334: [Clang] Add C++2b attribute [[assume(expression)]]

Evgeny Shulgin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 21 11:54:40 PST 2023


Izaron marked an inline comment as done.
Izaron added a comment.

In D144334#4142490 <https://reviews.llvm.org/D144334#4142490>, @erichkeane wrote:

> Just deliberately not support a part of C++2b.  Implementers have veto'ed features in the past exactly that way.

That's sad. Let's at least write some warning on the `cxx_status.html` like "we aren't gonna implement it".



================
Comment at: clang/lib/CodeGen/CGStmt.cpp:723-727
+    case attr::Assume: {
+      llvm::Value *ArgValue = EmitScalarExpr(cast<AssumeAttr>(A)->getCond());
+      llvm::Function *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
+      Builder.CreateCall(FnAssume, ArgValue);
+      break;
----------------
cor3ntin wrote:
> I'm not familiar with codegen. what makes the expression non-evaluated here?
The LLVM docs says it: https://llvm.org/docs/LangRef.html#llvm-assume-intrinsic
> No code is generated for this intrinsic, and instructions that contribute only to the provided condition are not used for code generation
The `ArgValue` and `FnAssume` are the instructions to be discarded according to this sentence.

I guess they do it via dead code elimination (at any optimization level).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144334



More information about the cfe-commits mailing list