Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2338,6 +2338,12 @@ } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") || Value.startswith("-mhwdiv") || Value.startswith("-march")) { // Do nothing, we'll validate it later. + } else if (Value == "--trap") { + CmdArgs.push_back("-target-feature"); + CmdArgs.push_back("+use-div-traps"); + } else if (Value == "--break") { + CmdArgs.push_back("-target-feature"); + CmdArgs.push_back("-use-div-traps"); } else { D.Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() << Value; Index: test/Driver/mips-ias-Wa.s =================================================================== --- /dev/null +++ test/Driver/mips-ias-Wa.s @@ -0,0 +1,24 @@ +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \ +// RUN: FileCheck -check-prefix=TRAP-DEFAULT %s +// TRAP-DEFAULT: -cc1as +// TRAP-DEFAULT-NOT: "-target-feature" "-use-div-traps" + +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,--trap 2>&1 | \ +// RUN: FileCheck -check-prefix=TRAP-ON %s +// TRAP-ON: -cc1as +// TRAP-ON: "-target-feature" "+use-div-traps" + +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,--break 2>&1 | \ +// RUN: FileCheck -check-prefix=TRAP-OFF %s +// TRAP-OFF: -cc1as +// TRAP-OFF: "-target-feature" "-use-div-traps + +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,--trap,--break 2>&1 | \ +// RUN: FileCheck -check-prefix=TRAP-BOTH-TRAP-FIRST %s +// TRAP-BOTH-TRAP-FIRST: -cc1as +// TRAP-BOTH-TRAP-FIRST: "-target-feature" "+use-div-traps" "-target-feature" "-use-div-traps" + +// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -Wa,--break,--trap 2>&1 | \ +// RUN: FileCheck -check-prefix=TRAP-BOTH-BREAK-FIRST %s +// TRAP-BOTH-BREAK-FIRST: -cc1as +// TRAP-BOTH-BREAK-FIRST: "-target-feature" "-use-div-traps" "-target-feature" "+use-div-traps"