Index: lib/Analysis/DependenceInfo.cpp =================================================================== --- lib/Analysis/DependenceInfo.cpp +++ lib/Analysis/DependenceInfo.cpp @@ -296,9 +296,10 @@ AI = isl_union_access_info_set_must_source(AI, isl_union_map_copy(Src)); AI = isl_union_access_info_set_schedule(AI, isl_schedule_copy(Schedule)); auto Flow = isl_union_access_info_compute_flow(AI); - DEBUG(if (!Flow) dbgs() << "last error: " - << isl_ctx_last_error(isl_schedule_get_ctx(Schedule)) - << '\n';); + LLVM_DEBUG(if (!Flow) dbgs() + << "last error: " + << isl_ctx_last_error(isl_schedule_get_ctx(Schedule)) + << '\n';); return Flow; } @@ -407,18 +408,18 @@ isl_schedule *Schedule; isl_union_set *TaggedStmtDomain; - DEBUG(dbgs() << "Scop: \n" << S << "\n"); + LLVM_DEBUG(dbgs() << "Scop: \n" << S << "\n"); collectInfo(S, Read, MustWrite, MayWrite, ReductionTagMap, TaggedStmtDomain, Level); bool HasReductions = !isl_union_map_is_empty(ReductionTagMap); - DEBUG(dbgs() << "Read: " << Read << '\n'; - dbgs() << "MustWrite: " << MustWrite << '\n'; - dbgs() << "MayWrite: " << MayWrite << '\n'; - dbgs() << "ReductionTagMap: " << ReductionTagMap << '\n'; - dbgs() << "TaggedStmtDomain: " << TaggedStmtDomain << '\n';); + LLVM_DEBUG(dbgs() << "Read: " << Read << '\n'; + dbgs() << "MustWrite: " << MustWrite << '\n'; + dbgs() << "MayWrite: " << MayWrite << '\n'; + dbgs() << "ReductionTagMap: " << ReductionTagMap << '\n'; + dbgs() << "TaggedStmtDomain: " << TaggedStmtDomain << '\n';); Schedule = S.getScheduleTree().release(); @@ -455,10 +456,10 @@ Schedule = isl_schedule_pullback_union_pw_multi_aff(Schedule, Tags); } - DEBUG(dbgs() << "Read: " << Read << "\n"; - dbgs() << "MustWrite: " << MustWrite << "\n"; - dbgs() << "MayWrite: " << MayWrite << "\n"; - dbgs() << "Schedule: " << Schedule << "\n"); + LLVM_DEBUG(dbgs() << "Read: " << Read << "\n"; + dbgs() << "MustWrite: " << MustWrite << "\n"; + dbgs() << "MayWrite: " << MayWrite << "\n"; + dbgs() << "Schedule: " << Schedule << "\n"); isl_union_map *StrictWAW = nullptr; { @@ -600,7 +601,7 @@ isl_union_map_copy(WAW), isl_union_set_copy(TaggedStmtDomain)); STMT_WAR = isl_union_map_intersect_domain(isl_union_map_copy(WAR), TaggedStmtDomain); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Wrapped Dependences:\n"; dump(); dbgs() << "\n"; @@ -648,7 +649,7 @@ addPrivatizationDependences(); } - DEBUG({ + LLVM_DEBUG({ dbgs() << "Final Wrapped Dependences:\n"; dump(); dbgs() << "\n"; @@ -698,7 +699,7 @@ RED = isl_union_map_zip(RED); TC_RED = isl_union_map_zip(TC_RED); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Zipped Dependences:\n"; dump(); dbgs() << "\n"; @@ -710,7 +711,7 @@ RED = isl_union_set_unwrap(isl_union_map_domain(RED)); TC_RED = isl_union_set_unwrap(isl_union_map_domain(TC_RED)); - DEBUG({ + LLVM_DEBUG({ dbgs() << "Unwrapped Dependences:\n"; dump(); dbgs() << "\n"; @@ -726,7 +727,7 @@ RED = isl_union_map_coalesce(RED); TC_RED = isl_union_map_coalesce(TC_RED); - DEBUG(dump()); + LLVM_DEBUG(dump()); } bool Dependences::isValidSchedule(Scop &S, Index: lib/Analysis/PolyhedralInfo.cpp =================================================================== --- lib/Analysis/PolyhedralInfo.cpp +++ lib/Analysis/PolyhedralInfo.cpp @@ -79,15 +79,15 @@ DI->getDependences(const_cast(S), Dependences::AL_Access); if (!D.hasValidDependences()) return false; - DEBUG(dbgs() << "Loop :\t" << L->getHeader()->getName() << ":\n"); + LLVM_DEBUG(dbgs() << "Loop :\t" << L->getHeader()->getName() << ":\n"); isl_union_map *Deps = D.getDependences(Dependences::TYPE_RAW | Dependences::TYPE_WAW | Dependences::TYPE_WAR | Dependences::TYPE_RED); - DEBUG(dbgs() << "Dependences :\t" << stringFromIslObj(Deps) << "\n"); + LLVM_DEBUG(dbgs() << "Dependences :\t" << stringFromIslObj(Deps) << "\n"); isl_union_map *Schedule = getScheduleForLoop(S, L); - DEBUG(dbgs() << "Schedule: \t" << stringFromIslObj(Schedule) << "\n"); + LLVM_DEBUG(dbgs() << "Schedule: \t" << stringFromIslObj(Schedule) << "\n"); IsParallel = D.isParallel(Schedule, Deps, MinDepDistPtr); isl_union_map_free(Schedule); @@ -123,14 +123,14 @@ Loop *L) const { isl_union_map *Schedule = isl_union_map_empty(S->getParamSpace().release()); int CurrDim = S->getRelativeLoopDepth(L); - DEBUG(dbgs() << "Relative loop depth:\t" << CurrDim << "\n"); + LLVM_DEBUG(dbgs() << "Relative loop depth:\t" << CurrDim << "\n"); assert(CurrDim >= 0 && "Loop in region should have at least depth one"); for (auto &SS : *S) { if (L->contains(SS.getSurroundingLoop())) { unsigned int MaxDim = SS.getNumIterators(); - DEBUG(dbgs() << "Maximum depth of Stmt:\t" << MaxDim << "\n"); + LLVM_DEBUG(dbgs() << "Maximum depth of Stmt:\t" << MaxDim << "\n"); isl_map *ScheduleMap = SS.getSchedule().release(); assert( ScheduleMap && Index: lib/Analysis/PruneUnprofitable.cpp =================================================================== --- lib/Analysis/PruneUnprofitable.cpp +++ lib/Analysis/PruneUnprofitable.cpp @@ -73,16 +73,18 @@ bool runOnScop(Scop &S) override { if (PollyProcessUnprofitable) { - DEBUG(dbgs() << "NOTE: -polly-process-unprofitable active, won't prune " - "anything\n"); + LLVM_DEBUG( + dbgs() << "NOTE: -polly-process-unprofitable active, won't prune " + "anything\n"); return false; } ScopsProcessed++; if (!S.isProfitable(true)) { - DEBUG(dbgs() << "SCoP pruned because it probably cannot be optimized in " - "a significant way\n"); + LLVM_DEBUG( + dbgs() << "SCoP pruned because it probably cannot be optimized in " + "a significant way\n"); S.invalidate(PROFITABLE, DebugLoc()); updateStatistics(S, true); } else { Index: lib/Analysis/ScopBuilder.cpp =================================================================== --- lib/Analysis/ScopBuilder.cpp +++ lib/Analysis/ScopBuilder.cpp @@ -1511,7 +1511,8 @@ DenseMap InvalidDomainMap; if (!scop->buildDomains(&R, DT, LI, InvalidDomainMap)) { - DEBUG(dbgs() << "Bailing-out because buildDomains encountered problems\n"); + LLVM_DEBUG( + dbgs() << "Bailing-out because buildDomains encountered problems\n"); return; } @@ -1530,7 +1531,7 @@ scop->removeStmtNotInDomainMap(); scop->simplifySCoP(false); if (scop->isEmpty()) { - DEBUG(dbgs() << "Bailing-out because SCoP is empty\n"); + LLVM_DEBUG(dbgs() << "Bailing-out because SCoP is empty\n"); return; } @@ -1546,7 +1547,7 @@ // Check early for a feasible runtime context. if (!scop->hasFeasibleRuntimeContext()) { - DEBUG(dbgs() << "Bailing-out because of unfeasible context (early)\n"); + LLVM_DEBUG(dbgs() << "Bailing-out because of unfeasible context (early)\n"); return; } @@ -1554,7 +1555,8 @@ // only the runtime context could become infeasible. if (!scop->isProfitable(UnprofitableScalarAccs)) { scop->invalidate(PROFITABLE, DebugLoc()); - DEBUG(dbgs() << "Bailing-out because SCoP is not considered profitable\n"); + LLVM_DEBUG( + dbgs() << "Bailing-out because SCoP is not considered profitable\n"); return; } @@ -1572,7 +1574,7 @@ scop->simplifyContexts(); if (!scop->buildAliasChecks(AA)) { - DEBUG(dbgs() << "Bailing-out because could not build alias checks\n"); + LLVM_DEBUG(dbgs() << "Bailing-out because could not build alias checks\n"); return; } @@ -1584,7 +1586,7 @@ // Check late for a feasible runtime context because profitability did not // change. if (!scop->hasFeasibleRuntimeContext()) { - DEBUG(dbgs() << "Bailing-out because of unfeasible context (late)\n"); + LLVM_DEBUG(dbgs() << "Bailing-out because of unfeasible context (late)\n"); return; } @@ -1608,12 +1610,12 @@ buildScop(*R, AC, ORE); - DEBUG(dbgs() << *scop); + LLVM_DEBUG(dbgs() << *scop); if (!scop->hasFeasibleRuntimeContext()) { InfeasibleScops++; Msg = "SCoP ends here but was dismissed."; - DEBUG(dbgs() << "SCoP detected but dismissed\n"); + LLVM_DEBUG(dbgs() << "SCoP detected but dismissed\n"); scop.reset(); } else { Msg = "SCoP ends here."; Index: lib/Analysis/ScopDetection.cpp =================================================================== --- lib/Analysis/ScopDetection.cpp +++ lib/Analysis/ScopDetection.cpp @@ -407,8 +407,8 @@ if (PollyTrackFailures) Log.report(RejectReason); - DEBUG(dbgs() << RejectReason->getMessage()); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << RejectReason->getMessage()); + LLVM_DEBUG(dbgs() << "\n"); } else { assert(!Assert && "Verification of detected scop failed"); } @@ -1362,14 +1362,14 @@ std::unique_ptr LastValidRegion; auto ExpandedRegion = std::unique_ptr(R.getExpandedRegion()); - DEBUG(dbgs() << "\tExpanding " << R.getNameStr() << "\n"); + LLVM_DEBUG(dbgs() << "\tExpanding " << R.getNameStr() << "\n"); while (ExpandedRegion) { const auto &It = DetectionContextMap.insert(std::make_pair( getBBPairForRegion(ExpandedRegion.get()), DetectionContext(*ExpandedRegion, AA, false /*verifying*/))); DetectionContext &Context = It.first->second; - DEBUG(dbgs() << "\t\tTrying " << ExpandedRegion->getNameStr() << "\n"); + LLVM_DEBUG(dbgs() << "\t\tTrying " << ExpandedRegion->getNameStr() << "\n"); // Only expand when we did not collect errors. if (!Context.Log.hasErrors()) { @@ -1403,7 +1403,7 @@ } } - DEBUG({ + LLVM_DEBUG({ if (LastValidRegion) dbgs() << "\tto " << LastValidRegion->getNameStr() << "\n"; else @@ -1609,23 +1609,23 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) const { Region &CurRegion = Context.CurRegion; - DEBUG(dbgs() << "Checking region: " << CurRegion.getNameStr() << "\n\t"); + LLVM_DEBUG(dbgs() << "Checking region: " << CurRegion.getNameStr() << "\n\t"); if (!PollyAllowFullFunction && CurRegion.isTopLevelRegion()) { - DEBUG(dbgs() << "Top level region is invalid\n"); + LLVM_DEBUG(dbgs() << "Top level region is invalid\n"); return false; } DebugLoc DbgLoc; if (CurRegion.getExit() && isa(CurRegion.getExit()->getTerminator())) { - DEBUG(dbgs() << "Unreachable in exit\n"); + LLVM_DEBUG(dbgs() << "Unreachable in exit\n"); return invalid(Context, /*Assert=*/true, CurRegion.getExit(), DbgLoc); } if (!CurRegion.getEntry()->getName().count(OnlyRegion)) { - DEBUG({ + LLVM_DEBUG({ dbgs() << "Region entry does not match -polly-region-only"; dbgs() << "\n"; }); @@ -1646,7 +1646,7 @@ return invalid(Context, /*Assert=*/true, &CurRegion, DbgLoc); - DEBUG(dbgs() << "OK\n"); + LLVM_DEBUG(dbgs() << "OK\n"); return true; } Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -3101,12 +3101,13 @@ // we make the assumed context infeasible. invalidate(ALIASING, DebugLoc()); - DEBUG(dbgs() << "\n\nNOTE: Run time checks for " << getNameStr() - << " could not be created as the number of parameters involved " - "is too high. The SCoP will be " - "dismissed.\nUse:\n\t--polly-rtc-max-parameters=X\nto adjust " - "the maximal number of parameters but be advised that the " - "compile time might increase exponentially.\n\n"); + LLVM_DEBUG( + dbgs() << "\n\nNOTE: Run time checks for " << getNameStr() + << " could not be created as the number of parameters involved " + "is too high. The SCoP will be " + "dismissed.\nUse:\n\t--polly-rtc-max-parameters=X\nto adjust " + "the maximal number of parameters but be advised that the " + "compile time might increase exponentially.\n\n"); return false; } @@ -4301,7 +4302,7 @@ } void Scop::invalidate(AssumptionKind Kind, DebugLoc Loc, BasicBlock *BB) { - DEBUG(dbgs() << "Invalidate SCoP because of reason " << Kind << "\n"); + LLVM_DEBUG(dbgs() << "Invalidate SCoP because of reason " << Kind << "\n"); addAssumption(Kind, isl::set::empty(getParamSpace()), Loc, AS_ASSUMPTION, BB); } Index: lib/CodeGen/CodeGeneration.cpp =================================================================== --- lib/CodeGen/CodeGeneration.cpp +++ lib/CodeGen/CodeGeneration.cpp @@ -100,7 +100,7 @@ if (!Verify || !verifyFunction(F, &errs())) return; - DEBUG({ + LLVM_DEBUG({ errs() << "== ISL Codegen created an invalid function ==\n\n== The " "SCoP ==\n"; errs() << S; @@ -196,7 +196,7 @@ // DependenceInfo or IslAstInfo around. IslAst &Ast = AI.getIslAst(); if (Ast.getSharedIslCtx() != S.getSharedIslCtx()) { - DEBUG(dbgs() << "Got an IstAst for a different Scop/isl_ctx\n"); + LLVM_DEBUG(dbgs() << "Got an IstAst for a different Scop/isl_ctx\n"); return false; } Index: lib/CodeGen/CodegenCleanup.cpp =================================================================== --- lib/CodeGen/CodegenCleanup.cpp +++ lib/CodeGen/CodegenCleanup.cpp @@ -117,12 +117,13 @@ virtual bool runOnFunction(llvm::Function &F) override { if (!F.hasFnAttribute("polly-optimized")) { - DEBUG(dbgs() << F.getName() - << ": Skipping cleanup because Polly did not optimize it."); + LLVM_DEBUG( + dbgs() << F.getName() + << ": Skipping cleanup because Polly did not optimize it."); return false; } - DEBUG(dbgs() << F.getName() << ": Running codegen cleanup..."); + LLVM_DEBUG(dbgs() << F.getName() << ": Running codegen cleanup..."); return FPM->run(F); } //@} Index: lib/CodeGen/IslAst.cpp =================================================================== --- lib/CodeGen/IslAst.cpp +++ lib/CodeGen/IslAst.cpp @@ -762,7 +762,7 @@ auto *Schedule = S.getScheduleTree().release(); - DEBUG({ + LLVM_DEBUG({ dbgs() << S.getContextStr() << "\n"; dbgs() << stringFromIslObj(Schedule); }); @@ -802,14 +802,15 @@ getAnalysis().getDependences(Dependences::AL_Statement); if (D.getSharedIslCtx() != Scop.getSharedIslCtx()) { - DEBUG(dbgs() << "Got dependence analysis for different SCoP/isl_ctx\n"); + LLVM_DEBUG( + dbgs() << "Got dependence analysis for different SCoP/isl_ctx\n"); Ast.reset(); return false; } Ast.reset(new IslAstInfo(Scop, D)); - DEBUG(printScop(dbgs(), Scop)); + LLVM_DEBUG(printScop(dbgs(), Scop)); return false; } Index: lib/CodeGen/ManagedMemoryRewrite.cpp =================================================================== --- lib/CodeGen/ManagedMemoryRewrite.cpp +++ lib/CodeGen/ManagedMemoryRewrite.cpp @@ -124,8 +124,8 @@ Instruction *I = Cur->getAsInstruction(); assert(I && "unable to convert ConstantExpr to Instruction"); - DEBUG(dbgs() << "Expanding ConstantExpression: (" << *Cur - << ") in Instruction: (" << *I << ")\n";); + LLVM_DEBUG(dbgs() << "Expanding ConstantExpression: (" << *Cur + << ") in Instruction: (" << *I << ")\n";); // Invalidate `Cur` so that no one after this point uses `Cur`. Rather, // they should mutate `I`. @@ -209,19 +209,20 @@ Array.hasInternalLinkage() || IgnoreLinkageForGlobals; if (!OnlyVisibleInsideModule) { - DEBUG(dbgs() << "Not rewriting (" << Array - << ") to managed memory " - "because it could be visible externally. To force rewrite, " - "use -polly-acc-rewrite-ignore-linkage-for-globals.\n"); + LLVM_DEBUG( + dbgs() << "Not rewriting (" << Array + << ") to managed memory " + "because it could be visible externally. To force rewrite, " + "use -polly-acc-rewrite-ignore-linkage-for-globals.\n"); return; } if (!Array.hasInitializer() || !isa(Array.getInitializer())) { - DEBUG(dbgs() << "Not rewriting (" << Array - << ") to managed memory " - "because it has an initializer which is " - "not a zeroinitializer.\n"); + LLVM_DEBUG(dbgs() << "Not rewriting (" << Array + << ") to managed memory " + "because it has an initializer which is " + "not a zeroinitializer.\n"); return; } @@ -288,14 +289,14 @@ auto *Alloca = dyn_cast(&I); if (!Alloca) continue; - DEBUG(dbgs() << "Checking if (" << *Alloca << ") may be captured: "); + LLVM_DEBUG(dbgs() << "Checking if (" << *Alloca << ") may be captured: "); if (PointerMayBeCaptured(Alloca, /* ReturnCaptures */ false, /* StoreCaptures */ true)) { Allocas.insert(Alloca); - DEBUG(dbgs() << "YES (captured).\n"); + LLVM_DEBUG(dbgs() << "YES (captured).\n"); } else { - DEBUG(dbgs() << "NO (not captured).\n"); + LLVM_DEBUG(dbgs() << "NO (not captured).\n"); } } } @@ -303,7 +304,7 @@ static void rewriteAllocaAsManagedMemory(AllocaInst *Alloca, const DataLayout &DL) { - DEBUG(dbgs() << "rewriting: (" << *Alloca << ") to managed mem.\n"); + LLVM_DEBUG(dbgs() << "rewriting: (" << *Alloca << ") to managed mem.\n"); Module *M = Alloca->getModule(); assert(M && "Alloca does not have a module"); Index: lib/CodeGen/PPCGCodeGeneration.cpp =================================================================== --- lib/CodeGen/PPCGCodeGeneration.cpp +++ lib/CodeGen/PPCGCodeGeneration.cpp @@ -2205,7 +2205,7 @@ /// memory store or at least before each kernel barrier. if (Kernel->n_block != 0 || Kernel->n_grid != 0) { BuildSuccessful = 0; - DEBUG( + LLVM_DEBUG( dbgs() << getUniqueScopName(&S) << " has a store to a scalar value that" " would be undefined to run in parallel. Bailing out.\n";); @@ -2440,10 +2440,10 @@ std::string GPUNodeBuilder::finalizeKernelFunction() { if (verifyModule(*GPUModule)) { - DEBUG(dbgs() << "verifyModule failed on module:\n"; - GPUModule->print(dbgs(), nullptr); dbgs() << "\n";); - DEBUG(dbgs() << "verifyModule Error:\n"; - verifyModule(*GPUModule, &dbgs());); + LLVM_DEBUG(dbgs() << "verifyModule failed on module:\n"; + GPUModule->print(dbgs(), nullptr); dbgs() << "\n";); + LLVM_DEBUG(dbgs() << "verifyModule Error:\n"; + verifyModule(*GPUModule, &dbgs());); if (FailOnVerifyModuleFailure) llvm_unreachable("VerifyModule failed."); @@ -3230,8 +3230,8 @@ if (!has_permutable || has_permutable < 0) { Schedule = isl_schedule_free(Schedule); - DEBUG(dbgs() << getUniqueScopName(S) - << " does not have permutable bands. Bailing out\n";); + LLVM_DEBUG(dbgs() << getUniqueScopName(S) + << " does not have permutable bands. Bailing out\n";); } else { const bool CreateTransferToFromDevice = !PollyManagedMemory; Schedule = map_to_device(PPCGGen, Schedule, CreateTransferToFromDevice); @@ -3409,8 +3409,8 @@ // Look for (*) among operands of Inst if (auto PtrTy = dyn_cast(Op->getType())) { if (isa(PtrTy->getElementType())) { - DEBUG(dbgs() << Inst - << " has illegal use of function in kernel.\n"); + LLVM_DEBUG(dbgs() << Inst + << " has illegal use of function in kernel.\n"); return true; } } @@ -3488,9 +3488,9 @@ auto *SplitBBTerm = Builder.GetInsertBlock()->getTerminator(); SplitBBTerm->setOperand(0, FalseI1); - DEBUG(dbgs() << "preloading invariant loads failed in function: " + - S->getFunction().getName() + - " | Scop Region: " + S->getNameStr()); + LLVM_DEBUG(dbgs() << "preloading invariant loads failed in function: " + + S->getFunction().getName() + " | Scop Region: " + + S->getNameStr()); // adjust the dominator tree accordingly. auto *ExitingBlock = StartBlock->getUniqueSuccessor(); assert(ExitingBlock); @@ -3550,8 +3550,8 @@ DL = &S->getRegion().getEntry()->getModule()->getDataLayout(); RI = &getAnalysis().getRegionInfo(); - DEBUG(dbgs() << "PPCGCodeGen running on : " << getUniqueScopName(S) - << " | loop depth: " << S->getMaxLoopDepth() << "\n"); + LLVM_DEBUG(dbgs() << "PPCGCodeGen running on : " << getUniqueScopName(S) + << " | loop depth: " << S->getMaxLoopDepth() << "\n"); // We currently do not support functions other than intrinsics inside // kernels, as code generation will need to offload function calls to the @@ -3560,7 +3560,7 @@ // address of an intrinsic function to send to the kernel. if (containsInvalidKernelFunction(CurrentScop, Architecture == GPUArch::NVPTX64)) { - DEBUG( + LLVM_DEBUG( dbgs() << getUniqueScopName(S) << " contains function which cannot be materialised in a GPU " "kernel. Bailing out.\n";); @@ -3575,8 +3575,8 @@ generateCode(isl_ast_node_copy(PPCGGen->tree), PPCGProg); CurrentScop.markAsToBeSkipped(); } else { - DEBUG(dbgs() << getUniqueScopName(S) - << " has empty PPCGGen->tree. Bailing out.\n"); + LLVM_DEBUG(dbgs() << getUniqueScopName(S) + << " has empty PPCGGen->tree. Bailing out.\n"); } freeOptions(PPCGScop); Index: lib/Support/DumpModulePass.cpp =================================================================== --- lib/Support/DumpModulePass.cpp +++ lib/Support/DumpModulePass.cpp @@ -63,7 +63,7 @@ } else { Dumpfile = Filename; } - DEBUG(dbgs() << "Dumping module to " << Dumpfile << '\n'); + LLVM_DEBUG(dbgs() << "Dumping module to " << Dumpfile << '\n'); std::unique_ptr Out; std::error_code EC; Index: lib/Support/SCEVValidator.cpp =================================================================== --- lib/Support/SCEVValidator.cpp +++ lib/Support/SCEVValidator.cpp @@ -205,11 +205,12 @@ } if ((Op.isIV() || Op.isPARAM()) && !Return.isINT()) { - DEBUG(dbgs() << "INVALID: More than one non-int operand in MulExpr\n" - << "\tExpr: " << *Expr << "\n" - << "\tPrevious expression type: " << Return << "\n" - << "\tNext operand (" << Op - << "): " << *Expr->getOperand(i) << "\n"); + LLVM_DEBUG( + dbgs() << "INVALID: More than one non-int operand in MulExpr\n" + << "\tExpr: " << *Expr << "\n" + << "\tPrevious expression type: " << Return << "\n" + << "\tNext operand (" << Op << "): " << *Expr->getOperand(i) + << "\n"); return ValidatorResult(SCEVType::INVALID); } @@ -225,7 +226,7 @@ class ValidatorResult visitAddRecExpr(const SCEVAddRecExpr *Expr) { if (!Expr->isAffine()) { - DEBUG(dbgs() << "INVALID: AddRec is not affine"); + LLVM_DEBUG(dbgs() << "INVALID: AddRec is not affine"); return ValidatorResult(SCEVType::INVALID); } @@ -240,9 +241,10 @@ auto *L = Expr->getLoop(); if (R->contains(L) && (!Scope || !L->contains(Scope))) { - DEBUG(dbgs() << "INVALID: Loop of AddRec expression boxed in an a " - "non-affine subregion or has a non-synthesizable exit " - "value."); + LLVM_DEBUG( + dbgs() << "INVALID: Loop of AddRec expression boxed in an a " + "non-affine subregion or has a non-synthesizable exit " + "value."); return ValidatorResult(SCEVType::INVALID); } @@ -253,8 +255,8 @@ return Result; } - DEBUG(dbgs() << "INVALID: AddRec within scop has non-int" - "recurrence part"); + LLVM_DEBUG(dbgs() << "INVALID: AddRec within scop has non-int" + "recurrence part"); return ValidatorResult(SCEVType::INVALID); } @@ -299,7 +301,7 @@ ValidatorResult Op = visit(Expr->getOperand(i)); if (!Op.isConstant()) { - DEBUG(dbgs() << "INVALID: UMaxExpr has a non-constant operand"); + LLVM_DEBUG(dbgs() << "INVALID: UMaxExpr has a non-constant operand"); return ValidatorResult(SCEVType::INVALID); } } @@ -309,8 +311,8 @@ ValidatorResult visitGenericInst(Instruction *I, const SCEV *S) { if (R->contains(I)) { - DEBUG(dbgs() << "INVALID: UnknownExpr references an instruction " - "within the region\n"); + LLVM_DEBUG(dbgs() << "INVALID: UnknownExpr references an instruction " + "within the region\n"); return ValidatorResult(SCEVType::INVALID); } @@ -358,7 +360,8 @@ if (LHS.isConstant() && RHS.isConstant()) return ValidatorResult(SCEVType::PARAM, DivExpr); - DEBUG(dbgs() << "INVALID: unsigned division of non-constant expressions"); + LLVM_DEBUG( + dbgs() << "INVALID: unsigned division of non-constant expressions"); return ValidatorResult(SCEVType::INVALID); } @@ -398,12 +401,12 @@ Value *V = Expr->getValue(); if (!Expr->getType()->isIntegerTy() && !Expr->getType()->isPointerTy()) { - DEBUG(dbgs() << "INVALID: UnknownExpr is not an integer or pointer"); + LLVM_DEBUG(dbgs() << "INVALID: UnknownExpr is not an integer or pointer"); return ValidatorResult(SCEVType::INVALID); } if (isa(V)) { - DEBUG(dbgs() << "INVALID: UnknownExpr references an undef value"); + LLVM_DEBUG(dbgs() << "INVALID: UnknownExpr references an undef value"); return ValidatorResult(SCEVType::INVALID); } @@ -605,7 +608,7 @@ return false; SCEVValidator Validator(R, Scope, SE, ILS); - DEBUG({ + LLVM_DEBUG({ dbgs() << "\n"; dbgs() << "Expr: " << *Expr << "\n"; dbgs() << "Region: " << R->getNameStr() << "\n"; @@ -614,7 +617,7 @@ ValidatorResult Result = Validator.visit(Expr); - DEBUG({ + LLVM_DEBUG({ if (Result.isValid()) dbgs() << "VALID\n"; dbgs() << "\n"; Index: lib/Transform/DeLICM.cpp =================================================================== --- lib/Transform/DeLICM.cpp +++ lib/Transform/DeLICM.cpp @@ -545,7 +545,7 @@ /// @see Knowledge::isConflicting bool isConflicting(const Knowledge &Proposed) { raw_ostream *OS = nullptr; - DEBUG(OS = &llvm::dbgs()); + LLVM_DEBUG(OS = &llvm::dbgs()); return Knowledge::isConflicting(Zone, Proposed, OS, 4); } @@ -557,8 +557,9 @@ if (SAI->isValueKind()) { auto *MA = S->getValueDef(SAI); if (!MA) { - DEBUG(dbgs() - << " Reject because value is read-only within the scop\n"); + LLVM_DEBUG( + dbgs() + << " Reject because value is read-only within the scop\n"); return false; } @@ -573,7 +574,7 @@ auto UserInst = cast(User); if (!S->contains(UserInst)) { - DEBUG(dbgs() << " Reject because value is escaping\n"); + LLVM_DEBUG(dbgs() << " Reject because value is escaping\n"); return false; } } @@ -590,8 +591,9 @@ auto PHI = cast(MA->getAccessInstruction()); for (auto Incoming : PHI->blocks()) { if (!S->contains(Incoming)) { - DEBUG(dbgs() << " Reject because at least one incoming block is " - "not in the scop region\n"); + LLVM_DEBUG(dbgs() + << " Reject because at least one incoming block is " + "not in the scop region\n"); return false; } } @@ -599,7 +601,7 @@ return true; } - DEBUG(dbgs() << " Reject ExitPHI or other non-value\n"); + LLVM_DEBUG(dbgs() << " Reject ExitPHI or other non-value\n"); return false; } @@ -687,13 +689,14 @@ auto DefTarget = give(isl_map_apply_domain( TargetElt.copy(), isl_map_reverse(DefSched.copy()))); simplify(DefTarget); - DEBUG(dbgs() << " Def Mapping: " << DefTarget << '\n'); + LLVM_DEBUG(dbgs() << " Def Mapping: " << DefTarget << '\n'); auto OrigDomain = getDomainFor(DefMA); auto MappedDomain = give(isl_map_domain(DefTarget.copy())); if (!isl_set_is_subset(OrigDomain.keep(), MappedDomain.keep())) { - DEBUG(dbgs() - << " Reject because mapping does not encompass all instances\n"); + LLVM_DEBUG( + dbgs() + << " Reject because mapping does not encompass all instances\n"); return false; } @@ -704,7 +707,7 @@ isl::union_map DefUses; std::tie(DefUses, Lifetime) = computeValueUses(SAI); - DEBUG(dbgs() << " Lifetime: " << Lifetime << '\n'); + LLVM_DEBUG(dbgs() << " Lifetime: " << Lifetime << '\n'); /// { [Element[] -> Zone[]] } auto EltZone = give( @@ -868,13 +871,14 @@ auto PHITarget = give(isl_map_apply_range(PHISched.copy(), TargetElt.copy())); simplify(PHITarget); - DEBUG(dbgs() << " Mapping: " << PHITarget << '\n'); + LLVM_DEBUG(dbgs() << " Mapping: " << PHITarget << '\n'); auto OrigDomain = getDomainFor(PHIRead); auto MappedDomain = give(isl_map_domain(PHITarget.copy())); if (!isl_set_is_subset(OrigDomain.keep(), MappedDomain.keep())) { - DEBUG(dbgs() - << " Reject because mapping does not encompass all instances\n"); + LLVM_DEBUG( + dbgs() + << " Reject because mapping does not encompass all instances\n"); return false; } @@ -901,16 +905,19 @@ if (!DelicmPartialWrites && !isl_union_set_is_subset(UniverseWritesDom.keep(), ExpandedWritesDom.keep())) { - DEBUG(dbgs() << " Reject because did not find PHI write mapping for " - "all instances\n"); + LLVM_DEBUG( + dbgs() << " Reject because did not find PHI write mapping for " + "all instances\n"); if (DelicmOverapproximateWrites) - DEBUG(dbgs() << " Relevant Mapping: " << RelevantWritesTarget - << '\n'); - DEBUG(dbgs() << " Deduced Mapping: " << WritesTarget << '\n'); - DEBUG(dbgs() << " Missing instances: " - << give(isl_union_set_subtract(UniverseWritesDom.copy(), - ExpandedWritesDom.copy())) - << '\n'); + LLVM_DEBUG(dbgs() << " Relevant Mapping: " + << RelevantWritesTarget << '\n'); + LLVM_DEBUG(dbgs() << " Deduced Mapping: " << WritesTarget + << '\n'); + LLVM_DEBUG( + dbgs() << " Missing instances: " + << give(isl_union_set_subtract(UniverseWritesDom.copy(), + ExpandedWritesDom.copy())) + << '\n'); return false; } @@ -921,7 +928,7 @@ // { DomainRead[] -> Zone[] } auto Lifetime = betweenScatter(PerPHIWriteScatter, PHISched, false, true); simplify(Lifetime); - DEBUG(dbgs() << " Lifetime: " << Lifetime << "\n"); + LLVM_DEBUG(dbgs() << " Lifetime: " << Lifetime << "\n"); // { DomainWrite[] -> Zone[] } auto WriteLifetime = give(isl_union_map_apply_domain( @@ -1041,7 +1048,7 @@ auto EltTarget = give(isl_map_apply_range(Target.take(), TargetAccRel.take())); simplify(EltTarget); - DEBUG(dbgs() << " Target mapping is " << EltTarget << '\n'); + LLVM_DEBUG(dbgs() << " Target mapping is " << EltTarget << '\n'); // Stack of elements not yet processed. SmallVector Worklist; @@ -1079,8 +1086,8 @@ if (Closed.count(SAI)) continue; Closed.insert(SAI); - DEBUG(dbgs() << "\n Trying to map " << MA << " (SAI: " << SAI - << ")\n"); + LLVM_DEBUG(dbgs() << "\n Trying to map " << MA << " (SAI: " << SAI + << ")\n"); // Skip non-mappable scalars. if (!isMappable(SAI)) @@ -1088,7 +1095,8 @@ auto MASize = DL.getTypeAllocSize(MA->getAccessValue()->getType()); if (MASize > StoreSize) { - DEBUG(dbgs() << " Reject because storage size is insufficient\n"); + LLVM_DEBUG( + dbgs() << " Reject because storage size is insufficient\n"); continue; } @@ -1226,7 +1234,7 @@ "The only reason that these things have not been computed should " "be if the max-operations limit hit"); DeLICMOutOfQuota++; - DEBUG(dbgs() << "DeLICM analysis exceeded max_operations\n"); + LLVM_DEBUG(dbgs() << "DeLICM analysis exceeded max_operations\n"); DebugLoc Begin, End; getDebugLocations(getBBPairForRegion(&S->getRegion()), Begin, End); OptimizationRemarkAnalysis R(DEBUG_TYPE, "OutOfQuota", Begin, @@ -1237,7 +1245,7 @@ } Zone = OriginalZone = Knowledge(nullptr, EltUnused, EltKnown, EltWritten); - DEBUG(dbgs() << "Computed Zone:\n"; OriginalZone.print(dbgs(), 4)); + LLVM_DEBUG(dbgs() << "Computed Zone:\n"; OriginalZone.print(dbgs(), 4)); assert(Zone.isUsable() && OriginalZone.isUsable()); return true; @@ -1259,8 +1267,8 @@ continue; if (MA->isMayWrite()) { - DEBUG(dbgs() << "Access " << MA - << " pruned because it is a MAY_WRITE\n"); + LLVM_DEBUG(dbgs() << "Access " << MA + << " pruned because it is a MAY_WRITE\n"); OptimizationRemarkMissed R(DEBUG_TYPE, "TargetMayWrite", MA->getAccessInstruction()); R << "Skipped possible mapping target because it is not an " @@ -1270,8 +1278,8 @@ } if (Stmt.getNumIterators() == 0) { - DEBUG(dbgs() << "Access " << MA - << " pruned because it is not in a loop\n"); + LLVM_DEBUG(dbgs() << "Access " << MA + << " pruned because it is not in a loop\n"); OptimizationRemarkMissed R(DEBUG_TYPE, "WriteNotInLoop", MA->getAccessInstruction()); R << "skipped possible mapping target because it is not in a loop"; @@ -1280,8 +1288,9 @@ } if (isScalarAccess(MA)) { - DEBUG(dbgs() << "Access " << MA - << " pruned because it writes only a single element\n"); + LLVM_DEBUG(dbgs() + << "Access " << MA + << " pruned because it writes only a single element\n"); OptimizationRemarkMissed R(DEBUG_TYPE, "ScalarWrite", MA->getAccessInstruction()); R << "skipped possible mapping target because the memory location " @@ -1291,8 +1300,8 @@ } if (!isa(MA->getAccessInstruction())) { - DEBUG(dbgs() << "Access " << MA - << " pruned because it is not a StoreInst\n"); + LLVM_DEBUG(dbgs() << "Access " << MA + << " pruned because it is not a StoreInst\n"); OptimizationRemarkMissed R(DEBUG_TYPE, "NotAStore", MA->getAccessInstruction()); R << "skipped possible mapping target because non-store instructions " @@ -1314,9 +1323,9 @@ // arguments. isl::union_map AccRel = MA->getLatestAccessRelation(); if (!AccRel.is_single_valued().is_true()) { - DEBUG(dbgs() << "Access " << MA - << " is incompatible because it writes multiple " - "elements per instance\n"); + LLVM_DEBUG(dbgs() << "Access " << MA + << " is incompatible because it writes multiple " + "elements per instance\n"); OptimizationRemarkMissed R(DEBUG_TYPE, "NonFunctionalAccRel", MA->getAccessInstruction()); R << "skipped possible mapping target because it writes more than " @@ -1327,7 +1336,7 @@ isl::union_set TouchedElts = AccRel.range(); if (!TouchedElts.is_subset(CompatibleElts)) { - DEBUG( + LLVM_DEBUG( dbgs() << "Access " << MA << " is incompatible because it touches incompatible elements\n"); @@ -1341,7 +1350,7 @@ assert(isCompatibleAccess(MA)); NumberOfCompatibleTargets++; - DEBUG(dbgs() << "Analyzing target access " << MA << "\n"); + LLVM_DEBUG(dbgs() << "Analyzing target access " << MA << "\n"); if (collapseScalarsToStore(MA)) Modified = true; } @@ -1380,15 +1389,15 @@ Impl = make_unique(&S, &LI); if (!Impl->computeZone()) { - DEBUG(dbgs() << "Abort because cannot reliably compute lifetimes\n"); + LLVM_DEBUG(dbgs() << "Abort because cannot reliably compute lifetimes\n"); return; } - DEBUG(dbgs() << "Collapsing scalars to unused array elements...\n"); + LLVM_DEBUG(dbgs() << "Collapsing scalars to unused array elements...\n"); Impl->greedyCollapse(); - DEBUG(dbgs() << "\nFinal Scop:\n"); - DEBUG(dbgs() << S); + LLVM_DEBUG(dbgs() << "\nFinal Scop:\n"); + LLVM_DEBUG(dbgs() << S); } public: Index: lib/Transform/FlattenAlgo.cpp =================================================================== --- lib/Transform/FlattenAlgo.cpp +++ lib/Transform/FlattenAlgo.cpp @@ -180,7 +180,7 @@ // Would cause an infinite loop. if (!isDimBoundedByConstant(ScatterSet, 0)) { - DEBUG(dbgs() << "Abort; dimension is not of fixed size\n"); + LLVM_DEBUG(dbgs() << "Abort; dimension is not of fixed size\n"); return nullptr; } @@ -191,8 +191,8 @@ auto Counter = isl::pw_aff(isl::local_space(ParamSpace.set_from_params())); while (!ScatterSet.is_empty()) { - DEBUG(dbgs() << "Next counter:\n " << Counter << "\n"); - DEBUG(dbgs() << "Remaining scatter set:\n " << ScatterSet << "\n"); + LLVM_DEBUG(dbgs() << "Next counter:\n " << Counter << "\n"); + LLVM_DEBUG(dbgs() << "Remaining scatter set:\n " << ScatterSet << "\n"); auto ThisSet = ScatterSet.project_out(isl::dim::set, 1, Dims - 1); auto ThisFirst = ThisSet.lexmin(); auto ScatterFirst = ThisFirst.add_dims(isl::dim::set, Dims - 1); @@ -207,10 +207,11 @@ auto RemainingSubSchedule = scheduleProjectOut(SubSchedule, 0, 1); auto FirstSubScatter = isl::set(FirstSubSchedule.range()); - DEBUG(dbgs() << "Next step in sequence is:\n " << FirstSubScatter << "\n"); + LLVM_DEBUG(dbgs() << "Next step in sequence is:\n " << FirstSubScatter + << "\n"); if (!isDimBoundedByParameter(FirstSubScatter, 0)) { - DEBUG(dbgs() << "Abort; sequence step is not bounded\n"); + LLVM_DEBUG(dbgs() << "Abort; sequence step is not bounded\n"); return nullptr; } @@ -241,7 +242,8 @@ Counter = Counter.add(PartLen); } - DEBUG(dbgs() << "Sequence-flatten result is:\n " << NewSchedule << "\n"); + LLVM_DEBUG(dbgs() << "Sequence-flatten result is:\n " << NewSchedule + << "\n"); return NewSchedule; } @@ -268,19 +270,19 @@ SubExtent = SubExtent.project_out(isl::dim::set, 1, SubDims - 1); if (!isDimBoundedByConstant(SubExtent, 0)) { - DEBUG(dbgs() << "Abort; dimension not bounded by constant\n"); + LLVM_DEBUG(dbgs() << "Abort; dimension not bounded by constant\n"); return nullptr; } auto Min = SubExtent.dim_min(0); - DEBUG(dbgs() << "Min bound:\n " << Min << "\n"); + LLVM_DEBUG(dbgs() << "Min bound:\n " << Min << "\n"); auto MinVal = getConstant(Min, false, true); auto Max = SubExtent.dim_max(0); - DEBUG(dbgs() << "Max bound:\n " << Max << "\n"); + LLVM_DEBUG(dbgs() << "Max bound:\n " << Max << "\n"); auto MaxVal = getConstant(Max, true, false); if (!MinVal || !MaxVal || MinVal.is_nan() || MaxVal.is_nan()) { - DEBUG(dbgs() << "Abort; dimension bounds could not be determined\n"); + LLVM_DEBUG(dbgs() << "Abort; dimension bounds could not be determined\n"); return nullptr; } @@ -298,14 +300,15 @@ auto IndexMap = isl::union_map(Index); auto Result = IndexMap.flat_range_product(RemainingSubSchedule); - DEBUG(dbgs() << "Loop-flatten result is:\n " << Result << "\n"); + LLVM_DEBUG(dbgs() << "Loop-flatten result is:\n " << Result << "\n"); return Result; } } // anonymous namespace isl::union_map polly::flattenSchedule(isl::union_map Schedule) { auto Dims = scheduleScatterDims(Schedule); - DEBUG(dbgs() << "Recursive schedule to process:\n " << Schedule << "\n"); + LLVM_DEBUG(dbgs() << "Recursive schedule to process:\n " << Schedule + << "\n"); // Base case; no dimensions left if (Dims == 0) { @@ -319,20 +322,20 @@ // Fixed dimension; no need to preserve variabledness. if (!isVariableDim(Schedule)) { - DEBUG(dbgs() << "Fixed dimension; try sequence flattening\n"); + LLVM_DEBUG(dbgs() << "Fixed dimension; try sequence flattening\n"); auto NewScheduleSequence = tryFlattenSequence(Schedule); if (NewScheduleSequence) return NewScheduleSequence; } // Constant stride - DEBUG(dbgs() << "Try loop flattening\n"); + LLVM_DEBUG(dbgs() << "Try loop flattening\n"); auto NewScheduleLoop = tryFlattenLoop(Schedule); if (NewScheduleLoop) return NewScheduleLoop; // Try again without loop condition (may blow up the number of pieces!!) - DEBUG(dbgs() << "Try sequence flattening again\n"); + LLVM_DEBUG(dbgs() << "Try sequence flattening again\n"); auto NewScheduleSequence = tryFlattenSequence(Schedule); if (NewScheduleSequence) return NewScheduleSequence; Index: lib/Transform/FlattenSchedule.cpp =================================================================== --- lib/Transform/FlattenSchedule.cpp +++ lib/Transform/FlattenSchedule.cpp @@ -59,23 +59,23 @@ // OldSchedule. IslCtx = S.getSharedIslCtx(); - DEBUG(dbgs() << "Going to flatten old schedule:\n"); + LLVM_DEBUG(dbgs() << "Going to flatten old schedule:\n"); OldSchedule = S.getSchedule(); - DEBUG(printSchedule(dbgs(), OldSchedule, 2)); + LLVM_DEBUG(printSchedule(dbgs(), OldSchedule, 2)); auto Domains = S.getDomains(); auto RestrictedOldSchedule = OldSchedule.intersect_domain(Domains); - DEBUG(dbgs() << "Old schedule with domains:\n"); - DEBUG(printSchedule(dbgs(), RestrictedOldSchedule, 2)); + LLVM_DEBUG(dbgs() << "Old schedule with domains:\n"); + LLVM_DEBUG(printSchedule(dbgs(), RestrictedOldSchedule, 2)); auto NewSchedule = flattenSchedule(RestrictedOldSchedule); - DEBUG(dbgs() << "Flattened new schedule:\n"); - DEBUG(printSchedule(dbgs(), NewSchedule, 2)); + LLVM_DEBUG(dbgs() << "Flattened new schedule:\n"); + LLVM_DEBUG(printSchedule(dbgs(), NewSchedule, 2)); NewSchedule = NewSchedule.gist_domain(Domains); - DEBUG(dbgs() << "Gisted, flattened new schedule:\n"); - DEBUG(printSchedule(dbgs(), NewSchedule, 2)); + LLVM_DEBUG(dbgs() << "Gisted, flattened new schedule:\n"); + LLVM_DEBUG(printSchedule(dbgs(), NewSchedule, 2)); S.setSchedule(NewSchedule); return false; Index: lib/Transform/ForwardOpTree.cpp =================================================================== --- lib/Transform/ForwardOpTree.cpp +++ lib/Transform/ForwardOpTree.cpp @@ -298,12 +298,12 @@ Known = nullptr; Translator = nullptr; NormalizeMap = nullptr; - DEBUG(dbgs() << "Known analysis exceeded max_operations\n"); + LLVM_DEBUG(dbgs() << "Known analysis exceeded max_operations\n"); return false; } KnownAnalyzed++; - DEBUG(dbgs() << "All known: " << Known << "\n"); + LLVM_DEBUG(dbgs() << "All known: " << Known << "\n"); return true; } @@ -491,12 +491,13 @@ return FD_CanForwardProfitably; if (Access) { - DEBUG(dbgs() << " forwarded known load with preexisting MemoryAccess" - << Access << "\n"); + LLVM_DEBUG( + dbgs() << " forwarded known load with preexisting MemoryAccess" + << Access << "\n"); } else { Access = makeReadArrayAccess(TargetStmt, LI, SameVal); - DEBUG(dbgs() << " forwarded known load with new MemoryAccess" << Access - << "\n"); + LLVM_DEBUG(dbgs() << " forwarded known load with new MemoryAccess" + << Access << "\n"); // { ValInst[] } isl::space ValInstSpace = ExpectedVal.get_space().range(); @@ -531,13 +532,14 @@ isl::map LocalTranslator = DefToTarget.reverse().product(ValToVal); Translator = Translator.add_map(LocalTranslator); - DEBUG(dbgs() << " local translator is " << LocalTranslator - << "\n"); + LLVM_DEBUG(dbgs() << " local translator is " << LocalTranslator + << "\n"); } } - DEBUG(dbgs() << " expected values where " << TargetExpectedVal - << "\n"); - DEBUG(dbgs() << " candidate elements where " << Candidates << "\n"); + LLVM_DEBUG(dbgs() << " expected values where " << TargetExpectedVal + << "\n"); + LLVM_DEBUG(dbgs() << " candidate elements where " << Candidates + << "\n"); assert(Access); NumKnownLoadsForwarded++; @@ -761,8 +763,9 @@ if (TargetUse.getKind() == VirtualUse::Synthesizable) return FD_CanForwardLeaf; - DEBUG(dbgs() << " Synthesizable would not be synthesizable anymore: " - << *UseVal << "\n"); + LLVM_DEBUG( + dbgs() << " Synthesizable would not be synthesizable anymore: " + << *UseVal << "\n"); return FD_CannotForward; } @@ -834,7 +837,7 @@ // When no method is found to forward the operand tree, we effectively // cannot handle it. - DEBUG(dbgs() << " Cannot forward instruction: " << *Inst << "\n"); + LLVM_DEBUG(dbgs() << " Cannot forward instruction: " << *Inst << "\n"); return FD_CannotForward; } @@ -844,7 +847,7 @@ /// Try to forward an operand tree rooted in @p RA. bool tryForwardTree(MemoryAccess *RA) { assert(RA->isLatestScalarKind()); - DEBUG(dbgs() << "Trying to forward operand tree " << RA << "...\n"); + LLVM_DEBUG(dbgs() << "Trying to forward operand tree " << RA << "...\n"); ScopStmt *Stmt = RA->getStatement(); Loop *InLoop = Stmt->getSurroundingLoop(); @@ -966,22 +969,22 @@ Impl = llvm::make_unique(&S, &LI, MaxOpGuard); if (AnalyzeKnown) { - DEBUG(dbgs() << "Prepare forwarders...\n"); + LLVM_DEBUG(dbgs() << "Prepare forwarders...\n"); Impl->computeKnownValues(); } - DEBUG(dbgs() << "Forwarding operand trees...\n"); + LLVM_DEBUG(dbgs() << "Forwarding operand trees...\n"); Impl->forwardOperandTrees(); if (MaxOpGuard.hasQuotaExceeded()) { - DEBUG(dbgs() << "Not all operations completed because of " - "max_operations exceeded\n"); + LLVM_DEBUG(dbgs() << "Not all operations completed because of " + "max_operations exceeded\n"); KnownOutOfQuota++; } } - DEBUG(dbgs() << "\nFinal Scop:\n"); - DEBUG(dbgs() << S); + LLVM_DEBUG(dbgs() << "\nFinal Scop:\n"); + LLVM_DEBUG(dbgs() << S); // Update statistics auto ScopStats = S.getStatistics(); Index: lib/Transform/ScheduleOptimizer.cpp =================================================================== --- lib/Transform/ScheduleOptimizer.cpp +++ lib/Transform/ScheduleOptimizer.cpp @@ -1338,7 +1338,7 @@ MatMulInfoTy MMI; if (PMBasedOpts && User && isMatrMultPattern(isl::manage_copy(Node), OAI->D, MMI)) { - DEBUG(dbgs() << "The matrix multiplication pattern was detected\n"); + LLVM_DEBUG(dbgs() << "The matrix multiplication pattern was detected\n"); MatMulOpts++; return optimizeMatMulPattern(isl::manage(Node), OAI->TTI, MMI).release(); } @@ -1484,7 +1484,7 @@ getAnalysis().getDependences(Dependences::AL_Statement); if (D.getSharedIslCtx() != S.getSharedIslCtx()) { - DEBUG(dbgs() << "DependenceInfo for another SCoP/isl_ctx\n"); + LLVM_DEBUG(dbgs() << "DependenceInfo for another SCoP/isl_ctx\n"); return false; } @@ -1539,10 +1539,10 @@ "or 'no'. Falling back to default: 'yes'\n"; } - DEBUG(dbgs() << "\n\nCompute schedule from: "); - DEBUG(dbgs() << "Domain := " << Domain << ";\n"); - DEBUG(dbgs() << "Proximity := " << Proximity << ";\n"); - DEBUG(dbgs() << "Validity := " << Validity << ";\n"); + LLVM_DEBUG(dbgs() << "\n\nCompute schedule from: "); + LLVM_DEBUG(dbgs() << "Domain := " << Domain << ";\n"); + LLVM_DEBUG(dbgs() << "Proximity := " << Proximity << ";\n"); + LLVM_DEBUG(dbgs() << "Validity := " << Validity << ";\n"); unsigned IslSerializeSCCs; @@ -1608,7 +1608,7 @@ ScopsRescheduled++; - DEBUG({ + LLVM_DEBUG({ auto *P = isl_printer_to_str(Ctx); P = isl_printer_set_yaml_style(P, ISL_YAML_STYLE_BLOCK); P = isl_printer_print_schedule(P, Schedule.get()); Index: lib/Transform/ScopInliner.cpp =================================================================== --- lib/Transform/ScopInliner.cpp +++ lib/Transform/ScopInliner.cpp @@ -62,8 +62,8 @@ if (!F) return false; if (F->isDeclaration()) { - DEBUG(dbgs() << "Skipping " << F->getName() - << "because it is a declaration.\n"); + LLVM_DEBUG(dbgs() << "Skipping " << F->getName() + << "because it is a declaration.\n"); return false; } @@ -79,8 +79,8 @@ SD.ValidRegions.count(RI.getTopLevelRegion()) > 0; if (HasScopAsTopLevelRegion) { - DEBUG(dbgs() << "Skipping " << F->getName() - << " has scop as top level region"); + LLVM_DEBUG(dbgs() << "Skipping " << F->getName() + << " has scop as top level region"); F->addFnAttr(llvm::Attribute::AlwaysInline); ModuleAnalysisManager MAM; @@ -91,8 +91,8 @@ assert(M && "Function has illegal module"); MPM.run(*M, MAM); } else { - DEBUG(dbgs() << F->getName() - << " does NOT have scop as top level region\n"); + LLVM_DEBUG(dbgs() << F->getName() + << " does NOT have scop as top level region\n"); } return false; Index: lib/Transform/Simplify.cpp =================================================================== --- lib/Transform/Simplify.cpp +++ lib/Transform/Simplify.cpp @@ -194,8 +194,8 @@ // If all of a write's elements are overwritten, remove it. isl::union_map AccRelUnion = AccRel; if (AccRelUnion.is_subset(WillBeOverwritten)) { - DEBUG(dbgs() << "Removing " << MA - << " which will be overwritten anyway\n"); + LLVM_DEBUG(dbgs() << "Removing " << MA + << " which will be overwritten anyway\n"); Stmt.removeSingleMemoryAccess(MA); OverwritesRemoved++; @@ -453,9 +453,9 @@ isl::map AccRelStoredVal = isl::map::from_domain_and_range( AccRelWrapped, makeValueSet(StoredVal)); if (isl::union_map(AccRelStoredVal).is_subset(Known)) { - DEBUG(dbgs() << "Cleanup of " << MA << ":\n"); - DEBUG(dbgs() << " Scalar: " << *StoredVal << "\n"); - DEBUG(dbgs() << " AccRel: " << AccRel << "\n"); + LLVM_DEBUG(dbgs() << "Cleanup of " << MA << ":\n"); + LLVM_DEBUG(dbgs() << " Scalar: " << *StoredVal << "\n"); + LLVM_DEBUG(dbgs() << " AccRel: " << AccRel << "\n"); Stmt.removeSingleMemoryAccess(MA); @@ -497,8 +497,8 @@ S->simplifySCoP(true); assert(NumStmtsBefore >= S->getSize()); StmtsRemoved = NumStmtsBefore - S->getSize(); - DEBUG(dbgs() << "Removed " << StmtsRemoved << " (of " << NumStmtsBefore - << ") statements\n"); + LLVM_DEBUG(dbgs() << "Removed " << StmtsRemoved << " (of " << NumStmtsBefore + << ") statements\n"); TotalStmtsRemoved[CallNo] += StmtsRemoved; } @@ -516,8 +516,9 @@ if (!AccRel.is_empty().is_true()) continue; - DEBUG(dbgs() << "Removing " << MA - << " because it's a partial access that never occurs\n"); + LLVM_DEBUG( + dbgs() << "Removing " << MA + << " because it's a partial access that never occurs\n"); DeferredRemove.push_back(MA); } @@ -548,7 +549,8 @@ for (MemoryAccess *MA : AllMAs) { if (UsedMA.count(MA)) continue; - DEBUG(dbgs() << "Removing " << MA << " because its value is not used\n"); + LLVM_DEBUG(dbgs() << "Removing " << MA + << " because its value is not used\n"); ScopStmt *Stmt = MA->getStatement(); Stmt->removeSingleMemoryAccess(MA); @@ -569,8 +571,8 @@ for (Instruction *Inst : AllInsts) { auto It = UsedInsts.find({&Stmt, Inst}); if (It == UsedInsts.end()) { - DEBUG(dbgs() << "Removing "; Inst->print(dbgs()); - dbgs() << " because it is not used\n"); + LLVM_DEBUG(dbgs() << "Removing "; Inst->print(dbgs()); + dbgs() << " because it is not used\n"); DeadInstructionsRemoved++; TotalDeadInstructionsRemoved[CallNo]++; continue; @@ -636,29 +638,29 @@ this->S = &S; ScopsProcessed[CallNo]++; - DEBUG(dbgs() << "Removing partial writes that never happen...\n"); + LLVM_DEBUG(dbgs() << "Removing partial writes that never happen...\n"); removeEmptyPartialAccesses(); - DEBUG(dbgs() << "Removing overwrites...\n"); + LLVM_DEBUG(dbgs() << "Removing overwrites...\n"); removeOverwrites(); - DEBUG(dbgs() << "Coalesce partial writes...\n"); + LLVM_DEBUG(dbgs() << "Coalesce partial writes...\n"); coalesceWrites(); - DEBUG(dbgs() << "Removing redundant writes...\n"); + LLVM_DEBUG(dbgs() << "Removing redundant writes...\n"); removeRedundantWrites(); - DEBUG(dbgs() << "Cleanup unused accesses...\n"); + LLVM_DEBUG(dbgs() << "Cleanup unused accesses...\n"); LoopInfo *LI = &getAnalysis().getLoopInfo(); markAndSweep(LI); - DEBUG(dbgs() << "Removing statements without side effects...\n"); + LLVM_DEBUG(dbgs() << "Removing statements without side effects...\n"); removeUnnecessaryStmts(); if (isModified()) ScopsModified[CallNo]++; - DEBUG(dbgs() << "\nFinal Scop:\n"); - DEBUG(dbgs() << S); + LLVM_DEBUG(dbgs() << "\nFinal Scop:\n"); + LLVM_DEBUG(dbgs() << S); auto ScopStats = S.getStatistics(); NumValueWrites[CallNo] += ScopStats.NumValueWrites; Index: lib/Transform/ZoneAlgo.cpp =================================================================== --- lib/Transform/ZoneAlgo.cpp +++ lib/Transform/ZoneAlgo.cpp @@ -339,7 +339,8 @@ if (MA->isRead()) { // Reject load after store to same location. if (!isl_union_map_is_disjoint(Stores.keep(), AccRel.keep())) { - DEBUG(dbgs() << "Load after store of same element in same statement\n"); + LLVM_DEBUG( + dbgs() << "Load after store of same element in same statement\n"); OptimizationRemarkMissed R(PassName, "LoadAfterStore", MA->getAccessInstruction()); R << "load after store of same element in same statement"; @@ -359,7 +360,7 @@ // might be in a boxed loop. if (Stmt->isRegionStmt() && !isl_union_map_is_disjoint(Loads.keep(), AccRel.keep())) { - DEBUG(dbgs() << "WRITE in non-affine subregion not supported\n"); + LLVM_DEBUG(dbgs() << "WRITE in non-affine subregion not supported\n"); OptimizationRemarkMissed R(PassName, "StoreInSubregion", MA->getAccessInstruction()); R << "store is in a non-affine subregion"; @@ -371,7 +372,7 @@ // Do not allow more than one store to the same location. if (!isl_union_map_is_disjoint(Stores.keep(), AccRel.keep()) && !onlySameValueWrites(Stmt)) { - DEBUG(dbgs() << "WRITE after WRITE to same element\n"); + LLVM_DEBUG(dbgs() << "WRITE after WRITE to same element\n"); OptimizationRemarkMissed R(PassName, "StoreAfterStore", MA->getAccessInstruction()); R << "store after store of same element in same statement";