Skip to content

Commit

Permalink
Do not do checking for returning undef value
Browse files Browse the repository at this point in the history
Upstream does not like to check undef value and clang-format will
fail due to this. Let us remove checking for returning undef value.
A related test is also removed.
  • Loading branch information
Yonghong Song committed Feb 21, 2025
1 parent 7998775 commit a5811fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
24 changes: 2 additions & 22 deletions llvm/lib/Target/BPF/BPFCheckUndefIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
//
// Check 'undef' and 'unreachable' IRs and issue proper warnings.
// Check 'unreachable' IRs and issue proper warnings.
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -34,7 +34,6 @@ class BPFCheckUndefIR final : public ModulePass {
private:
void BPFCheckUndefIRImpl(Function &F);
void BPFCheckInst(Function &F, BasicBlock &BB, Instruction &I);
void HandleReturnInsn(Function &F, ReturnInst *I);
void HandleUnreachableInsn(Function &F, BasicBlock &BB, Instruction &I);
};
} // End anonymous namespace
Expand All @@ -45,17 +44,6 @@ INITIALIZE_PASS(BPFCheckUndefIR, DEBUG_TYPE, "BPF Check Undef IRs", false,

ModulePass *llvm::createBPFCheckUndefIR() { return new BPFCheckUndefIR(); }

void BPFCheckUndefIR::HandleReturnInsn(Function &F, ReturnInst *I) {
Value *RetValue = I->getReturnValue();
// PoisonValue is a special UndefValue where compiler intentionally to
// poisons a value since it shouldn't be used.
if (!RetValue || isa<PoisonValue>(RetValue) || !isa<UndefValue>(RetValue))
return;

dbgs() << "WARNING: return undefined value in func " << F.getName()
<< ", due to uninitialized variable?\n";
}

void BPFCheckUndefIR::HandleUnreachableInsn(Function &F, BasicBlock &BB,
Instruction &I) {
// LLVM may create a switch statement with default to a 'unreachable' basic
Expand Down Expand Up @@ -87,16 +75,8 @@ void BPFCheckUndefIR::HandleUnreachableInsn(Function &F, BasicBlock &BB,

void BPFCheckUndefIR::BPFCheckInst(Function &F, BasicBlock &BB,
Instruction &I) {
switch (I.getOpcode()) {
case Instruction::Ret:
HandleReturnInsn(F, cast<ReturnInst>(&I));
break;
case Instruction::Unreachable:
if (I.getOpcode() == Instruction::Unreachable)
HandleUnreachableInsn(F, BB, I);
break;
default:
break;
}
}

void BPFCheckUndefIR::BPFCheckUndefIRImpl(Function &F) {
Expand Down
14 changes: 0 additions & 14 deletions llvm/test/CodeGen/BPF/undef-sroa.ll

This file was deleted.

0 comments on commit a5811fb

Please sign in to comment.