bridge, libgo: update runtime error calls
In CL 213642, we changed the compiler-generated runtime error
calls from __go_runtime_error to runtime.panicXXX. Update the
backend accordingly.
Change-Id: I075ce6f416b9cb3962379b2b0189c08a3502d380
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/213661
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/bridge/go-llvm-tree-integrity.cpp b/bridge/go-llvm-tree-integrity.cpp
index 1bb6515..d18619a 100644
--- a/bridge/go-llvm-tree-integrity.cpp
+++ b/bridge/go-llvm-tree-integrity.cpp
@@ -217,7 +217,7 @@
if (e->flavor() == N_Call) {
// ok to duplicate runtime error calls, but not other calls
Bfunction *target = e->getCallTarget();
- if (!target || target->name() != "__go_runtime_error")
+ if (!target || target->name().compare(0, 13, "runtime.panic") != 0)
return false;
}
if (e->flavor() == N_BinaryOp &&
diff --git a/bridge/go-llvm.cpp b/bridge/go-llvm.cpp
index df92d6c..c634909 100644
--- a/bridge/go-llvm.cpp
+++ b/bridge/go-llvm.cpp
@@ -3216,7 +3216,7 @@
// Mark nil checks "make_implicit". GoNilChecks pass will
// try to elide the branch.
if (llvm::Function *fn = llvm::cast<llvm::CallBase>(inst)->getCalledFunction())
- if (fn->getName() == "__go_runtime_error")
+ if (fn->getName() == "runtime.panicmem")
if (llvm::BasicBlock *pred = inst->getParent()->getSinglePredecessor()) {
llvm::Instruction *br = pred->getTerminator();
br->setMetadata(llvm::LLVMContext::MD_make_implicit,
diff --git a/libgo/CMakeLists.txt b/libgo/CMakeLists.txt
index 8d0265a..7ba6e3d 100644
--- a/libgo/CMakeLists.txt
+++ b/libgo/CMakeLists.txt
@@ -417,7 +417,6 @@
"runtime/go-now.c"
"runtime/go-nosys.c"
"runtime/go-reflect-call.c"
- "runtime/go-runtime-error.c"
"runtime/go-setenv.c"
"runtime/go-signal.c"
"runtime/go-unsafe-pointer.c"
diff --git a/passes/GoNilChecks.cpp b/passes/GoNilChecks.cpp
index 753db33..19e08b8 100644
--- a/passes/GoNilChecks.cpp
+++ b/passes/GoNilChecks.cpp
@@ -675,7 +675,7 @@
// load/store // handler: faultBB
// ...
// faultBB:
- // invoke __go_runtime_error(...) unwind label padBB
+ // invoke runtime.panicmem() unwind label padBB
// padBB:
// exception handler
//
@@ -717,7 +717,7 @@
// call).
for (MachineInstr &MI : *FaultBB)
if (MI.isCall() && MI.getOperand(0).isGlobal() &&
- MI.getOperand(0).getGlobal()->getName() == "__go_runtime_error") {
+ MI.getOperand(0).getGlobal()->getName() == "runtime.panicmem") {
MI.eraseFromParent();
break;
}
diff --git a/unittests/BackendCore/BackendTreeIntegrity.cpp b/unittests/BackendCore/BackendTreeIntegrity.cpp
index 35e931b..06b9e62 100644
--- a/unittests/BackendCore/BackendTreeIntegrity.cpp
+++ b/unittests/BackendCore/BackendTreeIntegrity.cpp
@@ -181,22 +181,19 @@
EXPECT_FALSE(ivis.repairableSubTree(call2));
// Create runtime error function.
- const char *rtename = "__go_runtime_error";
- BFunctionType *bfterr = mkFuncTyp(be,
- L_PARM, bi32t,
- L_END);
+ const char *rtename = "runtime.panicmem";
+ BFunctionType *bfterr = mkFuncTyp(be, L_END);
unsigned fflags = (Backend::function_is_visible |
Backend::function_is_inlinable |
Backend::function_does_not_return |
Backend::function_is_declaration);
Bfunction *rtefcn = be->function(bfterr, rtename, rtename, fflags, loc);
- // p0 != nil ? *p0 + 3 : runtime_error(6)
+ // p0 != nil ? *p0 + 3 : runtime.panicmem()
Bexpression *cmp2 = be->binary_expression(OPERATOR_NOTEQ, vex3, npe, loc);
Bexpression *der3 = be->indirect_expression(bi32t, vex3, false, loc);
Bexpression *add2 = be->binary_expression(OPERATOR_PLUS, mkInt32Const(be, 3), der3, loc);
- Bexpression *const6 = mkInt32Const(be, 6);
- Bexpression *call3 = h.mkCallExpr(be, rtefcn, const6, nullptr);
+ Bexpression *call3 = h.mkCallExpr(be, rtefcn, nullptr);
Bexpression *condex2 = be->conditional_expression(func, bi32t, cmp2, add2,
call3, loc);