<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - WinEHPrepare failed to demote instruction" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23884&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=hFkR_ZBVNA_A4RUBVco0Mn_-r3gXH_AAYmlogi8bkpA&s=HGHlwOcZIpsY-o4En3_TecohkU_lCkonITI2gUJpLGw&e=">23884</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WinEHPrepare failed to demote instruction
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alex@crichton.co
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compiling this IR:

```
target triple = "x86_64-pc-windows-msvc"                                     

declare i32 @__C_specific_handler(...)                                       
declare void @bar()                                                          
declare void @baz()                                                          
declare void @free(i8*)                                                      

define void @foo() {                                                         
  invoke void @baz()                                                         
          to label %normal unwind label %unwind1                             

normal:                                                                      
  unreachable                                                                

unwind1:                                                                     
  %lp5 = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler
          cleanup                                                            
  %rem = load i8*, i8** undef, align 8                                       
  invoke void @bar()                                                         
          to label %normal unwind label %unwind2                             

unwind2:                                                                     
  %lp6 = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler
          cleanup                                                            
  invoke void @baz()                                                         
          to label %normal2 unwind label %unwind3                            

normal2:                                                                     
  call void @free(i8* %rem)                                                  
  unreachable                                                                

unwind3:                                                                     
  %lp4 = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler
          cleanup                                                            
  unreachable                                                                
}                                                                            
```

will end up yielding the following when compiled with llc:

Failed to demote instruction used in exception handler of function foo:
    %rem = load i8*, i8** undef, align 8
LLVM ERROR: WinEHPrepare failed to demote instruction


This may be a dupe of one of these bugs, but I didn't see a reduced version of
them so I wasn't sure unfortnately:

* <a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - WinEHPrepare failed to demote instruction" href="show_bug.cgi?id=23427">https://llvm.org/bugs/show_bug.cgi?id=23427</a>
* <a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - WinEHPrepare failed to demote instruction" href="show_bug.cgi?id=23557">https://llvm.org/bugs/show_bug.cgi?id=23557</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>