66//
77// ===----------------------------------------------------------------------===//
88//
9- // Check 'undef' and ' unreachable' IRs and issue proper warnings.
9+ // Check 'unreachable' IRs and issue proper warnings.
1010//
1111// ===----------------------------------------------------------------------===//
1212
@@ -34,7 +34,6 @@ class BPFCheckUndefIR final : public ModulePass {
3434private:
3535 void BPFCheckUndefIRImpl (Function &F);
3636 void BPFCheckInst (Function &F, BasicBlock &BB, Instruction &I);
37- void HandleReturnInsn (Function &F, ReturnInst *I);
3837 void HandleUnreachableInsn (Function &F, BasicBlock &BB, Instruction &I);
3938};
4039} // End anonymous namespace
@@ -45,17 +44,6 @@ INITIALIZE_PASS(BPFCheckUndefIR, DEBUG_TYPE, "BPF Check Undef IRs", false,
4544
4645ModulePass *llvm::createBPFCheckUndefIR() { return new BPFCheckUndefIR (); }
4746
48- void BPFCheckUndefIR::HandleReturnInsn (Function &F, ReturnInst *I) {
49- Value *RetValue = I->getReturnValue ();
50- // PoisonValue is a special UndefValue where compiler intentionally to
51- // poisons a value since it shouldn't be used.
52- if (!RetValue || isa<PoisonValue>(RetValue) || !isa<UndefValue>(RetValue))
53- return ;
54-
55- dbgs () << " WARNING: return undefined value in func " << F.getName ()
56- << " , due to uninitialized variable?\n " ;
57- }
58-
5947void BPFCheckUndefIR::HandleUnreachableInsn (Function &F, BasicBlock &BB,
6048 Instruction &I) {
6149 // LLVM may create a switch statement with default to a 'unreachable' basic
@@ -87,16 +75,8 @@ void BPFCheckUndefIR::HandleUnreachableInsn(Function &F, BasicBlock &BB,
8775
8876void BPFCheckUndefIR::BPFCheckInst (Function &F, BasicBlock &BB,
8977 Instruction &I) {
90- switch (I.getOpcode ()) {
91- case Instruction::Ret:
92- HandleReturnInsn (F, cast<ReturnInst>(&I));
93- break ;
94- case Instruction::Unreachable:
78+ if (I.getOpcode () == Instruction::Unreachable)
9579 HandleUnreachableInsn (F, BB, I);
96- break ;
97- default :
98- break ;
99- }
10080}
10181
10282void BPFCheckUndefIR::BPFCheckUndefIRImpl (Function &F) {
0 commit comments