[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-05-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

This went through a few rounds of testing on our internal benchmarks and it's 
at a point where there are no meaningful run-time regressions observed, but the 
compile-time improvements remain and are significant enough to move fwd with 
the change.
Approving to move things forward. If folks do encounter regressions from this 
change before or after landing, please flag them here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145265/new/

https://reviews.llvm.org/D145265

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-03-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Nit: the diffs would be easier to analyze with "-fno-discard-value-names".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145265/new/

https://reviews.llvm.org/D145265

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-26 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Following this change, the following emits warnings: 
https://godbolt.org/z/cvGdMWqEa, https://godbolt.org/z/GhTP85WzE

Can you please fix fwd or revert until resolved?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133574/new/

https://reviews.llvm.org/D133574

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140085: [NFC] Rename Instruction::insertAt() to Instruction::insertInto(), to be consistent with BasicBlock::insertInto()

2022-12-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Rebase to trigger pre-merge checks?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140085/new/

https://reviews.llvm.org/D140085

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140068: [NFC] Rename Function::insertBasicBlockAt() to Function::insert().

2022-12-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

lgtm.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140068/new/

https://reviews.llvm.org/D140068

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136806: [Pipelines] Introduce SROA after (final, full) loop unrolling

2022-11-17 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Green light perf-wise.
I cannot comment on whether the position is "the right" one though. I'm 
deferring to the other reviewers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136806/new/

https://reviews.llvm.org/D136806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136806: [Pipelines] Introduce SROA after (final, full) loop unrolling

2022-11-16 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

As far as performance, this looks fine. Not seeing measurable gains.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136806/new/

https://reviews.llvm.org/D136806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136806: [Pipelines] Introduce SROA after (final, full) loop unrolling

2022-11-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

IIUC compile time impact for adding another SROA (the one outside LTO) is 
negligible?

Regarding the principle of adding another pass and where in the pipeline, we're 
still at a case by case basis. We had a discussion/round table at LLVM Dev on 
the documenting the current new pass manager pipeline precisely for 
understanding pass dependencies and being able to get resolutions on cases such 
as this. I'm still putting together the summary for that but it should be up on 
discourse this week.

Testing this change in parallel - I'll follow up tomorrow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136806/new/

https://reviews.llvm.org/D136806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113304: [NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses

2021-11-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

LGTM, but please wait to see if @nikic has additional comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113304/new/

https://reviews.llvm.org/D113304

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113304: [NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses

2021-11-08 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Thank you for the additional clarifications in the comments and descriptions!

The invalidations are essentially postponed until after the function 
simplification pipeline with this patch.
Before, everything was invalidated in the SCC pass even if only one function 
was touched, and nothing was invalidated after the function passes. With this 
patch, only what is touched is invalidated in the SCC pass, then function 
passes that follow find analyses available (where functions were unmodified), 
and only afterwards all function analyses are invalidated in the 
ModuleToFunction adaptor. The balance is from turning on both D113196 
 and D100917 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113304/new/

https://reviews.llvm.org/D113304

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113210: [NewPM] Use the default AA pipeline by default

2021-11-04 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Can you also update `lib/LTO/LTOBackend.cpp` to something like:

  // Parse a custom AA pipeline if asked to, otherwise the default will be used.
  if (!Conf.AAPipeline.empty()) {
AAManager AA;
if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) {
  report_fatal_error(Twine("unable to parse AA pipeline description '") +
 Conf.AAPipeline + "': " + toString(std::move(Err)));
}
// Register the AA manager first so that our version is the one used.
FAM.registerPass([&] { return std::move(AA); });
  } 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113210/new/

https://reviews.llvm.org/D113210

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111471: [NVPTX] Add a late SROA pass which allows optimizing away more allocas.

2021-10-18 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111471/new/

https://reviews.llvm.org/D111471

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106401: [CUDA, MemCpyOpt] Add a flag to force-enable memcpyopt and use it for CUDA.

2021-08-06 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

lgtm.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106401/new/

https://reviews.llvm.org/D106401

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93743: [NewPM] Run ObjC ARC passes

2021-01-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

The changes LGTM, but I'd rather defer final review to ahatanak@.
It would be good to have some testing but it could be addressed in a separate 
patch, potentially by folks more familiar with the ObjCARC passes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93743/new/

https://reviews.llvm.org/D93743

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93002: [NPM] Support -fmerge-functions

2020-12-10 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Thank you for adding this support.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93002/new/

https://reviews.llvm.org/D93002

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92436: [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation

2020-12-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

lgtm.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92436/new/

https://reviews.llvm.org/D92436

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

2020-11-11 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

AFAICT all issues were addressed.
@Meinersbur: are there any concerns left with this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89158/new/

https://reviews.llvm.org/D89158

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90437: [NFC] Clean up PassBuilder

2020-10-29 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Neat!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90437/new/

https://reviews.llvm.org/D90437

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89158: [NewPM] Run all EP callbacks under -O0

2020-10-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:1659
+ bool DebugLogging) {
+  for (auto &C : PipelineStartEPCallbacks)
+C(MPM);

aeubanks wrote:
> ychen wrote:
> > What I have in mind is a newly added `O0EPCallbacks` field in PassBuilder 
> > class. Then we can keep existing EPCallbacks (including 
> > PipelineStartEPCallbacks) for >O0 optimization pipeline. Yeah, then you 
> > need to add related passes to O0EPCallbacks (for BPF in this case).
> It's a tradeoff between having to specify required passes in both 
> O0EPCallbacks and PipelineStartEPCallbacks which is repetitive, versus making 
> all callbacks in PipelineStartEPCallbacks run at -O0, meaning even optional 
> passes in PipelineStartEPCallbacks will run at -O0 (may be skipped via 
> optnone).
> 
> The legacy PM chooses the first, and I'm inclined to keep it that way just 
> for consistency.
> 
> If we did go down the second route, we could just have a second TargetMachine 
> API like TargetMachine::addO0Passes() which directly adds passes to a 
> ModulePassManager.
This seems more in line with the LPM behavior for O0.
If BPF needs those passes even for O0 they should be added as such.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89158/new/

https://reviews.llvm.org/D89158

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88138: [NPM] Add target specific hook to add passes for New Pass Manager

2020-10-05 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Thank you, Ankit!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88138/new/

https://reviews.llvm.org/D88138

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I checked in a fix in https://reviews.llvm.org/rGfc8200633122, but I haven't 
yet verified it addresses all the failures reported.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Right!
I believe the solution is to set the location size to unknown after a phi 
translation with the same ptr, but I need to properly verify that.

  // include/llvm/Analysis/MemorySSA.h:1233
  CurrentPair.second = Location.getWithNewSize(LocationSize::unknown());
  return


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Yes, the load should have the Phi as the defining access. I'm still looking 
into where this information should come from, but it's not hitting the phi 
translation.
Thank you for the revert, I'll update with the fix once I have it available.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-14 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I'd suggest reverting if the failures are blocking, but we do need a reproducer 
so it can be recommitted after a fix is in place.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-10 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

I'm running additional testing in the background. I don't have anything holding 
this back at this point.
Either check in and if something shows up, I'll let you know to resolve or 
revert, or wait another 1-2 days for the testing I'm running to complete.
I'm ok with either option, and may even be inclined for the former, because 
there may be additional parties coming forward if issues arise, and I'd like 
these to come up earlier rather than later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:312
 switch (II->getIntrinsicID()) {
 default: llvm_unreachable("doesn't pass 'hasAnalyzableMemoryWrite' 
predicate");
 case Intrinsic::lifetime_end:

The crash is hitting this unreachable for the intrinsic "llvm.memcpy.inline".
Simple repro: opt -dse test1.ll
```
define void @test(i8* noalias nocapture %0, i8* noalias nocapture readonly %1) {
  tail call void @llvm.memcpy.inline(i8* align 1 %0, i8* align 1 %1, i64 3, i1 
false)
  ret void
}

declare void @llvm.memcpy.inline(i8* noalias nocapture writeonly, i8* noalias 
nocapture readonly, i64 immarg, i1 immarg)
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea requested changes to this revision.
asbirlea added a comment.
This revision now requires changes to proceed.

I'm running into a crash with this, could you please hold off until tomorrow? 
I'm working on getting a reproducer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.

Green light from me as well. I think there's still room for improvement for the 
NPM, but this is the right step to move forward infrastructure-wise.

Regarding the MemCpyOpt question from nikic@, please let me know if you want to 
take that over.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87163/new/

https://reviews.llvm.org/D87163

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85676: [NewPM] collapsing nested pass mangers of the same type

2020-08-28 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Seems like a good idea. I'm curious if you saw any impact from this change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85676/new/

https://reviews.llvm.org/D85676

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.

Diff looks reasonable at this point. Thank you for the patch!
Please wait on @nikic for compile-time impact or additional feedback.

Just out of curiosity, in D65060 , it was 
mentioned that using BFI got you ~7% improvement for a CPU related metric 
(@wenlei). Are you seeing benefits from this patch? And which pass manager are 
you using?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86156/new/

https://reviews.llvm.org/D86156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h:273
   : nullptr;
+BlockFrequencyInfo *BFI = UseBlockFrequencyInfo
+  ? (&AM.getResult(F))

Add `&& F.hasProfileData()` check here, in the NPM as well?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86156/new/

https://reviews.llvm.org/D86156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Your understanding is correct. I only have one more comment on preserving 
passes in LICM too.

As a general note, it may make sense to include BFI in the set of loop passes 
always preserved (`getLoopPassPreservedAnalyses()`), if its nature is to always 
be preserved (with some potential info loss) due to the callbacks deleting 
blocks. But since we're only looking at LICM effect for now, this can be a 
follow up when/if needed.

Please allow some time for nikic@ to take a look too.




Comment at: llvm/test/Other/opt-O2-pipeline.ll:281
 ; CHECK-NEXT: Loop Invariant Code Motion
 ; CHECK-NEXT:   Lazy Branch Probability Analysis
 ; CHECK-NEXT:   Lazy Block Frequency Analysis

Mark LICM to preserve these passes so they get moved above LICM rather than 
recomputed here (same as they are preserved in unswitch).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86156/new/

https://reviews.llvm.org/D86156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-26 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:522
   FPM.addPass(createFunctionToLoopPassAdaptor(
-  std::move(LPM2), /*UseMemorySSA=*/false, DebugLogging));
+  std::move(LPM2), /*UseMemorySSA=*/false, /*UseBlockFrequencyInfo=*/true,
+  DebugLogging));

It doesn't look like `UseBlockFrequencyInfo` is used for LPM2 here and below. 
Would it make sense to set it to `false` at this point?




Comment at: llvm/test/Other/pass-pipelines.ll:57
 ; CHECK-O2: Loop Pass Manager
-; CHECK-O2-NOT: Manager
+; Requiring block frequency for LICM will place ICM and rotation under 
separate Loop Pass Manager
 ; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and

Add `; CHECK-O2: Loop Pass Manager` along with this comment.


Please consider if splitting the loop pass pipeline has any effects on 
optimizations. This is for the legacyPM only, so those who switched to the 
newPM will not be affected.
The solution may be to mark the analyses preserved in loop unswitch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86156/new/

https://reviews.llvm.org/D86156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-08-21 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Done in https://reviews.llvm.org/rG7ea0ee30588,


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84713/new/

https://reviews.llvm.org/D84713

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-20 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea requested changes to this revision.
asbirlea added a comment.
This revision now requires changes to proceed.

A couple of quick comments, I haven't gone into details yet.

- please split off the changes that are NFCs (deleted spaces) and clang-format 
for ease to review.
- the test changes show a lot of dependencies that overload the loop pipeline. 
If only LICM benefits from it, I'd consider creating a BFI instance for the 
duration of the LICM pass, or only enabling it in loop pipelines that have LICM 
in them (see example comment in one of the tests).




Comment at: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h:278
AM.getResult(F),
+   
&AM.getResult(F),
MSSA};

This should not be unconditional. See MSSA approach.



Comment at: llvm/test/Transforms/LoopRotate/pr35210.ll:51
+; MSSA-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; MSSA-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f

e.g. there's no use of creating these for LoopRotate.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86156/new/

https://reviews.llvm.org/D86156

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-29 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I'm looking into it.  If needed this can be reverted as it's not blocking the 
work for DomTree updates with a CFGView.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84713/new/

https://reviews.llvm.org/D84713

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-28 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe22de4e46d1d: [DominatorTree] Simplify ChildrenGetter. 
(authored by asbirlea).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84713/new/

https://reviews.llvm.org/D84713

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h

Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  if (!BUI)
-return Get(N, Tag());
+  template 
+  static SmallVector getChildren(NodePtr N, BatchUpdatePtr BUI) {
+if (BUI)
   return BUI->PreViewCFG.template getChildren(N);
-}
-  };
+GraphDiffT GD;
+return GD.template getChildren(N);
+  }
 
   NodePtr getIDom(NodePtr BB) const {
 auto InfoIt = NodeToInfo.find(BB);
@@ -194,8 +176,7 @@
   NumToNode.push_back(BB);
 
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  for (const NodePtr Succ : getChildren(BB, BatchUpdates)) {
 const auto SIT = NodeToInfo.find(Succ);
 // Don't visit nodes more than once but remember to collect
 // ReverseChildren.
@@ -330,7 +311,7 @@
   // to CFG nodes within infinite loops.
   static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) {
 assert(N && "N must be a valid node");
-return !ChildrenGetter::Get(N, BUI).empty();
+return !getChildren(N, BUI).empty();
   }
 
   static NodePtr GetEntryNode(const DomTreeT &DT) {
@@ -748,8 +729,7 @@
 //
 // Invariant: there is an optimal path from `To` to TN with the minimum
 // depth being CurrentLevel.
-for (const NodePtr Succ :
- ChildrenGetter::Get(TN->getBlock(), BUI)) {
+for (const NodePtr Succ : getChildren(TN->getBlock(), BUI)) {
   const TreeNodePtr SuccTN = DT.getNode(Succ);
   assert(SuccTN &&
  "Unreachable successor found at reachable insertion");
@@ -879,7 +859,7 @@
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.
 auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) {
-  auto Successors = ChildrenGetter::Get(Of, BUI);
+  auto Successors = getChildren(Of, BUI);
   return llvm::find(Successors, SuccCandidate) != Successors.end();
 };
 (void)IsSuccessor;
@@ -967,7 +947,7 @@
 LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN)
   << "\n");
 auto TNB = TN->getBlock();
-for (const NodePtr Pred : ChildrenGetter::Get(TNB, BUI)) {
+for (const NodePtr Pred : getChildren(TNB, BUI)) {
   LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
   if (!DT.getNode(Pred)) continue;
 
Index: clang/include/clang/Analysis/Analyses/Dominators.h
===
--- clang/include/clang/Analysis/Analyses/Dominators.h
+++ clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- /*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy ClangCFGDomChildrenGetter::Get(
-clang::

[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-28 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 281382.
asbirlea added a comment.

Renamed ChildrenGet to getChildren. The same name only exists in GraphDiff, 
it's ok to keep a consistent naming.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84713/new/

https://reviews.llvm.org/D84713

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h

Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  if (!BUI)
-return Get(N, Tag());
+  template 
+  static SmallVector getChildren(NodePtr N, BatchUpdatePtr BUI) {
+if (BUI)
   return BUI->PreViewCFG.template getChildren(N);
-}
-  };
+GraphDiffT GD;
+return GD.template getChildren(N);
+  }
 
   NodePtr getIDom(NodePtr BB) const {
 auto InfoIt = NodeToInfo.find(BB);
@@ -194,8 +176,7 @@
   NumToNode.push_back(BB);
 
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  for (const NodePtr Succ : getChildren(BB, BatchUpdates)) {
 const auto SIT = NodeToInfo.find(Succ);
 // Don't visit nodes more than once but remember to collect
 // ReverseChildren.
@@ -330,7 +311,7 @@
   // to CFG nodes within infinite loops.
   static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) {
 assert(N && "N must be a valid node");
-return !ChildrenGetter::Get(N, BUI).empty();
+return !getChildren(N, BUI).empty();
   }
 
   static NodePtr GetEntryNode(const DomTreeT &DT) {
@@ -748,8 +729,7 @@
 //
 // Invariant: there is an optimal path from `To` to TN with the minimum
 // depth being CurrentLevel.
-for (const NodePtr Succ :
- ChildrenGetter::Get(TN->getBlock(), BUI)) {
+for (const NodePtr Succ : getChildren(TN->getBlock(), BUI)) {
   const TreeNodePtr SuccTN = DT.getNode(Succ);
   assert(SuccTN &&
  "Unreachable successor found at reachable insertion");
@@ -879,7 +859,7 @@
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.
 auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) {
-  auto Successors = ChildrenGetter::Get(Of, BUI);
+  auto Successors = getChildren(Of, BUI);
   return llvm::find(Successors, SuccCandidate) != Successors.end();
 };
 (void)IsSuccessor;
@@ -967,7 +947,7 @@
 LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN)
   << "\n");
 auto TNB = TN->getBlock();
-for (const NodePtr Pred : ChildrenGetter::Get(TNB, BUI)) {
+for (const NodePtr Pred : getChildren(TNB, BUI)) {
   LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
   if (!DT.getNode(Pred)) continue;
 
Index: clang/include/clang/Analysis/Analyses/Dominators.h
===
--- clang/include/clang/Analysis/Analyses/Dominators.h
+++ clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- /*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy ClangCFGDomChildrenGetter::Get(
-clang::CFGBlock *N, std::integral_constant) {
-

[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

I'm ok if this is added in either this or a follow-up patch.
I think it's useful to have it in the codebase now, with one test to showcase 
it (e.g. do another run line in `new-pass-manager.ll`, with `check-prefixes`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84774/new/

https://reviews.llvm.org/D84774

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Does it make sense to have the option to enable seeing where the adaptors are 
run?

Otherwise this looks good, it's nice to have the "Starting" and "Finished" 
match now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84774/new/

https://reviews.llvm.org/D84774

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
asbirlea added reviewers: kuhar, dblaikie.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Simplify ChildrenGetter to a simple wrapper around a GraphDiff call.
GraphDiff already handles nullptr in children, so the special casing in
clang can also be removed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84713

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h

Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  if (!BUI)
-return Get(N, Tag());
+  template 
+  static SmallVector ChildrenGet(NodePtr N, BatchUpdatePtr BUI) {
+if (BUI)
   return BUI->PreViewCFG.template getChildren(N);
-}
-  };
+GraphDiffT GD;
+return GD.template getChildren(N);
+  }
 
   NodePtr getIDom(NodePtr BB) const {
 auto InfoIt = NodeToInfo.find(BB);
@@ -194,8 +176,7 @@
   NumToNode.push_back(BB);
 
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  for (const NodePtr Succ : ChildrenGet(BB, BatchUpdates)) {
 const auto SIT = NodeToInfo.find(Succ);
 // Don't visit nodes more than once but remember to collect
 // ReverseChildren.
@@ -330,7 +311,7 @@
   // to CFG nodes within infinite loops.
   static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) {
 assert(N && "N must be a valid node");
-return !ChildrenGetter::Get(N, BUI).empty();
+return !ChildrenGet(N, BUI).empty();
   }
 
   static NodePtr GetEntryNode(const DomTreeT &DT) {
@@ -748,8 +729,7 @@
 //
 // Invariant: there is an optimal path from `To` to TN with the minimum
 // depth being CurrentLevel.
-for (const NodePtr Succ :
- ChildrenGetter::Get(TN->getBlock(), BUI)) {
+for (const NodePtr Succ : ChildrenGet(TN->getBlock(), BUI)) {
   const TreeNodePtr SuccTN = DT.getNode(Succ);
   assert(SuccTN &&
  "Unreachable successor found at reachable insertion");
@@ -879,7 +859,7 @@
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.
 auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) {
-  auto Successors = ChildrenGetter::Get(Of, BUI);
+  auto Successors = ChildrenGet(Of, BUI);
   return llvm::find(Successors, SuccCandidate) != Successors.end();
 };
 (void)IsSuccessor;
@@ -967,7 +947,7 @@
 LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN)
   << "\n");
 auto TNB = TN->getBlock();
-for (const NodePtr Pred : ChildrenGetter::Get(TNB, BUI)) {
+for (const NodePtr Pred : ChildrenGet(TNB, BUI)) {
   LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
   if (!DT.getNode(Pred)) continue;
 
Index: clang/include/clang/Analysis/Analyses/Dominators.h
===
--- clang/include/clang/Analysis/Analyses/Dominators.h
+++ clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- /*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy ClangCFGDomChildre

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bf4c1f4fb25: Reapply "[DomTree] Replace ChildrenGetter 
with GraphTraits over GraphDiff." (authored by asbirlea).

Changed prior to commit:
  https://reviews.llvm.org/D77341?vs=280326&id=280590#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,50 +120,16 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-: BUI->FutureSuccessors;
-  auto FCIt = FutureChildren.find(N);
-  if (FCIt == Fu

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Great, thank you for confirming :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Yes. The difference in perf in instructions and cycles count is due to 
reversing the update order.
I'm still not seeing meaningful changes in wall-time even with the update order 
reversed, but reliable wall-time testing is hard.

I do have changes that

- drop the GraphTraits usage entirely in favor of the getChildren() method in 
GraphDiff
- refactor the hashmaps in GraphDiff

but I plan to send those separately.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-23 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 280326.
asbirlea added a comment.

The increase in number of instructions and cycles was caused by reversing the 
order in which the updates are applied by GraphDiff.
I'll look into re-adding some of the original cleanups in a follow-up patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,50 +120,16 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-: BUI->FutureSuccessors;
-  auto FCIt = FutureChildren.find(N);
-  if (FCIt == FutureChil

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-10 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Thank you for the testing. Could you help with with instructions on how to run 
the tracker myself?
My local testing showed a negligible regression for mafft and a negligible 
improvement on other benchmarks, so it looked like noise on average.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 276891.
asbirlea added a comment.

Nit: re-add `const`s


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,49 +120,23 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-: BUI->FutureSuccessors;
-  auto FCIt = FutureChildren.find(N);
-  if (FCIt == FutureChildren.end()) return Res;
-
-  for (auto ChildAndKind : FCIt->second) {
-const NodePtr Child = ChildAndKind.getPointer();
-const UpdateKind UK = ChildAndKind.getInt();
-

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 276890.
asbirlea added a comment.
This revision is now accepted and ready to land.

Updated to include the part of the patch that's moving the Updates to a CFGDiff 
object. Splitting off from the clean-up work merging the two branches when BUI 
is null.
This patch does not exhibit the compile-time regression which caused it to be 
reverted previously.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,8 +107,7 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
+  template  struct ChildrenGetter {
 using ResultTy = SmallVector;
 
 static ResultTy Get(NodePtr N, std::integral_constant) {
@@ -121,49 +120,23 @@
   return ResultTy(IChildren.begin(), IChildren.end());
 }
 
-using Tag = std::integral_constant;
+using Tag = std::integral_constant;
 
 // The function below is the core part of the batch updater. It allows the
 // Depth Based Search algorithm to perform incremental updates in lockstep
 // with updates to the CFG. We emulated lockstep CFG updates by getting its
 // next snapshots by reverse-applying future updates.
 static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != IsPostDom) ? BUI->FuturePredecessors
-   

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-06 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

In D83013#2132088 , @aeubanks wrote:

> In D83013#2132070 , @echristo wrote:
>
> > Adding Chandler and Alina here as well.
> >
> > In general, I don't think that this is such a great idea. Being able to 
> > have this sort of thing work more reliably is one of the reasons for the 
> > new pass manager. I think I'd like to see this split out into an old versus 
> > new pass manager pass to avoid the difficulty of cleaning this up after we 
> > finish migrating llvm to the new pass manager. This also seems to add some 
> > technical debt around options and other enablement which is also less than 
> > ideal. Is this compelling to add right now versus finishing work migrating 
> > llvm completely to the new pass manager and removing the old one? From 
> > speaking with Alina I think that work should be done in a short while.
> >
> > Thanks.
> >
> > -eric
>
>
> I don't think we're that close yet, probably at least a couple months out, 
> there are lots of loose ends to be tied up. I'll make a post soon in llvm-dev 
> (maybe first we can sync up again) about what I think needs to be done before 
> the NPM switch.


+1 to sync up again and make progress towards the NPM switch.

I don't want to block this patch, but I do agree with Eric's point. We *really* 
want to focus more on the switch then invest into more LPM infra. Short term 
resolutions to unblock folks, with the best split possible, sure, keeping in 
mind they'll need to be cleaned up. But I don't want us to lose focus on tying 
up the remaining loose ends for the switch.
I think it's critical for LLVM's codebase health to focus on the NPM switch in 
the next couple of months.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-05-13 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd541b217f4d: [NewPassManager] Add assertions when getting 
statefull cached analysis. (authored by asbirlea).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop &L, LoopAnalysisManager &AM,
 LoopStandardAnalysisResults &AR) {
 auto &FAMP = AM.getResult(L, AR);
-auto &FAM = FAMP.getManager();
 Function &F = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int &RunCount, int &AnalyzedInstrCount,
-   int &AnalyzedFunctionCount,
+   int &AnalyzedFunctionCount, ModuleAnalysisManager &MAM,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
 ++RunCount;
 
-const ModuleAnalysisManager &MAM =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto &ModuleProxy = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int &RunCount;
   int &AnalyzedInstrCount;
   int &AnalyzedFunctionCount;
+  ModuleAnalysisManager &MAM;
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ 

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-05-12 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 263590.
asbirlea marked 3 inline comments as done.
asbirlea added a comment.

Address comments.
Thank you for the review!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop &L, LoopAnalysisManager &AM,
 LoopStandardAnalysisResults &AR) {
 auto &FAMP = AM.getResult(L, AR);
-auto &FAM = FAMP.getManager();
 Function &F = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int &RunCount, int &AnalyzedInstrCount,
-   int &AnalyzedFunctionCount,
+   int &AnalyzedFunctionCount, ModuleAnalysisManager &MAM,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
 ++RunCount;
 
-const ModuleAnalysisManager &MAM =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto &ModuleProxy = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int &RunCount;
   int &AnalyzedInstrCount;
   int &AnalyzedFunctionCount;
+  ModuleAnalysisManager &MAM;
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ AnalyzedFunctionCount3, MAM));
   

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-05-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Weekly re-ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-05-04 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Thank you for adding this!

Please update first sentence in the description to:

  We want to add a way to avoid merging identical calls so as to keep the 
separate debug-information for those calls. There is also an asan usecase where 
having this attribute would be beneficial to avoid alternative work-arounds.




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78659/new/

https://reviews.llvm.org/D78659



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-30 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea reopened this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.
Herald added a project: LLVM.

I'm working to update this revision to address the compile-time regression.
Re-opening so I can rebase and add misc fixes and will mark as changes planned 
until I address the compile-time issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-30 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 261404.
asbirlea added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/CFGDiff.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,13 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
+  using GraphDiffNodePair = std::pair;
+  using GraphDiffInvNodePair = std::pair>;
+  using GraphDiffNodePairIfDomT =
+  std::conditional_t;
+  using GraphDiffNodePairIfPDomT =
+  std::conditional_t;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +84,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,67 +113,6 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was performed.
-  auto &FutureChildren = (Inverse != Is

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-30 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Gentle ping for more comments :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78659: Add nomerge function attribute to supress tail merge optimization in simplifyCFG

2020-04-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I think that expanding the patch description will help motivate this and 
clarify the use-cases for which this is useful, and how it differentiates from 
`noinline`.
Perhaps include that the attribute aims to avoid merging identical calls so as 
to keep the separate debug-information for those calls, and that there is an 
asan usecase where having this attribute would be beneficial to avoid 
alternative work-arounds.
If you have a link to the feature request for this, include that in the 
description as well, or include the motivation behind it.

Note there are other LLVM passes (beside SimplifyCFG) that may need to check 
for this argument to prevent optimizations (e.g. LICM does instruction 
sinking/hoising, add check ~LICM.cpp:1092?).

Include a comment in the `clang/test/CodeGen/attr-nomerge.c` test on the 
expected outcome of the test. Something like:
"The attribute no-merge prevents the 3 bar() calls from being merged into one 
inside foo. Check that there are still 3 tail calls."


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78659/new/

https://reviews.llvm.org/D78659



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-22 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 259450.
asbirlea marked 8 inline comments as done.
asbirlea added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop &L, LoopAnalysisManager &AM,
 LoopStandardAnalysisResults &AR) {
 auto &FAMP = AM.getResult(L, AR);
-auto &FAM = FAMP.getManager();
 Function &F = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int &RunCount, int &AnalyzedInstrCount,
-   int &AnalyzedFunctionCount,
+   int &AnalyzedFunctionCount, ModuleAnalysisManager &MAM,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
 ++RunCount;
 
-const ModuleAnalysisManager &MAM =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto &ModuleProxy = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int &RunCount;
   int &AnalyzedInstrCount;
   int &AnalyzedFunctionCount;
+  ModuleAnalysisManager &MAM;
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ AnalyzedFunctionCount3, MAM));
 FPM.addPass(TestInvalida

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-22 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/include/llvm/Analysis/CGSCCPassManager.h:856-858
+auto *ResultFAMCP =
+&CGAM.getResult(*C, CG);
+ResultFAMCP->updateFAM(FAM);

chandlerc wrote:
> Check that it doesn't hit an assert failure, but I think you can remove this 
> one.
Removing this hits the assertion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-09 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa90374988e4e: [DomTree] Replace ChildrenGetter with 
GraphTraits over GraphDiff. (authored by asbirlea).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/IR/CFGDiff.h
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,13 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
+  using GraphDiffNodePair = std::pair;
+  using GraphDiffInvNodePair = std::pair>;
+  using GraphDiffNodePairIfDomT =
+  std::conditional_t;
+  using GraphDiffNodePairIfPDomT =
+  std::conditional_t;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +84,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,67 +113,6 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's 

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea marked 2 inline comments as done.
asbirlea added a comment.

Thank you for all the comments.




Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:325
+auto &GD = BUI ? BUI->PreViewCFG : EmptyGD;
+return !empty(children({&GD, N}));
   }

kuhar wrote:
> asbirlea wrote:
> > kuhar wrote:
> > > This pattern repeats a few times. Could it be pushed into a helper 
> > > function to get something like this?
> > > 
> > > ```
> > > return !empty(children(GetGraphDiffNodePair(BUI, N)));
> > > ```
> > > 
> > My dilemma here is how to not allocate a GraphDiffT instance. There are 4 
> > cases where the pattern is inside a static method and once in a class 
> > method. I used a stack var for the 4 cases and a unique_ptr for the class 
> > method.
> > 
> > Sure, I can do:
> > ```
> > static auto getGDNPair(BUI, EmptyGD, N) {
> > return std::make_pair<>(BUI ? BUI->PreViewCFG : EmptyGD, N);
> > }
> > {
> > ...
> > GraphDiffT EmptyGD;
> > return !empty(children(getGDNPair(BUI, &EmptyGD, N)));
> > }
> > ```
> > But it felt like moving one line at the callsite to a oneline helper is not 
> > making things much better.
> > 
> > 
> > I was hoping for something more along the lines of:
> > ```
> > return !empty(children({getGD(BUI), N});
> > ```
> > Or, ensure BUI is always non-null, and simplify to:
> > ```
> > return !empty(children({BUI->PreViewCFG, N});
> > ```
> > 
> > 
> > Thoughts?
> Does allocating a GD have a big cost?
> 
> I think you could get away with returning a temporary GD object that would 
> die as soon as the expression evaluation ends -- should be no different than 
> placing it on the stack just before the function call.
> 
> Overall, I still don't understand why you try to avoid creating a wrapper 
> function / struct that returns children, and call `childredn<...>(...)` 
> directly. Either way, I being able to write:
> ```
> return !empty(children({getGD(BUI), N});
> ```
> or 
> ```
> return !empty(getChildren(BUI, N));
> ```
> would definitely be concise and readable enough IMO.
> Does allocating a GD have a big cost?
AFAIU, dynamically allocating the object does, vs having a stack variable.


I'll do a follow-up cleanup attempt.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea marked 4 inline comments as done.
asbirlea added inline comments.



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:325
+auto &GD = BUI ? BUI->PreViewCFG : EmptyGD;
+return !empty(children({&GD, N}));
   }

kuhar wrote:
> This pattern repeats a few times. Could it be pushed into a helper function 
> to get something like this?
> 
> ```
> return !empty(children(GetGraphDiffNodePair(BUI, N)));
> ```
> 
My dilemma here is how to not allocate a GraphDiffT instance. There are 4 cases 
where the pattern is inside a static method and once in a class method. I used 
a stack var for the 4 cases and a unique_ptr for the class method.

Sure, I can do:
```
static auto getGDNPair(BUI, EmptyGD, N) {
return std::make_pair<>(BUI ? BUI->PreViewCFG : EmptyGD, N);
}
{
...
GraphDiffT EmptyGD;
return !empty(children(getGDNPair(BUI, &EmptyGD, N)));
}
```
But it felt like moving one line at the callsite to a oneline helper is not 
making things much better.


I was hoping for something more along the lines of:
```
return !empty(children({getGD(BUI), N});
```
Or, ensure BUI is always non-null, and simplify to:
```
return !empty(children({BUI->PreViewCFG, N});
```


Thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 255852.
asbirlea marked an inline comment as done.
asbirlea added a comment.

Name anonymous namespace.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/IR/CFGDiff.h
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,13 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
+  using GraphDiffNodePair = std::pair;
+  using GraphDiffInvNodePair = std::pair>;
+  using GraphDiffNodePairIfDomT =
+  std::conditional_t;
+  using GraphDiffNodePairIfPDomT =
+  std::conditional_t;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +84,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,67 +113,6 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-03 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 254943.
asbirlea marked 16 inline comments as done.
asbirlea added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/IR/CFGDiff.h
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,13 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
+  using GraphDiffNodePair = std::pair;
+  using GraphDiffInvNodePair = std::pair>;
+  using GraphDiffNodePairIfDomT =
+  std::conditional_t;
+  using GraphDiffNodePairIfPDomT =
+  std::conditional_t;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +84,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewCFG)
+: PreViewCFG(PreViewCFG),
+  NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT &PreViewCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,67 +113,6 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  ResultTy Res = Get(N, Tag());
-  // If there's no batch update in progress, simply return node's children.
-  if (!BUI) return Res;
-
-  // CFG children are actually its *most current* children, and we have to
-  // reverse-apply the future updates to get the node's children at the
-  // point in time the update was perfor

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-03 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:185
+  std::make_pair(GDTmp, BB);
+  for (auto &Pair : children(GDNodePair)) {
+const NodePtr Succ = Pair.second;

kuhar wrote:
> Won't children infer the template parameter based on the passes value? I 
> don't get why the template argument type is a pair where the second argument 
> is a directed nodeptr, but the runtime value is always a plain nodeptr. 
> Couldn't the second pair type also be directed for `GDNodePair`?
The directed nodeptr is the equivalent of a bool inside GraphDiff translating 
to what kind of children do you want; the second pair argument bears no info of 
that kind, only the actual NodePtr for which we desire the children.



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:186
+  for (auto &Pair : children(GDNodePair)) {
+const NodePtr Succ = Pair.second;
 const auto SIT = NodeToInfo.find(Succ);

kuhar wrote:
> kuhar wrote:
> > Could this new code be a hoisted into a helper function?
> Or alternatively, could the old `ChildrenGetter` be implemented with these 5 
> magic lines?
I think it looks much cleaner after the latest update, let me know what you 
think.



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:1543
+  // FIXME: Updated to use the PreViewCFG and behave the same as until now.
+  // This behavior is however incorrect; this actually needs the PostViewCFG.
+  GraphDiff PreViewCFG(

kuhar wrote:
> Does this care about the direction (pre- or post-) at all, or does it need 
> some CFG view? Why is pre-view incorrect?
The purpose of this method was to update the DT assuming an additional list of 
updates (the argument given). In practice, the BUI argument is ignored in the 
`CalculateFromScratch` call below. Hence we need the additional changes to 
support this kind of updates inside `CalculateFromScratch` and the other 
methods.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I sent this out to get some general feedback, but I'd like to be able to 
simplify the fact that this is replacing a `for` over `ChildrenGetter` with a 
`for` over `children(pair)`, plus 5 lines to set up the type and pair; 
one simplification is around getting the type inside `children` 
(`GraphDiffBBPair`) and another around having the BUI or not; for the latter 
I'm considering updating a few places such that BUI is never nullptr.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77341/new/

https://reviews.llvm.org/D77341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
asbirlea added reviewers: kuhar, dblaikie, NutshellySima.
Herald added subscribers: cfe-commits, hiraditya.
Herald added a project: clang.
asbirlea added a comment.
asbirlea added a parent revision: D77167: [GraphDiff] Extend GraphDiff to track 
a list of updates..

I sent this out to get some general feedback, but I'd like to be able to 
simplify the fact that this is replacing a `for` over `ChildrenGetter` with a 
`for` over `children(pair)`, plus 5 lines to set up the type and pair; 
one simplification is around getting the type inside `children` 
(`GraphDiffBBPair`) and another around having the BUI or not; for the latter 
I'm considering updating a few places such that BUI is never nullptr.


This replaces the ChildrenGetter inside the DominatorTree with
GraphTraits over a GraphDiff object, an object which encapsulated the
view of the previous CFG.
This also simplifies the extentions in clang which use DominatorTree, as
GraphDiff also filters nullptrs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77341

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/IR/CFGDiff.h
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree &DT, BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree &DT, DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree &DT, DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree &DT,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree &DT,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewOfCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT &PreViewOfCFG)
+: PreViewOfCFG(&PreViewOfCFG),
+  NumLegalized(PreViewOfCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT *PreViewOfCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,67 +107,6 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Sear

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-01 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 254378.
asbirlea added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update clang test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72893/new/

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop &L, LoopAnalysisManager &AM,
 LoopStandardAnalysisResults &AR) {
 auto &FAMP = AM.getResult(L, AR);
-auto &FAM = FAMP.getManager();
 Function &F = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int &RunCount, int &AnalyzedInstrCount,
-   int &AnalyzedFunctionCount,
+   int &AnalyzedFunctionCount, ModuleAnalysisManager &MAM,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
 ++RunCount;
 
-const ModuleAnalysisManager &MAM =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto &ModuleProxy = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int &RunCount;
   int &AnalyzedInstrCount;
   int &AnalyzedFunctionCount;
+  ModuleAnalysisManager &MAM;
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ AnalyzedFunctionCount3, MAM));

[PATCH] D73162: [test] Avoid loop-unroll.c test getting confused by fadd in git revision

2020-01-22 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

SGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73162/new/

https://reviews.llvm.org/D73162



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73162: [test] Avoid loop-unroll.c test getting confused by fadd in git revision

2020-01-22 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Oh, wow! Might I ask you add the same for fmul? We may get a revision like that 
next time :).
Thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73162/new/

https://reviews.llvm.org/D73162



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68535: Fix loop unrolling initialization in the new pass manager

2019-10-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Maybe elaborate in the patch description what `determine when and how we will 
unroll loops.` means?
e.g.: 
"The default before and after this patch is for LoopUnroll to be enabled, and 
for it to use a cost model to determine whether to unroll the loop 
(`OnlyWhenForced = false`). Before this patch, disabling loop unroll would not 
run the LoopUnroll pass. After this patch, the LoopUnroll pass is being run, 
but it restricts unrolling to only the loops marked by a pragma 
(`OnlyWhenForced = true`).
In addition, this patch disables the UnrollAndJam pass when disabling 
unrolling."

Otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68535/new/

https://reviews.llvm.org/D68535



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61879: WIP: Prototype of DSE optimizations for -ftrivial-auto-var-init

2019-07-08 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/include/llvm/Analysis/MemorySSA.h:1109
 // else.
-if (MemoryPhi *MP = dyn_cast(Access))
+if (const MemoryPhi *MP = dyn_cast(Access))
   return MP->getIncomingValue(ArgNo);

Could changes in this file be landed separately?
They seem unrelated and not in need of review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61879/new/

https://reviews.llvm.org/D61879



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-24 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361653: [NewPassManager] Add tuning option: LoopUnrolling 
[clang-change] (authored by asbirlea, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D61620?vs=198704&id=201285#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61620/new/

https://reviews.llvm.org/D61620

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/loop-unroll.c


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1051,6 +1051,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHE

[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-23 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361534: [NewPassManager] Add tuning option: SLPVectorization 
[clang-change] (authored by asbirlea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61617?vs=198587&id=201033#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61617/new/

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/loop-vectorize.c


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1050,7 +1050,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
Index: test/CodeGen/loop-vectorize.c
===
--- test/CodeGen/loop-vectorize.c
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fno-vectorize -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+// CHECK-DISABLE-VECT-NOT: fmul <{{[0-9]+}} x double>
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1050,7 +1050,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
Index: test/CodeGen/loop-vectorize.c
===
--- test/CodeGen/loop-vectorize.c
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+// CHECK-DISABLE-VECT-NOT: fmul <{{[0-9]+}} x double>
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-08 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198704.
asbirlea added a comment.

Update test.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61620/new/

https://reviews.llvm.org/D61620

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/loop-unroll.c


Index: test/CodeGen/loop-unroll.c
===
--- /dev/null
+++ test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang -target x86_64 -S -c -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -target x86_64 -S -c -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-funroll-loops -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fno-unroll-loops -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1026,6 +1026,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


Index: test/CodeGen/loop-unroll.c
===
--- /dev/null
+++ test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang -target x86_64 -S -c -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -target x86_64 -S -c -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CH

[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198587.
asbirlea added a comment.

Updated test.
Improvement suggestions are always *very* much welcome!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61617/new/

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/loop-vectorize.c


Index: test/CodeGen/loop-vectorize.c
===
--- /dev/null
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fno-vectorize -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+// CHECK-DISABLE-VECT-NOT: fmul <{{[0-9]+}} x double>
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {


Index: test/CodeGen/loop-vectorize.c
===
--- /dev/null
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+// CHECK-DISABLE-VECT-NOT: fmul <{{[0-9]+}} x double>
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198562.
asbirlea added a comment.

Updated test.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61617/new/

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/loop-vectorize.c


Index: test/CodeGen/loop-vectorize.c
===
--- /dev/null
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,24 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fno-vectorize -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {


Index: test/CodeGen/loop-vectorize.c
===
--- /dev/null
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,24 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198561.
asbirlea added a comment.

Rename new test for clarity.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61617/new/

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGenCXX/no-pragma-loop-vectorize.cpp


Index: test/CodeGenCXX/no-pragma-loop-vectorize.cpp
===
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop-vectorize.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -S -c -O1 -fvectorize -std=c++11 -emit-llvm -o - %s | FileCheck 
%s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -S -c -O1 -fno-vectorize -std=c++11 -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fvectorize 
-std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize 
-std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT: for.body:
+// CHECK-ENABLE-VECT: vector.body:
+
+// CHECK-DISABLE-VECT: for.body:
+// CHECK-DISABLE-VECT-NOT: vector.body:
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {


Index: test/CodeGenCXX/no-pragma-loop-vectorize.cpp
===
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop-vectorize.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -S -c -O1 -fvectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -S -c -O1 -fno-vectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fvectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT: for.body:
+// CHECK-ENABLE-VECT: vector.body:
+
+// CHECK-DISABLE-VECT: for.body:
+// CHECK-DISABLE-VECT-NOT: vector.body:
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198560.
asbirlea added a comment.
Herald added a subscriber: zzheng.

Added test. Last RUN line fails before this patch (i.e. unrolling is not 
disabled with the given flag in the new pass manager).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61620/new/

https://reviews.llvm.org/D61620

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGenCXX/no-pragma-loop-unroll.cpp


Index: test/CodeGenCXX/no-pragma-loop-unroll.cpp
===
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop-unroll.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -funroll-loops 
-std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-unroll-loops 
-std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL: for.body:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: for.body5:
+
+// CHECK-DISABLE-UNROLL: for.body:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: for.body5:
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1026,6 +1026,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


Index: test/CodeGenCXX/no-pragma-loop-unroll.cpp
===
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop-unroll.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -funroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-unroll-loops -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL: for.body:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: for.body5:
+
+// CHECK-DISABLE-UNROLL: for.body:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: for.body5:
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1026,6 +1026,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-07 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198540.
asbirlea added a comment.

Added test. The last RUN line fails before this patch (i.e. the flag to disable 
vectorization was not used by the new pass manager)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61617/new/

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGenCXX/no-pragma-loop.cpp


Index: test/CodeGenCXX/no-pragma-loop.cpp
===
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -S -c -O1 -fvectorize -std=c++11 -emit-llvm -o - %s | FileCheck 
%s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -S -c -O1 -fno-vectorize -std=c++11 -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fvectorize 
-std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize 
-std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT: for.body:
+// CHECK-ENABLE-VECT: vector.body:
+
+// CHECK-DISABLE-VECT: for.body:
+// CHECK-DISABLE-VECT-NOT: vector.body:
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
+
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {


Index: test/CodeGenCXX/no-pragma-loop.cpp
===
--- /dev/null
+++ test/CodeGenCXX/no-pragma-loop.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -S -c -O1 -fvectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -S -c -O1 -fno-vectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fvectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -std=c++11 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT: for.body:
+// CHECK-ENABLE-VECT: vector.body:
+
+// CHECK-DISABLE-VECT: for.body:
+// CHECK-DISABLE-VECT-NOT: vector.body:
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
+
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-06 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
asbirlea added a reviewer: chandlerc.
Herald added subscribers: cfe-commits, dmgreen, jlebar.
Herald added a project: clang.

Use CodeGenOpts's setting for loop unrolling.
[to be coupled with D61618 ]


Repository:
  rC Clang

https://reviews.llvm.org/D61620

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1024,6 +1024,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1024,6 +1024,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-06 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
asbirlea added a reviewer: chandlerc.
Herald added subscribers: cfe-commits, jlebar.
Herald added a project: clang.

NewPassManager is not using CodeGenOpts values before this patch.
[to be coupled with D61616 ]


Repository:
  rC Clang

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1023,7 +1023,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1023,7 +1023,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61142: Set LoopInterleaved in the PassManagerBuilder.

2019-04-30 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359616: Set LoopInterleaved in the PassManagerBuilder. 
(authored by asbirlea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61142?vs=196696&id=197445#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61142/new/

https://reviews.llvm.org/D61142

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -560,6 +560,9 @@
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
+  // Loop interleaving in the loop vectorizer has historically been set to be
+  // enabled when loop unrolling is enabled.
+  PMBuilder.LoopsInterleaved = CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
   PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -560,6 +560,9 @@
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
+  // Loop interleaving in the loop vectorizer has historically been set to be
+  // enabled when loop unrolling is enabled.
+  PMBuilder.LoopsInterleaved = CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
   PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61142: Set LoopInterleaved in the PassManagerBuilder.

2019-04-25 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
Herald added subscribers: cfe-commits, jlebar.
Herald added a project: clang.

Corresponds to D61030 .


Repository:
  rC Clang

https://reviews.llvm.org/D61142

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -544,6 +544,7 @@
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
+  PMBuilder.LoopsInterleaved = CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
   PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -544,6 +544,7 @@
   PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop;
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
+  PMBuilder.LoopsInterleaved = CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
   PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits