diff options
author | Nikita Popov <npopov@redhat.com> | 2023-12-08 17:15:51 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-12-08 17:18:20 +0100 |
commit | a87738f86b17f4a8dcde538c60826506e2a27ed1 (patch) | |
tree | cfc0d169b0e79fc3890b8eee8548dc5aee1829c5 | |
parent | d5199b43bee5af88994b568447dc16ae967aac0c (diff) | |
download | llvm-a87738f86b17f4a8dcde538c60826506e2a27ed1.zip llvm-a87738f86b17f4a8dcde538c60826506e2a27ed1.tar.gz llvm-a87738f86b17f4a8dcde538c60826506e2a27ed1.tar.bz2 |
[AutoUpgrade] Don't try to upgrade struct return of non-intrinsic
This code should only be run for intrinsics known to LLVM (otherwise
it will crash), not for everything that starts with "llvm.".
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Assembler/struct-ret-without-upgrade.ll | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 67ee7b7..645691f 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -1293,7 +1293,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { } auto *ST = dyn_cast<StructType>(F->getReturnType()); - if (ST && (!ST->isLiteral() || ST->isPacked())) { + if (ST && (!ST->isLiteral() || ST->isPacked()) && + F->getIntrinsicID() != Intrinsic::not_intrinsic) { // Replace return type with literal non-packed struct. Only do this for // intrinsics declared to return a struct, not for intrinsics with // overloaded return type, in which case the exact struct type will be diff --git a/llvm/test/Assembler/struct-ret-without-upgrade.ll b/llvm/test/Assembler/struct-ret-without-upgrade.ll index 992b2f9..14f931c 100644 --- a/llvm/test/Assembler/struct-ret-without-upgrade.ll +++ b/llvm/test/Assembler/struct-ret-without-upgrade.ll @@ -15,4 +15,15 @@ define %ty @test(%ty %arg) { ret %ty %copy } +define %ty @test_not_real_intrinsic() { +; CHECK-LABEL: @test_not_real_intrinsic( +; CHECK-NEXT: [[RET:%.*]] = call [[TY:%.*]] @llvm.dummy() +; CHECK-NEXT: ret [[TY]] [[RET]] +; + %ret = call %ty @llvm.dummy() + ret %ty %ret +} + +declare %ty @llvm.dummy() + declare %ty @llvm.ssa.copy.s_tys(%ty) |