[llvm] [OMPIRBuilder] Fix build failure after 151306. (PR #153061)

Abid Qadeer via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 11:07:02 PDT 2025


https://github.com/abidh created https://github.com/llvm/llvm-project/pull/153061

A function added in pr#151306 was under NDEBUG macro which caused the build to fail in certain cases. It has been moved out of the #ifdef check to ensure it is always compiled.

>From 5cd291df0aba8cbc70a8e7400f83b6d93f3b94f7 Mon Sep 17 00:00:00 2001
From: Abid Qadeer <haqadeer at amd.com>
Date: Mon, 11 Aug 2025 19:03:40 +0100
Subject: [PATCH] [OMPIRBuilder] Fix build failure after 151306.

A function added in pr#151306 was under NDEBUG macro which caused the
build to fail in certain cases. It has been moved out of the #ifdef
check to ensure it is always compiled.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 24 +++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 5ea8631c0706f..2ac9a0d3fbd66 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -92,18 +92,6 @@ static bool isConflictIP(IRBuilder<>::InsertPoint IP1,
   return IP1.getBlock() == IP2.getBlock() && IP1.getPoint() == IP2.getPoint();
 }
 
-/// This is wrapper over IRBuilderBase::restoreIP that also restores the current
-/// debug location to the last instruction in the specified basic block if the
-/// insert point points to the end of the block.
-static void restoreIPandDebugLoc(llvm::IRBuilderBase &Builder,
-                                 llvm::IRBuilderBase::InsertPoint IP) {
-  Builder.restoreIP(IP);
-  llvm::BasicBlock *BB = Builder.GetInsertBlock();
-  llvm::BasicBlock::iterator I = Builder.GetInsertPoint();
-  if (!BB->empty() && I == BB->end())
-    Builder.SetCurrentDebugLocation(BB->back().getStableDebugLoc());
-}
-
 static bool isValidWorkshareLoopScheduleType(OMPScheduleType SchedType) {
   // Valid ordered/unordered and base algorithm combinations.
   switch (SchedType & ~OMPScheduleType::MonotonicityMask) {
@@ -163,6 +151,18 @@ static bool isValidWorkshareLoopScheduleType(OMPScheduleType SchedType) {
 }
 #endif
 
+/// This is wrapper over IRBuilderBase::restoreIP that also restores the current
+/// debug location to the last instruction in the specified basic block if the
+/// insert point points to the end of the block.
+static void restoreIPandDebugLoc(llvm::IRBuilderBase &Builder,
+                                 llvm::IRBuilderBase::InsertPoint IP) {
+  Builder.restoreIP(IP);
+  llvm::BasicBlock *BB = Builder.GetInsertBlock();
+  llvm::BasicBlock::iterator I = Builder.GetInsertPoint();
+  if (!BB->empty() && I == BB->end())
+    Builder.SetCurrentDebugLocation(BB->back().getStableDebugLoc());
+}
+
 static const omp::GV &getGridValue(const Triple &T, Function *Kernel) {
   if (T.isAMDGPU()) {
     StringRef Features =



More information about the llvm-commits mailing list