6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
//
9
- // Check 'undef' and ' unreachable' IRs and issue proper warnings.
9
+ // Check 'unreachable' IRs and issue proper warnings.
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
@@ -34,7 +34,6 @@ class BPFCheckUndefIR final : public ModulePass {
34
34
private:
35
35
void BPFCheckUndefIRImpl (Function &F);
36
36
void BPFCheckInst (Function &F, BasicBlock &BB, Instruction &I);
37
- void HandleReturnInsn (Function &F, ReturnInst *I);
38
37
void HandleUnreachableInsn (Function &F, BasicBlock &BB, Instruction &I);
39
38
};
40
39
} // End anonymous namespace
@@ -45,17 +44,6 @@ INITIALIZE_PASS(BPFCheckUndefIR, DEBUG_TYPE, "BPF Check Undef IRs", false,
45
44
46
45
ModulePass *llvm::createBPFCheckUndefIR() { return new BPFCheckUndefIR (); }
47
46
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
-
59
47
void BPFCheckUndefIR::HandleUnreachableInsn (Function &F, BasicBlock &BB,
60
48
Instruction &I) {
61
49
// LLVM may create a switch statement with default to a 'unreachable' basic
@@ -87,16 +75,8 @@ void BPFCheckUndefIR::HandleUnreachableInsn(Function &F, BasicBlock &BB,
87
75
88
76
void BPFCheckUndefIR::BPFCheckInst (Function &F, BasicBlock &BB,
89
77
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)
95
79
HandleUnreachableInsn (F, BB, I);
96
- break ;
97
- default :
98
- break ;
99
- }
100
80
}
101
81
102
82
void BPFCheckUndefIR::BPFCheckUndefIRImpl (Function &F) {
0 commit comments