Skip to content

Commit 9ceb54c

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
1 parent 4a45618 commit 9ceb54c

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -4111,6 +4111,11 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
41114111
Call, Builder.CreateBitOrPointerCast(ReturnedArg, CallTy));
41124112
}
41134113

4114+
// Drop unnecessary callee_type metadata from calls that were converted
4115+
// into direct calls.
4116+
if (Call.getMetadata(LLVMContext::MD_callee_type) && !Call.isIndirectCall())
4117+
Call.setMetadata(LLVMContext::MD_callee_type, nullptr);
4118+
41144119
// Drop unnecessary kcfi operand bundles from calls that were converted
41154120
// into direct calls.
41164121
auto Bundle = Call.getOperandBundle(LLVMContext::OB_kcfi);

llvm/test/CodeGen/MIR/X86/call-site-info-direct-calls-typeid.mir

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
# CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: []
1414

1515
--- |
16-
declare noundef i32 @_Z4fizzii(i32 noundef %x, i32 noundef %y)
17-
18-
declare noundef i32 @_Z4buzzii(i32 noundef %x, i32 noundef %y)
19-
20-
define dso_local noundef i32 @_Z3barii(i32 noundef %x, i32 noundef %y) {
16+
declare !type !0 noundef i32 @_Z4fizzii(i32 noundef %x, i32 noundef %y)
17+
18+
declare !type !0 noundef i32 @_Z4buzzii(i32 noundef %x, i32 noundef %y)
19+
20+
define dso_local noundef i32 @_Z3barii(i32 noundef %x, i32 noundef %y) !type !0 {
2121
entry:
2222
%x.addr = alloca i32, align 4
2323
%y.addr = alloca i32, align 4
@@ -33,7 +33,7 @@
3333
ret i32 %sub
3434
}
3535

36-
define dso_local noundef i32 @_Z3fooii(i32 noundef %x, i32 noundef %y) {
36+
define dso_local noundef i32 @_Z3fooii(i32 noundef %x, i32 noundef %y) !type !0 {
3737
entry:
3838
%x.addr = alloca i32, align 4
3939
%y.addr = alloca i32, align 4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
;; Test if the callee_type metadata is dropped when an indirect function call through a function ptr is promoted
2+
;; to a direct function call during instcombine.
3+
4+
; RUN: opt < %s -O2 | llvm-dis | FileCheck %s
5+
6+
define dso_local noundef i32 @_Z13call_indirectPFicEc(ptr noundef %func, i8 noundef signext %x) local_unnamed_addr !type !0 {
7+
entry:
8+
%call = call noundef i32 %func(i8 noundef signext %x), !callee_type !1
9+
ret i32 %call
10+
}
11+
12+
define dso_local noundef i32 @_Z3barv() local_unnamed_addr !type !3 {
13+
entry:
14+
; CHECK: %call.i = tail call noundef i32 @_Z3fooc(i8 noundef signext 97)
15+
; CHECK-NOT: %call.i = tail call noundef i32 @_Z3fooc(i8 noundef signext 97), !callee_type !1
16+
%call = call noundef i32 @_Z13call_indirectPFicEc(ptr noundef nonnull @_Z3fooc, i8 noundef signext 97)
17+
ret i32 %call
18+
}
19+
20+
declare !type !2 noundef i32 @_Z3fooc(i8 noundef signext)
21+
22+
!0 = !{i64 0, !"_ZTSFiPvcE.generalized"}
23+
!1 = !{!2}
24+
!2 = !{i64 0, !"_ZTSFicE.generalized"}
25+
!3 = !{i64 0, !"_ZTSFivE.generalized"}

0 commit comments

Comments
 (0)