[PATCH] D42940: Fix a crash when emitting DIEs for variable-length arrays
Volodymyr Sapsai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 16:18:53 PST 2018
vsapsai added inline comments.
================
Comment at: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:590
+ return dependsOn(B, A);
+}
+
----------------
`std::stable_sort` requires comparison function object to satisfy [Compare concept](http://en.cppreference.com/w/cpp/concept/Compare). It is mentioned that `comp(a, b)` establishes [strict weak ordering](https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings) relation. One of the requirements of this ordering is transitivity of incomparability, i.e. if `x <> y` and `y <> z` then it should be `x <> z`. But with dependency relation it is possible that x and y are independent, y and z are independent, but x depends on z.
During my testing I had `DbgVariable` in the following order
```
array
count
vla_expr
```
and the sorting proceeded as
```
is [1] < [0] => false, no swapping
is [2] < [1] => false, no swapping
finish sort
```
We didn't even check that `array` depends on `vla_expr`.
Looks like for dependency relation something like stable topological sorting is more appropriate.
Repository:
rL LLVM
https://reviews.llvm.org/D42940
More information about the llvm-commits
mailing list