Lines Matching defs:I
99 void visitMemoryReference(Instruction &I, const MemoryLocation &Loc,
102 void visitReturnInst(ReturnInst &I);
103 void visitLoadInst(LoadInst &I);
104 void visitStoreInst(StoreInst &I);
105 void visitXor(BinaryOperator &I);
106 void visitSub(BinaryOperator &I);
107 void visitLShr(BinaryOperator &I);
108 void visitAShr(BinaryOperator &I);
109 void visitShl(BinaryOperator &I);
110 void visitSDiv(BinaryOperator &I);
111 void visitUDiv(BinaryOperator &I);
112 void visitSRem(BinaryOperator &I);
113 void visitURem(BinaryOperator &I);
114 void visitAllocaInst(AllocaInst &I);
115 void visitVAArgInst(VAArgInst &I);
116 void visitIndirectBrInst(IndirectBrInst &I);
117 void visitExtractElementInst(ExtractElementInst &I);
118 void visitInsertElementInst(InsertElementInst &I);
119 void visitUnreachableInst(UnreachableInst &I);
190 void Lint::visitCallBase(CallBase &I) {
191 Value *Callee = I.getCalledOperand();
193 visitMemoryReference(I, MemoryLocation::getAfter(Callee), std::nullopt,
198 Check(I.getCallingConv() == F->getCallingConv(),
200 &I);
203 unsigned NumActualArgs = I.arg_size();
209 &I);
211 Check(FT->getReturnType() == I.getType(),
214 &I);
219 auto AI = I.arg_begin(), AE = I.arg_end();
227 &I);
233 AttributeList PAL = I.getAttributes();
235 for (auto *BI = I.arg_begin(); BI != AE; ++BI, ++ArgNo) {
241 if (Formal->onlyReadsMemory() && I.onlyReadsMemory(ArgNo))
245 if (I.doesNotAccessMemory(ArgNo))
251 "Unusual: noalias argument aliases another argument", &I);
261 visitMemoryReference(I, Loc, DL->getABITypeAlign(Ty), Ty,
268 if (const auto *CI = dyn_cast<CallInst>(&I)) {
272 for (Value *Arg : I.args()) {
281 &I);
286 if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I))
295 MemCpyInst *MCI = cast<MemCpyInst>(&I);
296 visitMemoryReference(I, MemoryLocation::getForDest(MCI),
298 visitMemoryReference(I, MemoryLocation::getForSource(MCI),
312 "Undefined behavior: memcpy source and destination overlap", &I);
316 MemMoveInst *MMI = cast<MemMoveInst>(&I);
317 visitMemoryReference(I, MemoryLocation::getForDest(MMI),
319 visitMemoryReference(I, MemoryLocation::getForSource(MMI),
324 MemSetInst *MSI = cast<MemSetInst>(&I);
325 visitMemoryReference(I, MemoryLocation::getForDest(MSI),
330 MemSetInlineInst *MSII = cast<MemSetInlineInst>(&I);
331 visitMemoryReference(I, MemoryLocation::getForDest(MSII),
338 visitMemoryReference(I, MemoryLocation::getForArgument(&I, 0, TLI),
342 visitMemoryReference(I, MemoryLocation::getForArgument(&I, 0, TLI),
344 visitMemoryReference(I, MemoryLocation::getForArgument(&I, 1, TLI),
348 visitMemoryReference(I, MemoryLocation::getForArgument(&I, 0, TLI),
356 visitMemoryReference(I, MemoryLocation::getForArgument(&I, 0, TLI),
360 if (auto *TripCount = dyn_cast<ConstantInt>(I.getArgOperand(1)))
364 &I);
369 void Lint::visitReturnInst(ReturnInst &I) {
370 Function *F = I.getParent()->getParent();
372 "Unusual: Return statement in function with noreturn attribute", &I);
374 if (Value *V = I.getReturnValue()) {
376 Check(!isa<AllocaInst>(Obj), "Unusual: Returning alloca value", &I);
382 void Lint::visitMemoryReference(Instruction &I, const MemoryLocation &Loc,
392 "Undefined behavior: Null pointer dereference", &I);
394 "Undefined behavior: Undef pointer dereference", &I);
397 "Unusual: All-ones pointer dereference", &I);
400 "Unusual: Address one pointer dereference", &I);
405 &I);
408 "Undefined behavior: Write to text section", &I);
412 &I);
414 "Undefined behavior: Load from block address", &I);
418 "Undefined behavior: Call to block address", &I);
423 "Undefined behavior: Branch to non-blockaddress", &I);
459 "Undefined behavior: Buffer overflow", &I);
467 "Undefined behavior: Memory reference address is misaligned", &I);
471 void Lint::visitLoadInst(LoadInst &I) {
472 visitMemoryReference(I, MemoryLocation::get(&I), I.getAlign(), I.getType(),
476 void Lint::visitStoreInst(StoreInst &I) {
477 visitMemoryReference(I, MemoryLocation::get(&I), I.getAlign(),
478 I.getOperand(0)->getType(), MemRef::Write);
481 void Lint::visitXor(BinaryOperator &I) {
482 Check(!isa<UndefValue>(I.getOperand(0)) || !isa<UndefValue>(I.getOperand(1)),
483 "Undefined result: xor(undef, undef)", &I);
486 void Lint::visitSub(BinaryOperator &I) {
487 Check(!isa<UndefValue>(I.getOperand(0)) || !isa<UndefValue>(I.getOperand(1)),
488 "Undefined result: sub(undef, undef)", &I);
491 void Lint::visitLShr(BinaryOperator &I) {
492 if (ConstantInt *CI = dyn_cast<ConstantInt>(findValue(I.getOperand(1),
494 Check(CI->getValue().ult(cast<IntegerType>(I.getType())->getBitWidth()),
495 "Undefined result: Shift count out of range", &I);
498 void Lint::visitAShr(BinaryOperator &I) {
500 dyn_cast<ConstantInt>(findValue(I.getOperand(1), /*OffsetOk=*/false)))
501 Check(CI->getValue().ult(cast<IntegerType>(I.getType())->getBitWidth()),
502 "Undefined result: Shift count out of range", &I);
505 void Lint::visitShl(BinaryOperator &I) {
507 dyn_cast<ConstantInt>(findValue(I.getOperand(1), /*OffsetOk=*/false)))
508 Check(CI->getValue().ult(cast<IntegerType>(I.getType())->getBitWidth()),
509 "Undefined result: Shift count out of range", &I);
535 for (unsigned I = 0, N = cast<FixedVectorType>(VecTy)->getNumElements();
536 I != N; ++I) {
537 Constant *Elem = C->getAggregateElement(I);
549 void Lint::visitSDiv(BinaryOperator &I) {
550 Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
551 "Undefined behavior: Division by zero", &I);
554 void Lint::visitUDiv(BinaryOperator &I) {
555 Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
556 "Undefined behavior: Division by zero", &I);
559 void Lint::visitSRem(BinaryOperator &I) {
560 Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
561 "Undefined behavior: Division by zero", &I);
564 void Lint::visitURem(BinaryOperator &I) {
565 Check(!isZero(I.getOperand(1), I.getDataLayout(), DT, AC),
566 "Undefined behavior: Division by zero", &I);
569 void Lint::visitAllocaInst(AllocaInst &I) {
570 if (isa<ConstantInt>(I.getArraySize()))
572 Check(&I.getParent()->getParent()->getEntryBlock() == I.getParent(),
573 "Pessimization: Static alloca outside of entry block", &I);
578 void Lint::visitVAArgInst(VAArgInst &I) {
579 visitMemoryReference(I, MemoryLocation::get(&I), std::nullopt, nullptr,
583 void Lint::visitIndirectBrInst(IndirectBrInst &I) {
584 visitMemoryReference(I, MemoryLocation::getAfter(I.getAddress()),
587 Check(I.getNumDestinations() != 0,
588 "Undefined behavior: indirectbr with no destinations", &I);
591 void Lint::visitExtractElementInst(ExtractElementInst &I) {
592 if (ConstantInt *CI = dyn_cast<ConstantInt>(findValue(I.getIndexOperand(),
596 cast<FixedVectorType>(I.getVectorOperandType())->getNumElements()),
597 "Undefined result: extractelement index out of range", &I);
600 void Lint::visitInsertElementInst(InsertElementInst &I) {
601 if (ConstantInt *CI = dyn_cast<ConstantInt>(findValue(I.getOperand(2),
604 cast<FixedVectorType>(I.getType())->getNumElements()),
605 "Undefined result: insertelement index out of range", &I);
608 void Lint::visitUnreachableInst(UnreachableInst &I) {
610 Check(&I == &I.getParent()->front() ||
611 std::prev(I.getIterator())->mayHaveSideEffects(),
614 &I);