[llvm-commits] [llvm] r65123 - /llvm/trunk/lib/Transforms/Utils/Mem2Reg.cpp
Chris Lattner
clattner at apple.com
Fri Feb 20 09:36:06 PST 2009
On Feb 20, 2009, at 8:31 AM, Zhou Sheng wrote:
> Author: sheng
> Date: Fri Feb 20 10:31:35 2009
> New Revision: 65123
>
> URL: http://llvm.org/viewvc/llvm-project?rev=65123&view=rev
> Log:
> patch to update the line number information in pass -mem2reg.
> Currently this pass will delete the variable declaration info,
> and keep the line number info. But the kept line number info is not
> updated,
> and some is redundant or not correct, this patch just updates those
> info.
Hi Sheng,
High level question: why do you want mem2reg to do this? Doesn't
instcombine already do it? If not, it should.
> +/// Remove the invalid or redundant debug information.
> +static void CleanDbgInfo(Function& F) {
> + std::vector<Instruction*> DeadDbgs;
> + for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI !=
> BBE; ++BBI) {
> + if (BBI->size() <= 1)
> + continue;
size() is O(n), please don't call it here.
>
> + for (BasicBlock::iterator I = BBI->begin(), E = BBI-
> >getTerminator();
> + I != E; ++I) {
> + BasicBlock::iterator NextI = I;
> + ++NextI;
> + if (isa<DbgStopPointInst>(I) && isa<DbgStopPointInst>(NextI))
> + DeadDbgs.push_back(I);
You don't need the temporary vector, just preincrement the iterator.
>
> + else if (isa<DbgStopPointInst>(I) && isa<BranchInst>(NextI))
> + DeadDbgs.push_back(I);
> + }
Deleting stoppoints before branches isn't correct. You can have
control flow within a line (e.g. ?: expressions) and the intermediate
blocks need to get that stoppoint.
-Chris
More information about the llvm-commits
mailing list