Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift issue using max() and min() sequentially while archiving on Xcode

On "Compiling swift files" step while archiving, it said that a particular file had this error:

PHI node has multiple entries for the same basic block with different incoming values!
  %31 = phi i64 [ 3, %385 ], [ %386, %385 ], [ 1, %29 ], !dbg !1370
label %385
i64 3
  %386 = phi i64 [ %23, %27 ], !dbg !1433
LLVM ERROR: Broken function found, compilation aborted!

After commenting the file's code for a while I found out that the following lines of code were the issue:

var normalizedStrikes = max(1, strikes)
normalizedStrikes = min(normalizedStrikes, 3)

After trying out a lot of things I discovered that I couldn't use max() and then min(), here is what solved the issue for me:

var normalizedStrikes = strikes
if (normalizedStrikes <= 0) {
    normalizedStrikes = 1
}
normalizedStrikes = min(normalizedStrikes, 3)

Another very nice thing I've found is that if I change the condition to "< 1", it throws the same error. Good stuff.

var normalizedStrikes = strikes
if (normalizedStrikes < 1) {
    normalizedStrikes = 1
}
normalizedStrikes = min(normalizedStrikes, 3)

My question is: why that happened?

Btw I'm using Xcode Version 6.1.1 (6A2008a)

like image 949
Rafael Garcia Avatar asked Feb 14 '15 14:02

Rafael Garcia


1 Answers

This is resolved as of Xcode 6.3 (6D570).

like image 197
Aaron Brager Avatar answered Oct 22 '22 01:10

Aaron Brager