diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2017-02-15 23:16:20 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@dberlin.org> | 2017-02-15 23:16:20 +0000 |
commit | 3c1432fecf4a10751c24a7d38d8334c1f49c4ab8 (patch) | |
tree | abb5811e0fb2b4e929cce9f41a7b9ffab43f8cca /llvm/lib/IR/AutoUpgrade.cpp | |
parent | 9584508d5c4eb4ca57fd457d914bb9866ce13d18 (diff) | |
download | bcm5719-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/AutoUpgrade.cpp')
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index b68bc3f0561..41f4159c559 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -489,6 +489,12 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { break; } } + // Remangle our intrinsic since we upgrade the mangling + auto Result = llvm::Intrinsic::remangleIntrinsicFunction(F); + if (Result != None) { + NewFn = Result.getValue(); + return true; + } // This may not belong here. This function is effectively being overloaded // to both detect an intrinsic which needs upgrading, and to provide the @@ -1821,8 +1827,17 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { CI->setName(Name + ".old"); switch (NewFn->getIntrinsicID()) { - default: - llvm_unreachable("Unknown function for CallInst upgrade."); + default: { + // Handle generic mangling change, but nothing else + assert( + (CI->getCalledFunction()->getName() != NewFn->getName()) && + "Unknown function for CallInst upgrade and isn't just a name change"); + SmallVector<Value *, 4> Args(CI->arg_operands().begin(), + CI->arg_operands().end()); + CI->replaceAllUsesWith(Builder.CreateCall(NewFn, Args)); + CI->eraseFromParent(); + return; + } case Intrinsic::arm_neon_vld1: case Intrinsic::arm_neon_vld2: |