[llvm] r266514 - Do not modify a cl::opt programmatically, global mutable state is evil.
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 15 21:58:31 PDT 2016
Author: mehdi_amini
Date: Fri Apr 15 23:58:30 2016
New Revision: 266514
URL: http://llvm.org/viewvc/llvm-project?rev=266514&view=rev
Log:
Do not modify a cl::opt programmatically, global mutable state is evil.
Found by TSAN on ThinLTO.
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=266514&r1=266513&r2=266514&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original)
+++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Fri Apr 15 23:58:30 2016
@@ -62,9 +62,18 @@ static cl::opt<unsigned> HugeRegion("dag
"prior to scheduling, at which point a trade-off "
"is made to avoid excessive compile time."));
-static cl::opt<unsigned> ReductionSize("dag-maps-reduction-size", cl::Hidden,
+static cl::opt<unsigned> ReductionSize(
+ "dag-maps-reduction-size", cl::Hidden,
cl::desc("A huge scheduling region will have maps reduced by this many "
- "nodes at a time. Defaults to HugeRegion / 2."));
+ "nodes at a time. Defaults to HugeRegion / 2."));
+
+static unsigned getReductionSize() {
+ // Always reduce a huge region with half of the elements, except
+ // when user sets this number explicitly.
+ if (ReductionSize.getNumOccurrences() == 0)
+ return HugeRegion / 2;
+ return ReductionSize;
+}
static void dumpSUList(ScheduleDAGInstrs::SUList &L) {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -878,11 +887,6 @@ void ScheduleDAGInstrs::buildSchedGraph(
// done.
Value2SUsMap NonAliasStores, NonAliasLoads(1 /*TrueMemOrderLatency*/);
- // Always reduce a huge region with half of the elements, except
- // when user sets this number explicitly.
- if (ReductionSize.getNumOccurrences() == 0)
- ReductionSize = (HugeRegion / 2);
-
// Remove any stale debug info; sometimes BuildSchedGraph is called again
// without emitting the info from the previous call.
DbgValues.clear();
@@ -1077,11 +1081,11 @@ void ScheduleDAGInstrs::buildSchedGraph(
// Reduce maps if they grow huge.
if (Stores.size() + Loads.size() >= HugeRegion) {
DEBUG(dbgs() << "Reducing Stores and Loads maps.\n";);
- reduceHugeMemNodeMaps(Stores, Loads, ReductionSize);
+ reduceHugeMemNodeMaps(Stores, Loads, getReductionSize());
}
if (NonAliasStores.size() + NonAliasLoads.size() >= HugeRegion) {
DEBUG(dbgs() << "Reducing NonAliasStores and NonAliasLoads maps.\n";);
- reduceHugeMemNodeMaps(NonAliasStores, NonAliasLoads, ReductionSize);
+ reduceHugeMemNodeMaps(NonAliasStores, NonAliasLoads, getReductionSize());
}
}
More information about the llvm-commits
mailing list