Skip to content

Commit e559426

Browse files
committed
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@289482 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6e5e12e commit e559426

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

include/llvm/Analysis/ScalarEvolutionExpander.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
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"
1917
#include "llvm/ADT/Optional.h"
2018
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
2119
#include "llvm/Analysis/ScalarEvolutionNormalization.h"
2220
#include "llvm/Analysis/TargetFolder.h"
2321
#include "llvm/IR/IRBuilder.h"
2422
#include "llvm/IR/ValueHandle.h"
23+
#include <set>
2524

2625
namespace llvm {
2726
class TargetTransformInfo;
@@ -44,12 +43,11 @@ namespace llvm {
4443
const char* IVName;
4544

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

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

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

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

0 commit comments

Comments
 (0)