[llvm] 8e5a8f6 - [ORC] Don't require a null-terminator on MemoryBuffers for objects in archives.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 12:16:56 PDT 2020
Author: Lang Hames
Date: 2020-04-01T12:16:38-07:00
New Revision: 8e5a8f620cc2ac2805fce77eddea3405329f90df
URL: https://github.com/llvm/llvm-project/commit/8e5a8f620cc2ac2805fce77eddea3405329f90df
DIFF: https://github.com/llvm/llvm-project/commit/8e5a8f620cc2ac2805fce77eddea3405329f90df.diff
LOG: [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.
Added:
llvm/test/ExecutionEngine/OrcLazy/Inputs/bar-return-i32-call-foo.ll
llvm/test/ExecutionEngine/OrcLazy/Inputs/foo-return-i32-0.ll
Modified:
llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
llvm/test/ExecutionEngine/OrcLazy/basic-object-file-loading.ll
llvm/test/ExecutionEngine/OrcLazy/static-library-support.ll
Removed:
llvm/test/ExecutionEngine/OrcLazy/Inputs/basic-object-source.ll
################################################################################
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index a98445a2295e..50f1ca3fe3df 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 000000000000..5a36041640ce
--- /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 0d815782b1cb..9dc74d5241bb 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 304160c7f787..a13441187aa8 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
}
More information about the llvm-commits
mailing list