[llvm-bugs] [Bug 32416] Compiler crash

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 3 11:10:06 PDT 2017


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

Vedant Kumar <vsk at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |INVALID
                 CC|                            |vsk at apple.com

--- Comment #6 from Vedant Kumar <vsk at apple.com> ---
There doesn't seem to be a compiler bug here: this code violates C's aliasing
rules. A load from a i8* isn't allowed to alias a load from a struct.typeB, so
the compiler throws away the pointer comparison.

Here's the IR:

define i32 @main() local_unnamed_addr #0 {
  %1 = tail call i8* @calloc(i64 1, i64 64)
  %2 = getelementptr inbounds i8, i8* %1, i64 64
  %3 = getelementptr inbounds %struct.typeB, i8* %1, i64 4
  %4 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8],
[19 x i8]* @.str, i64 0, i64 0), i8* %2, %struct.typeB* %3) #3
  tail call void @__assert_rtn(i8* getelementptr inbounds ([6 x i8], [6 x i8]*
@__func__.init1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]*
@.str.1, i64 0, i64 0), i32 34, i8* getelementptr inbounds ([27 x i8], [27 x
i8]* @.str.2, i64 0, i64 0)) #4
  unreachable
}

-- 
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/20170403/9e2ed776/attachment.html>


More information about the llvm-bugs mailing list