Subzero: Translate the unreachable bitcode directly to ud2.
This removes ice_unreachable() from the Subzero runtime. The ice_unreachable() implementation is problematic since it makes a call to external function abort(), which leads to an undefined symbol error in the linker because abort() is internalized at link time.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4091
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/945953002
diff --git a/runtime/szrt.c b/runtime/szrt.c
index d9d578a..4721758 100644
--- a/runtime/szrt.c
+++ b/runtime/szrt.c
@@ -15,8 +15,6 @@
#include <stdint.h>
#include <stdlib.h>
-void ice_unreachable(void) { abort(); }
-
uint32_t cvtftoui32(float value) { return (uint32_t)value; }
uint32_t cvtdtoui32(double value) { return (uint32_t)value; }
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 1e4d282..13476c8 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -4119,10 +4119,7 @@
}
void TargetX8632::lowerUnreachable(const InstUnreachable * /*Inst*/) {
- const SizeT MaxSrcs = 0;
- Variable *Dest = nullptr;
- InstCall *Call = makeHelperCall("ice_unreachable", Dest, MaxSrcs);
- lowerCall(Call);
+ _ud2();
}
// Turn an i64 Phi instruction into a pair of i32 Phi instructions, to
diff --git a/tests_lit/llvm2ice_tests/unreachable.ll b/tests_lit/llvm2ice_tests/unreachable.ll
index fc6620f..ad055fe 100644
--- a/tests_lit/llvm2ice_tests/unreachable.ll
+++ b/tests_lit/llvm2ice_tests/unreachable.ll
@@ -20,7 +20,7 @@
; CHECK-LABEL: divide
; CHECK: cmp
-; CHECK: call {{.*}} R_{{.*}} ice_unreachable
+; CHECK: ud2
; CHECK: cdq
; CHECK: idiv
; CHECK: ret