mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Teach computeKnownBits to use new align attribute/metadata
Reviewed By: reames Differential Revision: http://reviews.llvm.org/D13470 llvm-svn: 249557
This commit is contained in:
parent
18e0c425d4
commit
8b3cc14fdc
@ -1415,7 +1415,7 @@ static void computeKnownBitsFromOperator(Operator *I, APInt &KnownZero,
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned getAlignment(Value *V, const DataLayout &DL) {
|
||||
static unsigned getAlignment(const Value *V, const DataLayout &DL) {
|
||||
unsigned Align = 0;
|
||||
if (auto *GO = dyn_cast<GlobalObject>(V)) {
|
||||
Align = GO->getAlignment();
|
||||
@ -1433,7 +1433,7 @@ static unsigned getAlignment(Value *V, const DataLayout &DL) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Argument *A = dyn_cast<Argument>(V)) {
|
||||
} else if (const Argument *A = dyn_cast<Argument>(V)) {
|
||||
Align = A->getType()->isPointerTy() ? A->getParamAlignment() : 0;
|
||||
|
||||
if (!Align && A->hasStructRetAttr()) {
|
||||
@ -1442,7 +1442,16 @@ static unsigned getAlignment(Value *V, const DataLayout &DL) {
|
||||
if (EltTy->isSized())
|
||||
Align = DL.getABITypeAlignment(EltTy);
|
||||
}
|
||||
}
|
||||
} else if (const AllocaInst *AI = dyn_cast<AllocaInst>(V))
|
||||
Align = AI->getAlignment();
|
||||
else if (auto CS = ImmutableCallSite(V))
|
||||
Align = CS.getAttributes().getParamAlignment(AttributeSet::ReturnIndex);
|
||||
else if (const LoadInst *LI = dyn_cast<LoadInst>(V))
|
||||
if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
|
||||
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
|
||||
Align = CI->getLimitedValue();
|
||||
}
|
||||
|
||||
return Align;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,32 @@ for.end: ; preds = %for.body
|
||||
ret void
|
||||
}
|
||||
|
||||
declare align 8 i8* @get()
|
||||
|
||||
; Check that redundant align assume is removed
|
||||
; CHECK-LABEL: @test
|
||||
; CHECK-NOT: call void @llvm.assume
|
||||
define void @test1() {
|
||||
%p = call align 8 i8* @get()
|
||||
%ptrint = ptrtoint i8* %p to i64
|
||||
%maskedptr = and i64 %ptrint, 7
|
||||
%maskcond = icmp eq i64 %maskedptr, 0
|
||||
call void @llvm.assume(i1 %maskcond)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Check that redundant align assume is removed
|
||||
; CHECK-LABEL: @test
|
||||
; CHECK-NOT: call void @llvm.assume
|
||||
define void @test3() {
|
||||
%p = alloca i8, align 8
|
||||
%ptrint = ptrtoint i8* %p to i64
|
||||
%maskedptr = and i64 %ptrint, 7
|
||||
%maskcond = icmp eq i64 %maskedptr, 0
|
||||
call void @llvm.assume(i1 %maskcond)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @llvm.assume(i1) #1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user