GBE/PRINTF: store variable instead of pointer in PrintfSlot.

Submitted by Luo, Xionghu on Aug. 7, 2015, 7:38 a.m.

Details

Message ID 1438933133-12302-1-git-send-email-xionghu.luo@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Luo, Xionghu Aug. 7, 2015, 7:38 a.m.
From: Luo Xionghu <xionghu.luo@intel.com>

this could fix the bug: https://bugs.freedesktop.org/show_bug.cgi?id=90472

Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
---
 backend/src/ir/printf.cpp               |  4 ++--
 backend/src/ir/printf.hpp               | 12 ++++++------
 backend/src/llvm/llvm_printf_parser.cpp |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/backend/src/ir/printf.cpp b/backend/src/ir/printf.cpp
index 3d9b2fd..dffa4b0 100644
--- a/backend/src/ir/printf.cpp
+++ b/backend/src/ir/printf.cpp
@@ -40,12 +40,12 @@  namespace gbe
         if (f->type == PRINTF_SLOT_TYPE_STRING)
           continue;
 
-        slots.push_back(&(*f));
+        slots.push_back(*f);
       }
 
       /* Update the total size of size. */
       if (slots.size() > 0)
-        sizeOfSize = slots.back()->state->out_buf_sizeof_offset
+        sizeOfSize = slots.back().state->out_buf_sizeof_offset
                      + getPrintfBufferElementSize(slots.size() - 1);
 
       return (uint32_t)fmts.size();
diff --git a/backend/src/ir/printf.hpp b/backend/src/ir/printf.hpp
index cbab759..fad09b1 100644
--- a/backend/src/ir/printf.hpp
+++ b/backend/src/ir/printf.hpp
@@ -177,7 +177,7 @@  namespace gbe
         }
 
         for (size_t i = 0; i < other.slots.size(); ++i) {
-          PrintfSlot* s = other.slots[i];
+          PrintfSlot s = other.slots[i];
           slots.push_back(s);
         }
 
@@ -215,15 +215,15 @@  namespace gbe
       uint8_t getIndexBufBTI() const { return btiIndexBuf; }
 
       uint32_t getPrintfBufferElementSize(uint32_t i) {
-        PrintfSlot* slot = slots[i];
+        PrintfSlot& slot = slots[i];
         int vec_num = 1;
-        if (slot->state->vector_n > 0) {
-          vec_num = slot->state->vector_n;
+        if (slot.state->vector_n > 0) {
+          vec_num = slot.state->vector_n;
         }
 
         assert(vec_num > 0 && vec_num <= 16);
 
-        switch (slot->state->conversion_specifier) {
+        switch (slot.state->conversion_specifier) {
           case PRINTF_CONVERSION_I:
           case PRINTF_CONVERSION_D:
           case PRINTF_CONVERSION_O:
@@ -257,7 +257,7 @@  namespace gbe
 
     private:
       vector<PrintfFmt> fmts;
-      vector<PrintfSlot*> slots;
+      vector<PrintfSlot> slots;
       uint32_t sizeOfSize; // Total sizeof size.
       friend struct LockOutput;
       uint8_t btiBuf;
diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp
index 2f85443..3d84457 100644
--- a/backend/src/llvm/llvm_printf_parser.cpp
+++ b/backend/src/llvm/llvm_printf_parser.cpp
@@ -291,7 +291,7 @@  again:
 #if 0
     {
       int j = 0;
-      for (auto &s : *printf_fmt) {
+      for (auto &s : printf_fmt->first) {
         j++;
         if (s.type == PRINTF_SLOT_TYPE_STATE) {
           fprintf(stderr, "---- %d ---: state : \n", j);