Change the order of the code
authorxiuli pan <xiuli.pan@intel.com>
Fri, 21 Feb 2014 08:25:20 +0000 (16:25 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Fri, 21 Feb 2014 08:31:15 +0000 (16:31 +0800)
Fix the 66K problem in the OpenCV testing.
The bug was casued by the incorrect order
of the code, it will result the beignet to
calculate the whole localsize of the kernel
file. Now the OpenCV test can pass.

Reviewed-by: Zhigang Gong <zhigang.gong@intel.com>
backend/src/llvm/llvm_gen_backend.cpp

index 2d4fb0a..fce328e 100644 (file)
@@ -1394,15 +1394,6 @@ namespace gbe
 
       ir::AddressSpace addrSpace = addressSpaceLLVMToGen(v.getType()->getAddressSpace());
       if(addrSpace == ir::MEM_LOCAL) {
-        ir::Function &f = ctx.getFunction();
-        f.setUseSLM(true);
-        const Constant *c = v.getInitializer();
-        Type *ty = c->getType();
-        uint32_t oldSlm = f.getSLMSize();
-        uint32_t align = 8 * getAlignmentByte(unit, ty);
-        uint32_t padding = getPadding(oldSlm*8, align);
-
-        f.setSLMSize(oldSlm + padding/8 + getTypeByteSize(unit, ty));
         const Value * val = cast<Value>(&v);
         // local variable can only be used in one kernel function. so, don't need to check its all uses.
         // loop through the Constant to find the instruction that use the global variable
@@ -1420,6 +1411,16 @@ namespace gbe
         const Function * func = bb->getParent();
         if(func != &F) continue;
 
+        ir::Function &f = ctx.getFunction();
+        f.setUseSLM(true);
+        const Constant *c = v.getInitializer();
+        Type *ty = c->getType();
+        uint32_t oldSlm = f.getSLMSize();
+        uint32_t align = 8 * getAlignmentByte(unit, ty);
+        uint32_t padding = getPadding(oldSlm*8, align);
+
+        f.setSLMSize(oldSlm + padding/8 + getTypeByteSize(unit, ty));
+
         this->newRegister(const_cast<GlobalVariable*>(&v));
         ir::Register reg = regTranslator.getScalar(const_cast<GlobalVariable*>(&v), 0);
         ctx.LOADI(ir::TYPE_S32, reg, ctx.newIntegerImmediate(oldSlm + padding/8, ir::TYPE_S32));