@@ -252,6 +252,44 @@ class IRBuilderSpec : XCTestCase {
252252 // CONTROLFLOW-NEXT: }
253253 module. dump ( )
254254 } )
255+
256+ XCTAssert ( fileCheckOutput ( of: . stderr, withPrefixes: [ " CAST " ] ) {
257+ // CAST: ; ModuleID = '[[ModuleName:IRBuilderTest]]'
258+ // CAST-NEXT: source_filename = "[[ModuleName]]"
259+ let module = Module ( name: " IRBuilderTest " )
260+ let builder = IRBuilder ( module: module)
261+
262+ // CAST: define i32 @main() {
263+ let main = builder. addFunction ( " main " ,
264+ type: FunctionType ( argTypes: [ ] ,
265+ returnType: IntType . int32) )
266+
267+ // CAST-NEXT: entry:
268+ let entry = main. appendBasicBlock ( named: " entry " )
269+ builder. positionAtEnd ( of: entry)
270+
271+ // CAST-NEXT: %0 = alloca i64
272+ let alloca = builder. buildAlloca ( type: IntType . int64)
273+
274+ // CAST-NEXT: %1 = ptrtoint i64* %0 to i64
275+ _ = builder. buildPtrToInt ( alloca, type: IntType . int64)
276+
277+ // CAST-NEXT: %2 = load i64, i64* %0
278+ let val = builder. buildLoad ( alloca)
279+
280+ // CAST-NEXT: %3 = inttoptr i64 %2 to i64*
281+ _ = builder. buildIntToPtr ( val,
282+ type: PointerType ( pointee: IntType . int64) )
283+
284+ // CAST-NEXT: %4 = bitcast i64* %0 to i8*
285+ _ = builder. buildBitCast ( alloca, type: PointerType . toVoid)
286+
287+ // CAST-NEXT: ret i32 0
288+ builder. buildRet ( IntType . int32. constant ( 0 ) )
289+
290+ // CAST-NEXT: }
291+ module. dump ( )
292+ } )
255293 }
256294
257295 #if !os(macOS)
0 commit comments