From 96f4b128800cc567a4355025963ea64caa750904 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 15 Mar 2016 14:18:26 +0000 Subject: [GlobalOpt] Don't look through aliases when sorting names of globals. If both are different aliases to the same value the sorting becomes non-deterministic as array_pod_sort is not stable. llvm-svn: 263550 --- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index b9cef720a13..f6458f50696 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -2199,8 +2199,9 @@ static bool EvaluateStaticConstructor(Function *F, const DataLayout &DL, } static int compareNames(Constant *const *A, Constant *const *B) { - return (*A)->stripPointerCasts()->getName().compare( - (*B)->stripPointerCasts()->getName()); + Value *AStripped = (*A)->stripPointerCastsNoFollowAliases(); + Value *BStripped = (*B)->stripPointerCastsNoFollowAliases(); + return AStripped->getName().compare(BStripped->getName()); } static void setUsedInitializer(GlobalVariable &V, -- cgit v1.2.3