178e87970SHeejin Ahn; RUN: llc < %s -verify-machineinstrs | FileCheck %s 278e87970SHeejin Ahn 378e87970SHeejin Ahn; Wasm does not currently support function addresses with offsets, so we 478e87970SHeejin Ahn; shouldn't try to create a folded SDNode like (function + offset). This is a 578e87970SHeejin Ahn; regression test for the folding bug and this should not crash in MCInstLower. 678e87970SHeejin Ahn 778e87970SHeejin Ahntarget triple = "wasm32-unknown-unknown" 878e87970SHeejin Ahn 978e87970SHeejin Ahn; 'hidden' here should be present to reproduce the bug 10*73856247SNikita Popovdeclare hidden void @ham(ptr) 1178e87970SHeejin Ahn 12*73856247SNikita Popovdefine void @bar(ptr %ptr) { 1378e87970SHeejin Ahnbb1: 1478e87970SHeejin Ahn br i1 undef, label %bb3, label %bb2 1578e87970SHeejin Ahn 1678e87970SHeejin Ahnbb2: 1778e87970SHeejin Ahn ; While lowering this switch, isel creates (@ham + 1) expression as a course 1878e87970SHeejin Ahn ; of range optimization for switch, and tries to fold the expression, but 1978e87970SHeejin Ahn ; wasm does not support with function addresses with offsets. This folding 2078e87970SHeejin Ahn ; should be disabled. 2178e87970SHeejin Ahn ; CHECK: i32.const ham 2278e87970SHeejin Ahn ; CHECK-NEXT: i32.const 1 2378e87970SHeejin Ahn ; CHECK-NEXT: i32.add 24*73856247SNikita Popov switch i32 ptrtoint (ptr @ham to i32), label %bb4 [ 2578e87970SHeejin Ahn i32 -1, label %bb3 2678e87970SHeejin Ahn i32 0, label %bb3 2778e87970SHeejin Ahn ] 2878e87970SHeejin Ahn 2978e87970SHeejin Ahnbb3: 3078e87970SHeejin Ahn unreachable 3178e87970SHeejin Ahn 3278e87970SHeejin Ahnbb4: 33*73856247SNikita Popov %tmp = load i8, ptr %ptr 3478e87970SHeejin Ahn unreachable 3578e87970SHeejin Ahn} 36