Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy elision: if-err with scalar types
```zig export fn entry() void { var x: error!i32 = 1234; var y = if (x) |a| a else |e| 5678; } ``` ```llvm define void @entry() #2 !dbg !41 { Entry: %x = alloca { i16, i32 }, align 4 %y = alloca i32, align 4 %0 = bitcast { i16, i32 }* %x to i8*, !dbg !56 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %0, i8* align 4 bitcast ({ i16, i32 }* @0 to i8*), i64 8, i1 false), !dbg !56 call void @llvm.dbg.declare(metadata { i16, i32 }* %x, metadata !45, metadata !DIExpression()), !dbg !57 %1 = getelementptr inbounds { i16, i32 }, { i16, i32 }* %x, i32 0, i32 0, !dbg !58 %2 = load i16, i16* %1, align 2, !dbg !58 %3 = icmp ne i16 %2, 0, !dbg !58 br i1 %3, label %IfErrElse, label %IfErrThen, !dbg !58 IfErrThen: ; preds = %Entry %4 = getelementptr inbounds { i16, i32 }, { i16, i32 }* %x, i32 0, i32 1, !dbg !58 call void @llvm.dbg.declare(metadata i32* %4, metadata !52, metadata !DIExpression()), !dbg !58 %5 = load i32, i32* %4, align 4, !dbg !59 store i32 %5, i32* %y, align 4, !dbg !59 br label %IfErrEnd, !dbg !58 IfErrElse: ; preds = %Entry %6 = load i16, i16* %1, align 2, !dbg !58 call void @llvm.dbg.declare(metadata i16* %1, metadata !54, metadata !DIExpression()), !dbg !58 store i32 5678, i32* %y, align 4, !dbg !61 br label %IfErrEnd, !dbg !58 IfErrEnd: ; preds = %IfErrElse, %IfErrThen call void @llvm.dbg.declare(metadata i32* %y, metadata !55, metadata !DIExpression()), !dbg !63 ret void, !dbg !64 } ```
- Loading branch information