[llvm-bugs] [Bug 42932] New: Assertion failed when shifting 1 i128 by 64 and storing it to an internal global, crashes in optimizer

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 8 05:58:41 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42932

            Bug ID: 42932
           Summary: Assertion failed when shifting 1 i128 by 64 and
                    storing it to an internal global, crashes in optimizer
           Product: libraries
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: asterite at gmail.com
                CC: llvm-bugs at lists.llvm.org

Given this ll code in file "foo.ll":

```
@X = internal global i128 0

define i128 @foo(i32 %argc, i8** %argv) {
entry:
  call void @store()
  %0 = load i128, i128* @X, align 8
  ret i128 %0
}

define void @store() {
entry:
  %0 = shl i128 1, 64
  store i128 %0, i128* @X, align 8
  ret void
}
```

When you run this:

```
$ llvm-as foo.ll -o foo.bc
$ opt foo.bc -o foo.bc.opt -O3
```

You get:

```
Assertion failed: (getActiveBits() <= 64 && "Too many bits for uint64_t"),
function getZExtValue, file
/var/cache/omnibus/src/llvm/llvm-6.0.1.src/include/llvm/ADT/APInt.h, line 1545.
0  opt                      0x000000010fb558f4
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  opt                      0x000000010fb54fd4 llvm::sys::RunSignalHandlers() +
83
2  opt                      0x000000010fb55d94 SignalHandler(int) + 237
3  libsystem_platform.dylib 0x00007fff766a1b5d _sigtramp + 29
4  opt                      0x00000001106d2275 llvm::InstrProfError::ID + 64724
5  libsystem_c.dylib        0x00007fff7655b6a6 abort + 127
6  libsystem_c.dylib        0x00007fff7652420d basename_r + 0
7  opt                      0x000000010f137be4
llvm::BitVector::BitVector(unsigned int, bool) + 0
8  opt                      0x000000010f7f9c97
processInternalGlobal(llvm::GlobalVariable*, llvm::GlobalStatus const&,
llvm::TargetLibraryInfo*, llvm::function_ref<llvm::DominatorTree&
(llvm::Function&)>) + 9378
9  opt                      0x000000010f7f774c
processGlobal(llvm::GlobalValue&, llvm::TargetLibraryInfo*,
llvm::function_ref<llvm::DominatorTree& (llvm::Function&)>) + 273
10 opt                      0x000000010f7f6ae6
optimizeGlobalsInModule(llvm::Module&, llvm::DataLayout const&,
llvm::TargetLibraryInfo*, llvm::function_ref<llvm::DominatorTree&
(llvm::Function&)>) + 1656
11 opt                      0x000000010f800fbc (anonymous
namespace)::GlobalOptLegacyPass::runOnModule(llvm::Module&) + 80
12 opt                      0x000000010f77734e
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 618
13 opt                      0x000000010f141a7b main + 8402
14 libdyld.dylib            0x00007fff764b63d5 start + 1
15 libdyld.dylib            0x0000000000000005 start + 2310315057
Stack dump:
0.      Program arguments: opt foo.bc -O3 -o foo.bc.opt
1.      Running pass 'Global Variable Optimizer' on module 'foo.bc'.
Abort trap: 6
```

It seems when trying to optimize the shifting of 1 with type i128 by 64, which
exceeds the maximum capacity of uint64, *but only when later trying to store
that in an internal global* (works fine if it's just global), LLVM crashes.

I am able to confirm that this also crashed in LLVM 6.0.1 and LLVM 8.

Sorry about the component in the bug report, it might not be correct (I'm not
familiar with where code is located).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190808/16724511/attachment-0001.html>


More information about the llvm-bugs mailing list