summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-02-15 23:16:20 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-02-15 23:16:20 +0000
commit3c1432fecf4a10751c24a7d38d8334c1f49c4ab8 (patch)
treeabb5811e0fb2b4e929cce9f41a7b9ffab43f8cca /llvm/lib/IR/Function.cpp
parent9584508d5c4eb4ca57fd457d914bb9866ce13d18 (diff)
downloadbcm5719-llvm-3c1432fecf4a10751c24a7d38d8334c1f49c4ab8.tar.gz
bcm5719-llvm-3c1432fecf4a10751c24a7d38d8334c1f49c4ab8.zip
Implement intrinsic mangling for literal struct types.
Fixes PR 31921 Summary: Predicateinfo requires an ugly workaround to try to avoid literal struct types due to the intrinsic mangling not being implemented. This workaround actually does not work in all cases (you can hit the assert by bootstrapping with -print-predicateinfo), and can't be made to work without DFS'ing the type (IE copying getMangledStr and using a version that detects if it would crash). Rather than do that, i just implemented the mangling. It seems simple, since they are unified structurally. Looking at the overloaded-mangling testcase we have, it actually turns out the gc intrinsics will *also* crash if you try to use a literal struct. Thus, the testcase added fails before this patch, and works after, without needing to resort to predicateinfo. Reviewers: chandlerc, davide Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D29925 llvm-svn: 295253
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 62e8717a0f1..0c6b3520dad 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -505,10 +505,18 @@ static std::string getMangledTypeStr(Type* Ty) {
} else if (ArrayType* ATyp = dyn_cast<ArrayType>(Ty)) {
Result += "a" + llvm::utostr(ATyp->getNumElements()) +
getMangledTypeStr(ATyp->getElementType());
- } else if (StructType* STyp = dyn_cast<StructType>(Ty)) {
- assert(!STyp->isLiteral() && "TODO: implement literal types");
- Result += STyp->getName();
- } else if (FunctionType* FT = dyn_cast<FunctionType>(Ty)) {
+ } else if (StructType *STyp = dyn_cast<StructType>(Ty)) {
+ if (!STyp->isLiteral()) {
+ Result += "s_";
+ Result += STyp->getName();
+ } else {
+ Result += "sl_";
+ for (auto Elem : STyp->elements())
+ Result += getMangledTypeStr(Elem);
+ }
+ // Ensure nested structs are distinguishable.
+ Result += "s";
+ } else if (FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
Result += "f_" + getMangledTypeStr(FT->getReturnType());
for (size_t i = 0; i < FT->getNumParams(); i++)
Result += getMangledTypeStr(FT->getParamType(i));
OpenPOWER on IntegriCloud