|
21 | 21 | #include "llvm/Transforms/Utils/Local.h"
|
22 | 22 | #include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
23 | 23 | #include "llvm/Transforms/Utils/SSAUpdater.h"
|
| 24 | +#include "llvm/Transforms/Utils/ValueMapper.h" |
24 | 25 | #include "llvm/Support/CommandLine.h"
|
25 | 26 | #include "llvm/Support/Debug.h"
|
26 | 27 | #include "llvm/ADT/Statistic.h"
|
27 |
| -#include "llvm/ADT/SmallVector.h" |
28 | 28 | using namespace llvm;
|
29 | 29 |
|
30 | 30 | #define MAX_HEADER_SIZE 16
|
@@ -177,7 +177,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
|
177 | 177 | // Begin by walking OrigHeader and populating ValueMap with an entry for
|
178 | 178 | // each Instruction.
|
179 | 179 | BasicBlock::iterator I = OrigHeader->begin(), E = OrigHeader->end();
|
180 |
| - DenseMap<const Value *, Value *> ValueMap; |
| 180 | + ValueToValueMapTy ValueMap; |
181 | 181 |
|
182 | 182 | // For PHI nodes, the value available in OldPreHeader is just the
|
183 | 183 | // incoming value from OldPreHeader.
|
@@ -233,6 +233,11 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
|
233 | 233 | Value *OrigHeaderVal = I;
|
234 | 234 | Value *OrigPreHeaderVal = ValueMap[OrigHeaderVal];
|
235 | 235 |
|
| 236 | + // If there are no uses of the value (e.g. because it returns void), there |
| 237 | + // is nothing to rewrite. |
| 238 | + if (OrigHeaderVal->use_empty() && OrigPreHeaderVal->use_empty()) |
| 239 | + continue; |
| 240 | + |
236 | 241 | // The value now exits in two versions: the initial value in the preheader
|
237 | 242 | // and the loop "next" value in the original header.
|
238 | 243 | SSA.Initialize(OrigHeaderVal->getType(), OrigHeaderVal->getName());
|
|
0 commit comments