[llvm] r233346 - [AsmPrinter] Don't assert on GOT equivalent non-constant users.

Ahmed Bougacha ahmed.bougacha at gmail.com
Thu Mar 26 18:40:55 PDT 2015


Author: ab
Date: Thu Mar 26 20:40:54 2015
New Revision: 233346

URL: http://llvm.org/viewvc/llvm-project?rev=233346&view=rev
Log:
[AsmPrinter] Don't assert on GOT equivalent non-constant users.

We used to dyn_cast<Constant> in the recursive call, but cast<> in the
initial one, and there can be non-Constant initial users.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=233346&r1=233345&r2=233346&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Mar 26 20:40:54 2015
@@ -957,7 +957,7 @@ static bool isGOTEquivalentCandidate(con
   // 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;
 }

Modified: llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll?rev=233346&r1=233345&r2=233346&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll (original)
+++ llvm/trunk/test/MC/MachO/cstexpr-gotpcrel-64.ll Thu Mar 26 20:40:54 2015
@@ -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
+}





More information about the llvm-commits mailing list