erichkeane added inline comments.
================ 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; ---------------- Izaron wrote: > 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). So interestingly, with __builtin_assume, we have some code that checks for side-effects (https://godbolt.org/z/fo73TvY68) and just doesn't emit the assume at all into IR. I believe we are not able to do that (as side-effects don't prevent attribute-assume from having 'an effect'), so additional work needs to happen to make sure an example like the above has those side effects removed, but considered by the backend. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144334/new/ https://reviews.llvm.org/D144334 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits