[CoroSplit] Use freeze instead of bitcast for dummy instructions
authorNikita Popov <npopov@redhat.com>
Fri, 1 Apr 2022 11:06:44 +0000 (13:06 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 1 Apr 2022 11:07:25 +0000 (13:07 +0200)
Not all types that can appear in arguments can be bitcasts -- in
particular, bitcasts do not support struct types.

llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll

index f111abf..9ac2569 100644 (file)
@@ -878,8 +878,7 @@ void CoroCloner::create() {
   // frame.
   SmallVector<Instruction *> DummyArgs;
   for (Argument &A : OrigF.args()) {
-    DummyArgs.push_back(
-        new BitCastInst(UndefValue::get(A.getType()), A.getType()));
+    DummyArgs.push_back(new FreezeInst(UndefValue::get(A.getType())));
     VMap[&A] = DummyArgs.back();
   }
 
index 499cddb..53a0426 100644 (file)
@@ -5,7 +5,7 @@
 target datalayout = "p:64:64:64"
 
 declare {i8*, i8*, i32} @prototype_f(i8*, i1)
-define {i8*, i8*, i32} @f(i8* %buffer, i32 %n) {
+define {i8*, i8*, i32} @f(i8* %buffer, i32 %n, { i32 } %dummy) {
 ; CHECK-LABEL: @f(
 ; CHECK-NEXT:  coro.return:
 ; CHECK-NEXT:    [[N_VAL_SPILL_ADDR:%.*]] = getelementptr inbounds [[F_FRAME:%.*]], ptr [[BUFFER:%.*]], i64 0, i32 1