[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 17 21:19:17 PDT 2004
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.51 -> 1.52
---
Log message:
Start emitting the LLVM unreachable instruction after calls to noreturn functions
and after calling the C++ terminate function in bad EH situations.
---
Diffs of the changes: (+9 -17)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.51 llvm-gcc/gcc/llvm-expand.c:1.52
--- llvm-gcc/gcc/llvm-expand.c:1.51 Mon Oct 4 19:19:18 2004
+++ llvm-gcc/gcc/llvm-expand.c Sun Oct 17 23:19:04 2004
@@ -3042,20 +3042,12 @@
return D2V(Call)->Ty != VoidTy ? D2V(Call) : 0;
}
-/* llvm_expand_dummy_return - output a return instruction so that the optimizer
- * knows that control flow doesn't reach here. Unless elide_new_block is set,
- * this also adds a block immediately after the return.
+/* llvm_expand_unreachable - output an unreachable instruction so that the
+ * optimizer knows that control flow doesn't reach here. Unless elide_new_block
+ * is set, this also adds a block immediately after the return.
*/
-static void llvm_expand_dummy_return(llvm_function *Fn, bool elide_new_block) {
- llvm_type *RetTy =
- GET_FUNCTION_TYPE_RETURN(GET_POINTER_TYPE_ELEMENT(G2V(Fn)->Ty));
- if (RetTy != VoidTy) {
- llvm_instruction *Ret = llvm_instruction_new(VoidTy, "", O_Ret, 1);
- Ret->Operands[0] = llvm_constant_get_null(RetTy);
- append_inst(Fn, Ret);
- } else {
- append_inst(Fn, llvm_instruction_new(VoidTy, "", O_Ret, 0));
- }
+static void llvm_expand_unreachable(llvm_function *Fn, bool elide_new_block) {
+ append_inst(Fn, llvm_instruction_new(VoidTy, "", O_Unreachable, 0));
if (!elide_new_block) {
/* Start a new block so that if statements are emitted after the return,
@@ -3128,11 +3120,11 @@
Result = llvm_expand_call_of(Fn, Callee, exp, DestLoc);
/* If the function has the volatile bit set, then it is a "noreturn" function.
- * Output a return right after the function to prevent LLVM from thinking that
- * control flow will fall into the subsequent block.
+ * Output an unreachable instruction right after the function to prevent LLVM
+ * from thinking that control flow will fall into the subsequent block.
*/
if (TREE_CODE(fn) == ADDR_EXPR && TREE_THIS_VOLATILE(TREE_OPERAND(fn, 0))) {
- llvm_expand_dummy_return(Fn, 0);
+ llvm_expand_unreachable(Fn, 0);
}
return Result;
@@ -6916,7 +6908,7 @@
build_function_type(void_type_node, void_list_node)));
append_inst(Fn, Call);
- llvm_expand_dummy_return(Fn, 1);
+ llvm_expand_unreachable(Fn, 1);
}
/* Emitting all of these labels should have caused all of the goto fixups to
More information about the llvm-commits
mailing list