Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LowerTypeTests: Teach the pass to respect global alignments.
We were previously ignoring alignment entirely when combining globals together in this pass. There are two main things that we need to do here: add additional padding before each global to meet the alignment requirements, and set the combined global's alignment to the maximum of all of the original globals' alignments. Since we now need to calculate layout as we go anyway, use the calculated layout to produce GlobalLayout instead of using StructLayout. Differential Revision: https://reviews.llvm.org/D65033 llvm-svn: 366722
- Loading branch information
Showing
2 changed files
with
42 additions
and
19 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
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,16 @@ | ||
; RUN: opt -S -lowertypetests < %s | FileCheck %s | ||
|
||
target datalayout = "e-p:32:32" | ||
|
||
; CHECK: private constant { i32, [4 x i8], i32 } { i32 1, [4 x i8] zeroinitializer, i32 2 }, align 8 | ||
@a = constant i32 1, !type !0 | ||
@b = constant i32 2, align 8, !type !0 | ||
|
||
!0 = !{i32 0, !"typeid1"} | ||
|
||
declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone | ||
|
||
define i1 @foo(i8* %p) { | ||
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1") | ||
ret i1 %x | ||
} |