[PATCH] D12957: Fix "Got assumption for the wrong function!" assert

Artur Pilipenko via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 08:29:59 PDT 2015


apilipenko updated this revision to Diff 35262.
apilipenko added a comment.

Testcase added.


http://reviews.llvm.org/D12957

Files:
  lib/Transforms/Utils/InlineFunction.cpp
  test/Transforms/Inline/align.ll

Index: test/Transforms/Inline/align.ll
===================================================================
--- test/Transforms/Inline/align.ll
+++ test/Transforms/Inline/align.ll
@@ -96,3 +96,20 @@
 
 attributes #0 = { nounwind uwtable }
 
+; This is a regression test. It checks that InlineFunction AddAlignmentAssumptions 
+; passes correct assumption cache to getKnownAlignment. Otherwise this code will 
+; fail with an assertion in computeKnownBitsFromAssume.
+
+; CHECK: define void @caller
+; CHECK-NOT: call i8 @callee
+define void @caller(i8* %a) {
+  call i8 @callee(i8* %a)
+  ret void
+}
+
+declare void @llvm.assume(i1 %cond)
+define i8 @callee(i8* align 8 %a) {
+  call void @llvm.assume(i1 1)
+  %res = load i8, i8* %a
+  ret i8 %res
+}
\ No newline at end of file
Index: lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- lib/Transforms/Utils/InlineFunction.cpp
+++ lib/Transforms/Utils/InlineFunction.cpp
@@ -741,7 +741,7 @@
       // caller, then don't bother inserting the assumption.
       Value *Arg = CS.getArgument(I->getArgNo());
       if (getKnownAlignment(Arg, DL, CS.getInstruction(),
-                            &IFI.ACT->getAssumptionCache(*CalledFunc),
+                            &IFI.ACT->getAssumptionCache(*CS.getCaller()),
                             &DT) >= Align)
         continue;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12957.35262.patch
Type: text/x-patch
Size: 1388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150921/2c1cced4/attachment.bin>


More information about the llvm-commits mailing list