OSDN Git Service

[AsmPrinter] Don't assert on GOT equivalent non-constant users.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 27 Mar 2015 01:40:54 +0000 (01:40 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Fri, 27 Mar 2015 01:40:54 +0000 (01:40 +0000)
We used to dyn_cast<Constant> in the recursive call, but cast<> in the
initial one, and there can be non-Constant initial users.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233346 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
test/MC/MachO/cstexpr-gotpcrel-64.ll

index 098e798..07d6731 100644 (file)
@@ -957,7 +957,7 @@ static bool isGOTEquivalentCandidate(const GlobalVariable *GV,
   // To be a got equivalent, at least one of its users need to be a constant
   // expression used by another global variable.
   for (auto *U : GV->users())
-    NumGOTEquivUsers += getNumGlobalVariableUses(cast<Constant>(U));
+    NumGOTEquivUsers += getNumGlobalVariableUses(dyn_cast<Constant>(U));
 
   return NumGOTEquivUsers > 0;
 }
index c9c24ae..bf15564 100644 (file)
@@ -79,3 +79,8 @@ define i32 @t0(i32 %a) {
                            to i32), %a
   ret i32 %x
 }
+
+; Also test direct instruction uses.
+define i32** @t1() {
+  ret i32** @bargotequiv
+}