[llvm-commits] PATCH: cleanup the GetFirstDebugLocInBasicBlock utility

Rotem, Nadav nadav.rotem at intel.com
Sun Jun 24 23:50:16 PDT 2012


LGTM. 

From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Bendersky, Eli
Sent: Sunday, June 24, 2012 13:21
To: llvm-commits at cs.uiuc.edu
Subject: [llvm-commits] PATCH: cleanup the GetFirstDebugLocInBasicBlock utility

The GetFirstDebugLocInBasicBlock function in lib/Transforms/Utils/BasicBlockUtils.cpp looks like this:

/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a 
/// given basic block.
DebugLoc llvm::GetFirstDebugLocInBasicBlock(const BasicBlock *BB) {
  if (const Instruction *I = BB->getFirstNonPHI())
    return I->getDebugLoc();
  // Scanning entire block may be too expensive, if the first instruction
  // does not have valid location info.
  return DebugLoc();
}

As you can see, neither the name of the function, nor the comment describing it correctly reflect what the function is doing. It does not, in fact, return the first debug loc in the block, doing it only if the first (non-PHI) instruction has debug loc. Otherwise it returns an empty debug loc. This change was made as an optimization (originally the function did act according to its spec), and the name was not updated.

Since this function is only used in a single place in the code-base (SSAUpdater), the attached patch proposes to just remove it, folding its short implementation into the calling site. Thus the confusion will be avoided.

Eli


---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the llvm-commits mailing list