Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 9b021f2

Browse files
committed
Re-land "[SCEVExpander] Use llvm data structures; NFC"
This change re-lands r289215, by reverting r289482. The underlying issue that caused it to be reverted has been fixed by Tim Northover in r289496. Original commit message for r289215: [SCEVExpander] Use llvm data structures; NFC Original commit message for r289482: Revert "[SCEVExpander] Use llvm data structures; NFC" This reverts r289215 (git SHA1 cb7b86a). It breaks the ubsan build because a DenseMap that keys off of `AssertingVH<T>` 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<llvm::PHINode>::getValPtr() const llvm/include/llvm/IR/ValueHandle.h:212:39 #1 0x25cea20 in llvm::AssertingVH<llvm::PHINode>::operator=(llvm::AssertingVH<llvm::PHINode> const&) llvm/include/llvm/IR/ValueHandle.h:234:19 #2 0x25d0092 in llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::PHINode>, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::AssertingVH<llvm::PHINode> >, llvm::detail::DenseSetPair<llvm::AssertingVH<llvm::PHINode> > >, llvm::AssertingVH<llvm::PHINode>, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<llvm::AssertingVH<llvm::PHINode> >, llvm::detail::DenseSetPair<llvm::AssertingVH<llvm::PHINode> > >::clear() llvm/include/llvm/ADT/DenseMap.h:113:23 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289602 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a740af8 commit 9b021f2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

include/llvm/Analysis/ScalarEvolutionExpander.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H
1515
#define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H
1616

17+
#include "llvm/ADT/DenseMap.h"
18+
#include "llvm/ADT/DenseSet.h"
1719
#include "llvm/ADT/Optional.h"
1820
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
1921
#include "llvm/Analysis/ScalarEvolutionNormalization.h"
2022
#include "llvm/Analysis/TargetFolder.h"
2123
#include "llvm/IR/IRBuilder.h"
2224
#include "llvm/IR/ValueHandle.h"
23-
#include <set>
2425

2526
namespace llvm {
2627
class TargetTransformInfo;
@@ -43,11 +44,12 @@ namespace llvm {
4344
const char* IVName;
4445

4546
// InsertedExpressions caches Values for reuse, so must track RAUW.
46-
std::map<std::pair<const SCEV *, Instruction *>, TrackingVH<Value> >
47-
InsertedExpressions;
47+
DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>>
48+
InsertedExpressions;
49+
4850
// InsertedValues only flags inserted instructions so needs no RAUW.
49-
std::set<AssertingVH<Value> > InsertedValues;
50-
std::set<AssertingVH<Value> > InsertedPostIncValues;
51+
DenseSet<AssertingVH<Value>> InsertedValues;
52+
DenseSet<AssertingVH<Value>> InsertedPostIncValues;
5153

5254
/// A memoization of the "relevant" loop for a given SCEV.
5355
DenseMap<const SCEV *, const Loop *> RelevantLoops;
@@ -67,7 +69,7 @@ namespace llvm {
6769
Instruction *IVIncInsertPos;
6870

6971
/// Phis that complete an IV chain. Reuse
70-
std::set<AssertingVH<PHINode> > ChainedPhis;
72+
DenseSet<AssertingVH<PHINode>> ChainedPhis;
7173

7274
/// When true, expressions are expanded in "canonical" form. In particular,
7375
/// addrecs are expanded as arithmetic based on a canonical induction

0 commit comments

Comments
 (0)