[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] MS style ASM failure and crash
From:       JB Feldman <jb.feldman () kyrus-tech ! com>
Date:       2014-02-28 1:47:50
Message-ID: CA+ZU17u=hZeeUU48_ZhXFdogpvLT=9nHNBt5vFfND4mk0NpVpw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I don't understand what you mean by that. By Decl, I assumed you meant the
TypedefNameDecl created for the object "KPCR", but as far as I can tell,
only types have a getAs field.

For actually solving the problem, it seems that "fs:[0] 12" is equivalent
to "fs:[12]". I see that there are several calls to
AsmRewrites->push_back... is there a way to amend the most recent thing you
pushed onto that object?

Thanks,
JB


On Thu, Feb 27, 2014 at 12:23 PM, Reid Kleckner <rnk@google.com> wrote:

> It is, but you probably want to look for any RecordDecl to see if it's
> possible to do a field access.  You can use Decl->getAs<RecordDecl>() to
> look through typedefs automatically.
> 
> 
> On Thu, Feb 27, 2014 at 11:12 AM, JB Feldman <jb.feldman@kyrus-tech.com>wrote:
> 
> > I'm trying to track this down, am I correct that in the example I pasted
> > above: "KPCR" (in the bug report, "s") should be a TypedefNameDecl?
> > 
> > 
> > On Thu, Feb 27, 2014 at 11:38 AM, JB Feldman <jb.feldman@kyrus-tech.com>wrote:
> > 
> > > Bug has been filed: http://llvm.org/bugs/show_bug.cgi?id=18994
> > > 
> > > 
> > > On Thu, Feb 27, 2014 at 10:52 AM, Reid Kleckner <rnk@google.com> wrote:
> > > 
> > > > This also happens (just once) in the Chromium build:
> > > > 
> > > > http://build.chromium.org/p/chromium.fyi/builders/Chromium%20Win%20Clang/builds/645/steps/compile/logs/stdio
> > > >  
> > > > Parsing this involves Clang and
> > > > llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp.  It's really tricky because
> > > > C++ expressions can occur in lots of places, making it harder to parse the
> > > > assembly.
> > > > 
> > > > Feel free to file a bug on this.
> > > > 
> > > > 
> > > > On Thu, Feb 27, 2014 at 7:22 AM, JB Feldman <jb.feldman@kyrus-tech.com>wrote:
> > > > 
> > > > > Hi guys,
> > > > > 
> > > > > I will file a bug report in a little bit (once I get a minimal test
> > > > > case) but I wanted to ask if anyone understands the problem I'm seeing.
> > > > > 
> > > > > Trying to include ntddk.h and compiling with clang-cl, I get the
> > > > > following message:
> > > > > 
> > > > > In file included from kbfiltr.c:19:
> > > > > In file included from ./kbfiltr.h:28:
> > > > > C:\WINDDK\3790.1830\inc\ddk\wxp\ntddk.h(7149,29) :  error: unexpected
> > > > > type name
> > > > > 'KPCR': expected expression
> > > > > __asm {  movzx eax, _PCR KPCR.Number  }
> > > > > ^
> > > > > Assertion failed: End.getPointer() <= EndPtr && "frontend claimed part
> > > > > of a token?", file
> > > > > ..\..\..\..\..\lib\Target\X86\AsmParser\X86AsmParser.cpp, line 1481
> > > > > clang-cl.exe: error: clang frontend command failed with exit code 3
> > > > > (use -v to s
> > > > > ee invocation)
> > > > > 
> > > > > The assertion failure obviously results in a crash.
> > > > > 
> > > > > So my initial guess was some kind of Lexer issue, maybe because of no
> > > > > semicolon, or... who knows. But then, I rewrote that code to read:
> > > > > 
> > > > > int x = FIELD_OFFSET(KPCR, Number);
> > > > > __asm { movzx eax, fs:[x] }
> > > > > 
> > > > > Which compiles to the same code, and that actually did work with
> > > > > clang-cl. Can anyone tell me why one works and the other doesn't? (My
> > > > > guess: MS not following standard Intel notation spec)
> > > > > 
> > > > > Thanks,
> > > > > JB
> > > > > 
> > > > > _______________________________________________
> > > > > cfe-dev mailing list
> > > > > cfe-dev@cs.uiuc.edu
> > > > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> > > > > 
> > > > > 
> > > > 
> > > 
> > 
> 


