mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Reapply [IRBuilder] Always respect inserter/folder
Some IRBuilder methods that were originally defined on IRBuilderBase do not respect custom IRBuilder inserters/folders, because those were not accessible prior to D73835. Fix this by making use of existing (and now accessible) IRBuilder methods, which will handle inserters/folders correctly. There are some changes in OpenMP and Instrumentation tests, where bitcasts now get constant folded. I've also highlighted one InstCombine test which now finishes in two rather than three iterations, thanks to new instructions being inserted into the worklist. Differential Revision: https://reviews.llvm.org/D74787
This commit is contained in:
parent
c708922cd0
commit
453ec55b92
@ -65,38 +65,19 @@ Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
|
||||
return Ptr;
|
||||
|
||||
// Otherwise, we need to insert a bitcast.
|
||||
PT = getInt8PtrTy(PT->getAddressSpace());
|
||||
BitCastInst *BCI = new BitCastInst(Ptr, PT, "");
|
||||
BB->getInstList().insert(InsertPt, BCI);
|
||||
SetInstDebugLocation(BCI);
|
||||
return BCI;
|
||||
return CreateBitCast(Ptr, getInt8PtrTy(PT->getAddressSpace()));
|
||||
}
|
||||
|
||||
static CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
|
||||
IRBuilderBase *Builder,
|
||||
const Twine &Name = "",
|
||||
Instruction *FMFSource = nullptr) {
|
||||
CallInst *CI = CallInst::Create(Callee, Ops, Name);
|
||||
CallInst *CI = Builder->CreateCall(Callee, Ops, Name);
|
||||
if (FMFSource)
|
||||
CI->copyFastMathFlags(FMFSource);
|
||||
Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI);
|
||||
Builder->SetInstDebugLocation(CI);
|
||||
return CI;
|
||||
}
|
||||
|
||||
static InvokeInst *createInvokeHelper(Function *Invokee, BasicBlock *NormalDest,
|
||||
BasicBlock *UnwindDest,
|
||||
ArrayRef<Value *> Ops,
|
||||
IRBuilderBase *Builder,
|
||||
const Twine &Name = "") {
|
||||
InvokeInst *II =
|
||||
InvokeInst::Create(Invokee, NormalDest, UnwindDest, Ops, Name);
|
||||
Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),
|
||||
II);
|
||||
Builder->SetInstDebugLocation(II);
|
||||
return II;
|
||||
}
|
||||
|
||||
CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
|
||||
MaybeAlign Align, bool isVolatile,
|
||||
MDNode *TBAATag, MDNode *ScopeTag,
|
||||
@ -696,8 +677,8 @@ static InvokeInst *CreateGCStatepointInvokeCommon(
|
||||
std::vector<Value *> Args =
|
||||
getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee, Flags,
|
||||
InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
|
||||
return createInvokeHelper(FnStatepoint, NormalDest, UnwindDest, Args, Builder,
|
||||
Name);
|
||||
return Builder->CreateInvoke(FnStatepoint, NormalDest, UnwindDest, Args,
|
||||
Name);
|
||||
}
|
||||
|
||||
InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
|
||||
|
@ -21,8 +21,7 @@ define i32 @foo(i32 %guard, ...) {
|
||||
; CHECK: [[B:%.*]] = add i64 0, [[A]]
|
||||
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
|
||||
|
||||
; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 [[STACK]], i64 [[B]], i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 bitcast ({{.*}} @__msan_va_arg_tls to i8*), i64 [[B]], i1 false)
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
|
||||
declare void @llvm.va_start(i8*) #2
|
||||
|
@ -21,8 +21,7 @@ define i32 @foo(i32 %guard, ...) {
|
||||
; CHECK: [[B:%.*]] = add i64 0, [[A]]
|
||||
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
|
||||
|
||||
; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 [[STACK]], i64 [[B]], i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 bitcast ({{.*}} @__msan_va_arg_tls to i8*), i64 [[B]], i1 false)
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
|
||||
declare void @llvm.va_start(i8*) #2
|
||||
|
@ -21,8 +21,7 @@ define i32 @foo(i32 %guard, ...) {
|
||||
; CHECK: [[B:%.*]] = add i64 0, [[A]]
|
||||
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
|
||||
|
||||
; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 [[STACK]], i64 [[B]], i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 bitcast ({{.*}} @__msan_va_arg_tls to i8*), i64 [[B]], i1 false)
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
|
||||
declare void @llvm.va_start(i8*) #2
|
||||
@ -98,8 +97,7 @@ define i32 @bar6([2 x i64]* %arg) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @bar6
|
||||
; CHECK: [[SHADOW:%[0-9]+]] = bitcast [2 x i64]* bitcast ([100 x i64]* @__msan_va_arg_tls to [2 x i64]*) to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[SHADOW]], i8* align 8 {{.*}}, i64 16, i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 bitcast ([100 x i64]* @__msan_va_arg_tls to i8*), i8* align 8 {{.*}}, i64 16, i1 false)
|
||||
; CHECK: store {{.*}} 16, {{.*}} @__msan_va_arg_overflow_size_tls
|
||||
|
||||
; Check 16-aligned byval.
|
||||
@ -109,8 +107,7 @@ define i32 @bar7([4 x i64]* %arg) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @bar7
|
||||
; CHECK: [[SHADOW:%[0-9]+]] = bitcast [4 x i64]* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 8) to [4 x i64]*)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[SHADOW]], i8* align 8 {{.*}}, i64 32, i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_param_tls to i64), i64 8) to i8*), i8* align 8 {{.*}}, i64 32, i1 false)
|
||||
; CHECK: store {{.*}} 40, {{.*}} @__msan_va_arg_overflow_size_tls
|
||||
|
||||
|
||||
|
@ -21,8 +21,7 @@ define i32 @foo(i32 %guard, ...) {
|
||||
; CHECK: [[B:%.*]] = add i64 0, [[A]]
|
||||
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
|
||||
|
||||
; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 [[STACK]], i64 [[B]], i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[C]], i8* align 8 bitcast ({{.*}} @__msan_va_arg_tls to i8*), i64 [[B]], i1 false)
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
|
||||
declare void @llvm.va_start(i8*) #2
|
||||
@ -82,8 +81,7 @@ define i32 @bar6([2 x i64]* %arg) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @bar6
|
||||
; CHECK: [[SHADOW:%[0-9]+]] = bitcast [2 x i64]* bitcast ([100 x i64]* @__msan_va_arg_tls to [2 x i64]*) to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[SHADOW]], i8* align 8 {{.*}}, i64 16, i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 bitcast ([100 x i64]* @__msan_va_arg_tls to i8*), i8* align 8 {{.*}}, i64 16, i1 false)
|
||||
; CHECK: store {{.*}} 16, {{.*}} @__msan_va_arg_overflow_size_tls
|
||||
|
||||
; Check 16-aligned byval.
|
||||
@ -93,8 +91,7 @@ define i32 @bar7([4 x i64]* %arg) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @bar7
|
||||
; CHECK: [[SHADOW:%[0-9]+]] = bitcast [4 x i64]* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 8) to [4 x i64]*)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[SHADOW]], i8* align 8 {{.*}}, i64 32, i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_param_tls to i64), i64 8) to i8*), i8* align 8 {{.*}}, i64 32, i1 false)
|
||||
; CHECK: store {{.*}} 40, {{.*}} @__msan_va_arg_overflow_size_tls
|
||||
|
||||
; Test that MSan doesn't generate code overflowing __msan_va_arg_tls when too many arguments are
|
||||
|
@ -42,10 +42,8 @@ entry:
|
||||
%cmp9 = icmp sgt i32 %n, 0
|
||||
br i1 %cmp9, label %for.body.lr.ph, label %for.end
|
||||
|
||||
; CHECK: [[VA_ARG_TLS:%[_0-9a-z]+]] = bitcast {{.*}} @__msan_va_arg_tls
|
||||
; CHECK: call void @llvm.memcpy.{{.*}} [[SHADOW_COPY:%[_0-9a-z]+]], {{.*}} [[VA_ARG_TLS]]
|
||||
; CHECK-ORIGIN: [[VA_ARG_ORIGIN_TLS:%[_0-9a-z]+]] = bitcast {{.*}} @__msan_va_arg_origin_tls
|
||||
; CHECK-ORIGIN: call void @llvm.memcpy{{.*}} [[ORIGIN_COPY:%[_0-9a-z]+]], {{.*}} [[VA_ARG_ORIGIN_TLS]]
|
||||
; CHECK: call void @llvm.memcpy.{{.*}} [[SHADOW_COPY:%[_0-9a-z]+]], {{.*}} bitcast ({{.*}} @__msan_va_arg_tls to i8*)
|
||||
; CHECK-ORIGIN: call void @llvm.memcpy{{.*}} [[ORIGIN_COPY:%[_0-9a-z]+]], {{.*}} bitcast ({{.*}} @__msan_va_arg_origin_tls to i8*)
|
||||
|
||||
; CHECK: call void @llvm.va_start
|
||||
; CHECK: call void @llvm.memcpy.{{.*}}, {{.*}} [[SHADOW_COPY]], i{{.*}} [[REGSAVE:[0-9]+]]
|
||||
|
@ -9,8 +9,7 @@ target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
%struct.S = type { i64, i64, i64, [8 x i8] }
|
||||
|
||||
; CHECK: [[A:%.*]] = bitcast i64* {{.*}} add {{.*}} ptrtoint {{.*}} @__msan_param_tls {{.*}} i64 8)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[A]], i8* align 8 {{.*}}, i64 32, i1 false)
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 {{.*}} add {{.*}} ptrtoint {{.*}} @__msan_param_tls {{.*}} i64 8) {{.*}}, i8* align 8 {{.*}}, i64 32, i1 false)
|
||||
|
||||
define void @Caller() sanitize_memory {
|
||||
entry:
|
||||
|
@ -929,8 +929,7 @@ entry:
|
||||
; CHECK: store i64 {{.*}}, i64* {{.*}}@__msan_va_arg_tls{{.*}}, i64 32){{.*}}, align 8
|
||||
; third struct through the overflow area byval
|
||||
; CHECK: ptrtoint %struct.StructByVal* {{.*}} to i64
|
||||
; CHECK: bitcast { i32, i32, i32, i32 }* {{.*}}@__msan_va_arg_tls {{.*}}, i64 176
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64{{.*}}@__msan_va_arg_tls {{.*}}, i64 176
|
||||
; CHECK: store i64 16, i64* @__msan_va_arg_overflow_size_tls
|
||||
; CHECK: call void (i32, ...) @VAArgStructFn
|
||||
; CHECK: ret void
|
||||
@ -954,7 +953,7 @@ entry:
|
||||
|
||||
attributes #0 = { "target-features"="+fxsr,+x87,-sse" }
|
||||
|
||||
; CHECK: bitcast { i32, i32, i32, i32 }* {{.*}}@__msan_va_arg_tls {{.*}}, i64 48
|
||||
; CHECK call void @llvm.memcpy.p0i8.p0i8.i64{{.*}}@__msan_va_arg_tls {{.*}}, i64 48
|
||||
|
||||
declare i32 @InnerTailCall(i32 %a)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||
; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
|
||||
|
||||
;
|
||||
; Saturating addition.
|
||||
|
Loading…
x
Reference in New Issue
Block a user