Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading CombinedParsers assert on 1.8 with "Illegal inttoptr" #45702

Closed
KristofferC opened this issue Jun 16, 2022 · 4 comments
Closed

Loading CombinedParsers assert on 1.8 with "Illegal inttoptr" #45702

KristofferC opened this issue Jun 16, 2022 · 4 comments
Assignees
Labels
compiler:llvm For issues that relate to LLVM regression Regression in behavior compared to a previous version upstream The issue is with an upstream dependency, e.g. LLVM

Comments

@KristofferC
Copy link
Member

KristofferC commented Jun 16, 2022

(Running with assertions on)

https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/8b2e406_vs_742b9ab/CombinedParsers.primary.log

julia> using CombinedParsers
[ Info: Precompiling CombinedParsers [5ae71ed2-6f8a-4ed1-b94f-e14e8158f19e]
Illegal inttoptr
          %magicptr = ptrtoint {} addrspace(10)* %132 to i64, !dbg !27

signal (6): Aborted
in expression starting at /home/kc/.julia/packages/CombinedParsers/kbHhW/src/re-parser.jl:42
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
raise at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
runOnFunction at /home/kc/julia1.8/src/llvm-gc-invariant-verifier.cpp:194
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
operator() at /home/kc/julia1.8/src/jitlayers.cpp:515
_ZN4llvm3orc14IRCompileLayer4emitESt10unique_ptrINS0_29MaterializationResponsibilityESt14default_deleteIS3_EENS0_16ThreadSafeModuleE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc31BasicIRLayerMaterializationUnit11materializeESt10unique_ptrINS0_29MaterializationResponsibilityESt14default_deleteIS3_EE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc19MaterializationTask3runEv at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm6detail18UniqueFunctionBaseIvJSt10unique_ptrINS_3orc4TaskESt14default_deleteIS4_EEEE8CallImplIPFvS7_EEEvPvRS7_ at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession12dispatchTaskESt10unique_ptrINS0_4TaskESt14default_deleteIS3_EE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession22dispatchOutstandingMUsEv at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession17OL_completeLookupESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EESt10shared_ptrINS0_23AsynchronousSymbolQueryEESt8functionIFvRKNS_8DenseMapIPNS0_8JITDylibENS_8DenseSetINS0_15SymbolStringPtrENS_12DenseMapInfoISF_EEEENSG_ISD_EENS_6detail12DenseMapPairISD_SI_EEEEEE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc25InProgressFullLookupState8completeESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession19OL_applyQueryPhase1ESt10unique_ptrINS0_21InProgressLookupStateESt14default_deleteIS3_EENS_5ErrorE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupENS0_10LookupKindERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS8_EENS0_15SymbolLookupSetENS0_11SymbolStateENS_15unique_functionIFvNS_8ExpectedINS_8DenseMapINS0_15SymbolStringPtrENS_18JITEvaluatedSymbolENS_12DenseMapInfoISI_EENS_6detail12DenseMapPairISI_SJ_EEEEEEEEESt8functionIFvRKNSH_IS6_NS_8DenseSetISI_SL_EENSK_IS6_EENSN_IS6_SV_EEEEEE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS7_EERKNS0_15SymbolLookupSetENS0_10LookupKindENS0_11SymbolStateESt8functionIFvRKNS_8DenseMapIS5_NS_8DenseSetINS0_15SymbolStringPtrENS_12DenseMapInfoISK_EEEENSL_IS5_EENS_6detail12DenseMapPairIS5_SN_EEEEEE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupERKSt6vectorISt4pairIPNS0_8JITDylibENS0_19JITDylibLookupFlagsEESaIS7_EENS0_15SymbolStringPtrENS0_11SymbolStateE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupENS_8ArrayRefIPNS0_8JITDylibEEENS0_15SymbolStringPtrENS0_11SymbolStateE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
_ZN4llvm3orc16ExecutionSession6lookupENS_8ArrayRefIPNS0_8JITDylibEEENS_9StringRefENS0_11SymbolStateE at /home/kc/julia1.8/usr/bin/../lib/libLLVM-13jl.so (unknown line)
addModule at /home/kc/julia1.8/src/jitlayers.cpp:945
jl_add_to_ee at /home/kc/julia1.8/src/jitlayers.cpp:1238 [inlined]
jl_add_to_ee at /home/kc/julia1.8/src/jitlayers.cpp:1282
jl_add_to_ee at /home/kc/julia1.8/src/jitlayers.cpp:1304 [inlined]
_jl_compile_codeinst at /home/kc/julia1.8/src/jitlayers.cpp:149
jl_generate_fptr_impl at /home/kc/julia1.8/src/jitlayers.cpp:327
jl_compile_method_internal at /home/kc/julia1.8/src/gf.c:2072 [inlined]
jl_compile_method_internal at /home/kc/julia1.8/src/gf.c:2016
_jl_invoke at /home/kc/julia1.8/src/gf.c:2350 [inlined]
ijl_apply_generic at /home/kc/julia1.8/src/gf.c:2540
#Sequence#47 at /home/kc/.julia/packages/CombinedParsers/kbHhW/src/CombinedParsers.jl:993
_jl_invoke at /home/kc/julia1.8/src/gf.c:2339 [inlined]
ijl_apply_generic at /home/kc/julia1.8/src/gf.c:2540
jl_apply at /home/kc/julia1.8/src/julia.h:1838 [inlined]
do_apply at /home/kc/julia1.8/src/builtins.c:730
Sequence at /home/kc/.julia/packages/CombinedParsers/kbHhW/src/CombinedParsers.jl:987
@KristofferC KristofferC added this to the 1.8 milestone Jun 16, 2022
@KristofferC KristofferC added the regression Regression in behavior compared to a previous version label Jun 16, 2022
@JeffBezanson JeffBezanson added the compiler:codegen Generation of LLVM IR and native code label Jun 16, 2022
@vtjnash vtjnash added upstream The issue is with an upstream dependency, e.g. LLVM compiler:llvm For issues that relate to LLVM and removed compiler:codegen Generation of LLVM IR and native code labels Jun 27, 2022
@vtjnash
Copy link
Member

vtjnash commented Jun 27, 2022

Looks like a magicptr is at fault here. Very simple to fix, assuming this won't cause regressions for anyone (which should be very unlikely since it is a very rare case, and early-cse, gvn, or newgvn will usually handle this better anyways):

diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 399fc3baf7aa..53fa6f70a0a0 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -478,7 +478,7 @@ static bool dominatesMergePoint(Value *V, BasicBlock *BB,
 static ConstantInt *GetConstantInt(Value *V, const DataLayout &DL) {
   // Normal constant int.
   ConstantInt *CI = dyn_cast<ConstantInt>(V);
-  if (CI || !isa<Constant>(V) || !V->getType()->isPointerTy())
+  if (CI || !isa<Constant>(V) || !V->getType()->isPointerTy() || DL.isNonIntegralPointerType(V->getType()))
     return CI;
 
   // This is some kind of pointer constant. Turn it into a pointer-sized
diff --git a/llvm/test/Transforms/SimplifyCFG/unprofit2.ll b/llvm/test/Transforms/SimplifyCFG/unprofit2.ll
new file mode 100644
index 000000000000..00c295ddc5c6
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/unprofit2.ll
@@ -0,0 +1,29 @@
+; RUN: opt -simplifycfg -verify -S < %s | FileCheck %s
+; RUN: opt -passes=simplifycfg,verify -S < %s | FileCheck %s
+
+target datalayout = "ni:1"
+
+define void @test_01(i64 addrspace(1)* align 8 %ptr) local_unnamed_addr #0 {
+; CHECK-LABEL: @test_01(
+; CHECK-NOT:   ptrtoint
+; CHECK-NEXT:  icmp eq i64 addrspace(1)* %ptr, null
+; CHECK-NOT:   ptrtoint
+  %cond1 = icmp eq i64 addrspace(1)* %ptr, null
+  %cond2 = icmp eq i64 addrspace(1)* %ptr, null
+  br i1 %cond1, label %true1, label %false1
+
+true1:
+  br i1 %cond2, label %true2, label %false2
+
+false1:
+  store i64 1, i64 addrspace(1)* %ptr, align 8
+  br label %true1
+
+true2:
+  store i64 2, i64 addrspace(1)* %ptr, align 8
+  ret void
+
+false2:
+  store i64 3, i64 addrspace(1)* %ptr, align 8
+  ret void
+}

KristofferC pushed a commit to KristofferC/llvm-project that referenced this issue Jun 30, 2022
@vchuravy
Copy link
Member

@vtjnash can you post this patch to upstream?

@vchuravy
Copy link
Member

Upstream: https://reviews.llvm.org/D128670

@vchuravy vchuravy self-assigned this Jun 30, 2022
vchuravy pushed a commit to JuliaLang/llvm-project that referenced this issue Jun 30, 2022
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Differential Revision: https://reviews.llvm.org/D128670

(cherry picked from commit b904e7e94c5cc9d86762b32211cd0e35670534cb)
vchuravy pushed a commit to JuliaLang/llvm-project that referenced this issue Jun 30, 2022
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Differential Revision: https://reviews.llvm.org/D128670

(cherry picked from commit b904e7e94c5cc9d86762b32211cd0e35670534cb)
@vchuravy
Copy link
Member

Picked up the fix and I am releasing a new binary for LLVM 13 JuliaPackaging/Yggdrasil#5092

@vchuravy vchuravy removed this from the 1.8 milestone Jul 7, 2022
@vtjnash vtjnash closed this as completed Aug 10, 2022
vchuravy pushed a commit to llvm/llvm-project that referenced this issue Aug 15, 2022
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D128670
vchuravy pushed a commit to JuliaLang/llvm-project that referenced this issue Aug 23, 2022
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Differential Revision: https://reviews.llvm.org/D128670

(cherry picked from commit b904e7e94c5cc9d86762b32211cd0e35670534cb)
thilinarmtb pushed a commit to nomp-org/llvm-project that referenced this issue Aug 24, 2022
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D128670
pchintalapudi pushed a commit to JuliaLang/llvm-project that referenced this issue Oct 20, 2022
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Differential Revision: https://reviews.llvm.org/D128670

(cherry picked from commit b904e7e94c5cc9d86762b32211cd0e35670534cb)
vchuravy pushed a commit to JuliaLang/llvm-project that referenced this issue Feb 14, 2023
…ters

SimplifyCFG expects to be able to cast both sides to an int, if either side can be case to an int, but this is not desirable or legal, in general, per D104547.

Spotted in JuliaLang/julia#45702

Differential Revision: https://reviews.llvm.org/D128670

(cherry picked from commit b904e7e94c5cc9d86762b32211cd0e35670534cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:llvm For issues that relate to LLVM regression Regression in behavior compared to a previous version upstream The issue is with an upstream dependency, e.g. LLVM
Projects
None yet
Development

No branches or pull requests

4 participants