@@ -307,7 +307,7 @@ void unfold(DomTreeUpdater *DTU, SelectInstToUnfold SIToUnfold,
307
307
308
308
struct ClonedBlock {
309
309
BasicBlock *BB;
310
- uint64_t State; // /< \p State corresponds to the next value of a switch stmnt.
310
+ APInt State; // /< \p State corresponds to the next value of a switch stmnt.
311
311
};
312
312
313
313
typedef std::deque<BasicBlock *> PathType;
@@ -344,9 +344,9 @@ inline raw_ostream &operator<<(raw_ostream &OS, const PathType &Path) {
344
344
// / exit state, and the block that determines the next state.
345
345
struct ThreadingPath {
346
346
// / Exit value is DFA's exit state for the given path.
347
- uint64_t getExitValue () const { return ExitVal; }
347
+ APInt getExitValue () const { return ExitVal; }
348
348
void setExitValue (const ConstantInt *V) {
349
- ExitVal = V->getZExtValue ();
349
+ ExitVal = V->getValue ();
350
350
IsExitValSet = true ;
351
351
}
352
352
bool isExitValueSet () const { return IsExitValSet; }
@@ -365,7 +365,7 @@ struct ThreadingPath {
365
365
366
366
private:
367
367
PathType Path;
368
- uint64_t ExitVal;
368
+ APInt ExitVal;
369
369
const BasicBlock *DBB = nullptr ;
370
370
bool IsExitValSet = false ;
371
371
};
@@ -744,7 +744,7 @@ struct TransformDFA {
744
744
745
745
for (ThreadingPath &TPath : SwitchPaths->getThreadingPaths ()) {
746
746
PathType PathBBs = TPath.getPath ();
747
- uint64_t NextState = TPath.getExitValue ();
747
+ APInt NextState = TPath.getExitValue ();
748
748
const BasicBlock *Determinator = TPath.getDeterminatorBB ();
749
749
750
750
// Update Metrics for the Switch block, this is always cloned
@@ -901,7 +901,7 @@ struct TransformDFA {
901
901
DuplicateBlockMap &DuplicateMap,
902
902
SmallSet<BasicBlock *, 16 > &BlocksToClean,
903
903
DomTreeUpdater *DTU) {
904
- uint64_t NextState = Path.getExitValue ();
904
+ APInt NextState = Path.getExitValue ();
905
905
const BasicBlock *Determinator = Path.getDeterminatorBB ();
906
906
PathType PathBBs = Path.getPath ();
907
907
@@ -993,13 +993,14 @@ struct TransformDFA {
993
993
// / This function also includes updating phi nodes in the successors of the
994
994
// / BB, and remapping uses that were defined locally in the cloned BB.
995
995
BasicBlock *cloneBlockAndUpdatePredecessor (BasicBlock *BB, BasicBlock *PrevBB,
996
- uint64_t NextState,
996
+ const APInt & NextState,
997
997
DuplicateBlockMap &DuplicateMap,
998
998
DefMap &NewDefs,
999
999
DomTreeUpdater *DTU) {
1000
1000
ValueToValueMapTy VMap;
1001
1001
BasicBlock *NewBB = CloneBasicBlock (
1002
- BB, VMap, " .jt" + std::to_string (NextState), BB->getParent ());
1002
+ BB, VMap, " .jt" + std::to_string (NextState.getLimitedValue ()),
1003
+ BB->getParent ());
1003
1004
NewBB->moveAfter (BB);
1004
1005
NumCloned++;
1005
1006
@@ -1034,7 +1035,7 @@ struct TransformDFA {
1034
1035
// / This means creating a new incoming value from NewBB with the new
1035
1036
// / instruction wherever there is an incoming value from BB.
1036
1037
void updateSuccessorPhis (BasicBlock *BB, BasicBlock *ClonedBB,
1037
- uint64_t NextState, ValueToValueMapTy &VMap,
1038
+ const APInt & NextState, ValueToValueMapTy &VMap,
1038
1039
DuplicateBlockMap &DuplicateMap) {
1039
1040
std::vector<BasicBlock *> BlocksToUpdate;
1040
1041
@@ -1144,7 +1145,7 @@ struct TransformDFA {
1144
1145
void updateLastSuccessor (ThreadingPath &TPath,
1145
1146
DuplicateBlockMap &DuplicateMap,
1146
1147
DomTreeUpdater *DTU) {
1147
- uint64_t NextState = TPath.getExitValue ();
1148
+ APInt NextState = TPath.getExitValue ();
1148
1149
BasicBlock *BB = TPath.getPath ().back ();
1149
1150
BasicBlock *LastBlock = getClonedBB (BB, NextState, DuplicateMap);
1150
1151
@@ -1198,7 +1199,7 @@ struct TransformDFA {
1198
1199
1199
1200
// / Checks if BB was already cloned for a particular next state value. If it
1200
1201
// / was then it returns this cloned block, and otherwise null.
1201
- BasicBlock *getClonedBB (BasicBlock *BB, uint64_t NextState,
1202
+ BasicBlock *getClonedBB (BasicBlock *BB, const APInt & NextState,
1202
1203
DuplicateBlockMap &DuplicateMap) {
1203
1204
CloneList ClonedBBs = DuplicateMap[BB];
1204
1205
@@ -1212,10 +1213,10 @@ struct TransformDFA {
1212
1213
1213
1214
// / Helper to get the successor corresponding to a particular case value for
1214
1215
// / a switch statement.
1215
- BasicBlock *getNextCaseSuccessor (SwitchInst *Switch, uint64_t NextState) {
1216
+ BasicBlock *getNextCaseSuccessor (SwitchInst *Switch, const APInt & NextState) {
1216
1217
BasicBlock *NextCase = nullptr ;
1217
1218
for (auto Case : Switch->cases ()) {
1218
- if (Case.getCaseValue ()->getZExtValue () == NextState) {
1219
+ if (Case.getCaseValue ()->getValue () == NextState) {
1219
1220
NextCase = Case.getCaseSuccessor ();
1220
1221
break ;
1221
1222
}
0 commit comments