[Beignet] [PATCH] [PATCH]Fix compile errors for CLANG compiler
Song, Ruiling
ruiling.song at intel.com
Thu Aug 7 18:29:01 PDT 2014
No, std::vector implementation must make sure its elements stored in contiguous memory.
Seems c++98 standard missed this, but in c++03 standard, it's already clearly stated. There are many posts on stackoverflow.com talking about this.
Nanhai's suggestion is good. Although we immediately assign value to those GenRegister,
It is still good to make GenRegister initialized.
Thanks!
Ruiling
-----Original Message-----
From: Lv, Meng
Sent: Friday, August 08, 2014 8:58 AM
To: Zou, Nanhai; Song, Ruiling; beignet at lists.freedesktop.org
Subject: RE: [Beignet] [PATCH] [PATCH]Fix compile errors for CLANG compiler
HI, the vector would also have problem, in the following function "sel.READ64(tmpAddr, dst, valueNum, bti.bti[0]);", we need pass down the data pointer "dst" to READ64 function. The data in vector may not be continuous.
,
-----Original Message-----
From: Zou, Nanhai
Sent: Thursday, August 07, 2014 3:59 PM
To: Zou, Nanhai; Song, Ruiling; Lv, Meng; beignet at lists.freedesktop.org
Cc: Lv, Meng
Subject: RE: [Beignet] [PATCH] [PATCH]Fix compile errors for CLANG compiler
The previous patch was wrong.
With static_cast, constructor of each elements in dst was bypassed.
This will leave random initial value in GenRegister.
So please use std::vector
Thanks
Zou Nanhai
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zou, Nanhai
Sent: Thursday, August 07, 2014 3:40 PM
To: Song, Ruiling; Lv, Meng; beignet at lists.freedesktop.org
Cc: Lv, Meng
Subject: Re: [Beignet] [PATCH] [PATCH]Fix compile errors for CLANG compiler
Replace those with something like
vector<GenRegister> dst[valueNum];
would be better.
Thanks
Zou Nanhai
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Song, Ruiling
Sent: Thursday, August 07, 2014 3:30 PM
To: Lv, Meng; beignet at lists.freedesktop.org
Cc: Lv, Meng
Subject: Re: [Beignet] [PATCH] [PATCH]Fix compile errors for CLANG compiler
The patch LGTM.
Ruiling
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Lv Meng
Sent: Wednesday, August 06, 2014 10:31 AM
To: beignet at lists.freedesktop.org
Cc: Lv, Meng
Subject: [Beignet] [PATCH] [PATCH]Fix compile errors for CLANG compiler
this patch would fix variable length array of non-POD element type error for CLANG compiler.
Signed-off-by: Lv Meng <meng.lv at intel.com>
---
backend/src/backend/gen_insn_selection.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 090f897..39f5141 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2799,7 +2799,7 @@ namespace gbe
/* XXX support scalar only right now. */
GBE_ASSERT(valueNum == 1);
GBE_ASSERT(bti.count == 1);
- GenRegister dst[valueNum];
+ GenRegister *dst = static_cast<GenRegister
+ *>(alloca(sizeof(GenRegister) * valueNum));
GenRegister tmpAddr = getRelativeAddress(sel, addr, insn.getAddressSpace(), bti.bti[0]);
for ( uint32_t dstID = 0; dstID < valueNum; ++dstID)
dst[dstID] = sel.selReg(insn.getValue(dstID), ir::TYPE_U64); @@ -2999,7 +2999,7 @@ namespace gbe
/* XXX support scalar only right now. */
GBE_ASSERT(valueNum == 1);
addr = GenRegister::retype(addr, GEN_TYPE_UD);
- GenRegister src[valueNum];
+ GenRegister *src = static_cast<GenRegister
+ *>(alloca(sizeof(GenRegister) * valueNum));
for (uint32_t valueID = 0; valueID < valueNum; ++valueID)
src[valueID] = sel.selReg(insn.getValue(valueID), ir::TYPE_U64); @@ -3710,11 +3710,10 @@ namespace gbe
{
using namespace ir;
GenRegister msgPayloads[4];
- GenRegister dst[insn.getDstNum()];
uint32_t srcNum = insn.getSrcNum();
uint32_t valueID = 0;
uint32_t msgLen = 0;
-
+ GenRegister *dst = static_cast<GenRegister
+ *>(alloca(sizeof(GenRegister) * insn.getDstNum()));
for (valueID = 0; valueID < insn.getDstNum(); ++valueID)
dst[valueID] = sel.selReg(insn.getDst(valueID), insn.getDstType());
--
1.8.3.2
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list