}
}
+static Optional<StringRef> nameOrNone(const Value *V) {
+ if (V->hasName())
+ return V->getName();
+ return None;
+}
+
void MemoryOpRemark::visitVariable(const Value *V,
SmallVectorImpl<VariableInfo> &Result) {
+ if (auto *GV = dyn_cast<GlobalVariable>(V)) {
+ auto *Ty = cast<PointerType>(GV->getType())->getElementType();
+ int64_t Size = DL.getTypeSizeInBits(Ty).getFixedSize();
+ VariableInfo Var{nameOrNone(GV), Size};
+ if (!Var.isEmpty())
+ Result.push_back(std::move(Var));
+ return;
+ }
+
// If we find some information in the debug info, take that.
bool FoundDI = false;
// Try to get an llvm.dbg.declare, which has a DILocalVariable giving us the
return;
// If not, get it from the alloca.
- Optional<StringRef> Name = AI->hasName() ? Optional<StringRef>(AI->getName())
- : Optional<StringRef>(None);
Optional<TypeSize> TySize = AI->getAllocationSizeInBits(DL);
Optional<uint64_t> Size =
TySize ? getSizeInBytes(TySize->getFixedSize()) : None;
- VariableInfo Var{Name, Size};
+ VariableInfo Var{nameOrNone(AI), Size};
if (!Var.isEmpty())
Result.push_back(std::move(Var));
}
ret void
}
+@dropbear = external unnamed_addr constant [3 x i8], align 1
+@koala = external unnamed_addr constant [7 x i8], align 1
+
+define void @slicePun() {
+bb:
+; GISEL: remark: <unknown>:0:0: Call to memcpy. Memory operation size: 24 bytes.{{$}}
+; GISEL-NEXT: Read Variables: koala (56 bytes).
+; GISEL-NEXT: Written Variables: dropbear (24 bytes).
+ tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 getelementptr inbounds ([3 x i8], [3 x i8]* @dropbear, i64 0, i64 0),
+ i8* getelementptr inbounds ([7 x i8], [7 x i8]* @koala, i64 0, i64 0), i64 24, i1 false)
+ ret void
+}
+
attributes #0 = { noinline nounwind ssp uwtable "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-a7" "target-features"="+aes,+crypto,+fp-armv8,+neon,+sha2,+zcm,+zcz" }
attributes #1 = { nounwind "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-a7" "target-features"="+aes,+crypto,+fp-armv8,+neon,+sha2,+zcm,+zcz" }
attributes #2 = { nofree nosync nounwind readnone speculatable willreturn }