From f265603512ab9840c8e8c3327814d1b273d8cea1 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Fri, 27 Mar 2015 01:40:54 +0000 Subject: [PATCH] [AsmPrinter] Don't assert on GOT equivalent non-constant users. We used to dyn_cast 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 | 2 +- test/MC/MachO/cstexpr-gotpcrel-64.ll | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 098e7989e94..07d673190eb 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -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(U)); + NumGOTEquivUsers += getNumGlobalVariableUses(dyn_cast(U)); return NumGOTEquivUsers > 0; } diff --git a/test/MC/MachO/cstexpr-gotpcrel-64.ll b/test/MC/MachO/cstexpr-gotpcrel-64.ll index c9c24ae3fda..bf155647f12 100644 --- a/test/MC/MachO/cstexpr-gotpcrel-64.ll +++ b/test/MC/MachO/cstexpr-gotpcrel-64.ll @@ -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 +}