[StackSafety] Bailout on some function calls
authorVitaly Buka <vitalybuka@google.com>
Wed, 27 May 2020 09:45:43 +0000 (02:45 -0700)
committerVitaly Buka <vitalybuka@google.com>
Wed, 27 May 2020 09:48:42 +0000 (02:48 -0700)
Don't miss values used in calls outside regular argument list.

llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/test/Analysis/StackSafetyAnalysis/local.ll

index 9c937b0..a447326 100644 (file)
@@ -345,12 +345,18 @@ bool StackSafetyLocalAnalysis::analyzeAllUses(Value *Ptr, UseInfo &US) {
         assert(isa<Function>(Callee) || isa<GlobalAlias>(Callee));
 
         auto B = CB.arg_begin(), E = CB.arg_end();
+        int Found = 0;
         for (auto A = B; A != E; ++A) {
           if (A->get() == V) {
+            ++Found;
             ConstantRange Offset = offsetFrom(UI, Ptr);
             US.Calls.emplace_back(Callee, A - B, Offset);
           }
         }
+        if (!Found) {
+          US.updateRange(UnknownRange);
+          return false;
+        }
 
         break;
       }
index eeb7ccb..5dee4b5 100644 (file)
@@ -412,3 +412,15 @@ entry:
   %val = load %zerosize_type, %zerosize_type* %p, align 4
   ret void
 }
+
+define void @OperandBundle() {
+; CHECK-LABEL: @OperandBundle dso_preemptable{{$}}
+; CHECK-NEXT: args uses:
+; CHECK-NEXT: allocas uses:
+; CHECK-NEXT:   a[4]: full-set
+; CHECK-NOT: ]:
+entry:
+  %a = alloca i32, align 4
+  call void @LeakAddress() ["unknown"(i32* %a)]
+  ret void
+}