[all-commits] [llvm/llvm-project] 95ef55: [Polly] Preserve DetectionContext references.
Michael Kruse via All-commits
all-commits at lists.llvm.org
Sat Feb 13 01:37:43 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 95ef556bd12ad879fd27157ea60cdc213717459d
https://github.com/llvm/llvm-project/commit/95ef556bd12ad879fd27157ea60cdc213717459d
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2021-02-13 (Sat, 13 Feb 2021)
Changed paths:
M polly/include/polly/ScopDetection.h
M polly/include/polly/ScopPass.h
M polly/lib/Analysis/ScopDetection.cpp
M polly/test/Isl/CodeGen/multiple-codegens.ll
Log Message:
-----------
[Polly] Preserve DetectionContext references.
DetectionContext objects are stored as values in a DenseMap. When the
DenseMap reaches its maximum load factor, it is resized and all its
objects moved to a new memory allocation. Unfortunately Scop object have
a reference to its DetectionContext. When the DenseMap resizes, all the
DetectionContexts reference now point to invalid memory, even if caused
by an unrelated DetectionContext.
Even worse, NewPM's ScopPassManager called isMaxRegionInScop with the
Verify=true parameter before each pass. This caused the old
DetectionContext to be removed an a new on created and re-verified.
Of course, the Scop object was already created pointing to the old
DetectionContext. Because the new DetectionContext would
usually be stored at the same position in the DenseMap, the reference
would usually reference the new DetectionContext of the same Region.
Usually.
If not, the old position still points to memory in the DenseMap
allocation (unless also a resizing occurs) such that tools like Valgrind
and AddressSanitizer would not be able to diagnose this.
Instead of storing the DetectionContext inside the DenseMap, use a
std::unique_ptr to a DetectionContext allocation, i.e. it will not move
around anymore. This also allows use to remove the very strange
DetectionContext(const DetectionContext &&)
copy/move(?) constructor. DetectionContext objects now are neither
copied nor moved.
As a result, every re-verification of a DetectionContext will use a new
allocation. Therefore, once a Scop object has been created using a
DetectionContext, it must not be re-verified (the Scop data structure
requires its underlying Region to not change before code generation
anyway). The NewPM may call isMaxRegionInScop only with
Validate=false parameter.
More information about the All-commits
mailing list