diff options
author | Dan Gohman <gohman@apple.com> | 2010-07-14 23:08:16 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-07-14 23:08:16 +0000 |
commit | f10cd5c6cb8bc01af49f5143d994ea197b91419d (patch) | |
tree | af9b7466429b37ac8887856d9871baafd64142ef /llvm/lib/CodeGen/MachineModuleInfo.cpp | |
parent | 769aedd523cf8485efa85ca7aa26b874b3861e95 (diff) | |
download | bcm5719-llvm-f10cd5c6cb8bc01af49f5143d994ea197b91419d.tar.gz bcm5719-llvm-f10cd5c6cb8bc01af49f5143d994ea197b91419d.zip |
Make the order in which variables are described in debug information
independent of the order that isel happens to visit the dbg_declare
intrinsics. This fixes a bug in which the formal arguments were
being printed in reverse order, now that fast isel is going bottom up.
llvm-svn: 108369
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 25284d6f5fc..15778b46fe0 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -563,3 +563,26 @@ unsigned MachineModuleInfo::getPersonalityIndex() const { return 0; } +namespace { + /// VariableDebugSorter - Comparison to sort the VariableDbgInfo map + /// by source location, to avoid depending on the arbitrary order that + /// instruction selection visits variables in. + struct VariableDebugSorter { + bool operator()(const MachineModuleInfo::VariableDbgInfoMapTy::value_type &A, + const MachineModuleInfo::VariableDbgInfoMapTy::value_type &B) + const { + if (A.second.second.getLine() != B.second.second.getLine()) + return A.second.second.getLine() < B.second.second.getLine(); + if (A.second.second.getCol() != B.second.second.getCol()) + return A.second.second.getCol() < B.second.second.getCol(); + return false; + } + }; +} + +MachineModuleInfo::VariableDbgInfoMapTy & +MachineModuleInfo::getVariableDbgInfo() { + std::stable_sort(VariableDbgInfo.begin(), VariableDbgInfo.end(), + VariableDebugSorter()); + return VariableDbgInfo; +} |