[llvm-bugs] [Bug 35899] New: -globals-aa affected by dbg intrinsic leading to different code after instcombine

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 10 23:58:08 PST 2018


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

            Bug ID: 35899
           Summary: -globals-aa affected by dbg intrinsic leading to
                    different code after instcombine
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mikael.holmen at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19650
  --> https://bugs.llvm.org/attachment.cgi?id=19650&action=edit
reproducer

opt -S -o - foo.ll -globals-aa -instcombine
and
opt -S -o - foo.ll -strip-debug -globals-aa -instcombine

yields different results on the attached foo.ll.

We get

define void @foo() {
  store i8 42, i8* @g, align 1
  call void @bar(i8 1)
  %_tmp = load i8, i8* @g, align 1
  call void @gaz(i8 %_tmp)
  ret void
}

and

define void @foo() {
  store i8 42, i8* @g, align 1
  call void @bar(i8 1)
  call void @gaz(i8 42)
  ret void
}

It seems like the

  call void @llvm.dbg.value(metadata i64 0, metadata !6, metadata
!DIExpression()), !dbg !13

in 

define void @bar(i8 %p) {
  call void @llvm.dbg.value(metadata i64 0, metadata !6, metadata
!DIExpression()), !dbg !13
  ret void
}
disturbs -globals-aa then leading to instcombine not doing the optimization.

I don't know -globals-aa at all, but I examined what happened in
GlobalsModRef.cpp a little bit and I found that if I do

-          if (isAllocationFn(&I, &TLI) || isFreeCall(&I, &TLI)) {
+          if (isa<DbgInfoIntrinsic>(I))
+            continue;
+          else if (isAllocationFn(&I, &TLI) || isFreeCall(&I, &TLI)) {

in GlobalsAAResult::AnalyzeCallGraph around line 578 then I don't get the
difference anymore. I've no idea if that's a sane fix or not though.

-- 
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/20180111/a914ab64/attachment.html>


More information about the llvm-bugs mailing list