Skip to content

Commit a87738f

Browse files
committed
[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.".
1 parent d5199b4 commit a87738f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
12931293
}
12941294

12951295
auto *ST = dyn_cast<StructType>(F->getReturnType());
1296-
if (ST && (!ST->isLiteral() || ST->isPacked())) {
1296+
if (ST && (!ST->isLiteral() || ST->isPacked()) &&
1297+
F->getIntrinsicID() != Intrinsic::not_intrinsic) {
12971298
// Replace return type with literal non-packed struct. Only do this for
12981299
// intrinsics declared to return a struct, not for intrinsics with
12991300
// overloaded return type, in which case the exact struct type will be

llvm/test/Assembler/struct-ret-without-upgrade.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ define %ty @test(%ty %arg) {
1515
ret %ty %copy
1616
}
1717

18+
define %ty @test_not_real_intrinsic() {
19+
; CHECK-LABEL: @test_not_real_intrinsic(
20+
; CHECK-NEXT: [[RET:%.*]] = call [[TY:%.*]] @llvm.dummy()
21+
; CHECK-NEXT: ret [[TY]] [[RET]]
22+
;
23+
%ret = call %ty @llvm.dummy()
24+
ret %ty %ret
25+
}
26+
27+
declare %ty @llvm.dummy()
28+
1829
declare %ty @llvm.ssa.copy.s_tys(%ty)

0 commit comments

Comments
 (0)