[llvm-branch-commits] [llvm] [JumpTableToSwitch] Use `ConstGlobalIterator` to iterate the jump table (PR #242994)
Ömer Sinan Ağacan via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Nov 21 08:08:03 PST 2026
https://github.com/osa1 updated https://github.com/llvm/llvm-project/pull/242994
>From f1b4c62e278194ba04a3483cd3c06bc90d51762e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= <omer at osa1.net>
Date: Fri, 13 Nov 2026 11:25:13 +0000
Subject: [PATCH] [JumpTableToSwitch] Use ConstGlobalIterator to read jump
table entries
Replace JTTS's own jump table parsing with the `ConstGlobalIterator` helper,
which is also used by instcombine's `foldCmpLoadFromIndexedGlobal`.
As a result JTTS now also handles GEPs without nusw/nuw flags, by masking the
index the same way instcombine does.
Note that the helper requires the indices to be in canonical index type, so
JTTS only works with canonical index types now. This is not a problem in
practice as JTTS only runs after instcombine.
---
.../Transforms/Scalar/JumpTableToSwitch.cpp | 66 ++++--------
.../Transforms/JumpTableToSwitch/basic.ll | 102 +++++++++---------
.../JumpTableToSwitch/callee-type-mismatch.ll | 16 +--
.../Transforms/JumpTableToSwitch/gep-flags.ll | 18 +++-
.../JumpTableToSwitch/max_function_size.ll | 8 +-
.../profile-no-guid-metadata.ll | 28 ++---
.../Transforms/JumpTableToSwitch/remarks.ll | 4 +-
.../test/Transforms/JumpTableToSwitch/skip.ll | 77 +++++++------
.../Transforms/JumpTableToSwitch/stats.ll | 8 +-
.../Transforms/JumpTableToSwitch/stride.ll | 12 +--
.../Transforms/JumpTableToSwitch/struct.ll | 14 +--
11 files changed, 172 insertions(+), 181 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp b/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
index bcc9a696b9d114..0119d9544e627e 100644
--- a/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/DomTreeUpdater.h"
+#include "llvm/Analysis/Loads.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/IR/IRBuilder.h"
@@ -49,47 +50,27 @@ static Function *getExpandableCallee(const ScalarOptions &Opts, Value *V,
}
static std::optional<JumpTable> parseJumpTable(const ScalarOptions &Opts,
- GetElementPtrInst *GEP,
- PointerType *PtrTy,
- FunctionType *CallFTy) {
- Constant *Ptr = dyn_cast<Constant>(GEP->getPointerOperand());
- if (!Ptr)
+ LoadInst *LI, PointerType *PtrTy,
+ FunctionType *CallFTy,
+ IRBuilderBase &Builder) {
+ std::optional<ConstGlobalIterator> GlobalIter =
+ ConstGlobalIterator::fromLoadInst(LI);
+ if (!GlobalIter)
return std::nullopt;
- GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr);
- if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer())
- return std::nullopt;
-
- Function &F = *GEP->getParent()->getParent();
- const DataLayout &DL = F.getDataLayout();
- const unsigned BitWidth =
- DL.getIndexSizeInBits(GEP->getPointerAddressSpace());
- SmallMapVector<Value *, APInt, 4> VariableOffsets;
- APInt ConstantOffset(BitWidth, 0);
- if (!GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset))
- return std::nullopt;
- if (VariableOffsets.size() != 1)
- return std::nullopt;
- // TODO: consider supporting more general patterns
- if (!ConstantOffset.isZero())
- return std::nullopt;
- APInt StrideBytes = VariableOffsets.front().second;
- const uint64_t JumpTableSizeBytes = GV->getGlobalSize(DL);
- if (JumpTableSizeBytes % StrideBytes.getZExtValue() != 0)
- return std::nullopt;
++NumEligibleJumpTables;
- const uint64_t N = JumpTableSizeBytes / StrideBytes.getZExtValue();
+
+ uint64_t N = GlobalIter->size();
if (N > Opts.jump_table_to_switch_size_threshold)
return std::nullopt;
- JumpTable JT;
- JT.Index = VariableOffsets.front().first;
- JT.Funcs.reserve(N);
+ Function &F = *LI->getParent()->getParent();
+
+ SmallVector<std::pair<uint64_t, Function *>, 10> Funcs;
+ Funcs.reserve(N);
+
for (uint64_t Index = 0; Index < N; ++Index) {
- // ConstantOffset is zero.
- APInt Offset = Index * StrideBytes;
- Constant *C =
- ConstantFoldLoadFromConst(GV->getInitializer(), PtrTy, Offset, DL);
+ Constant *C = GlobalIter->elementAt(Index);
if (!C)
return std::nullopt;
if ((isa<ConstantPointerNull>(C) &&
@@ -99,12 +80,13 @@ static std::optional<JumpTable> parseJumpTable(const ScalarOptions &Opts,
Function *Func = getExpandableCallee(Opts, C, CallFTy);
if (!Func)
return std::nullopt;
- JT.Funcs.push_back({Index, Func});
+ Funcs.push_back({Index, Func});
}
// Empty table, or only values that are UB when called
- if (JT.Funcs.empty())
+ if (Funcs.empty())
return std::nullopt;
- return JT;
+
+ return JumpTable{GlobalIter->getIndex(Builder), std::move(Funcs)};
}
static BasicBlock *
@@ -255,16 +237,12 @@ PreservedAnalyses JumpTableToSwitchPass::run(Function &F,
JT->Funcs.push_back({0, F0});
JT->Funcs.push_back({1, F1});
} else if (auto *L = dyn_cast<LoadInst>(Call->getCalledOperand())) {
- // Skip atomic or volatile loads.
- if (!L || !L->isSimple())
- continue;
- auto *GEP = dyn_cast<GetElementPtrInst>(L->getPointerOperand());
- if (!GEP ||
- (!GEP->hasNoUnsignedWrap() && !GEP->hasNoUnsignedSignedWrap()))
+ if (!L)
continue;
auto *PtrTy = dyn_cast<PointerType>(L->getType());
assert(PtrTy && "call operand must be a pointer");
- JT = parseJumpTable(Opts, GEP, PtrTy, Call->getFunctionType());
+ IRBuilder<> Builder(Call);
+ JT = parseJumpTable(Opts, L, PtrTy, Call->getFunctionType(), Builder);
}
if (!JT)
continue;
diff --git a/llvm/test/Transforms/JumpTableToSwitch/basic.ll b/llvm/test/Transforms/JumpTableToSwitch/basic.ll
index c6f59406f73378..9895ed2e1ace3d 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/basic.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/basic.ll
@@ -37,14 +37,14 @@ define i32 @func1() !guid !1 {
ret i32 2
}
-define i32 @function_with_jump_table(i32 %index) {
+define i32 @function_with_jump_table(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_1:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_1:%.*]]
; CHECK-NEXT: ], !prof [[PROF2:![0-9]+]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -59,26 +59,26 @@ define i32 @function_with_jump_table(i32 %index) {
; CHECK-NEXT: ret i32 [[TMP3]]
;
; THRESHOLD-0-LABEL: define i32 @function_with_jump_table(
-; THRESHOLD-0-SAME: i32 [[INDEX:%.*]]) {
-; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; THRESHOLD-0-SAME: i64 [[INDEX:%.*]]) {
+; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; THRESHOLD-0-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
; THRESHOLD-0-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](), !prof [[PROF2:![0-9]+]]
; THRESHOLD-0-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
%result = call i32 %func_ptr(), !prof !2
ret i32 %result
}
-define i32 @basic_block_splitted_twice(i32 %index) {
+define i32 @basic_block_splitted_twice(i64 %index) {
; CHECK-LABEL: define i32 @basic_block_splitted_twice(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR1:%.*]] = load ptr, ptr [[GEP1]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_1:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_1:%.*]]
; CHECK-NEXT: ], !prof [[PROF3:![0-9]+]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -90,11 +90,11 @@ define i32 @basic_block_splitted_twice(i32 %index) {
; CHECK-NEXT: br label [[DOTTAIL]]
; CHECK: .tail:
; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP1]], [[CALL_0]] ], [ [[TMP2]], [[CALL_1]] ]
-; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR2:%.*]] = load ptr, ptr [[GEP2]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE1:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_02:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_13:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE1:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_02:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_13:%.*]]
; CHECK-NEXT: ], !prof [[PROF3]]
; CHECK: default.switch.case.unreachable1:
; CHECK-NEXT: unreachable
@@ -110,20 +110,20 @@ define i32 @basic_block_splitted_twice(i32 %index) {
; CHECK-NEXT: ret i32 [[RESULT]]
;
; THRESHOLD-0-LABEL: define i32 @basic_block_splitted_twice(
-; THRESHOLD-0-SAME: i32 [[INDEX:%.*]]) {
-; THRESHOLD-0-NEXT: [[GEP1:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; THRESHOLD-0-SAME: i64 [[INDEX:%.*]]) {
+; THRESHOLD-0-NEXT: [[GEP1:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; THRESHOLD-0-NEXT: [[FUNC_PTR1:%.*]] = load ptr, ptr [[GEP1]], align 8
; THRESHOLD-0-NEXT: [[RESULT1:%.*]] = call i32 [[FUNC_PTR1]]()
-; THRESHOLD-0-NEXT: [[GEP2:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; THRESHOLD-0-NEXT: [[GEP2:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; THRESHOLD-0-NEXT: [[FUNC_PTR2:%.*]] = load ptr, ptr [[GEP2]], align 8
; THRESHOLD-0-NEXT: [[RESULT2:%.*]] = call i32 [[FUNC_PTR2]]()
; THRESHOLD-0-NEXT: [[RESULT:%.*]] = add i32 [[RESULT1]], [[RESULT2]]
; THRESHOLD-0-NEXT: ret i32 [[RESULT]]
;
- %gep1 = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 %index
+ %gep1 = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 %index
%func_ptr1 = load ptr, ptr %gep1
%result1 = call i32 %func_ptr1()
- %gep2 = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 %index
+ %gep2 = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 %index
%func_ptr2 = load ptr, ptr %gep2
%result2 = call i32 %func_ptr2()
%result = add i32 %result1, %result2
@@ -152,14 +152,14 @@ define void @void_func1() {
@void_func_array = constant [2 x ptr] [ptr @void_func0, ptr @void_func1]
-define void @void_function_with_jump_table(i32 %index) {
+define void @void_function_with_jump_table(i64 %index) {
; CHECK-LABEL: define void @void_function_with_jump_table(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_1:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_1:%.*]]
; CHECK-NEXT: ], !prof [[PROF3]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -173,26 +173,26 @@ define void @void_function_with_jump_table(i32 %index) {
; CHECK-NEXT: ret void
;
; THRESHOLD-0-LABEL: define void @void_function_with_jump_table(
-; THRESHOLD-0-SAME: i32 [[INDEX:%.*]]) {
-; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i32 0, i32 [[INDEX]]
+; THRESHOLD-0-SAME: i64 [[INDEX:%.*]]) {
+; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i64 0, i64 [[INDEX]]
; THRESHOLD-0-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
; THRESHOLD-0-NEXT: call void [[FUNC_PTR]]()
; THRESHOLD-0-NEXT: ret void
;
- %gep = getelementptr inbounds [2 x ptr], ptr @void_func_array, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @void_func_array, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
call void %func_ptr()
ret void
}
-define void @void_function_with_jump_table_and_call_site_attr(i32 %index) {
+define void @void_function_with_jump_table_and_call_site_attr(i64 %index) {
; CHECK-LABEL: define void @void_function_with_jump_table_and_call_site_attr(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_1:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_1:%.*]]
; CHECK-NEXT: ], !prof [[PROF3]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -206,13 +206,13 @@ define void @void_function_with_jump_table_and_call_site_attr(i32 %index) {
; CHECK-NEXT: ret void
;
; THRESHOLD-0-LABEL: define void @void_function_with_jump_table_and_call_site_attr(
-; THRESHOLD-0-SAME: i32 [[INDEX:%.*]]) {
-; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i32 0, i32 [[INDEX]]
+; THRESHOLD-0-SAME: i64 [[INDEX:%.*]]) {
+; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @void_func_array, i64 0, i64 [[INDEX]]
; THRESHOLD-0-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
; THRESHOLD-0-NEXT: call void [[FUNC_PTR]]() #[[ATTR0:[0-9]+]]
; THRESHOLD-0-NEXT: ret void
;
- %gep = getelementptr inbounds [2 x ptr], ptr @void_func_array, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @void_func_array, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
call void %func_ptr() nounwind
ret void
@@ -241,14 +241,14 @@ define i32 @func1_addrspace_42() addrspace(42) {
@func_array_addrspace_42 = addrspace(42) constant [2 x ptr addrspace(42)] [ptr addrspace(42) @func0_addrspace_42, ptr addrspace(42) @func1_addrspace_42]
-define i32 @function_with_jump_table_addrspace_42(i32 %index) addrspace(42) {
+define i32 @function_with_jump_table_addrspace_42(i64 %index) addrspace(42) {
; CHECK-LABEL: define i32 @function_with_jump_table_addrspace_42(
-; CHECK-SAME: i32 [[INDEX:%.*]]) addrspace(42) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr addrspace(42)], ptr addrspace(42) @func_array_addrspace_42, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) addrspace(42) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr addrspace(42)], ptr addrspace(42) @func_array_addrspace_42, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr addrspace(42), ptr addrspace(42) [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_1:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_1:%.*]]
; CHECK-NEXT: ], !prof [[PROF3]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -263,13 +263,13 @@ define i32 @function_with_jump_table_addrspace_42(i32 %index) addrspace(42) {
; CHECK-NEXT: ret i32 [[TMP3]]
;
; THRESHOLD-0-LABEL: define i32 @function_with_jump_table_addrspace_42(
-; THRESHOLD-0-SAME: i32 [[INDEX:%.*]]) addrspace(42) {
-; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr addrspace(42)], ptr addrspace(42) @func_array_addrspace_42, i32 0, i32 [[INDEX]]
+; THRESHOLD-0-SAME: i64 [[INDEX:%.*]]) addrspace(42) {
+; THRESHOLD-0-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr addrspace(42)], ptr addrspace(42) @func_array_addrspace_42, i64 0, i64 [[INDEX]]
; THRESHOLD-0-NEXT: [[FUNC_PTR:%.*]] = load ptr addrspace(42), ptr addrspace(42) [[GEP]], align 8
; THRESHOLD-0-NEXT: [[RESULT:%.*]] = call addrspace(42) i32 [[FUNC_PTR]]()
; THRESHOLD-0-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [2 x ptr addrspace(42)], ptr addrspace(42) @func_array_addrspace_42, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr addrspace(42)], ptr addrspace(42) @func_array_addrspace_42, i64 0, i64 %index
%func_ptr = load ptr addrspace(42), ptr addrspace(42) %gep, align 8
%result = call addrspace(42) i32 %func_ptr()
ret i32 %result
diff --git a/llvm/test/Transforms/JumpTableToSwitch/callee-type-mismatch.ll b/llvm/test/Transforms/JumpTableToSwitch/callee-type-mismatch.ll
index 66014b9ca97699..ab566c43ecc27e 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/callee-type-mismatch.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/callee-type-mismatch.ll
@@ -19,29 +19,29 @@ define i64 @f_rettype() {
ret i64 123
}
-define i32 @argcount(i32 %idx) {
+define i32 @argcount(i64 %idx) {
; CHECK-LABEL: define i32 @argcount(
-; CHECK-SAME: i32 [[IDX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @arr_argcount, i32 0, i32 [[IDX]]
+; CHECK-SAME: i64 [[IDX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @arr_argcount, i64 0, i64 [[IDX]]
; CHECK-NEXT: [[FP:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: [[R:%.*]] = call i32 [[FP]]()
; CHECK-NEXT: ret i32 [[R]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @arr_argcount, i32 0, i32 %idx
+ %gep = getelementptr inbounds [1 x ptr], ptr @arr_argcount, i64 0, i64 %idx
%fp = load ptr, ptr %gep
%r = call i32 %fp()
ret i32 %r
}
-define i32 @rettype(i32 %idx) {
+define i32 @rettype(i64 %idx) {
; CHECK-LABEL: define i32 @rettype(
-; CHECK-SAME: i32 [[IDX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @arr_rettype, i32 0, i32 [[IDX]]
+; CHECK-SAME: i64 [[IDX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @arr_rettype, i64 0, i64 [[IDX]]
; CHECK-NEXT: [[FP:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: [[R:%.*]] = call i32 [[FP]]()
; CHECK-NEXT: ret i32 [[R]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @arr_rettype, i32 0, i32 %idx
+ %gep = getelementptr inbounds [1 x ptr], ptr @arr_rettype, i64 0, i64 %idx
%fp = load ptr, ptr %gep
%r = call i32 %fp()
ret i32 %r
diff --git a/llvm/test/Transforms/JumpTableToSwitch/gep-flags.ll b/llvm/test/Transforms/JumpTableToSwitch/gep-flags.ll
index cbb8869114c14c..45501b2eb0bee3 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/gep-flags.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/gep-flags.ll
@@ -22,7 +22,21 @@ define i32 @test_no_flags(i64 %i) {
; CHECK-SAME: i64 [[I:%.*]]) {
; CHECK-NEXT: [[P:%.*]] = getelementptr [2 x ptr], ptr @table, i64 0, i64 [[I]]
; CHECK-NEXT: [[F:%.*]] = load ptr, ptr [[P]], align 8
-; CHECK-NEXT: [[R:%.*]] = call i32 [[F]]()
+; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[I]], 2305843009213693951
+; CHECK-NEXT: switch i64 [[TMP1]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
+; CHECK-NEXT: i64 0, label %[[CALL_0:.*]]
+; CHECK-NEXT: i64 1, label %[[CALL_1:.*]]
+; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
+; CHECK: [[DEFAULT_SWITCH_CASE_UNREACHABLE]]:
+; CHECK-NEXT: unreachable
+; CHECK: [[CALL_0]]:
+; CHECK-NEXT: [[TMP2:%.*]] = call i32 @f0()
+; CHECK-NEXT: br label %[[DOTTAIL:.*]]
+; CHECK: [[CALL_1]]:
+; CHECK-NEXT: [[TMP3:%.*]] = call i32 @f1()
+; CHECK-NEXT: br label %[[DOTTAIL]]
+; CHECK: [[DOTTAIL]]:
+; CHECK-NEXT: [[R:%.*]] = phi i32 [ [[TMP2]], %[[CALL_0]] ], [ [[TMP3]], %[[CALL_1]] ]
; CHECK-NEXT: ret i32 [[R]]
;
%p = getelementptr [2 x ptr], ptr @table, i64 0, i64 %i
@@ -39,7 +53,7 @@ define i32 @test_nusw(i64 %i) {
; CHECK-NEXT: switch i64 [[I]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
; CHECK-NEXT: i64 0, label %[[CALL_0:.*]]
; CHECK-NEXT: i64 1, label %[[CALL_1:.*]]
-; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
+; CHECK-NEXT: ], !prof [[PROF0]]
; CHECK: [[DEFAULT_SWITCH_CASE_UNREACHABLE]]:
; CHECK-NEXT: unreachable
; CHECK: [[CALL_0]]:
diff --git a/llvm/test/Transforms/JumpTableToSwitch/max_function_size.ll b/llvm/test/Transforms/JumpTableToSwitch/max_function_size.ll
index 565916f47911bc..381ae69113871c 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/max_function_size.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/max_function_size.ll
@@ -19,15 +19,15 @@ define i32 @large_func() {
ret i32 %x
}
-define i32 @function_with_jump_table_with_large_func(i32 %index) {
+define i32 @function_with_jump_table_with_large_func(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table_with_large_func(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]]()
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep, align 8
%result = call i32 %func_ptr()
ret i32 %result
diff --git a/llvm/test/Transforms/JumpTableToSwitch/profile-no-guid-metadata.ll b/llvm/test/Transforms/JumpTableToSwitch/profile-no-guid-metadata.ll
index e10e7fd15080e1..86fd3711d3fb3f 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/profile-no-guid-metadata.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/profile-no-guid-metadata.ll
@@ -25,14 +25,14 @@ define i32 @jt_target_1() {
ret i32 20
}
-define i32 @caller(i32 %idx) {
+define i32 @caller(i64 %idx) {
; CHECK-LABEL: define i32 @caller(
-; CHECK-SAME: i32 [[IDX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 [[IDX]]
+; CHECK-SAME: i64 [[IDX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @jt, i64 0, i64 [[IDX]]
; CHECK-NEXT: [[FPTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[IDX]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
-; CHECK-NEXT: i32 0, label %[[CALL0:.*]]
-; CHECK-NEXT: i32 1, label %[[CALL1:.*]]
+; CHECK-NEXT: switch i64 [[IDX]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
+; CHECK-NEXT: i64 0, label %[[CALL0:.*]]
+; CHECK-NEXT: i64 1, label %[[CALL1:.*]]
; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
; CHECK: [[DEFAULT_SWITCH_CASE_UNREACHABLE]]:
; CHECK-NEXT: unreachable
@@ -46,20 +46,20 @@ define i32 @caller(i32 %idx) {
; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP1]], %[[CALL0]] ], [ [[TMP2]], %[[CALL1]] ]
; CHECK-NEXT: ret i32 [[TMP3]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 %idx
+ %gep = getelementptr inbounds [2 x ptr], ptr @jt, i64 0, i64 %idx
%fptr = load ptr, ptr %gep
%r = call i32 %fptr(), !prof !0
ret i32 %r
}
-define i32 @caller_only_zero_guids(i32 %idx) {
+define i32 @caller_only_zero_guids(i64 %idx) {
; CHECK-LABEL: define i32 @caller_only_zero_guids(
-; CHECK-SAME: i32 [[IDX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 [[IDX]]
+; CHECK-SAME: i64 [[IDX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @jt, i64 0, i64 [[IDX]]
; CHECK-NEXT: [[FPTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[IDX]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
-; CHECK-NEXT: i32 0, label %[[CALL_0:.*]]
-; CHECK-NEXT: i32 1, label %[[CALL_1:.*]]
+; CHECK-NEXT: switch i64 [[IDX]], label %[[DEFAULT_SWITCH_CASE_UNREACHABLE:.*]] [
+; CHECK-NEXT: i64 0, label %[[CALL_0:.*]]
+; CHECK-NEXT: i64 1, label %[[CALL_1:.*]]
; CHECK-NEXT: ], !prof [[PROF1:![0-9]+]]
; CHECK: [[DEFAULT_SWITCH_CASE_UNREACHABLE]]:
; CHECK-NEXT: unreachable
@@ -73,7 +73,7 @@ define i32 @caller_only_zero_guids(i32 %idx) {
; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP1]], %[[CALL_0]] ], [ [[TMP2]], %[[CALL_1]] ]
; CHECK-NEXT: ret i32 [[TMP3]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @jt, i32 0, i32 %idx
+ %gep = getelementptr inbounds [2 x ptr], ptr @jt, i64 0, i64 %idx
%fptr = load ptr, ptr %gep
%r = call i32 %fptr(), !prof !1
ret i32 %r
diff --git a/llvm/test/Transforms/JumpTableToSwitch/remarks.ll b/llvm/test/Transforms/JumpTableToSwitch/remarks.ll
index 0bce2267af0d0d..8afe185e8f8fa9 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/remarks.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/remarks.ll
@@ -12,8 +12,8 @@ define i32 @func1() {
ret i32 2
}
-define i32 @function_with_jump_table(i32 %index) {
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 %index
+define i32 @function_with_jump_table(i64 %index) {
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
%result = call i32 %func_ptr(), !dbg !8
ret i32 %result
diff --git a/llvm/test/Transforms/JumpTableToSwitch/skip.ll b/llvm/test/Transforms/JumpTableToSwitch/skip.ll
index aa788fa8ddec53..47b383d6f63dc7 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/skip.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/skip.ll
@@ -12,15 +12,15 @@ define i32 @func0() {
declare i32 @declared_only_func1()
-define i32 @function_with_jump_table_with_a_declared_only_func(i32 %index) {
+define i32 @function_with_jump_table_with_a_declared_only_func(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table_with_a_declared_only_func(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]]()
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep, align 8
%result = call i32 %func_ptr()
ret i32 %result
@@ -28,10 +28,10 @@ define i32 @function_with_jump_table_with_a_declared_only_func(i32 %index) {
declare i32 @__gxx_personality_v0(...)
-define i32 @function_with_jump_table_invoke(i32 %index) personality ptr @__gxx_personality_v0 {
+define i32 @function_with_jump_table_invoke(i64 %index) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define i32 @function_with_jump_table_invoke(
-; CHECK-SAME: i32 [[INDEX:%.*]]) personality ptr @__gxx_personality_v0 {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) personality ptr @__gxx_personality_v0 {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array0, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
; CHECK-NEXT: [[RESULT:%.*]] = invoke i32 [[FUNC_PTR]]()
; CHECK-NEXT: to label [[NORMAL:%.*]] unwind label [[EXCEPTIONAL:%.*]]
@@ -42,7 +42,7 @@ define i32 @function_with_jump_table_invoke(i32 %index) personality ptr @__gxx_p
; CHECK-NEXT: catch ptr null
; CHECK-NEXT: resume { ptr, i32 } [[LANDING_PAD]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array0, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep, align 8
%result = invoke i32 %func_ptr() to label %normal unwind label %exceptional
normal:
@@ -62,77 +62,76 @@ define i32 @func2(i32 %arg) {
ret i32 %arg
}
-define i32 @function_with_jump_table_musttail_call(i32 %index) {
+define i32 @function_with_jump_table_musttail_call(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table_musttail_call(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array1, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array1, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: [[RESULT:%.*]] = musttail call i32 [[FUNC_PTR]](i32 [[INDEX]])
+; CHECK-NEXT: [[RESULT:%.*]] = musttail call i32 [[FUNC_PTR]](i64 [[INDEX]])
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @func_array1, i32 0, i32 %index
+ %gep = getelementptr inbounds [1 x ptr], ptr @func_array1, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep, align 8
- %result = musttail call i32 %func_ptr(i32 %index)
+ %result = musttail call i32 %func_ptr(i64 %index)
ret i32 %result
}
-define i32 @function_with_jump_table_and_volatile_load(i32 %index) {
+define i32 @function_with_jump_table_and_volatile_load(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table_and_volatile_load(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array1, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array1, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load volatile ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i32 [[INDEX]])
+; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i64 [[INDEX]])
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @func_array1, i32 0, i32 %index
+ %gep = getelementptr inbounds [1 x ptr], ptr @func_array1, i64 0, i64 %index
%func_ptr = load volatile ptr, ptr %gep, align 8
- %result = call i32 %func_ptr(i32 %index)
+ %result = call i32 %func_ptr(i64 %index)
ret i32 %result
}
-define i32 @function_with_jump_table_and_atomic_load(i32 %index) {
+define i32 @function_with_jump_table_and_atomic_load(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table_and_atomic_load(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array1, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array1, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load atomic ptr, ptr [[GEP]] monotonic, align 8
-; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i32 [[INDEX]])
+; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i64 [[INDEX]])
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @func_array1, i32 0, i32 %index
+ %gep = getelementptr inbounds [1 x ptr], ptr @func_array1, i64 0, i64 %index
%func_ptr = load atomic ptr, ptr %gep monotonic, align 8
- %result = call i32 %func_ptr(i32 %index)
+ %result = call i32 %func_ptr(i64 %index)
ret i32 %result
}
@func_array2 = global [1 x ptr] [ptr @func2]
-define i32 @function_with_nonconstant_jump_table(i32 %index) {
+define i32 @function_with_nonconstant_jump_table(i64 %index) {
; CHECK-LABEL: define i32 @function_with_nonconstant_jump_table(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array2, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array2, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i32 [[INDEX]])
+; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i64 [[INDEX]])
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @func_array2, i32 0, i32 %index
+ %gep = getelementptr inbounds [1 x ptr], ptr @func_array2, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep, align 8
- %result = call i32 %func_ptr(i32 %index)
+ %result = call i32 %func_ptr(i64 %index)
ret i32 %result
}
@func_array3 = weak constant [1 x ptr] [ptr @func2]
-define i32 @function_with_constant_weak_jump_table(i32 %index) {
+define i32 @function_with_constant_weak_jump_table(i64 %index) {
; CHECK-LABEL: define i32 @function_with_constant_weak_jump_table(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array3, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [1 x ptr], ptr @func_array3, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i32 [[INDEX]])
+; CHECK-NEXT: [[RESULT:%.*]] = call i32 [[FUNC_PTR]](i64 [[INDEX]])
; CHECK-NEXT: ret i32 [[RESULT]]
;
- %gep = getelementptr inbounds [1 x ptr], ptr @func_array3, i32 0, i32 %index
+ %gep = getelementptr inbounds [1 x ptr], ptr @func_array3, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep, align 8
- %result = call i32 %func_ptr(i32 %index)
+ %result = call i32 %func_ptr(i64 %index)
ret i32 %result
}
-
diff --git a/llvm/test/Transforms/JumpTableToSwitch/stats.ll b/llvm/test/Transforms/JumpTableToSwitch/stats.ll
index 1533d7072bcc0d..1f4878d6dd60a6 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/stats.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/stats.ll
@@ -24,15 +24,15 @@ define i32 @func2() {
ret i32 %d
}
-define i32 @function_gets_converted(i32 %index) {
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array1, i32 0, i32 %index
+define i32 @function_gets_converted(i64 %index) {
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array1, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
%result = call i32 %func_ptr()
ret i32 %result
}
-define i32 @function_not_converted(i32 %index) {
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array2, i32 0, i32 %index
+define i32 @function_not_converted(i64 %index) {
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array2, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
%result = call i32 %func_ptr()
ret i32 %result
diff --git a/llvm/test/Transforms/JumpTableToSwitch/stride.ll b/llvm/test/Transforms/JumpTableToSwitch/stride.ll
index 1a04cff50c3c2d..16ef6eec5d044a 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/stride.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/stride.ll
@@ -17,13 +17,13 @@ define i32 @func1() {
ret i32 2
}
-define i32 @check_stride(i32 %index) {
+define i32 @check_stride(i64 %index) {
; CHECK-LABEL: define i32 @check_stride(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x { ptr, ptr }], ptr @func_array, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x { ptr, ptr }], ptr @func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -34,7 +34,7 @@ define i32 @check_stride(i32 %index) {
; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP1]], [[CALL_0]] ]
; CHECK-NEXT: ret i32 [[TMP2]]
;
- %gep = getelementptr inbounds [2 x { ptr, ptr }], ptr @func_array, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x { ptr, ptr }], ptr @func_array, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
%result = call i32 %func_ptr()
ret i32 %result
diff --git a/llvm/test/Transforms/JumpTableToSwitch/struct.ll b/llvm/test/Transforms/JumpTableToSwitch/struct.ll
index 37856ce0244c60..eb6861a15a546a 100644
--- a/llvm/test/Transforms/JumpTableToSwitch/struct.ll
+++ b/llvm/test/Transforms/JumpTableToSwitch/struct.ll
@@ -19,14 +19,14 @@ define i32 @func1() {
ret i32 2
}
-define i32 @function_with_jump_table(i32 %index) {
+define i32 @function_with_jump_table(i64 %index) {
; CHECK-LABEL: define i32 @function_with_jump_table(
-; CHECK-SAME: i32 [[INDEX:%.*]]) {
-; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 [[INDEX]]
+; CHECK-SAME: i64 [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 [[INDEX]]
; CHECK-NEXT: [[FUNC_PTR:%.*]] = load ptr, ptr [[GEP]], align 8
-; CHECK-NEXT: switch i32 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
-; CHECK-NEXT: i32 0, label [[CALL_0:%.*]]
-; CHECK-NEXT: i32 1, label [[CALL_1:%.*]]
+; CHECK-NEXT: switch i64 [[INDEX]], label [[DEFAULT_SWITCH_CASE_UNREACHABLE:%.*]] [
+; CHECK-NEXT: i64 0, label [[CALL_0:%.*]]
+; CHECK-NEXT: i64 1, label [[CALL_1:%.*]]
; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
; CHECK: default.switch.case.unreachable:
; CHECK-NEXT: unreachable
@@ -40,7 +40,7 @@ define i32 @function_with_jump_table(i32 %index) {
; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[TMP1]], [[CALL_0]] ], [ [[TMP2]], [[CALL_1]] ]
; CHECK-NEXT: ret i32 [[TMP3]]
;
- %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i32 0, i32 %index
+ %gep = getelementptr inbounds [2 x ptr], ptr @func_array, i64 0, i64 %index
%func_ptr = load ptr, ptr %gep
%result = call i32 %func_ptr()
ret i32 %result
More information about the llvm-branch-commits
mailing list