mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 17:56:53 +00:00
f5d3346387
For IR generated by a compiler, this is really simple: you just take the datalayout from the beginning of the file, and apply it to all the IR later in the file. For optimization testcases that don't care about the datalayout, this is also really simple: we just use the default datalayout. The complexity here comes from the fact that some LLVM tools allow overriding the datalayout: some tools have an explicit flag for this, some tools will infer a datalayout based on the code generation target. Supporting this properly required plumbing through a bunch of new machinery: we want to allow overriding the datalayout after the datalayout is parsed from the file, but before we use any information from it. Therefore, IR/bitcode parsing now has a callback to allow tools to compute the datalayout at the appropriate time. Not sure if I covered all the LLVM tools that want to use the callback. (clang? lli? Misc IR manipulation tools like llvm-link?). But this is at least enough for all the LLVM regression tests, and IR without a datalayout is not something frontends should generate. This change had some sort of weird effects for certain CodeGen regression tests: if the datalayout is overridden with a datalayout with a different program or stack address space, we now parse IR based on the overridden datalayout, instead of the one written in the file (or the default one, if none is specified). This broke a few AVR tests, and one AMDGPU test. Outside the CodeGen tests I mentioned, the test changes are all just fixing CHECK lines and moving around datalayout lines in weird places. Differential Revision: https://reviews.llvm.org/D78403
177 lines
4.2 KiB
LLVM
177 lines
4.2 KiB
LLVM
; RUN: opt %s -newgvn -S | FileCheck %s
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
define i8* @test1(i8** %v0, i8** %v1) {
|
|
; CHECK-LABEL: @test1(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
|
|
; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
|
|
; CHECK-NEXT: ret i8* [[V2]]
|
|
;
|
|
top:
|
|
%v2 = load i8*, i8** %v0, !nonnull !0
|
|
store i8* %v2, i8** %v1
|
|
%v3 = load i8*, i8** %v1
|
|
ret i8* %v3
|
|
}
|
|
|
|
; FIXME: could propagate nonnull to first load?
|
|
define i8* @test2(i8** %v0, i8** %v1) {
|
|
; CHECK-LABEL: @test2(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
|
|
; CHECK-NEXT: ret i8* [[V2]]
|
|
;
|
|
top:
|
|
%v2 = load i8*, i8** %v0
|
|
store i8* %v2, i8** %v1
|
|
%v3 = load i8*, i8** %v1, !nonnull !0
|
|
ret i8* %v3
|
|
}
|
|
|
|
declare void @use1(i8* %a) readonly
|
|
|
|
define i8* @test3(i8** %v0) {
|
|
; CHECK-LABEL: @test3(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: call void @use1(i8* [[V1]])
|
|
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
|
|
; CHECK: bb1:
|
|
; CHECK-NEXT: ret i8* [[V1]]
|
|
; CHECK: bb2:
|
|
; CHECK-NEXT: ret i8* [[V1]]
|
|
;
|
|
top:
|
|
%v1 = load i8*, i8** %v0
|
|
call void @use1(i8* %v1)
|
|
br i1 undef, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
%v2 = load i8*, i8** %v0, !nonnull !0
|
|
ret i8* %v2
|
|
|
|
bb2:
|
|
%v3 = load i8*, i8** %v0
|
|
ret i8* %v3
|
|
}
|
|
|
|
define i8* @test4(i8** %v0) {
|
|
; CHECK-LABEL: @test4(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: call void @use1(i8* [[V1]])
|
|
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
|
|
; CHECK: bb1:
|
|
; CHECK-NEXT: ret i8* [[V1]]
|
|
; CHECK: bb2:
|
|
; CHECK-NEXT: ret i8* [[V1]]
|
|
;
|
|
top:
|
|
%v1 = load i8*, i8** %v0
|
|
call void @use1(i8* %v1)
|
|
br i1 undef, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
%v2 = load i8*, i8** %v0
|
|
ret i8* %v2
|
|
|
|
bb2:
|
|
%v3 = load i8*, i8** %v0, !nonnull !0
|
|
ret i8* %v3
|
|
}
|
|
|
|
define i8* @test5(i8** %v0) {
|
|
; CHECK-LABEL: @test5(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
|
|
; CHECK-NEXT: call void @use1(i8* [[V1]])
|
|
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
|
|
; CHECK: bb1:
|
|
; CHECK-NEXT: ret i8* [[V1]]
|
|
; CHECK: bb2:
|
|
; CHECK-NEXT: ret i8* [[V1]]
|
|
;
|
|
top:
|
|
%v1 = load i8*, i8** %v0, !nonnull !0
|
|
call void @use1(i8* %v1)
|
|
br i1 undef, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
%v2 = load i8*, i8** %v0
|
|
ret i8* %v2
|
|
|
|
bb2:
|
|
%v3 = load i8*, i8** %v0
|
|
ret i8* %v3
|
|
}
|
|
|
|
define i8* @test6(i8** %v0, i8** %v1) {
|
|
; CHECK-LABEL: @test6(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
|
|
; CHECK: bb1:
|
|
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
|
|
; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
|
|
; CHECK-NEXT: ret i8* [[V2]]
|
|
; CHECK: bb2:
|
|
; CHECK-NEXT: [[V4:%.*]] = load i8*, i8** [[V0]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: store i8* [[V4]], i8** [[V1]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: ret i8* [[V4]]
|
|
;
|
|
top:
|
|
br i1 undef, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
%v2 = load i8*, i8** %v0, !nonnull !0
|
|
store i8* %v2, i8** %v1
|
|
%v3 = load i8*, i8** %v1
|
|
ret i8* %v3
|
|
|
|
bb2:
|
|
%v4 = load i8*, i8** %v0
|
|
store i8* %v4, i8** %v1
|
|
%v5 = load i8*, i8** %v1, !nonnull !0
|
|
ret i8* %v5
|
|
}
|
|
|
|
declare void @use2(i8* %a)
|
|
|
|
define i8* @test7(i8** %v0) {
|
|
; CHECK-LABEL: @test7(
|
|
; CHECK-NEXT: top:
|
|
; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], align 8, !nonnull !0
|
|
; CHECK-NEXT: call void @use2(i8* [[V1]])
|
|
; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
|
|
; CHECK: bb1:
|
|
; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: ret i8* [[V2]]
|
|
; CHECK: bb2:
|
|
; CHECK-NEXT: [[V3:%.*]] = load i8*, i8** [[V0]]
|
|
; CHECK-NOT: !nonnull
|
|
; CHECK-NEXT: ret i8* [[V3]]
|
|
;
|
|
top:
|
|
%v1 = load i8*, i8** %v0, !nonnull !0
|
|
call void @use2(i8* %v1)
|
|
br i1 undef, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
%v2 = load i8*, i8** %v0
|
|
ret i8* %v2
|
|
|
|
bb2:
|
|
%v3 = load i8*, i8** %v0
|
|
ret i8* %v3
|
|
}
|
|
|
|
!0 = !{}
|