Skip to content

Commit 4956179

Browse files
nikicLukacma
authored andcommitted
[SpeculativeExecution] Add support for ptrtoaddr
1 parent a5c6492 commit 4956179

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ static InstructionCost ComputeSpeculationCost(const Instruction *I,
227227
case Instruction::Call:
228228
case Instruction::BitCast:
229229
case Instruction::PtrToInt:
230+
case Instruction::PtrToAddr:
230231
case Instruction::IntToPtr:
231232
case Instruction::AddrSpaceCast:
232233
case Instruction::FPToUI:

llvm/test/Transforms/SpeculativeExecution/spec-casts.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ b:
4343
ret void
4444
}
4545

46+
define void @ifThen_ptrtoaddr(ptr %arg) {
47+
; CHECK-LABEL: define void @ifThen_ptrtoaddr(
48+
; CHECK-SAME: ptr [[ARG:%.*]]) {
49+
; CHECK-NEXT: [[X:%.*]] = ptrtoaddr ptr [[ARG]] to i64
50+
; CHECK-NEXT: br i1 true, label %[[A:.*]], label %[[B:.*]]
51+
; CHECK: [[A]]:
52+
; CHECK-NEXT: br label %[[B]]
53+
; CHECK: [[B]]:
54+
; CHECK-NEXT: ret void
55+
;
56+
br i1 true, label %a, label %b
57+
58+
a:
59+
%x = ptrtoaddr ptr %arg to i64
60+
br label %b
61+
62+
b:
63+
ret void
64+
}
65+
4666
define void @ifThen_inttoptr(i64 %arg) {
4767
; CHECK-LABEL: define void @ifThen_inttoptr(
4868
; CHECK-SAME: i64 [[ARG:%.*]]) {

0 commit comments

Comments
 (0)