<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 2/24/11 11:27 AM, Arushi Aggarwal wrote:
<blockquote
cite="mid:AANLkTi=zaTr9JmGtrv_qD66RuSRrwJwdCdug=MC87zXE@mail.gmail.com"
type="cite">Thanks John. You are right.<br>
<br>
Is this also true for constant GEP expressions? Do they also
create a pointer to the calculated type? The language manual does
not state so explicitly.<br>
</blockquote>
<br>
I would think so.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:AANLkTi=zaTr9JmGtrv_qD66RuSRrwJwdCdug=MC87zXE@mail.gmail.com"
type="cite"><br>
Arushi<br>
<br>
<div class="gmail_quote">
On Thu, Feb 24, 2011 at 10:47 AM, John Criswell <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div class="im">On 2/24/11 10:39 AM, Arushi Aggarwal wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
Given 2 GEPs as follows,<br>
<br>
%tmp124 = getelementptr inbounds %struct.termbox*
%termptr.1, i32 0, i32 5, !dbg !1051 ; <[2 x i16]*>
[#uses=1]<br>
%tmp125 = getelementptr inbounds [2 x i16]* %tmp124, i64
0, i64 0, !dbg !1051 ; <i16*> [#uses=1]<br>
<br>
can I replace the 2nd one with<br>
<br>
%tmp126 = getelementptr inbounds %struct.termbox*
%termptr.1, i32 0, i32 5, i64 0, i64 0 ; <i16*><br>
</blockquote>
<br>
</div>
You should double-check the LangRef manual, but I think the
problem stems from the fact that a GEP returns a pointer to
the type found after all indexing is completed.<br>
<br>
So, in %tmp124, indexing %termptr.1 by i32 0 and i32 5 yields
a [2xi16] type, and then the result of the GEP is a pointer to
that, which is of type [2xi16] *.<br>
<br>
In the new GEP you've created, I think you can remove the
first i64 0 index because the result of indexing i32 0 and i32
5 is a [2 x i16] and not a [2 x i16] *.<br>
<br>
-- John T.
<div>
<div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<br>
When I try to create this instruction i get the
follwoing error,<br>
<br>
opt:
/home/vadve/aggarwa4/llvm27/llvm-2.7/include/llvm/Instructions.h:276:
const llvm::Type* llvm::checkType(const llvm::Type*):
Assertion `Ty && "Invalid GetElementPtrInst
indices for type!"' failed.<br>
<br>
Thanks!<br>
Arushi<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>