summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2024-05-19 16:33:17 -0700
committerGitHub <noreply@github.com>2024-05-19 16:33:17 -0700
commit5d3f296733b66281a53dd451a983e69ae0bb482f (patch)
tree24f3737e88e2d61b9fbafa9d7fdc6fb3741a7d86 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent2f52bbeb6f6f3b7abef19cb5297773d95aa0b434 (diff)
[CallPromotionUtils]Implement conditional indirect call promotion with vtable-based comparison (#81378)
* Given the code sequence ``` bb: %vtable = load ptr, ptr %d, !prof !8 %vfn = getelementptr inbounds ptr, ptr %vtable, i64 1 %1 = load ptr, ptr %vfn %call = tail call i32 %1(ptr %d), !prof !9 ``` The transformation looks like ``` bb: %vtable = load ptr, ptr %d, align 8 %vfn = getelementptr inbounds i8, ptr %vtable, i64 8 <-- Inst 1 %func-addr = load ptr, ptr %vfn, align 8 <-- Inst 2 # compare loaded pointers with address point of vtables %1 = icmp eq ptr %vtable, getelementptr inbounds (i8, ptr @_ZTV<VTable>, i32 16) br i1 %1, label %if.true.direct_targ, label %if.false.orig_indirect, !prof !18 if.true.direct_targ: ; preds = %bb %2 = tail call i32 @<direct-call>(ptr nonnull %d) br label %if.end.icp if.false.orig_indirect: ; preds = %bb %call = tail call i32 %func-addr(ptr nonnull %d) br label %if.end.icp if.end.icp: ; preds = %if.false.orig_indirect, %if.true.direct_targ %4 = phi i32 [ %call, %if.false.orig_indirect ], [ %2, %if.true.direct_targ ] ``` It's intentional that `Inst 1` and `Inst2` remains in `bb` (not in `if.false.orig_indirect`). A follow up patch will implement code to sink them (something like how `instcombine` would [sink](https://github.com/llvm/llvm-project/blob/2fcfc9754a16805b81e541dc8222a8b5cf17a121/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L4293) instructions along with [debug intrinsics](https://github.com/llvm/llvm-project/blob/2fcfc9754a16805b81e541dc8222a8b5cf17a121/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L4356-L4368) if possible) * The parent patch is https://github.com/llvm/llvm-project/pull/81181
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions