================
@@ -2003,17 +2004,18 @@ class IRBuilderBase {
         new AtomicRMWInst(Op, Ptr, Val, *Align, Ordering, SSID, Elementwise));
   }
 
-  CallInst *CreateStructuredGEP(Type *BaseType, Value *PtrBase,
-                                ArrayRef<Value *> Indices,
-                                const Twine &Name = "") {
+  Value *CreateStructuredGEP(Type *BaseType, Value *PtrBase,
+                             ArrayRef<Value *> Indices,
+                             const Twine &Name = "") {
     SmallVector<Value *> Args;
     Args.push_back(PtrBase);
     llvm::append_range(Args, Indices);
 
-    CallInst *Output = CreateIntrinsic(Intrinsic::structured_gep,
-                                       {PtrBase->getType()}, Args, {}, Name);
-    Output->addParamAttr(
-        0, Attribute::get(getContext(), Attribute::ElementType, BaseType));
+    Value *Output = CreateIntrinsic(Intrinsic::structured_gep,
+                                    {PtrBase->getType()}, Args, {}, Name);
+    if (auto *CI = dyn_cast<CallInst>(Output))
+      CI->addParamAttr(
+          0, Attribute::get(getContext(), Attribute::ElementType, BaseType));
----------------
nikic wrote:

This kind of pattern is unsafe: If the intrinsic folds and the result just 
happens to be a new call, then this will set the attributes on the wrong 
instruction.

The attribute setting either needs to be directly integrated in 
CreateIntrinsinc(), or you need something like CreateIntrinsicWithoutFolding 
that is guaranteed to not fold the intrinsic.

https://github.com/llvm/llvm-project/pull/202738
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to