[LLVMdev] Loop unroll : approximate loop size for loops with debug info?

Chris Lattner sabre at nondot.org
Thu Nov 18 21:23:43 PST 2004


On Thu, 18 Nov 2004, Michael McCracken wrote:

> Hi, just a quick question about the intent of the
> ApproximateLoopSize() function in LoopUnroll.cpp:
>
> If a loop contains debug stoppoint intrinsics, does it make sense to count them?
> My understanding is that they are removed when not running under
> llvm-db anyway, so we probably shouldn't make size judgements based on
> them. Is that right, or am I missing something?
>
> Anyway, if I'm right, here's a patch that ignores them.

That sounds like a good idea, but just doing it just for stoppoints
doesn't, as you mentioned.  Would you be willing to make a DebugInfoInst
parent class of DbgStopPointInst in IntrinsicInst.h, and check for that
instead?  DebugInfoInst should match all of the debugger intrinsics, as
they can all be ignored.

There are probably other places that should be updated as well, tail
duplication comes to mind (it estimates tail size to control duplication),
but these can be done on demand.

-Chris

> Index: lib/Transforms/Scalar/LoopUnroll.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/LoopUnroll.cpp,v
> retrieving revision 1.13
> diff -u -r1.13 LoopUnroll.cpp
> --- lib/Transforms/Scalar/LoopUnroll.cpp        18 Oct 2004 14:38:48
> -0000      1.13
> +++ lib/Transforms/Scalar/LoopUnroll.cpp        19 Nov 2004 04:17:08 -0000
> @@ -28,6 +28,7 @@
>  #include "llvm/Support/Debug.h"
>  #include "llvm/ADT/Statistic.h"
>  #include "llvm/ADT/STLExtras.h"
> +#include "llvm/IntrinsicInst.h"
>  #include <cstdio>
>  #include <set>
>  #include <algorithm>
> @@ -86,6 +87,11 @@
>          // Ignore PHI nodes in the header.
>        } else if (I->hasOneUse() && I->use_back() == Term) {
>          // Ignore instructions only used by the loop terminator.
> +      } else if (DbgStopPointInst *SPI = dyn_cast<DbgStopPointInst>(I)) {
> +        // Ignore debug stop point instructions.
> +
> +       // TODO: Ignore other debug instructions once they are defined
> +       // in IntrinsicInst.h
>        } else {
>          ++Size;
>        }
>
>
>

-Chris

-- 
http://llvm.org/
http://nondot.org/sabre/




More information about the llvm-dev mailing list