[PATCH] D46495: Fix assertion in FunctionComparator::cmpInlineAsm

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 5 11:11:47 PDT 2018


nikic created this revision.
nikic added a reviewer: jfb.
Herald added subscribers: llvm-commits, eraman.

Fixes bug https://bugs.llvm.org/show_bug.cgi?id=37339.

InlineAsm is only uniqued if the FunctionTypes are exactly the
same, while cmpTypes() for example considers all pointer types
in the default address space to be the same. For this reason
the end of cmpInlineAsm() can be reached.

This patch replaces the unreachable assertion with a check that
the function types are not identical.


Repository:
  rL LLVM

https://reviews.llvm.org/D46495

Files:
  lib/Transforms/Utils/FunctionComparator.cpp
  test/Transforms/MergeFunc/inline-asm.ll


Index: test/Transforms/MergeFunc/inline-asm.ll
===================================================================
--- /dev/null
+++ test/Transforms/MergeFunc/inline-asm.ll
@@ -0,0 +1,18 @@
+; RUN: opt -mergefunc -S < %s | FileCheck %s
+declare void @stuff()
+
+define void @float_ptr() {
+  call void asm "nop", "r"(float* null)
+  call void @stuff()
+  call void @stuff()
+  ret void
+}
+
+define void @int_ptr() {
+; CHECK-LABEL: @int_ptr
+; CHECK-NEXT: tail call void @float_ptr
+  call void asm "nop", "r"(i32* null)
+  call void @stuff()
+  call void @stuff()
+  ret void
+}
Index: lib/Transforms/Utils/FunctionComparator.cpp
===================================================================
--- lib/Transforms/Utils/FunctionComparator.cpp
+++ lib/Transforms/Utils/FunctionComparator.cpp
@@ -710,7 +710,7 @@
     return Res;
   if (int Res = cmpNumbers(L->getDialect(), R->getDialect()))
     return Res;
-  llvm_unreachable("InlineAsm blocks were not uniqued.");
+  assert(L->getFunctionType() != R->getFunctionType());
   return 0;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46495.145377.patch
Type: text/x-patch
Size: 1047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180505/614251d6/attachment.bin>


More information about the llvm-commits mailing list