Skip to content

[WinEH] Incorrect block label reference in unwind table #176421

@nikic

Description

@nikic
target triple = "aarch64-pc-windows-msvc"

declare void @func()

define void @test(ptr %p) personality ptr @__CxxFrameHandler3 {
  %v0 = load i32, ptr %p
  %v1 = load i32, ptr %p
  %xor = xor i32 %v0, %v1
  %cmp = icmp eq i32 %xor, 0
  br i1 %cmp, label %exit, label %bb

bb:
  invoke void @func()
          to label %exit unwind label %unwind

unwind:
  %cp = cleanuppad within none []
  store volatile i32 0, ptr %p
  cleanupret from %cp unwind to caller

exit:
  ret void
}

declare i32 @__CxxFrameHandler3(...)

Produces something like this:

$stateUnwindMap$test:
	.word	-1                              // ToState
	.word	"?dtor$-1@?0?test@4HA"@IMGREL   // Action

Note the ?dtor$-1 referring to an unnumbered MBB. This ultimately causes linker errors.

Only observed on AArch64 Windows.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions