Hacking uSwift, a minimal stdlib... where is getOptionalDecl() defined?

Makes sense.

OK, next issue. :slight_smile:

(***left here for completeness but i started a new question for this... "Assertion failed: (isa<X>(Val) && “cast<Ty>() argument of incompatible type!”) from clang when trying to compile with an unusual target" ***)

When i'm compiling swift code to LLVM IR using my built version of swift, I'm getting a trap within the constructor for swift::irgen::IRGenModule. Specifically, the last line, IsSwiftErrorInRegister = clang::CodeGen::swiftcall::isSwiftErrorLoweredInRegister( ClangCodeGen->CGM());

Clang shows this method is simply...

// Is swifterror lowered to a register by the target ABI.
bool swiftcall::isSwiftErrorLoweredInRegister(CodeGenModule &CGM) {
  return getSwiftABIInfo(CGM).isSwiftErrorInRegister();
}

getSwiftABIInfo traps with...

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/carlpeto/avr/swift/llvm/include/llvm/Support/Casting.h, line 248.

The code in question looks simple...

static const SwiftABIInfo &getSwiftABIInfo(CodeGenModule &CGM) {
  return cast<SwiftABIInfo>(CGM.getTargetCodeGenInfo().getABIInfo());
}

So my best guess is that CGM.getTargetCodeGenInfo().getABIInfo() returns ABI info that's not Swift ABI info, whatever that means.

Does anyone have any ideas why that might be?