Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/IPO/LowerTypeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,9 @@ void LowerTypeTestsModule::replaceWeakDeclarationWithJumpTablePtr(
Constant::getNullValue(F->getType()));
Value *Select = Builder.CreateSelect(ICmp, JT,
Constant::getNullValue(F->getType()));

if (auto *SI = dyn_cast<SelectInst>(Select))
setExplicitlyUnknownBranchWeightsIfProfiled(*SI, DEBUG_TYPE);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcc a question - would it be technically possible to propagate information about the weak function from [thin]link over to this point, and thus know if we even need a select in the first place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just add a TODO to consider that.

// For phi nodes, we need to update the incoming value for all operands
// with the same predecessor.
if (PN)
Expand Down
5 changes: 3 additions & 2 deletions llvm/test/Transforms/LowerTypeTests/function-weak.ll
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ target triple = "x86_64-unknown-linux-gnu"
declare !type !0 extern_weak void @f()

; CHECK: define zeroext i1 @check_f()
define zeroext i1 @check_f() {
define zeroext i1 @check_f() !prof !{!"function_entry_count", i32 10} {
entry:
; CHECK: [[CMP:%.*]] = icmp ne ptr @f, null
; CHECK: [[SEL:%.*]] = select i1 [[CMP]], ptr @[[JT:.*]], ptr null
; CHECK: [[SEL:%.*]] = select i1 [[CMP]], ptr @[[JT:.*]], ptr null, !prof ![[SELPROF:[0-9]+]]
; CHECK: [[PTI:%.*]] = ptrtoint ptr [[SEL]] to i1
; CHECK: ret i1 [[PTI]]
ret i1 ptrtoint (ptr @f to i1)
Expand Down Expand Up @@ -165,3 +165,4 @@ define i1 @foo(ptr %p) {
; CHECK-NEXT: }

!0 = !{i32 0, !"typeid1"}
; CHECK: ![[SELPROF]] = !{!"unknown", !"lowertypetests"}
Loading