[PATCH] D9400: llvm.noalias - Use noalias intrinsics when inlining (and update them when cloning metadata)

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 10 01:02:56 PDT 2016


majnemer added inline comments.

================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:748-750
@@ +747,5 @@
+      // We also need to clone the metadata in noalias intrinsics.
+      if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(&J))
+        if (II->getIntrinsicID() == Intrinsic::noalias)
+          if (const MDNode *M = dyn_cast<MDNode>(cast<MetadataAsValue>(
+                                  II->getOperand(1))->getMetadata()))
----------------
`const auto *`

================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:839-841
@@ +838,5 @@
+    // Update the metadata referenced by a noalias intrinsic
+    if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(NI))
+      if (II->getIntrinsicID() == Intrinsic::noalias)
+        if (MDNode *M = dyn_cast<MDNode>(cast<MetadataAsValue>(
+                          II->getOperand(1))->getMetadata())) {
----------------
Ditto.

================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:864-865
@@ +863,4 @@
+
+  for (Function::const_arg_iterator I = CalledFunc->arg_begin(),
+       E = CalledFunc->arg_end(); I != E; ++I) {
+    if (I->hasNoAliasAttr() && !I->use_empty())
----------------
I'd use the range variant, `args()`

================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:897
@@ +896,3 @@
+
+    SmallVector<Metadata *, 8> AScopeListEntries(1, AScope);
+    MDNode *AScopeList =
----------------
Does it make sense to hoist this out of the loop and clear it on each iteration?

================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:919
@@ +918,3 @@
+       VMI != VMIE; ++VMI) {
+    if (isa<Instruction>(VMI->first)) {
+      if (!VMI->second)
----------------
You could reduce indentation by doing a `continue;` if `!isa<Instruction>`.

================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:923
@@ +922,3 @@
+
+      Instruction *NI = dyn_cast<Instruction>(VMI->second);
+      if (!NI || !NI->mayReadOrWriteMemory())
----------------
`auto *`


http://reviews.llvm.org/D9400





More information about the llvm-commits mailing list