From 676a789a5bc6d42838d01a1cddf8281dc1e058de Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Mon, 24 May 2021 17:14:17 -0700 Subject: [PATCH] [NFC][OMP] Fix 'unused' warning --- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 40 +++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index e192164f58cb..74f91e5862e5 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -2386,15 +2386,18 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicUpdate( if (!updateToLocation(Loc)) return Loc.IP; - Type *XTy = X.Var->getType(); - assert(XTy->isPointerTy() && "OMP Atomic expects a pointer to target memory"); - Type *XElemTy = XTy->getPointerElementType(); - assert((XElemTy->isFloatingPointTy() || XElemTy->isIntegerTy() || - XElemTy->isPointerTy()) && - "OMP atomic update expected a scalar type"); - assert((RMWOp != AtomicRMWInst::Max) && (RMWOp != AtomicRMWInst::Min) && - (RMWOp != AtomicRMWInst::UMax) && (RMWOp != AtomicRMWInst::UMin) && - "OpenMP atomic does not support LT or GT operations"); + LLVM_DEBUG({ + Type *XTy = X.Var->getType(); + assert(XTy->isPointerTy() && + "OMP Atomic expects a pointer to target memory"); + Type *XElemTy = XTy->getPointerElementType(); + assert((XElemTy->isFloatingPointTy() || XElemTy->isIntegerTy() || + XElemTy->isPointerTy()) && + "OMP atomic update expected a scalar type"); + assert((RMWOp != AtomicRMWInst::Max) && (RMWOp != AtomicRMWInst::Min) && + (RMWOp != AtomicRMWInst::UMax) && (RMWOp != AtomicRMWInst::UMin) && + "OpenMP atomic does not support LT or GT operations"); + }); emitAtomicUpdate(AllocIP, X.Var, Expr, AO, RMWOp, UpdateOp, X.IsVolatile, IsXLHSInRHSPart); @@ -2536,14 +2539,17 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicCapture( if (!updateToLocation(Loc)) return Loc.IP; - Type *XTy = X.Var->getType(); - assert(XTy->isPointerTy() && "OMP Atomic expects a pointer to target memory"); - Type *XElemTy = XTy->getPointerElementType(); - assert((XElemTy->isFloatingPointTy() || XElemTy->isIntegerTy() || - XElemTy->isPointerTy()) && - "OMP atomic capture expected a scalar type"); - assert((RMWOp != AtomicRMWInst::Max) && (RMWOp != AtomicRMWInst::Min) && - "OpenMP atomic does not support LT or GT operations"); + LLVM_DEBUG({ + Type *XTy = X.Var->getType(); + assert(XTy->isPointerTy() && + "OMP Atomic expects a pointer to target memory"); + Type *XElemTy = XTy->getPointerElementType(); + assert((XElemTy->isFloatingPointTy() || XElemTy->isIntegerTy() || + XElemTy->isPointerTy()) && + "OMP atomic capture expected a scalar type"); + assert((RMWOp != AtomicRMWInst::Max) && (RMWOp != AtomicRMWInst::Min) && + "OpenMP atomic does not support LT or GT operations"); + }); // If UpdateExpr is 'x' updated with some `expr` not based on 'x', // 'x' is simply atomically rewritten with 'expr'.