<div dir="ltr">reverted in r310008 </div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 3, 2017 at 5:20 PM, Vitaly Buka <span dir="ltr"><<a href="mailto:vitalybuka@google.com" target="_blank">vitalybuka@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><pre style="white-space:pre-wrap"><span class="m_-6101302661698830142gmail-m_-5723359485652069565gmail-stdout"><font color="#000000" face="Courier New, courier, monotype, monospace" size="3"><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6924/steps/check-llvm%20ubsan/logs/stdio" class="m_-6101302661698830142gmail-cremed m_-6101302661698830142cremed" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/sanitizer-x86_64-linux-<wbr>fast/builds/6924/steps/check-<wbr>llvm%20ubsan/logs/stdio</a><br></font></span></pre><pre style="white-space:pre-wrap"><span class="m_-6101302661698830142gmail-m_-5723359485652069565gmail-stdout"><font color="#000000" face="Courier New, courier, monotype, monospace" size="3"><br></font></span></pre><pre style="white-space:pre-wrap;font-family:"Courier New",courier,monotype,monospace;color:rgb(0,0,0);font-size:medium"><span class="m_-6101302661698830142gmail-m_-5723359485652069565gmail-stdout">Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.
FAIL: LLVM :: MC/AMDGPU/exp.s (14527 of 21592)
******************** TEST 'LLVM :: MC/AMDGPU/exp.s' FAILED ********************
Script:
--
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/./bin/llvm-<wbr>mc -arch=amdgcn -show-encoding /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/test/MC/AMDGPU/exp.s | /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/./bin/FileCh<wbr>eck -check-prefix=SI /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/test/MC/AMDGPU/exp.s
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/./bin/llvm-<wbr>mc -arch=amdgcn -mcpu=tonga -show-encoding /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/test/MC/AMDGPU/exp.s | /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/./bin/FileCh<wbr>eck -check-prefix=VI /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/test/MC/AMDGPU/exp.s
--
Exit Code: 2
Command Output (stderr):
--
lib/Target/AMDGPU/AMDGPUGenAsm<wbr>Matcher.inc:9073:33: runtime error: index -1 out of bounds for type 'unsigned int [12]'
#0 0x4e1272 in (anonymous namespace)::AMDGPUAsmParser::c<wbr>onvertToMCInst(unsigned int, llvm::MCInst&, unsigned int, llvm::SmallVectorImpl<std::uni<wbr>que_ptr<llvm::MCParsedAsmOpera<wbr>nd, std::default_delete<llvm::MCPa<wbr>rsedAsmOperand> > > const&, llvm::SmallBitVector const&) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/lib/Target/<wbr>AMDGPU/AMDGPUGenAsmMatcher.<wbr>inc:9073:33
#1 0x4c7230 in (anonymous namespace)::AMDGPUAsmParser::M<wbr>atchInstructionImpl(llvm::Smal<wbr>lVectorImpl<std::unique_ptr<<wbr>llvm::MCParsedAsmOperand, std::default_delete<llvm::MCPa<wbr>rsedAsmOperand> > > const&, llvm::MCInst&, unsigned long&, bool, unsigned int) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/lib/Target/<wbr>AMDGPU/AMDGPUGenAsmMatcher.<wbr>inc:19873:5
#2 0x4b55b8 in (anonymous namespace)::AMDGPUAsmParser::M<wbr>atchAndEmitInstruction(llvm::S<wbr>MLoc, unsigned int&, llvm::SmallVectorImpl<std::uni<wbr>que_ptr<llvm::MCParsedAsmOpera<wbr>nd, std::default_delete<llvm::MCPa<wbr>rsedAsmOperand> > >&, llvm::MCStreamer&, unsigned long&, bool) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/lib/Target/AMDGPU/AsmPar<wbr>ser/AMDGPUAsmParser.cpp:2222:<wbr>14
#3 0x8f37ad in (anonymous namespace)::AsmParser::parseSt<wbr>atement((anonymous namespace)::ParseStatementInfo<wbr>&, llvm::MCAsmParserSemaCallback*<wbr>) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/lib/MC/MCParser/AsmParse<wbr>r.cpp:2224:27
#4 0x8eb2c8 in (anonymous namespace)::AsmParser::Run(boo<wbr>l, bool) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/lib/MC/MCParser/AsmParse<wbr>r.cpp:883:10
#5 0x454d70 in AssembleInput(char const*, llvm::Target const*, llvm::SourceMgr&, llvm::MCContext&, llvm::MCStreamer&, llvm::MCAsmInfo&, llvm::MCSubtargetInfo&, llvm::MCInstrInfo&, llvm::MCTargetOptions&) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/llvm-mc/llvm-mc.<wbr>cpp:425:21
#6 0x453529 in main /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/llvm-mc/llvm-mc.<wbr>cpp:608:11
#7 0x7f0e4bcf382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so<wbr>.6+0x2082f)
#8 0x42d138 in _start (/mnt/b/sanitizer-buildbot3/sa<wbr>nitizer-x86_64-linux-fast/buil<wbr>d/llvm_build_ubsan/bin/llvm-<wbr>mc+0x42d138)
FileCheck error: '-' is empty.
FileCheck command line: /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm_build_ubsan/./bin/FileCh<wbr>eck -check-prefix=SI /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/test/MC/AMDGPU/exp.s</span></pre></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 3, 2017 at 8:40 AM, Nirav Dave via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: niravd<br>
Date: Thu Aug 3 08:40:21 2017<br>
New Revision: 309949<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=309949&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=309949&view=rev</a><br>
Log:<br>
[TableGen] AsmMatcher: fix OpIdx computation when HasOptionalOperands is true<br>
<br>
Consider the following instruction: "inst.eq $dst, $src" where ".eq"<br>
is an optional flag operand. The $src and $dst operands are<br>
registers. If we parse the instruction "inst r0, r1", the flag is not<br>
present and it will be marked in the "OptionalOperandsMask" variable.<br>
After the matching is complete we call the "convertToMCInst" method.<br>
<br>
The current implementation works only if the optional operands are at<br>
the end of the array. The "Operands" array looks like [token:"inst",<br>
reg:r0, reg:r1]. The first operand that must be added to the MCInst<br>
is the destination, the r0 register. The "OpIdx" (in the Operands<br>
array) for this register is 2. However, since the flag is not present<br>
in the Operands, the actual index for r0 should be 1. The flag is not<br>
present since we rely on the default value.<br>
<br>
This patch removes the "NumDefaults" variable and replaces it with an<br>
array (DefaultsOffset). This array contains an index for each operand<br>
(excluding the mnemonic). At each index, the array contains the<br>
number of optional operands that should be subtracted. For the<br>
previous example, this array looks like this: [0, 1, 1]. When we need<br>
to access the r0 register, we compute its index as 2 -<br>
DefaultsOffset[1] = 1.<br>
<br>
Patch by Alexandru Guduleasa!<br>
<br>
Reviewers: SamWot, nhaustov, niravd<br>
<br>
Subscribers: llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D35998" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3599<wbr>8</a><br>
<br>
Modified:<br>
llvm/trunk/utils/TableGen/AsmM<wbr>atcherEmitter.cpp<br>
<br>
Modified: llvm/trunk/utils/TableGen/AsmM<wbr>atcherEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=309949&r1=309948&r2=309949&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/utils/TableGe<wbr>n/AsmMatcherEmitter.cpp?rev=<wbr>309949&r1=309948&r2=309949&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/utils/TableGen/AsmM<wbr>atcherEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/AsmM<wbr>atcherEmitter.cpp Thu Aug 3 08:40:21 2017<br>
@@ -1847,13 +1847,30 @@ static void emitConvertFuncs(CodeGenTarg<br>
CvtOS << " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n";<br>
CvtOS << " const uint8_t *Converter = ConversionTable[Kind];\n";<br>
if (HasOptionalOperands) {<br>
- CvtOS << " unsigned NumDefaults = 0;\n";<br>
+ size_t MaxNumOperands = 0;<br>
+ for (const auto &MI : Infos) {<br>
+ MaxNumOperands = std::max(MaxNumOperands, MI->AsmOperands.size());<br>
+ }<br>
+ CvtOS << " unsigned DefaultsOffset[" << (MaxNumOperands) << "];\n";<br>
+ CvtOS << " assert(OptionalOperandsMask.si<wbr>ze() == " << (MaxNumOperands)<br>
+ << ");\n";<br>
+ CvtOS << " for (unsigned i = 0, NumDefaults = 0; i < " << (MaxNumOperands)<br>
+ << "; ++i) {\n";<br>
+ CvtOS << " DefaultsOffset[i] = NumDefaults;\n";<br>
+ CvtOS << " NumDefaults += (OptionalOperandsMask[i] ? 1 : 0);\n";<br>
+ CvtOS << " }\n";<br>
}<br>
CvtOS << " unsigned OpIdx;\n";<br>
CvtOS << " Inst.setOpcode(Opcode);\n";<br>
CvtOS << " for (const uint8_t *p = Converter; *p; p+= 2) {\n";<br>
if (HasOptionalOperands) {<br>
- CvtOS << " OpIdx = *(p + 1) - NumDefaults;\n";<br>
+ // OpIdx has different semantics for Tied operands and the rest of the<br>
+ // operands. For Tied it is the index in the Inst, therefore we use it<br>
+ // directly. For the rest of the operands, we need to account for the<br>
+ // offset.<br>
+ CvtOS << " OpIdx = *(p + 1);\n";<br>
+ CvtOS << " OpIdx -= (*p != CVT_Tied) ? DefaultsOffset[*(p + 1) - 1] : "<br>
+ "0;\n";<br>
} else {<br>
CvtOS << " OpIdx = *(p + 1);\n";<br>
}<br>
@@ -1988,7 +2005,6 @@ static void emitConvertFuncs(CodeGenTarg<br>
<< " " << Op.Class->DefaultMethod << "()"<br>
<< "->" << Op.Class->RenderMethod << "(Inst, "<br>
<< OpInfo.MINumOperands << ");\n"<br>
- << " ++NumDefaults;\n"<br>
<< " } else {\n"<br>
<< " static_cast<" << TargetOperandClass<br>
<< "&>(*Operands[OpIdx])." << Op.Class->RenderMethod<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>