HomePhabricator

[x86] change free truncate hook to handle only simple types (PR42880)

Authored by spatel on Aug 3 2019, 2:46 PM.

Description

[x86] change free truncate hook to handle only simple types (PR42880)

This avoids the crash from:
https://bugs.llvm.org/show_bug.cgi?id=42880
...and I think it's a proper constraint for the TLI hook.

But that example raises questions about what happens to get us
into this situation (created i29 types) and what happens later
(why does legalization die on those types), so I'm not sure if
we will resolve the bug based on this change.

llvm-svn: 367766

Details

Committed
spatelAug 3 2019, 2:46 PM
Parents
rG3c805d125a9b: [WebAssembly] Fix allocsize attribute in sjlj lowering
Branches
Unknown
Tags
Unknown

Event Timeline

This causes a compiler hang (I assume infinite loop or deadlock somewhere) when compiling the Linux kernel.

creduce'd reproducer:

struct {
  int : 8;
  int : 3;
  int : 11;
  int : 1;
  int : 1;
  int : 4;
  int : 4;
  int : 4;
  int : 3;
  int : 7;
  int : 1;
  int : 4;
  int : 12;
  int : 1;
  unsigned a : 3
} b;
c(int);
d() { c(b.a + d); }

Bisect results + log:

c9171bd0a955b420d166eed29b22cc62676370af is the first bad commit
commit c9171bd0a955b420d166eed29b22cc62676370af
Author: Sanjay Patel <spatel@rotateright.com>
Date:   Sat Aug 3 21:46:27 2019 +0000

    [x86] change free truncate hook to handle only simple types (PR42880)
    
    This avoids the crash from:
    https://bugs.llvm.org/show_bug.cgi?id=42880
    ...and I think it's a proper constraint for the TLI hook.
    
    But that example raises questions about what happens to get us
    into this situation (created i29 types) and what happens later
    (why does legalization die on those types), so I'm not sure if
    we will resolve the bug based on this change.
    
    llvm-svn: 367766

 llvm/lib/Target/X86/X86ISelLowering.cpp |  2 ++
 llvm/test/CodeGen/X86/shift-combine.ll  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 
git bisect start
# good: [a67d81e4e2fe17e4388599197cd2d8fc0213b52b] [lit] Print internal env commands
git bisect good a67d81e4e2fe17e4388599197cd2d8fc0213b52b
# bad: [305b961f64b75e73110e309341535f6d5a48ed72] [Attributor][NFC] Create some attributes earlier
git bisect bad 305b961f64b75e73110e309341535f6d5a48ed72
# bad: [2c7a8eaf3d3f50cebb0754e4eb56aeb6b7f21631] [OpenMP 5.0] libomptarget interface for declare mapper functions.
git bisect bad 2c7a8eaf3d3f50cebb0754e4eb56aeb6b7f21631
# good: [208e8a1b6623e545a81298519b0235f357e62057] Revert accidental change to __member_pointer_traits_imp.
git bisect good 208e8a1b6623e545a81298519b0235f357e62057
# bad: [fe37499207031f5ca9c276460651871ce7a97ddd] [JITLink] Fix an overly-wide read in the MachO/x86-64 test case.
git bisect bad fe37499207031f5ca9c276460651871ce7a97ddd
# good: [3daccaac8a6b261eaedf76e6eac6011295b08d7e] [JITLink] Add support for MachO/x86-64 UNSIGNED relocs with length=2.
git bisect good 3daccaac8a6b261eaedf76e6eac6011295b08d7e
# bad: [c9171bd0a955b420d166eed29b22cc62676370af] [x86] change free truncate hook to handle only simple types (PR42880)
git bisect bad c9171bd0a955b420d166eed29b22cc62676370af
# good: [3c805d125a9b239a44ee95025b7665496855233b] [WebAssembly] Fix allocsize attribute in sjlj lowering
git bisect good 3c805d125a9b239a44ee95025b7665496855233b
# first bad commit: [c9171bd0a955b420d166eed29b22cc62676370af] [x86] change free truncate hook to handle only simple types (PR42880)

The interestingness test, bisect test, and original preprocessed file can be found here: https://github.com/nathanchance/creduce-files/tree/c52bbfa0738eddc4ef4150f6ddd2e93b415b24e5/c9171bd0a955b420d166eed29b22cc62676370af

spatel added a comment.Aug 5 2019, 4:10 AM

Thanks - working on a fix now. Here's an IR reduction of the C code:

%struct.anon = type { [9 x i8], [3 x i8] }
  
@b = common local_unnamed_addr global %struct.anon zeroinitializer, align 4

define i32 @d() {
  %bf.load = load i72, i72* bitcast (%struct.anon* @b to i72*), align 4
  %bf.lshr = lshr i72 %bf.load, 64
  %t0 = trunc i72 %bf.lshr to i64
  %bf.cast = and i64 %t0, 7
  %add.ptr = getelementptr i8, i8* bitcast (i32 ()* @d to i8*), i64 %bf.cast
  %t1 = ptrtoint i8* %add.ptr to i64
  %t2 = trunc i64 %t1 to i32
  ret i32 %t2
}
spatel added a comment.Aug 5 2019, 5:14 AM

Should be fixed with:
rL367834