[PATCH] D68928: Fix clone_constant_impl to correctly deal with null pointers
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 13 09:06:36 PDT 2019
aqjune created this revision.
aqjune added reviewers: jdoerfert, CodaFi, deadalnix.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch resolves llvm-c-test's following error
LLVM ERROR: LLVMGetValueKind returned incorrect type
which arises when the input bitcode contains a null pointer.
Repository:
rL LLVM
https://reviews.llvm.org/D68928
Files:
test/Bindings/llvm-c/echo.ll
tools/llvm-c-test/echo.cpp
Index: tools/llvm-c-test/echo.cpp
===================================================================
--- tools/llvm-c-test/echo.cpp
+++ tools/llvm-c-test/echo.cpp
@@ -326,6 +326,13 @@
EltCount, LLVMIsPackedStruct(Ty));
}
+ // Try ConstantPointerNull
+ if (LLVMIsAConstantPointerNull(Cst)) {
+ check_value_kind(Cst, LLVMConstantPointerNullValueKind);
+ LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
+ return LLVMConstNull(Ty);
+ }
+
// Try undef
if (LLVMIsUndef(Cst)) {
check_value_kind(Cst, LLVMUndefValueValueKind);
Index: test/Bindings/llvm-c/echo.ll
===================================================================
--- test/Bindings/llvm-c/echo.ll
+++ test/Bindings/llvm-c/echo.ll
@@ -21,6 +21,7 @@
@protected = protected global i32 23
@section = global i32 27, section ".custom"
@align = global i32 31, align 4
+ at nullptr = global i32* null
@aliased1 = alias i32, i32* @var
@aliased2 = internal alias i32, i32* @var
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68928.224784.patch
Type: text/x-patch
Size: 992 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191013/7fb9217d/attachment.bin>
More information about the llvm-commits
mailing list