[PATCH] D50530: Added LLVM metadata to generated IR to increase vectorization width

Emmett Neyman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 9 12:54:14 PDT 2018


emmettneyman created this revision.
emmettneyman added reviewers: morehouse, kcc.
Herald added a subscriber: cfe-commits.

Edited `loop_proto_to_llvm` to emit metadata at the end of the generated IR. This metadata will increase the vector width when the IR is optimized.


Repository:
  rC Clang

https://reviews.llvm.org/D50530

Files:
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
===================================================================
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.h
@@ -15,6 +15,8 @@
 #include <cstddef>
 #include <string>
 
+#include "../handle-llvm/input_arrays.h"
+
 namespace clang_fuzzer {
 class LoopFunction;
 
Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===================================================================
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -135,7 +135,11 @@
             << x.statements()
             << "%ctnew = add i64 %ct, 1\n"
             << "%j = icmp eq i64 %ctnew, %s\n"
-            << "br i1 %j, label %end, label %loop\n}\n";
+            << "br i1 %j, label %end, label %loop, !llvm.loop !0\n}\n"
+            << "!0 = distinct !{!0, !1, !2}\n"
+            << "!1 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
+            << "!2 = !{!\"llvm.loop.vectorize.width\", i32 " << kArraySize
+            << "}\n";
 }
 
 // ---------------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50530.159978.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180809/9485fa41/attachment.bin>


More information about the cfe-commits mailing list