From: Sanjoy Das Date: Mon, 12 Dec 2016 23:00:12 +0000 (+0000) Subject: Revert "[SCEVExpander] Use llvm data structures; NFC" X-Git-Tag: llvmorg-4.0.0-rc1~2293 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=804b629812de6064c057bece0fd3425abafa5024;p=platform%2Fupstream%2Fllvm.git Revert "[SCEVExpander] Use llvm data structures; NFC" This reverts r289215 (git SHA1 cb7b86a1). It breaks the ubsan build because a DenseMap that keys off of `AssertingVH` will hit UB when it tries to cast the empty and tombstone keys to `T *` (due to insufficient alignment). This is the relevant stack trace (thanks to Mike Aizatsky): #0 0x25cf100 in llvm::AssertingVH::getValPtr() const llvm/include/llvm/IR/ValueHandle.h:212:39 #1 0x25cea20 in llvm::AssertingVH::operator=(llvm::AssertingVH const&) llvm/include/llvm/IR/ValueHandle.h:234:19 #2 0x25d0092 in llvm::DenseMapBase, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo >, llvm::detail::DenseSetPair > >, llvm::AssertingVH, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo >, llvm::detail::DenseSetPair > >::clear() llvm/include/llvm/ADT/DenseMap.h:113:23 llvm-svn: 289482 --- diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h index 517592a..a82506d 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -14,14 +14,13 @@ #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/Analysis/ScalarEvolutionNormalization.h" #include "llvm/Analysis/TargetFolder.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/ValueHandle.h" +#include namespace llvm { class TargetTransformInfo; @@ -44,12 +43,11 @@ namespace llvm { const char* IVName; // InsertedExpressions caches Values for reuse, so must track RAUW. - DenseMap, TrackingVH> - InsertedExpressions; - + std::map, TrackingVH > + InsertedExpressions; // InsertedValues only flags inserted instructions so needs no RAUW. - DenseSet> InsertedValues; - DenseSet> InsertedPostIncValues; + std::set > InsertedValues; + std::set > InsertedPostIncValues; /// A memoization of the "relevant" loop for a given SCEV. DenseMap RelevantLoops; @@ -69,7 +67,7 @@ namespace llvm { Instruction *IVIncInsertPos; /// Phis that complete an IV chain. Reuse - DenseSet> ChainedPhis; + std::set > ChainedPhis; /// When true, expressions are expanded in "canonical" form. In particular, /// addrecs are expanded as arithmetic based on a canonical induction