mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil-cloner] Always call doPreProcess when visiting SILInstructions.
It is important to call doPreProcess to correctly setup the available opened archetypes which were referenced from the original instruction being copied. This fixes a concrete bug in LoopRotate optimization and potential bugs related to cloning. rdar://27659420
This commit is contained in:
@@ -66,6 +66,14 @@ public:
|
||||
SILBuilder &getBuilder() { return Builder; }
|
||||
|
||||
protected:
|
||||
void beforeVisit(ValueBase *V) {
|
||||
if (auto I = dyn_cast<SILInstruction>(V)) {
|
||||
// Update the set of available opened archetypes with the opened
|
||||
// archetypes used by the current instruction.
|
||||
doPreProcess(I);
|
||||
}
|
||||
}
|
||||
|
||||
#define VALUE(CLASS, PARENT) \
|
||||
void visit##CLASS(CLASS *I) { \
|
||||
llvm_unreachable("SILCloner visiting non-instruction?"); \
|
||||
@@ -380,9 +388,6 @@ SILCloner<ImplClass>::visitSILBasicBlock(SILBasicBlock* BB) {
|
||||
SILFunction &F = getBuilder().getFunction();
|
||||
// Iterate over and visit all instructions other than the terminator to clone.
|
||||
for (auto I = BB->begin(), E = --BB->end(); I != E; ++I) {
|
||||
// Update the set of available opened archetypes with the opened archetypes
|
||||
// used by the current instruction.
|
||||
doPreProcess(&*I);
|
||||
asImpl().visit(&*I);
|
||||
}
|
||||
// Iterate over successors to do the depth-first search.
|
||||
|
||||
Reference in New Issue
Block a user