[llvm-commits] [llvm] r48982 - in /llvm/trunk: bindings/ocaml/analysis/analysis_ocaml.c bindings/ocaml/analysis/llvm_analysis.ml bindings/ocaml/analysis/llvm_analysis.mli include/llvm-c/Analysis.h lib/Analysis/Analysis.cpp
Erick Tryzelaar
idadesub at users.sourceforge.net
Mon Mar 31 09:22:09 PDT 2008
Author: erickt
Date: Mon Mar 31 11:22:09 2008
New Revision: 48982
URL: http://llvm.org/viewvc/llvm-project?rev=48982&view=rev
Log:
Expose Function::viewCFG and Function::viewCFGOnly to bindings.
Modified:
llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c
llvm/trunk/bindings/ocaml/analysis/llvm_analysis.ml
llvm/trunk/bindings/ocaml/analysis/llvm_analysis.mli
llvm/trunk/include/llvm-c/Analysis.h
llvm/trunk/lib/Analysis/Analysis.cpp
Modified: llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c?rev=48982&r1=48981&r2=48982&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c Mon Mar 31 11:22:09 2008
@@ -58,3 +58,15 @@
LLVMVerifyFunction(Fn, LLVMAbortProcessAction);
return Val_unit;
}
+
+/* Llvm.llvalue -> unit */
+CAMLprim value llvm_view_function_cfg(LLVMValueRef Fn) {
+ LLVMViewFunctionCFG(Fn);
+ return Val_unit;
+}
+
+/* Llvm.llvalue -> unit */
+CAMLprim value llvm_view_function_cfg_only(LLVMValueRef Fn) {
+ LLVMViewFunctionCFGOnly(Fn);
+ return Val_unit;
+}
Modified: llvm/trunk/bindings/ocaml/analysis/llvm_analysis.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/analysis/llvm_analysis.ml?rev=48982&r1=48981&r2=48982&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/analysis/llvm_analysis.ml (original)
+++ llvm/trunk/bindings/ocaml/analysis/llvm_analysis.ml Mon Mar 31 11:22:09 2008
@@ -17,3 +17,6 @@
external assert_valid_function : Llvm.llvalue -> unit
= "llvm_assert_valid_function"
+external view_function_cfg : Llvm.llvalue -> unit = "llvm_view_function_cfg"
+external view_function_cfg_only : Llvm.llvalue -> unit
+ = "llvm_view_function_cfg_only"
Modified: llvm/trunk/bindings/ocaml/analysis/llvm_analysis.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/analysis/llvm_analysis.mli?rev=48982&r1=48981&r2=48982&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/analysis/llvm_analysis.mli (original)
+++ llvm/trunk/bindings/ocaml/analysis/llvm_analysis.mli Mon Mar 31 11:22:09 2008
@@ -33,3 +33,14 @@
[llvm::verifyFunction]. *)
external assert_valid_function : Llvm.llvalue -> unit
= "llvm_assert_valid_function"
+
+(** [view_function_cfg f] opens up a ghostscript window displaying the CFG of
+ the current function with the code for each basic block inside.
+ See [llvm::Function::viewCFG]. *)
+external view_function_cfg : Llvm.llvalue -> unit = "llvm_view_function_cfg"
+
+(** [view_function_cfg_only f] works just like [view_function_cfg], but does not
+ include the contents of basic blocks into the nodes.
+ See [llvm::Function::viewCFGOnly]. *)
+external view_function_cfg_only : Llvm.llvalue -> unit
+ = "llvm_view_function_cfg_only"
Modified: llvm/trunk/include/llvm-c/Analysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Analysis.h?rev=48982&r1=48981&r2=48982&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Analysis.h (original)
+++ llvm/trunk/include/llvm-c/Analysis.h Mon Mar 31 11:22:09 2008
@@ -43,6 +43,10 @@
for debugging. */
int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action);
+/* Open up a ghostview window that displays the CFG of the current function.
+ Useful for debugging. */
+void LLVMViewFunctionCFG(LLVMValueRef Fn);
+void LLVMViewFunctionCFGOnly(LLVMValueRef Fn);
#ifdef __cplusplus
}
Modified: llvm/trunk/lib/Analysis/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?rev=48982&r1=48981&r2=48982&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Analysis.cpp (original)
+++ llvm/trunk/lib/Analysis/Analysis.cpp Mon Mar 31 11:22:09 2008
@@ -33,3 +33,12 @@
static_cast<VerifierFailureAction>(Action));
}
+void LLVMViewFunctionCFG(LLVMValueRef Fn) {
+ Function *F = unwrap<Function>(Fn);
+ F->viewCFG();
+}
+
+void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
+ Function *F = unwrap<Function>(Fn);
+ F->viewCFGOnly();
+}
More information about the llvm-commits
mailing list