[test-suite] r176561 - Bound the recursion to avoid stack overflow on unoptimized builds.
Chad Rosier
mcrosier at apple.com
Wed Mar 6 09:39:28 PST 2013
Author: mcrosier
Date: Wed Mar 6 11:39:28 2013
New Revision: 176561
URL: http://llvm.org/viewvc/llvm-project?rev=176561&view=rev
Log:
Bound the recursion to avoid stack overflow on unoptimized builds.
Modified:
test-suite/trunk/SingleSource/Benchmarks/SmallPT/smallpt.cpp
Modified: test-suite/trunk/SingleSource/Benchmarks/SmallPT/smallpt.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/SmallPT/smallpt.cpp?rev=176561&r1=176560&r2=176561&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/SmallPT/smallpt.cpp (original)
+++ test-suite/trunk/SingleSource/Benchmarks/SmallPT/smallpt.cpp Wed Mar 6 11:39:28 2013
@@ -53,6 +53,7 @@ Vec radiance(const Ray &r, int depth, un
Vec x=r.o+r.d*t, n=(x-obj.p).norm(), nl=n.dot(r.d)<0?n:n*-1, f=obj.c;
double p = f.x>f.y && f.x>f.z ? f.x : f.y>f.z ? f.y : f.z; // max refl
if (++depth>5) if (erand48(Xi)<p) f=f*(1/p); else return obj.e; //R.R.
+ if (depth>128) return obj.e; //Bound to avoid stack overflow at -O0.
if (obj.refl == DIFF){ // Ideal DIFFUSE reflection
double r1=2*M_PI*erand48(Xi), r2=erand48(Xi), r2s=sqrt(r2);
Vec w=nl, u=((fabs(w.x)>.1?Vec(0,1):Vec(1))%w).norm(), v=w%u;
More information about the llvm-commits
mailing list