Jan =?utf-8?q?Górski?= <jan.a.gor...@wp.pl>, Jan =?utf-8?q?Górski?= <jan.a.gor...@wp.pl> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/133...@github.com>
================ @@ -590,6 +590,29 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest, llvm::LoadInst *Load = CGF.Builder.CreateLoad(Ptr); Load->setAtomic(Order, Scope); Load->setVolatile(E->isVolatile()); + + if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { + CGF.Builder.CreateStore(Load, Dest); + return; + } + + QualType Ty = E->getValueType(); + if (!Ty->isBooleanType()) { + CGF.Builder.CreateStore(Load, Dest); + return; + } + + llvm::MDBuilder MDHelper(CGF.getLLVMContext()); + llvm::APInt BooleanMin = llvm::APInt(CGF.getContext().getTypeSize(Ty), 0); + llvm::APInt BooleanEnd = llvm::APInt(CGF.getContext().getTypeSize(Ty), 2); + + if (llvm::MDNode *RangeInfo = + MDHelper.createRange(BooleanMin, BooleanEnd)) { ---------------- efriedma-quic wrote: Please refactor the code from CodeGenFunction::EmitLoadOfScalar, instead of reinventing the code to compute the range metadata. https://github.com/llvm/llvm-project/pull/133546 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits