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

Michael McCracken michael.mccracken at gmail.com
Thu Nov 18 20:26:19 PST 2004


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.

-mike

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;
       }


-- 
Michael McCracken
UCSD CSE PhD Student
San Diego Supercomputer Center
http://www.cse.ucsd.edu/~mmccrack/




More information about the llvm-dev mailing list