forked from rust-lang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RelLookupTableConverter] Bail on invalid pointer size (x32)
The RelLookupTableConverter pass currently only supports 64-bit pointers. This is currently enforced using an isArch64Bit() check on the target triple. However, we consider x32 to be a 64-bit target, even though the pointers are 32-bit. (And independently of that specific example, there may be address spaces with different pointer sizes.) As such, add an additional guard for the size of the pointers that are actually part of the lookup table. Differential Revision: https://reviews.llvm.org/D131399
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
llvm/test/Transforms/RelLookupTableConverter/X86/gnux32.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -passes=rel-lookup-table-converter -relocation-model=pic -S | FileCheck %s | ||
; REQUIRES: x86-registered-target | ||
|
||
target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnux32" | ||
|
||
@a = internal constant i32 0, align 4 | ||
@b = internal constant i32 0, align 4 | ||
@c = internal constant i32 0, align 4 | ||
|
||
@table = private unnamed_addr constant [3 x ptr] [ptr @a, ptr @b, ptr @c] | ||
|
||
define ptr @test(i32 %cond) { | ||
; CHECK-LABEL: @test( | ||
; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x ptr], ptr @table, i32 0, i32 [[COND:%.*]] | ||
; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load ptr, ptr [[SWITCH_GEP]], align 8 | ||
; CHECK-NEXT: ret ptr [[SWITCH_LOAD]] | ||
; | ||
%switch.gep = getelementptr inbounds [3 x ptr], ptr @table, i32 0, i32 %cond | ||
%switch.load = load ptr, ptr %switch.gep, align 8 | ||
ret ptr %switch.load | ||
} |