aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis/CallGraph
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-09-09 12:40:47 +0000
committerDuncan Sands <baldrick@free.fr>2008-09-09 12:40:47 +0000
commit8f7eaea8167507155306ebc88dfafeaf70b586b9 (patch)
tree84e793a7309ee3a60aa0256992a89cc3c7ef4de9 /test/Analysis/CallGraph
parentf4885935aa8e6114700f20087a30e5d6f256f0a1 (diff)
downloadexternal_llvm-8f7eaea8167507155306ebc88dfafeaf70b586b9.zip
external_llvm-8f7eaea8167507155306ebc88dfafeaf70b586b9.tar.gz
external_llvm-8f7eaea8167507155306ebc88dfafeaf70b586b9.tar.bz2
Correct callgraph construction. It has two problems:
(1) code left over from the days of ConstantPointerRef: if a use of a function is a GlobalValue then that is not considered a reason to add an edge from the external node, even though the use may be as an initializer for an externally visible global! There might be some point to this behaviour when the use is by an alias (though the code predated aliases by some centuries), but I think PR2782 is a better way of handling that. (2) If function F calls function G, and also G is a parameter to the call, then an F->G edge is not added to the callgraph. While this doesn't seem to matter much, adding such an edge makes the callgraph more regular. In addition, the new code should be faster as well as simpler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/CallGraph')
-rw-r--r--test/Analysis/CallGraph/2008-09-09-DirectCall.ll12
-rw-r--r--test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll7
-rw-r--r--test/Analysis/CallGraph/dg.exp3
3 files changed, 22 insertions, 0 deletions
diff --git a/test/Analysis/CallGraph/2008-09-09-DirectCall.ll b/test/Analysis/CallGraph/2008-09-09-DirectCall.ll
new file mode 100644
index 0000000..4f090d5
--- /dev/null
+++ b/test/Analysis/CallGraph/2008-09-09-DirectCall.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | opt -analyze -callgraph -disable-output | grep {Calls function 'callee'} | count 2
+
+define internal void @callee(...) {
+entry:
+ unreachable
+}
+
+define void @caller() {
+entry:
+ call void (...)* @callee( void (...)* @callee )
+ unreachable
+}
diff --git a/test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll b/test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll
new file mode 100644
index 0000000..e37e112
--- /dev/null
+++ b/test/Analysis/CallGraph/2008-09-09-UsedByGlobal.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | opt -analyze -callgraph -disable-output | grep {Calls function}
+
+@a = global void ()* @f ; <void ()**> [#uses=0]
+
+define internal void @f() {
+ unreachable
+}
diff --git a/test/Analysis/CallGraph/dg.exp b/test/Analysis/CallGraph/dg.exp
new file mode 100644
index 0000000..f200589
--- /dev/null
+++ b/test/Analysis/CallGraph/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]