[LICM] Add assert of AST/MSSA exclusiveness.
authorAlina Sbirlea <asbirlea@google.com>
Tue, 3 Nov 2020 01:50:53 +0000 (17:50 -0800)
committerAlina Sbirlea <asbirlea@google.com>
Tue, 3 Nov 2020 02:04:43 +0000 (18:04 -0800)
The API `canSinkOrHoistInst` may be called by LoopSink. Add assert to
avoid having two analyses passed in.

llvm/lib/Transforms/Scalar/LICM.cpp

index b635440..3c9aa94 100644 (file)
@@ -1106,6 +1106,9 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
                               bool TargetExecutesOncePerLoop,
                               SinkAndHoistLICMFlags *Flags,
                               OptimizationRemarkEmitter *ORE) {
+  assert(((CurAST != nullptr) ^ (MSSAU != nullptr)) &&
+         "Either AliasSetTracker or MemorySSA should be initialized.");
+
   // If we don't understand the instruction, bail early.
   if (!isHoistableAndSinkableInst(I))
     return false;