forked from OSchip/llvm-project
Analysis: only query size of sized objects.
Recently we started looking into sret parameters, though the issue could crop up elsewhere. If the pointee type is opaque, we should not try to compute its size because that leads to an assertion failure.
This commit is contained in:
parent
af5be38a01
commit
630d264798
|
@ -678,7 +678,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitAllocaInst(AllocaInst &I) {
|
|||
SizeOffsetType ObjectSizeOffsetVisitor::visitArgument(Argument &A) {
|
||||
Type *MemoryTy = A.getPointeeInMemoryValueType();
|
||||
// No interprocedural analysis is done at the moment.
|
||||
if (!MemoryTy) {
|
||||
if (!MemoryTy|| !MemoryTy->isSized()) {
|
||||
++ObjectVisitorArgument;
|
||||
return unknown();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
; RUN: opt -instcombine -S %s | FileCheck %s
|
||||
%opaque = type opaque
|
||||
|
||||
; CHECK: call i64 @llvm.objectsize.i64
|
||||
define void @foo(%opaque* sret %in, i64* %sizeptr) {
|
||||
%ptr = bitcast %opaque* %in to i8*
|
||||
%size = call i64 @llvm.objectsize.i64(i8* %ptr, i1 0, i1 0, i1 0)
|
||||
store i64 %size, i64* %sizeptr
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i64 @llvm.objectsize.i64(i8*, i1, i1, i1)
|
Loading…
Reference in New Issue