diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-05-31 14:09:34 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-05-31 14:09:34 -0700 |
commit | f2fc125f21dc8181d452a1160796a460b990497b (patch) | |
tree | c396589601a899885cb95037e90ecb3f94443958 /lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp | |
parent | b74fb76de6dba430089e94fd5e8d0fa856cda3cc (diff) |
PNaCl: FlattenGlobals: Use ptrtoint+add instead of getelementptr+bitcast
The constructor for getelementptr ConstantExprs does some constant
folding which can add 1 or 2 more indexes to the getelementptr. This
complicates checking for FlattenGlobals' normal form in the PNaCl ABI
checker.
Worse, the GCC torture tests turned up a pathological case where this
constant folding adds 4 indexes to the getelementptr and leaves the
original struct type behind:
@q = global i8* getelementptr inbounds (
%union.u* bitcast ([260 x i8]* @v to %union.u*),
i32 0, i32 0, i32 0, i32 0, i32 4)
That comes from the following code in
gcc/testsuite/gcc.c-torture/execute/pr43784.c:
struct s {
unsigned char a[256];
};
union u {
struct { struct s b; int c; } d;
struct { int c; struct s b; } e;
};
static union u v;
static struct s *q = &v.e.b;
We can fix this by using ptrtoint+add instead of
getelementptr+bitcast, because ConstantExpr won't automatically
convert ptrtoint to something else.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3113
TEST=*.ll tests + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/15647009
Diffstat (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp')
0 files changed, 0 insertions, 0 deletions