summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2015-03-27 01:40:54 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2015-03-27 01:40:54 +0000
commit821880a7a10b67816c8599eda21797addb88c4a3 (patch)
tree8a375dec157c69eae93ac70ec5c60df7149c0760
parenta523022b5384d7a0901beea7a5f36ee9c09ba339 (diff)
downloadbcm5719-llvm-821880a7a10b67816c8599eda21797addb88c4a3.tar.gz
bcm5719-llvm-821880a7a10b67816c8599eda21797addb88c4a3.zip
[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. llvm-svn: 233346
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp2
-rw-r--r--llvm/test/MC/MachO/cstexpr-gotpcrel-64.ll5
2 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 098e7989e94..07d673190eb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/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<Constant>(U));
+ NumGOTEquivUsers += getNumGlobalVariableUses(dyn_cast<Constant>(U));
return NumGOTEquivUsers > 0;
}
diff --git a/llvm/test/MC/MachO/cstexpr-gotpcrel-64.ll b/llvm/test/MC/MachO/cstexpr-gotpcrel-64.ll
index c9c24ae3fda..bf155647f12 100644
--- a/llvm/test/MC/MachO/cstexpr-gotpcrel-64.ll
+++ b/llvm/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
+}
OpenPOWER on IntegriCloud