summaryrefslogtreecommitdiffstats
path: root/llvm/test/ExecutionEngine/MCJIT/weak-function.ll
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-08-08 22:53:37 +0000
committerLang Hames <lhames@gmail.com>2016-08-08 22:53:37 +0000
commit33c0b6bfcaf7579ec552bf4688da33b41f12847a (patch)
treed1a0c09f6e1cb16896eebab4882cd054ac84b7d7 /llvm/test/ExecutionEngine/MCJIT/weak-function.ll
parent30a3d8e402626d275fd18a658324f7c5a14983d2 (diff)
downloadbcm5719-llvm-33c0b6bfcaf7579ec552bf4688da33b41f12847a.tar.gz
bcm5719-llvm-33c0b6bfcaf7579ec552bf4688da33b41f12847a.zip
[RuntimeDyld][Orc][MCJIT] Add partial weak-symbol support to RuntimeDyld.
This patch causes RuntimeDyld to check for existing definitions when it encounters weak symbols. If a definition already exists then the new weak definition is discarded. All symbol lookups within a "logical dylib" should now agree on the address of any given weak symbol. This allows the JIT to better match the behavior of the static linker for C++ code. This support is only partial, as it does not allow strong definitions that occur after the first weak definition (in JIT symbol lookup order) to override the previous weak definitions. Support for this will be added in a future patch. llvm-svn: 278065
Diffstat (limited to 'llvm/test/ExecutionEngine/MCJIT/weak-function.ll')
-rw-r--r--llvm/test/ExecutionEngine/MCJIT/weak-function.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/ExecutionEngine/MCJIT/weak-function.ll b/llvm/test/ExecutionEngine/MCJIT/weak-function.ll
new file mode 100644
index 00000000000..562d6ade33b
--- /dev/null
+++ b/llvm/test/ExecutionEngine/MCJIT/weak-function.ll
@@ -0,0 +1,26 @@
+; RUN: lli -jit-kind=mcjit -extra-module %p/Inputs/weak-function-2.ll %s
+;
+; Check that functions in two different modules agree on the address of weak
+; function 'baz'
+
+define linkonce_odr i32 @baz() {
+entry:
+ ret i32 0
+}
+
+define i8* @foo() {
+entry:
+ ret i8* bitcast (i32 ()* @baz to i8*)
+}
+
+declare i8* @bar()
+
+define i32 @main(i32 %argc, i8** %argv) {
+entry:
+ %call = tail call i8* @foo()
+ %call1 = tail call i8* @bar()
+ %cmp = icmp ne i8* %call, %call1
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
OpenPOWER on IntegriCloud