[ORC] Don't require a null-terminator on MemoryBuffers for objects in archives.
The MemoryBuffer::getMemBuffer method's RequiresNullTerminator parameter
defaults to true, but object files are not null terminated so we need to
explicitly pass false here.
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index a98445a..50f1ca3 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -349,8 +349,8 @@
MemoryBufferRef ChildBufferRef(ChildBufferInfo.first,
ChildBufferInfo.second);
- if (auto Err =
- L.add(JD, MemoryBuffer::getMemBuffer(ChildBufferRef), VModuleKey()))
+ if (auto Err = L.add(JD, MemoryBuffer::getMemBuffer(ChildBufferRef, false),
+ VModuleKey()))
return Err;
}
diff --git a/llvm/test/ExecutionEngine/OrcLazy/Inputs/bar-return-i32-call-foo.ll b/llvm/test/ExecutionEngine/OrcLazy/Inputs/bar-return-i32-call-foo.ll
new file mode 100644
index 0000000..5a36041
--- /dev/null
+++ b/llvm/test/ExecutionEngine/OrcLazy/Inputs/bar-return-i32-call-foo.ll
@@ -0,0 +1,8 @@
+declare i32 @foo()
+
+define i32 @bar() {
+entry:
+ %0 = call i32 @foo()
+ ret i32 %0
+}
+
diff --git a/llvm/test/ExecutionEngine/OrcLazy/Inputs/basic-object-source.ll b/llvm/test/ExecutionEngine/OrcLazy/Inputs/foo-return-i32-0.ll
similarity index 100%
rename from llvm/test/ExecutionEngine/OrcLazy/Inputs/basic-object-source.ll
rename to llvm/test/ExecutionEngine/OrcLazy/Inputs/foo-return-i32-0.ll
diff --git a/llvm/test/ExecutionEngine/OrcLazy/basic-object-file-loading.ll b/llvm/test/ExecutionEngine/OrcLazy/basic-object-file-loading.ll
index 0d81578..9dc74d5 100644
--- a/llvm/test/ExecutionEngine/OrcLazy/basic-object-file-loading.ll
+++ b/llvm/test/ExecutionEngine/OrcLazy/basic-object-file-loading.ll
@@ -1,4 +1,4 @@
-; RUN: llc -filetype=obj -o %t %p/Inputs/basic-object-source.ll
+; RUN: llc -filetype=obj -o %t %p/Inputs/foo-return-i32-0.ll
; RUN: lli -jit-kind=orc-lazy -extra-object %t %s
;
; Check that we can load an object file and call a function in it.
diff --git a/llvm/test/ExecutionEngine/OrcLazy/static-library-support.ll b/llvm/test/ExecutionEngine/OrcLazy/static-library-support.ll
index 304160c..a134411 100644
--- a/llvm/test/ExecutionEngine/OrcLazy/static-library-support.ll
+++ b/llvm/test/ExecutionEngine/OrcLazy/static-library-support.ll
@@ -1,11 +1,13 @@
; This first line will generate the .o files for the next run line
-; RUN: llc -filetype=obj -o %t.o %p/Inputs/basic-object-source.ll
-; RUN: llvm-ar r %t.a %t.o
-; RUN: lli -jit-kind=orc-lazy -extra-archive %t.a %s
+; RUN: rm -rf %t && mkdir -p %t
+; RUN: llc -filetype=obj -o %t/foo.o %p/Inputs/foo-return-i32-0.ll
+; RUN: llc -filetype=obj -o %t/bar.o %p/Inputs/bar-return-i32-call-foo.ll
+; RUN: llvm-ar r %t/staticlib.a %t/foo.o %t/bar.o
+; RUN: lli -jit-kind=orc-lazy -extra-archive %t/staticlib.a %s
-declare i32 @foo()
+declare i32 @bar()
define i32 @main() {
- %r = call i32 @foo( ) ; <i32> [#uses=1]
+ %r = call i32 @bar() ; <i32> [#uses=1]
ret i32 %r
}