LLVM IR generation output by swiftc "error: instruction expected to be numbered"

Hello everyone,

I am very new to compiler development and LLVM, for a project I need to use an existing pass for LLVM and apply to to IR generated from swift code.

The original description passes the pass to the Clang front end. Is there a comparable option for the swiftc compiler?(as in clang -Xclang -load -Xclang "path to shared object implementing pass")

I attempted to generate the IR with swiftc -emit-bc/-emit-ir and then use opt to load the plugin directly on the IR.

however, the IR generated by the swiftc compiler seems to have some formatting issues and I do not understand why it is doing that.

After getting the IR I try to run it with lli. I find out the required libraries with otool.

This approach works for small codes where it is for example just one assignment or a print statement. However when I run larger codes I always get this type of error:

"error: instruction expected to be numbered %8"

code snippet:

br i1 %7, label %44, label %8

8: ; preds = %entry
store i64 %5, i64* getelementptr inbounds (%TSi, %TSi* @"$s4test11sec_counterSivp", i32 0, i32 0), align 8
%9 = ...


in LLVM the names of the registers are in numerical order, in this code the name of the label is the next consecutive number which is why lli seems to be complaining that different register name was expected. Why is it doing this and how can I circumvent it?