diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-30 15:39:48 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-30 15:39:48 +0000 |
commit | adb412daa41aef94a9f724dfd1ade9f579bb3a84 (patch) | |
tree | e70185344707fc03fefd43f8b39fefb4b8005d8c /lib/Transforms/Vectorize/SLPVectorizer.cpp | |
parent | 5a17a462cdba1b894cdd618798596076ed79c9ac (diff) | |
download | external_llvm-adb412daa41aef94a9f724dfd1ade9f579bb3a84.zip external_llvm-adb412daa41aef94a9f724dfd1ade9f579bb3a84.tar.gz external_llvm-adb412daa41aef94a9f724dfd1ade9f579bb3a84.tar.bz2 |
IRBuilder: Add RAII objects to reset insertion points or fast math flags.
Inspired by the object from the SLPVectorizer. This found a minor bug in the
debug loc restoration in the vectorizer where the location of a following
instruction was attached instead of the location from the original instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191673 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r-- | lib/Transforms/Vectorize/SLPVectorizer.cpp | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index 2b0bdfa..c8c8ba5 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -65,26 +65,6 @@ static const unsigned MinVecRegSize = 128; static const unsigned RecursionMaxDepth = 12; -/// RAII pattern to save the insertion point of the IR builder. -class BuilderLocGuard { -public: - BuilderLocGuard(IRBuilder<> &B) : Builder(B), Loc(B.GetInsertPoint()), - DbgLoc(B.getCurrentDebugLocation()) {} - ~BuilderLocGuard() { - Builder.SetCurrentDebugLocation(DbgLoc); - if (Loc) - Builder.SetInsertPoint(Loc); - } - -private: - // Prevent copying. - BuilderLocGuard(const BuilderLocGuard &); - BuilderLocGuard &operator=(const BuilderLocGuard &); - IRBuilder<> &Builder; - AssertingVH<Instruction> Loc; - DebugLoc DbgLoc; -}; - /// A helper class for numbering instructions in multiple blocks. /// Numbers start at zero for each basic block. struct BlockNumbering { @@ -1177,7 +1157,7 @@ Value *BoUpSLP::vectorizeTree(ArrayRef<Value *> VL) { } Value *BoUpSLP::vectorizeTree(TreeEntry *E) { - BuilderLocGuard Guard(Builder); + IRBuilder<>::InsertPointGuard Guard(Builder); if (E->VectorizedValue) { DEBUG(dbgs() << "SLP: Diamond merged for " << *E->Scalars[0] << ".\n"); |