[llvm] a87738f - [AutoUpgrade] Don't try to upgrade struct return of non-intrinsic
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 08:18:27 PST 2023
Author: Nikita Popov
Date: 2023-12-08T17:18:20+01:00
New Revision: a87738f86b17f4a8dcde538c60826506e2a27ed1
URL: https://github.com/llvm/llvm-project/commit/a87738f86b17f4a8dcde538c60826506e2a27ed1
DIFF: https://github.com/llvm/llvm-project/commit/a87738f86b17f4a8dcde538c60826506e2a27ed1.diff
LOG: [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.".
Added:
Modified:
llvm/lib/IR/AutoUpgrade.cpp
llvm/test/Assembler/struct-ret-without-upgrade.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 67ee7b7d97e9a..645691f441794 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 992b2f9f767fa..14f931c23abb6 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)
More information about the llvm-commits
mailing list