[llvm] r321662 - [AArch64][GlobalISel] Fix assert fail with unknown intrinsic.

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 2 10:56:39 PST 2018


Author: aemerson
Date: Tue Jan  2 10:56:39 2018
New Revision: 321662

URL: http://llvm.org/viewvc/llvm-project?rev=321662&view=rev
Log:
[AArch64][GlobalISel] Fix assert fail with unknown intrinsic.

A call may have an intrinsic name but not have a valid intrinsic ID,
for example with llvm.invariant.group.barrier. If so, treat it as a
normal call like FastISel does.

Added:
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/unknown-intrinsic.ll
Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp

Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=321662&r1=321661&r2=321662&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Tue Jan  2 10:56:39 2018
@@ -815,7 +815,14 @@ bool IRTranslator::translateCall(const U
   if (CI.isInlineAsm())
     return translateInlineAsm(CI, MIRBuilder);
 
-  if (!F || !F->isIntrinsic()) {
+  Intrinsic::ID ID = Intrinsic::not_intrinsic;
+  if (F && F->isIntrinsic()) {
+    ID = F->getIntrinsicID();
+    if (TII && ID == Intrinsic::not_intrinsic)
+      ID = static_cast<Intrinsic::ID>(TII->getIntrinsicID(F));
+  }
+
+  if (!F || !F->isIntrinsic() || ID == Intrinsic::not_intrinsic) {
     unsigned Res = CI.getType()->isVoidTy() ? 0 : getOrCreateVReg(CI);
     SmallVector<unsigned, 8> Args;
     for (auto &Arg: CI.arg_operands())
@@ -827,10 +834,6 @@ bool IRTranslator::translateCall(const U
     });
   }
 
-  Intrinsic::ID ID = F->getIntrinsicID();
-  if (TII && ID == Intrinsic::not_intrinsic)
-    ID = static_cast<Intrinsic::ID>(TII->getIntrinsicID(F));
-
   assert(ID != Intrinsic::not_intrinsic && "unknown intrinsic");
 
   if (translateKnownIntrinsic(CI, ID, MIRBuilder))

Added: llvm/trunk/test/CodeGen/AArch64/GlobalISel/unknown-intrinsic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/unknown-intrinsic.ll?rev=321662&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/unknown-intrinsic.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/unknown-intrinsic.ll Tue Jan  2 10:56:39 2018
@@ -0,0 +1,10 @@
+; RUN: llc -O0 -mtriple=arm64 < %s
+
+declare i8* @llvm.invariant.group.barrier(i8*)
+
+define i8* @barrier(i8* %p) {
+; CHECK: bl llvm.invariant.group.barrier
+        %q = call i8* @llvm.invariant.group.barrier(i8* %p)
+        ret i8* %q
+}
+




More information about the llvm-commits mailing list