diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-07-02 22:56:41 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-07-02 22:56:41 +0000 |
commit | 34263a0c955f51a20bd4f9680428d6007ed31169 (patch) | |
tree | 384c0b8e58ea0dbd066ffee034637c0c9305149d /llvm/lib/CodeGen/Passes.cpp | |
parent | 39e90029a2a597afa22d81c5c8f47b6c49128058 (diff) | |
download | bcm5719-llvm-34263a0c955f51a20bd4f9680428d6007ed31169.tar.gz bcm5719-llvm-34263a0c955f51a20bd4f9680428d6007ed31169.zip |
All glory to address sanitizer. ;]
It appears to have caught a use-after-free introduced as by r159567
and/or friends which call 'addPass' from many more places. The bug in
'addPass' doesn't appear to be new, and was spotted by inspection when
ASan shown a bright light of a stacktrace at these functions.
Hopefully this will fix the ASan failure -- I have no test case other
than running an ASan-built clang over the test suite.
llvm-svn: 159614
Diffstat (limited to 'llvm/lib/CodeGen/Passes.cpp')
-rw-r--r-- | llvm/lib/CodeGen/Passes.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/Passes.cpp b/llvm/lib/CodeGen/Passes.cpp index 1fefb9d45f4..9693780bdaa 100644 --- a/llvm/lib/CodeGen/Passes.cpp +++ b/llvm/lib/CodeGen/Passes.cpp @@ -280,11 +280,17 @@ AnalysisID TargetPassConfig::getPassSubstitution(AnalysisID ID) const { void TargetPassConfig::addPass(Pass *P) { assert(!Initialized && "PassConfig is immutable"); + // Cache the Pass ID here in case the pass manager finds this pass is + // redundant with ones already scheduled / available, and deletes it. + // Fundamentally, once we add the pass to the manager, we no longer own it + // and shouldn't reference it. + AnalysisID PassID = P->getPassID(); + if (Started && !Stopped) PM->add(P); - if (StopAfter == P->getPassID()) + if (StopAfter == PassID) Stopped = true; - if (StartAfter == P->getPassID()) + if (StartAfter == PassID) Started = true; if (Stopped && !Started) report_fatal_error("Cannot stop compilation after pass that is not run"); |