summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2017-02-10 02:43:09 +0000
committerQuentin Colombet <qcolombet@apple.com>2017-02-10 02:43:09 +0000
commit21136c0273502c91e4506a0d5686eaeb69cdc567 (patch)
tree08b1921591ef07e86e18c50ef71dd9346f8c6641
parentb4493e909f269d5a9f6e6f356543ab80b2ad18d8 (diff)
downloadbcm5719-llvm-21136c0273502c91e4506a0d5686eaeb69cdc567.tar.gz
bcm5719-llvm-21136c0273502c91e4506a0d5686eaeb69cdc567.zip
[TableGen][AsmWriterEmitter] Use a deterministic order to sort InstrAliases
Inside an alias group, when ordering instruction aliases, we rely on the priority field to sort them. When the priority is not set or more generally when there is a tie between two aliases, we used to rely on the lexicographic order. However, this order can change for the anonymous records when more instruction, intrinsic, etc. are inserted. For instance, given two anonymous records r1 and r2 with respective name A_999 and A_1000, their lexicography order will be r2 then r1. Now, if an instruction is added before them, their name will become respectively A_1000 and A_1001, thus the lexicography order will be r1 then r2, i.e., it changed. If that happens in an alias group, the assembly output would prefer a different alias for no apparent good reasons. A way to fix that is to use proper priority for all aliases, but we can also make the tie breaker comparison smarter and use a deterministic ordering. This is what this patch does. llvm-svn: 294695
-rw-r--r--llvm/utils/TableGen/AsmWriterEmitter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index a7c6104aaa2..61ebece99e9 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -741,7 +741,7 @@ struct AliasPriorityComparator {
if (LHS.second == RHS.second) {
// We don't actually care about the order, but for consistency it
// shouldn't depend on pointer comparisons.
- return LHS.first.TheDef->getName() < RHS.first.TheDef->getName();
+ return LessRecordByID()(LHS.first.TheDef, RHS.first.TheDef);
}
// Aliases with larger priorities should be considered first.
OpenPOWER on IntegriCloud