Skip to content

Commit 9f5c186

Browse files
Enable debug flag in all builds and conditionally run verification (#62)
1 parent 5ada032 commit 9f5c186

3 files changed

Lines changed: 16 additions & 24 deletions

File tree

src/numba/openmp/libs/pass/CGIntrinsicsOpenMP.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ OutlinedInfoStruct CGIntrinsicsOpenMP::createOutlinedFunction(
523523
DEBUG_ENABLE(dbgs() << "=== Dump OutlinedFn\n"
524524
<< *OutlinedFn << "=== End of Dump OutlinedFn\n");
525525

526-
if (verifyFunction(*OutlinedFn, &errs()))
526+
if (DebugOpenMPFlag && verifyFunction(*OutlinedFn, &errs()))
527527
FATAL_ERROR("Verification of OutlinedFn failed!");
528528

529529
CapturedVars.append(CapturedShared);
@@ -680,7 +680,7 @@ void CGIntrinsicsOpenMP::emitOMPParallelHostRuntime(
680680
DEBUG_ENABLE(dbgs() << "=== Dump OuterFn\n"
681681
<< *Fn << "=== End of Dump OuterFn\n");
682682

683-
if (verifyFunction(*Fn, &errs()))
683+
if (DebugOpenMPFlag && verifyFunction(*Fn, &errs()))
684684
FATAL_ERROR("Verification of OuterFn failed!");
685685
}
686686

@@ -756,7 +756,7 @@ void CGIntrinsicsOpenMP::emitOMPParallelDeviceRuntime(
756756
assert(OutlinedCI && "Expected valid call");
757757
OMPBuilder.Builder.CreateRetVoid();
758758

759-
if (verifyFunction(*OutlinedWrapperFn, &errs()))
759+
if (DebugOpenMPFlag && verifyFunction(*OutlinedWrapperFn, &errs()))
760760
FATAL_ERROR("Verification of OutlinedWrapperFn failed!");
761761

762762
DEBUG_ENABLE(dbgs() << "=== Dump OutlinedWrapper\n"
@@ -903,7 +903,7 @@ void CGIntrinsicsOpenMP::emitOMPParallelDeviceRuntime(
903903
DEBUG_ENABLE(dbgs() << "=== Dump OuterFn\n"
904904
<< *Fn << "=== End of Dump OuterFn\n");
905905

906-
if (verifyFunction(*Fn, &errs()))
906+
if (DebugOpenMPFlag && verifyFunction(*Fn, &errs()))
907907
FATAL_ERROR("Verification of OuterFn failed!");
908908
}
909909

@@ -1386,7 +1386,7 @@ void CGIntrinsicsOpenMP::emitLoop(DSAValueMapTy &DSAValueMap,
13861386
FATAL_ERROR("Failed to create barrier: " + toString(std::move(E)));
13871387
}
13881388

1389-
if (verifyFunction(*PreHeader->getParent(), &errs()))
1389+
if (DebugOpenMPFlag && verifyFunction(*PreHeader->getParent(), &errs()))
13901390
FATAL_ERROR("Verification of omp for lowering failed!");
13911391
}
13921392

@@ -2542,7 +2542,7 @@ void CGIntrinsicsOpenMP::emitOMPTeamsDeviceRuntime(
25422542
DEBUG_ENABLE(dbgs() << "=== Dump OuterFn\n"
25432543
<< *Fn << "=== End of Dump OuterFn\n");
25442544

2545-
if (verifyFunction(*Fn, &errs()))
2545+
if (DebugOpenMPFlag && verifyFunction(*Fn, &errs()))
25462546
FATAL_ERROR("Verification of OuterFn failed!");
25472547
}
25482548

@@ -2626,7 +2626,7 @@ void CGIntrinsicsOpenMP::emitOMPTeamsHostRuntime(
26262626
DEBUG_ENABLE(dbgs() << "=== Dump OuterFn\n"
26272627
<< *Fn << "=== End of Dump OuterFn\n");
26282628

2629-
if (verifyFunction(*Fn, &errs()))
2629+
if (DebugOpenMPFlag && verifyFunction(*Fn, &errs()))
26302630
FATAL_ERROR("Verification of OuterFn failed!");
26312631
}
26322632

src/numba/openmp/libs/pass/DebugOpenMP.h

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,18 @@
33

44
#include <string>
55

6-
#ifdef NDEBUG
7-
8-
#define DEBUG_ENABLE(X)
9-
#define DebugOpenMPInit()
10-
11-
#else
12-
136
extern bool DebugOpenMPFlag;
147
void DebugOpenMPInit();
158

169
#define DEBUG_ENABLE(X) \
17-
do { \
18-
if (DebugOpenMPFlag) { \
19-
X; \
20-
} \
21-
} while (false)
10+
do { \
11+
if (DebugOpenMPFlag) { \
12+
X; \
13+
} \
14+
} while (false)
2215

2316
#endif
2417

25-
[[noreturn]] void fatalError(const std::string &msg, const char *file, int line);
18+
[[noreturn]] void fatalError(const std::string &msg, const char *file,
19+
int line);
2620
#define FATAL_ERROR(msg) fatalError(msg, __FILE__, __LINE__)
27-
28-
#endif

src/numba/openmp/libs/pass/IntrinsicsOpenMP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ struct IntrinsicsOpenMP {
708708
FATAL_ERROR("Unknown directive");
709709
}
710710

711-
if (verifyFunction(*Fn, &errs()))
711+
if (DebugOpenMPFlag && verifyFunction(*Fn, &errs()))
712712
FATAL_ERROR("Verification of IntrinsicsOpenMP lowering failed!");
713713
}
714714
}
@@ -827,7 +827,7 @@ extern "C" int runIntrinsicsOpenMPPass(const char *BitcodePtr,
827827
MPM.run(*M, MAM);
828828

829829
// Verify the module before writing bitcode
830-
if (verifyModule(*M, &errs())) {
830+
if (DebugOpenMPFlag && verifyModule(*M, &errs())) {
831831
errs() << "ERROR: Module verification failed after IntrinsicsOpenMPPass\n";
832832
return 1;
833833
}

0 commit comments

Comments
 (0)