<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2017, at 01:51, Haidl, Michael <<a href="mailto:michael.haidl@uni-muenster.de" class="">michael.haidl@uni-muenster.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="">Hi Matt,<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">thanks for your response. I agree that the IR should be generated with the correct AS in the first place. However, for my project this is somehow impossible. </span></div></div></div></blockquote><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">I need the same IR with everything in AS 0 for CPU execution and again with GPU specific address spaces to avoid performance impacts of the generic address space. </span></div></div></div></blockquote><div>We have an optimization pass to eliminate generic accesses, so for the most part you shouldn’t have to worry about this too much. You can insert casts to flat and generally expect them to be eliminated. This is what HCC is doing now.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Doing this in the front-end means a way more intrusive change to clang and a way I did not want to go in the first place.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">I have the IR that goes into the pass manager attached to the mail.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">The PM is set up as follows:<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  llvm::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">TargetOptions</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>options;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  options.UnsafeFPMath =<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">false</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  options.NoInfsFPMath =<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">false</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  options.NoNaNsFPMath =<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">false</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  options.HonorSignDependentRoundingFPMathOption =<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">false</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  options.AllowFPOpFusion = FPOpFusion::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: darkslategray;" class="">Fast</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">Triple</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>TheTriple =<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">Triple</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">(</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: gray;" class="">M</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">.getTargetTriple());<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  std::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">string</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>Error;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">SmallString</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><128> hsaString;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  llvm::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">raw_svector_ostream</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>hsaOS(hsaString);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">if</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>(!_target)<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">    _target =<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">TargetRegistry</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">::lookupTarget(</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(163, 21, 21);" class="">"amdgcn"</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">, TheTriple, Error);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">if</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>(!_target) {<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">   <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">throw</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>common::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">generic_exception</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">(Error);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  }<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  llvm::legacy::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">PassManager</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>PM;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">PassManagerBuilder</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>builder;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  builder.OptLevel = 3;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  builder.populateModulePassManager(PM);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">  _machine.reset(_target->createTargetMachine(<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">      TheTriple.getTriple(), _cpu, _features, options, Reloc::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">Model</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: darkslategray;" class="">Static</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">     <span class="Apple-converted-space"> </span></span><span style="font-size: 9.5pt; font-family: Consolas;" class="">CodeModel::</span><span style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">Model</span><span style="font-size: 9.5pt; font-family: Consolas;" class="">::</span><span style="font-size: 9.5pt; font-family: Consolas; color: darkslategray;" class="">Medium</span><span style="font-size: 9.5pt; font-family: Consolas;" class="">, CodeGenOpt::</span><span style="font-size: 9.5pt; font-family: Consolas; color: darkslategray;" class="">Aggressive</span><span style="font-size: 9.5pt; font-family: Consolas;" class="">));<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 9.5pt; font-family: Consolas;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">if</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>(_machine</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: teal;" class="">-></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">addPassesToEmitFile(PM, hsaOS,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">                                   <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">TargetMachine</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: darkslategray;" class="">CGFT_ObjectFile</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">,<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">false</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">)) {<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">   <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: blue;" class="">throw</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""><span class="Apple-converted-space"> </span>std::</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(43, 145, 175);" class="">logic_error</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">(<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">       <span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas; color: rgb(163, 21, 21);" class="">"target does not support generation of this file type!\n"</span><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class="">);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9.5pt; font-family: Consolas;" class=""> <span class="Apple-converted-space"> </span></span><span style="font-size: 9.5pt; font-family: Consolas;" class="">}<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 9.5pt; font-family: Consolas;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 9.5pt; font-family: Consolas;" class="">  PM.run(</span><span style="font-size: 9.5pt; font-family: Consolas; color: gray;" class="">M</span><span style="font-size: 9.5pt; font-family: Consolas;" class="">);</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><a name="_MailEndCompose" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></a></div></div></div></blockquote><br class=""></div><div>I can’t see what’s going on with this. I would look into what happens when AMDGPUTTIImpl::isSourceOfDivergence is called in your broken example. I don’t see exactly how it would happen or how it would cause this, but I”m guessing something went wrong where the wrong address space mapping is being used at some point.</div><div><br class=""></div><div>-Matt</div></body></html>