aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2020-04-01 11:36:36 -0700
committerLang Hames <lhames@gmail.com>2020-04-01 12:16:38 -0700
commit8e5a8f620cc2ac2805fce77eddea3405329f90df (patch)
treea5ffa3dd9150d200f382ef19d94b6fe89bcfa88f
parent53e2380881076492b9124d726b6f38a7669c61cd (diff)
downloadllvm-8e5a8f620cc2ac2805fce77eddea3405329f90df.zip
llvm-8e5a8f620cc2ac2805fce77eddea3405329f90df.tar.gz
llvm-8e5a8f620cc2ac2805fce77eddea3405329f90df.tar.bz2
[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.
-rw-r--r--llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp4
-rw-r--r--llvm/test/ExecutionEngine/OrcLazy/Inputs/bar-return-i32-call-foo.ll8
-rw-r--r--llvm/test/ExecutionEngine/OrcLazy/Inputs/foo-return-i32-0.ll (renamed from llvm/test/ExecutionEngine/OrcLazy/Inputs/basic-object-source.ll)0
-rw-r--r--llvm/test/ExecutionEngine/OrcLazy/basic-object-file-loading.ll2
-rw-r--r--llvm/test/ExecutionEngine/OrcLazy/static-library-support.ll12
5 files changed, 18 insertions, 8 deletions
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 @@ Error StaticLibraryDefinitionGenerator::tryToGenerate(
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
index 1efae4e4..1efae4e4 100644
--- a/llvm/test/ExecutionEngine/OrcLazy/Inputs/basic-object-source.ll
+++ b/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
}