[Attachment #5 (text/html)]

<div dir="ltr">I don&#39;t understand what you mean by that. By Decl, I assumed you \
meant the TypedefNameDecl created for the object &quot;KPCR&quot;, but as far as I \
can tell, only types have a getAs field.<div><br></div> <div>For actually solving the \
problem, it seems that &quot;fs:[0] 12&quot; is equivalent to &quot;fs:[12]&quot;. I \
see that there are several calls to AsmRewrites-&gt;push_back... is there a way to \
amend the most recent thing you pushed onto that object?</div> \
<div><br></div><div>Thanks,<br>JB</div></div><div class="gmail_extra"><br><br><div \
class="gmail_quote">On Thu, Feb 27, 2014 at 12:23 PM, Reid Kleckner <span \
dir="ltr">&lt;<a href="mailto:rnk@google.com" \
target="_blank">rnk@google.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">It is, but you probably want to look for any \
RecordDecl to see if it&#39;s possible to do a field access.  You can use \
Decl-&gt;getAs&lt;RecordDecl&gt;() to look through typedefs automatically.</div> <div \
class="HOEnZb"><div class="h5"><div class="gmail_extra"> <br><br><div \
class="gmail_quote">On Thu, Feb 27, 2014 at 11:12 AM, JB Feldman <span \
dir="ltr">&lt;<a href="mailto:jb.feldman@kyrus-tech.com" \
target="_blank">jb.feldman@kyrus-tech.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">

<div dir="ltr">I&#39;m trying to track this down, am I correct that in the example I \
pasted above: &quot;KPCR&quot; (in the bug report, &quot;s&quot;) should be a \
TypedefNameDecl?</div><div><div> <div class="gmail_extra"><br><br><div \
class="gmail_quote"> On Thu, Feb 27, 2014 at 11:38 AM, JB Feldman <span \
dir="ltr">&lt;<a href="mailto:jb.feldman@kyrus-tech.com" \
target="_blank">jb.feldman@kyrus-tech.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">


<div dir="ltr">Bug has been filed: <a \
href="http://llvm.org/bugs/show_bug.cgi?id=18994" \
target="_blank">http://llvm.org/bugs/show_bug.cgi?id=18994</a></div><div><div><div \
class="gmail_extra"><br> <br><div class="gmail_quote">On Thu, Feb 27, 2014 at 10:52 \
AM, Reid Kleckner <span dir="ltr">&lt;<a href="mailto:rnk@google.com" \
target="_blank">rnk@google.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div>This also happens (just once) in the \
Chromium build:</div><div><a \
href="http://build.chromium.org/p/chromium.fyi/builders/Chromium%20Win%20Clang/builds/645/steps/compile/logs/stdio" \
target="_blank">http://build.chromium.org/p/chromium.fyi/builders/Chromium%20Win%20Clang/builds/645/steps/compile/logs/stdio</a><br>





</div><div><br></div><div>Parsing this involves Clang and \
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp.  It&#39;s really tricky because C++ \
expressions can occur in lots of places, making it harder to parse the \
assembly.</div>




<div><br></div><div>Feel free to file a bug on this.</div></div><div \
class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Thu, Feb 27, 2014 \
at 7:22 AM, JB Feldman <span dir="ltr">&lt;<a href="mailto:jb.feldman@kyrus-tech.com" \
target="_blank">jb.feldman@kyrus-tech.com</a>&gt;</span> wrote:<br>




</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi guys,<div><br></div><div>I \
will file a bug report in a little bit (once I get a minimal test case) but I wanted \
to ask if anyone understands the problem I&#39;m seeing.</div>




<div><br></div><div>Trying to include ntddk.h and compiling with clang-cl, I get the \
following message:</div> <div><br></div><div><div>In file included from \
kbfiltr.c:19:</div><div>In file included from \
./kbfiltr.h:28:</div><div>C:\WINDDK\3790.1830\inc\ddk\wxp\ntddk.h(7149,29) :  error: \
unexpected type name</div><div>      &#39;KPCR&#39;: expected expression</div>





<div>    __asm {  movzx eax, _PCR KPCR.Number  }</div><div>                           \
^</div><div>Assertion failed: End.getPointer() &lt;= EndPtr &amp;&amp; &quot;frontend \
claimed part of a token?&quot;, file \
..\..\..\..\..\lib\Target\X86\AsmParser\X86AsmParser.cpp, line 1481</div>





<div>clang-cl.exe: error: clang frontend command failed with exit code 3 (use -v to \
s</div><div>ee invocation)</div></div><div><br></div><div>The assertion failure \
obviously results in a crash.</div><div><br></div><div>So my initial guess was some \
kind of Lexer issue, maybe because of no semicolon, or... who knows. But then, I \
rewrote that code to read:</div>





<div><br></div><div>int x = FIELD_OFFSET(KPCR, Number);</div><div>__asm { movzx eax, \
fs:[x] } </div><div><br></div><div>Which compiles to the same code, and that actually \
did work with clang-cl. Can anyone tell me why one works and the other doesn&#39;t? \
(My guess: MS not following standard Intel notation spec)</div>





<div><br></div><div>Thanks,<br>JB</div></div>
<br></div></div><div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" \
target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br> \
<br></div></blockquote></div><br></div> </blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>



_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic