Index: src/IceTargetLowering.cpp |
diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp |
index ff93e70819b424a66ba423e10eeed48527cb9351..0ac6e8bee8f9a67b7c6c29f82b0312abab8c7a51 100644 |
--- a/src/IceTargetLowering.cpp |
+++ b/src/IceTargetLowering.cpp |
@@ -737,8 +737,11 @@ void TargetLowering::sortVarsByAlignment(VarList &Dest, |
// the buckets, if performance is an issue. |
std::sort(Dest.begin(), Dest.end(), |
[this](const Variable *V1, const Variable *V2) { |
- return typeWidthInBytesOnStack(V1->getType()) > |
- typeWidthInBytesOnStack(V2->getType()); |
+ const size_t WidthV1 = typeWidthInBytesOnStack(V1->getType()); |
+ const size_t WidthV2 = typeWidthInBytesOnStack(V2->getType()); |
+ if (WidthV1 == WidthV2) |
+ return V1->getIndex() < V2->getIndex(); |
+ return WidthV1 > WidthV2; |
}); |
} |