changeset 256:7d9b19ec7a62

cbclang output is still wrong
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 18:48:47 +0900
parents 8d0e9910c5b3
children 542e951674e9
files CbC_examples/arg.c CbC_examples/c-next1.c CbC_examples/conv1.c CbC_examples/fact-e.c CbC_examples/test_cs.c clang/lib/CodeGen/CGCall.cpp clang/lib/Parse/ParseCbC.cpp llvm/include/llvm/LinkAllPasses.h llvm/include/llvm/Transforms/Scalar.h llvm/lib/Passes/PassBuilderPipelines.cpp llvm/lib/Transforms/Scalar/SROA.cpp llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
diffstat 12 files changed, 581 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC_examples/arg.c	Fri Aug 18 18:48:47 2023 +0900
@@ -0,0 +1,112 @@
+#include "stdio.h"
+
+#define __environment _CbC_environment
+#define __return _CbC_return
+
+
+struct arg {
+   int a0;int a1;int a2;int a3;int a4;
+};
+
+extern void exit(int); 
+
+void *exit_env;
+__code (*exit___code)();
+
+// #ifndef __llvm__ 
+__code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(int, void*),void *env);
+__code cargs(struct arg args0,__code exit1(int, void*),void *env);
+__code carg4(struct arg args0,struct arg args1,int i, int j,int k,int l);
+__code carg5(struct arg args0,struct arg args1,int i, int j,int k,int l);
+__code carg6(int i, int j,int k,int l,struct arg args0);
+// #endif
+
+__code carg1(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(int, void*),void *env)
+{
+    printf("#0017:arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit___code,env==exit_env);
+    goto carg2(arg1,arg2,arg3,arg4,arg0,exit1,env);
+}
+
+__code carg2(int arg0,int arg1,int arg2,int arg3,int arg4,__code(*exit1)(int, void*),void *env)
+{
+    struct arg args0;
+    printf("#0024:arg1: %d %d %d %d %d : %x %x\n",arg0,arg1,arg2,arg3,arg4,exit1==exit___code,env==exit_env );
+    args0.a0 = arg0;
+    args0.a1 = arg1;
+    args0.a2 = arg2;
+    args0.a3 = arg3;
+    args0.a4 = arg4;
+    goto cargs(args0,exit1,env);
+}
+
+__code cargs(struct arg args0,__code exit1(int, void*),void *env)
+{
+    printf("#0035:args: %d %d %d %d %d : %x %x\n",
+	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,
+    exit1==exit___code,env==exit_env);
+    // goto exit1(321),env;
+    goto (*exit1)(0,env);
+}
+
+
+__code carg3(struct arg args0,struct arg args1,int i, int j,int k,int l)
+{
+    printf("#0045:args3: %d %d %d %d %d : %x %x %x %x\n",
+	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
+    printf("#0047:args3: args0 %d %d %d %d %d : args1 %d %d %d %d %d : %x %x %x %x\n",
+	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,
+	args1.a0,args1.a1,args1.a2,args1.a3,args1.a4,
+	i,j,k,l);
+    if (args0.a0==args1.a0) exit(0);
+    goto carg4(args0,args1,j,k,l,i);
+}
+
+__code carg4(struct arg args0,struct arg args1,int i, int j,int k,int l)
+{
+    printf("#0057:args4: %d %d %d %d %d : %x %x %x %x\n",
+	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
+    goto carg5(args1,args0,j,k,l,i);
+}
+
+__code carg5(struct arg args0,struct arg args1,int i, int j,int k,int l)
+{
+    printf("#0064:args5: %d %d %d %d %d : %x %x %x %x\n",
+	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
+    goto carg6(i,j,k,l,args0);
+}
+
+__code carg6(int i, int j,int k,int l,struct arg args0)
+{
+    printf("#0071:args6: %d %d %d %d %d : %x %x %x %x\n",
+	args0.a0,args0.a1,args0.a2,args0.a3,args0.a4,i,j,k,l);
+    goto carg3(args0,args0,i,j,k,l);
+}
+
+int main1(int n)
+{
+    goto carg1(0,1,2,3,4,exit___code=__return,exit_env=__environment);
+    return n;
+}
+
+struct arg a00;
+struct arg a01;
+
+int main( int ac, char *av[])
+{
+    int n;
+    n = main1(123);
+    printf("#0089:321=%d\n",n);
+
+    a00.a0 = 11;
+    a00.a1 = 22;
+    a00.a2 = 33;
+    a00.a3 = 44;
+    a00.a4 = 55;
+    a01.a0 = 66;
+    a01.a1 = 77;
+    a01.a2 = 88;
+    a01.a3 = 99;
+    a01.a4 = 10;
+    goto carg3(a00,a01,1,2,3,4);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC_examples/c-next1.c	Fri Aug 18 18:48:47 2023 +0900
@@ -0,0 +1,100 @@
+#define NEXT_OP(i) (i->op = *(MVMuint16 *)(i->cur_op), i->cur_op += 2, i->op)
+
+typedef unsigned short MVMuint16;
+typedef unsigned char MVMuint8;
+typedef long* MVMRegister;
+typedef void* MVMCompUnit;
+typedef void* MVMCallsite;
+//typedef void* MVMThreadContext;
+
+typedef struct MVMThreadContext {
+	MVMuint8 **interp_cur_op;
+	MVMuint8 **interp_bytecode_start;
+	MVMRegister **interp_reg_base;
+	MVMCompUnit **interp_cu;  
+} MVMThreadContext;
+
+
+typedef struct interp {
+     MVMuint16 op;
+     /* Points to the place in the bytecode right after the current opcode. */
+     /* See the NEXT_OP macro for making sense of this */
+     MVMuint8 *cur_op;
+
+     /* The current frame's bytecode start. */
+     MVMuint8 *bytecode_start;
+
+     /* Points to the base of the current register set for the frame we
+ *       * are presently in. */
+     MVMRegister *reg_base;
+
+     /* Points to the current compilation unit. */
+     MVMCompUnit *cu;
+
+     /* The current call site we're constructing. */
+     MVMCallsite *cur_callsite;
+
+     MVMThreadContext *tc;
+    
+    //__code (*ret)();
+    //__code (*main_ret)();
+    __code (*ret)(int, void*);
+    __code (*main_ret)(int, void*);
+    void *env;
+
+ } INTER,*INTERP;
+
+__code cbc_no_op(INTERP);
+__code cbc_exit(INTERP);
+
+__code (* CODES[])(INTERP) = {
+   cbc_no_op,
+   cbc_no_op,
+   cbc_exit,
+};
+
+__code cbc_next(INTERP i){
+    __code (*c)(INTERP);
+    c = CODES[NEXT_OP(i)];
+    c(i);
+    goto c(i);
+}
+
+__code cbc_no_op(INTERP i){
+   goto cbc_next(i);
+}
+
+__code cbc_exit(INTERP i){
+   goto i->main_ret(0,i->env);
+}
+
+//__code main_return(int i,stack sp) {
+//    if (loop-->0)
+//        goto f(233,sp);
+//    printf("#0103:%d\n",i);
+//    goto (( (struct main_continuation *)sp)->main_ret)(0,
+//           ((struct main_continuation *)sp)->env);
+//}
+
+int interp_run(MVMThreadContext *tc){
+	INTER inter = {0,0,0,0,0,0,0,0,0};
+	INTERP i  = &inter;
+	MVMuint8 cur_op[] = {0,1,1,0,1,2};
+//	i->ret =  main_return;
+        i->main_ret = _CbC_return;
+        i->env = _CbC_environment;
+	i->cur_op = cur_op;
+
+	tc->interp_cur_op         = &i->cur_op;
+	tc->interp_bytecode_start = &i->bytecode_start;
+	tc->interp_reg_base       = &i->reg_base;
+	tc->interp_cu             = &i->cu;
+        goto cbc_next(i);
+	return 0;
+}
+
+int main(int argc, char **argv){
+   MVMThreadContext tct = {0,0,0,0};
+   MVMThreadContext* tc = &tct;
+   interp_run(tc);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC_examples/conv1.c	Fri Aug 18 18:48:47 2023 +0900
@@ -0,0 +1,246 @@
+#include "stdio.h"
+
+extern int atoi (const char *);
+
+static int loop;
+
+#if 1 // def __micro_c__
+#define CC_ONLY 0
+#else
+#define CC_ONLY 1
+#endif
+
+/* classical function call case (0) */
+int g0(int);
+int h0(int);
+
+int
+f0(int i) {
+    int k,j;
+    k = 3+i;
+    j = g0(i+3);
+    return k+4+j;
+}
+
+int
+g0(int i) {
+    return h0(i+4)+i;
+}
+
+int
+h0(int i) {
+    return i+4;
+}
+
+#if !CC_ONLY
+
+/* straight conversion case (1) */
+
+typedef void *stack;
+
+struct cont_interface { // General Return Continuation
+    __code (*ret)(int, void *);
+};
+
+//#ifndef __llvm__ 
+__code f_g0(int i,int k,stack sp);
+__code f_g1(int j,stack sp);
+__code g(int i,stack sp);
+__code h(int i,stack sp);
+__code f2(int i,char *sp);
+__code g2(int i,int k,int j,char *sp);
+__code h2(int i,int k,char *sp);
+__code main_return2(int i,stack sp);
+__code g2_1(int k,int i,stack *sp);
+__code h2_11(int i,int k,stack *sp);
+//#endif
+
+__code f(int i,stack sp) {
+    int k,j;
+    k = 3+i;
+    goto f_g0(i,k,sp);
+}
+
+struct f_g0_interface {  // Specialized Return Continuation
+    __code (*ret)(int, void *);
+    int i_,k_,j_;
+};
+
+__code f_g1(int j,stack sp);
+
+__code f_g0(int i,int k,stack sp) { // Caller
+    struct f_g0_interface *c = 
+	(struct f_g0_interface *)(sp -= sizeof(struct f_g0_interface));
+
+    c->ret = f_g1;
+    c->k_ = k;
+    c->i_ = i;
+
+    goto g(i+3,sp);
+}
+
+__code f_g1(int j,stack sp) {  // Continuation 
+    struct f_g0_interface *c = (struct f_g0_interface *)sp;
+    int k = c->k_;
+    sp+=sizeof(struct f_g0_interface);
+    c = (struct f_g0_interface *)sp;
+    goto (c->ret)(k+4+j,sp);
+}
+
+__code g_h1(int j,stack sp);
+
+__code g(int i,stack sp) { // Caller
+    struct f_g0_interface *c = 
+	(struct f_g0_interface *)(sp -= sizeof(struct f_g0_interface));
+
+    c->ret = g_h1;
+    c->i_ = i;
+
+    goto h(i+3,sp);
+}
+
+__code g_h1(int j,stack sp) {  // Continuation 
+    struct f_g0_interface *c = (struct f_g0_interface *)sp;
+    int i = c->i_;
+    sp+=sizeof(struct f_g0_interface);
+    c = (struct f_g0_interface *)sp;
+    goto (c->ret)(j+i,sp);
+}
+
+__code h(int i,stack sp) {
+    struct f_g0_interface *c = (struct f_g0_interface *)sp;
+    goto (c->ret)(i+4,sp);
+}
+
+struct main_continuation { // General Return Continuation
+    __code (*ret)(int, void*);
+    __code (*main_ret)(int, void*);
+    void *env;
+};
+
+__code main_return(int i,stack sp) {
+    if (loop-->0)
+	goto f(233,sp);
+    printf("#0103:%d\n",i);
+    goto (( (struct main_continuation *)sp)->main_ret)(0,
+           ((struct main_continuation *)sp)->env);
+}
+
+/* little optimzation without stack continuation (2) */
+
+__code f2(int i,char *sp) {
+    int k,j;
+    k = 3+i;
+    goto g2(i,k,i+3,sp);
+}
+
+__code g2(int i,int k,int j,char *sp) {
+    j = j+4;
+    goto h2(i,k+4+j,sp);
+}
+
+__code h2_1(int i,int k,int j,char *sp) {
+    goto main_return2(i+j,sp);
+}
+
+__code h2(int i,int k,char *sp) {
+    goto h2_1(i,k,i+4,sp);
+}
+
+__code main_return2(int i,stack sp) {
+    if (loop-->0)
+	goto f2(233,sp);
+    printf("#0132:%d\n",i);
+    goto (( (struct main_continuation *)sp)->main_ret)(0,
+           ((struct main_continuation *)sp)->env);
+}
+
+/* little optimizaed case (3) */
+
+__code f2_1(int i,stack *sp) {
+    int k,j;
+    k = 3+i;
+    goto g2_1(k,i+3,sp);
+}
+
+__code g2_1(int k,int i,stack *sp) {
+    goto h2_11(k,i+4,sp);
+}
+
+__code f2_0_1(int k,int j,stack *sp);
+__code h2_1_1(int i,int k,int j,stack *sp) {
+    goto f2_0_1(k,i+j,sp);
+}
+
+__code h2_11(int i,int k,stack *sp) {
+    goto h2_1_1(i,k,i+4,sp);
+}
+
+__code f2_0_1(int k,int j,stack *sp) {
+    goto (( (struct cont_interface *)sp)->ret)(k+4+j,sp);
+}
+
+__code main_return2_1(int i,stack sp) {
+    if (loop-->0)
+        goto f2_1(233,sp);
+    printf("#0165:%d\n",i);
+    goto (( (struct main_continuation *)sp)->main_ret)(0,
+           ((struct main_continuation *)sp)->env);
+}
+
+#define STACK_SIZE 2048
+char main_stack[STACK_SIZE];
+#define stack_last (main_stack+STACK_SIZE)
+
+#endif
+
+#define LOOP_COUNT 10000000
+
+int
+main(int ac,char *av[])
+{
+#if !CC_ONLY
+    struct main_continuation *cont;
+    stack sp = stack_last;
+#endif
+    int sw;
+    int j;
+    if (ac==2) sw = atoi(av[1]);
+    else sw=3;
+
+    if (sw==0) {
+	for(loop=0;loop<LOOP_COUNT;loop++) {
+	   j = f0(233);
+	}
+	printf("#0193:%d\n",j);
+#if !CC_ONLY
+    } else if (sw==1) {
+	loop = LOOP_COUNT;
+	sp -= sizeof(*cont);
+	cont = (struct main_continuation *)sp;
+	cont->ret = main_return;
+	cont->main_ret = _CbC_return;
+	cont->env = _CbC_environment;
+	goto f(233,sp);
+    } else if (sw==2) {
+	loop = LOOP_COUNT;
+	sp -= sizeof(*cont);
+	cont = (struct main_continuation *)sp;
+	cont->ret = main_return2;
+	cont->main_ret = _CbC_return;
+	cont->env = _CbC_environment;
+	goto f2(233,sp);
+    } else if (sw==3) {
+	loop = LOOP_COUNT;
+	sp -= sizeof(*cont);
+	cont = (struct main_continuation *)sp;
+	cont->ret = main_return2_1;
+	cont->main_ret = _CbC_return;
+	cont->env = _CbC_environment;
+	goto f2_1(233,sp);
+#endif
+    }
+return 0;
+}
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC_examples/fact-e.c	Fri Aug 18 18:48:47 2023 +0900
@@ -0,0 +1,48 @@
+#define __environment _CbC_environment
+#define __return _CbC_return
+
+#include "stdio.h"
+#include "stdlib.h"
+
+struct F { int n; int r; int o; void *env; 
+       __code (*next)( struct F );
+       __code (*exit)( struct F );
+   };
+
+__code factorial(struct F arg)
+{
+    if (arg.n<0) {
+	printf("#0008:err %d!\n",arg.n);
+        exit(1);
+	// goto (*exit1)(0,exit1env);
+    }
+    if (arg.n==0)
+	goto arg.next(arg);
+    else {
+	arg.r *= arg.n;
+	arg.n--;
+	goto factorial(arg);
+    }
+}
+
+__code print(struct F arg);
+
+int main( int ac, char *av[])
+{
+    struct F arg;
+    arg.n = atoi(av[1]);
+    // arg.n = 10;
+    arg.r = 1;
+    arg.o = 1;
+    arg.next = print;
+    arg.exit = 0;
+    arg.env = 0;
+    goto factorial(arg);
+}
+
+__code print(struct F arg)
+{
+    printf("#0032:%d! = %d\n",arg.o, arg.r);
+    exit(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC_examples/test_cs.c	Fri Aug 18 18:48:47 2023 +0900
@@ -0,0 +1,58 @@
+//#include<stdio.h>
+//#include<stdlib.h>
+
+typedef unsigned long size_t;
+extern int printf(const char*, ...);
+extern     void exit(int status);
+
+__code cs_exit(int , double , char );
+__code cs1(int, int, int, int);
+__code cs2(double, double, int, double);
+void test_goto(void);
+
+#define ALLOCATE_SIZE 20000000
+#define NEW(type) (type*)(calloc(1, sizeof(type)))
+#define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
+
+extern void *calloc(size_t count, size_t size);
+struct Conext { char c[100]; };
+void (**v) (struct Context*);
+__code (**code) (struct Context*);
+
+int main(int argc, char **argv){
+        v = (void (**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*);
+        code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*);
+	printf("main start\n");
+	//goto cs2(2.22, 3.33, 4, 5.55);
+	test_goto();
+	return 0;
+}
+
+void test_goto(){
+	goto cs1(10, 20, 30, 40);
+}
+
+__code cs1(int a, int b, int c, int d){
+	printf("%4d, %4d, %4d, %4d\n", a, b, c, d);
+	a += 40, b += 40, c += 40, d += 40;
+	goto cs2((double)a, (double)b, c, (double)d);
+}
+
+__code cs2(double a, double b, int c, double d){
+	printf("%4d, %4d, %4d, %4d\n", (int)a, (int)b, (int)c, (int)d);
+	a += 40, b += 40, c += 40, d += 40;
+	goto cs_exit((int)a, b, (char)c);
+}
+
+__code cs_exit(int a, double b, char c){
+	printf("%4d, %4d, %4d\n", (int)a, (int)b, (int)c);
+	printf("cs_exit was called!\n");
+	exit(0);
+}
+
+
+void caller(int a, double b){
+	cs2(b,20.0,a, 40.4);
+	cs1(10,20,30, 40);
+}
+
--- a/clang/lib/CodeGen/CGCall.cpp	Fri Aug 18 12:35:07 2023 +0900
+++ b/clang/lib/CodeGen/CGCall.cpp	Fri Aug 18 18:48:47 2023 +0900
@@ -1887,11 +1887,6 @@
   if (CodeGenOpts.NoImplicitFloat)
     FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat);
 
-#ifndef noCbC
-  if (getLangOpts().HasCodeSegment) {
-        FpKind = "none";
-  }
-#endif
   if (AttrOnCallSite) {
     // Attributes that should go on the call site only.
     // FIXME: Look for 'BuiltinAttr' on the function rather than re-checking
--- a/clang/lib/Parse/ParseCbC.cpp	Fri Aug 18 12:35:07 2023 +0900
+++ b/clang/lib/Parse/ParseCbC.cpp	Fri Aug 18 18:48:47 2023 +0900
@@ -153,12 +153,7 @@
 #include "clang/Lex/Token.h"
 
 bool Parser::isBuiltinSetjmpDefined() {
-  IdentifierInfo *II = PP.getIdentifierInfo("__builtin_setjmp");
-  if (II != nullptr) {
-    int BuiltinID = II->getBuiltinID();
-    return (BuiltinID == Builtin::BI__builtin_setjmp);
-  }
-  return false;
+    return Actions.getASTContext().getTargetInfo().hasSjLjLowering();
 }
 
 /// Prepare__envForGotoWithTheEnvExpr - Prepare __CbC_environment, struct __CbC_env and some necessary statements.
@@ -401,7 +396,7 @@
     Param = CreateParam(0, 1, DeclSpec::TST_void);
     ParamInfo.push_back(DeclaratorChunk::ParamInfo(0, Loc, Param, 0));
     HasProto = true;
-    
+    SmallVector<NamedDecl *, 0> DeclsInPrototype;
     D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto, ESpecType, Loc, ParamInfo.data(),
                                                ParamInfo.size(), EllipsisLoc, Loc, 
                                                RefQualifierIsLValueRef, RefQualifierLoc,
@@ -410,7 +405,9 @@
                                                DynamicExceptions.data(), DynamicExceptionRanges.data(),
                                                DynamicExceptions.size(),
                                                // DynamicExceptions,
-                                               NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, ExceptionSpecTokens, None, Loc, Loc, D, TrailingReturnType,Loc, &FPDS),
+                                               NoexceptExpr.isUsable() ? NoexceptExpr.get() : nullptr, 
+                                               ExceptionSpecTokens, DeclsInPrototype, Loc, Loc, 
+                                               D, TrailingReturnType,Loc, &FPDS),
                   std::move(FnAttrs), Loc);
     PrototypeScope.Exit();
     DSp = &FDS;
@@ -601,11 +598,11 @@
   bool IsDependent = false;
   ParsedAttributes attrs(AttrFactory);
   MultiTemplateParamsArg TParams;
-      
+  Sema::SkipBodyInfo SkipBody; 
   TagOrTempResult = Actions.ActOnTag(getCurScope(), TagType, Sema::TUK_Definition, Loc,
                                      SDS.getTypeSpecScope(), Name, Loc, attrs, AS,
                                      SDS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
-                                     SourceLocation(), false, clang::TypeResult(), false, false);
+                                     SourceLocation(), false, clang::TypeResult(), false, false,OffsetOfState,&SkipBody);
 
   Decl *TagDecl = TagOrTempResult.get();
   PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl, Loc, "parsing struct/union body");
@@ -739,13 +736,15 @@
   IdentifierInfo *envII = CreateIdentifierInfo(__CBC_STRUCT_ENV_NAME, Loc);
   Param = CreateParam(envII, 1, DeclSpec::TST_void);
   ParamInfo.push_back(DeclaratorChunk::ParamInfo(envII, Loc, Param, 0));
+  SmallVector<NamedDecl *, 0> DeclsInPrototype;
 
   D.AddTypeInfo(DeclaratorChunk::getFunction(HasProto, IsAmbiguous, Loc, ParamInfo.data(), ParamInfo.size(), EllipsisLoc, Loc,
                                              RefQualifierIsLValueRef, RefQualifierLoc, 
                                              SourceLocation(),
                                              ESpecType, ESpecRange.getBegin(),
                                              DynamicExceptions.data(), DynamicExceptionRanges.data(), DynamicExceptions.size(),
-                                             NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, ExceptionSpecTokens, None,
+                                             NoexceptExpr.isUsable() ? NoexceptExpr.get() : 0, ExceptionSpecTokens, 
+                                             DeclsInPrototype,
                                              Loc, Loc, D, TrailingReturnType, Loc, &FDS), std::move(FnAttrs), Loc);
   PrototypeScope.Exit();
   
@@ -765,7 +764,7 @@
   StmtResult innerR;
   ExprResult retvalAssginmentExpr,LHS;
   ExprVector ArgExprs;
-  CommaLocsTy CommaLocs;
+  // SourceLocation CommaLocs;
   DeclSpec envDS(AttrFactory);
 
   if (! isBuiltinSetjmpDefined()) {
@@ -848,7 +847,7 @@
   ljLHS = LookupMemberAndBuildExpr(envII, ljLHS.get(), true);
   ljLHS = Actions.ActOnParenExpr(Loc, Loc, ljLHS.get());
   ljArgExprs.push_back(ljLHS.get());
-  CommaLocs.push_back(Loc);
+  // CommaLocs.push_back(Loc);
   ljLHS = Actions.ActOnIntegerConstant(Loc, 1 /* return value for setjmp */);
   ljArgExprs.push_back(ljLHS.get());
   ljExpr = Actions.ActOnCallExpr(getCurScope(), ljExpr.get(), Loc, ljArgExprs, Loc, 0);
@@ -963,12 +962,13 @@
     bool Owned = false;
     bool IsDependent = false;
     MultiTemplateParamsArg TParams;
+    Sema::SkipBodyInfo SkipBody; 
     TagOrTempResult = Actions.ActOnTag(getCurScope(), T, Sema::TUK_Reference, Loc,
                                        SS, Name, Loc, attrs, AS_none,
                                        DS->getModulePrivateSpecLoc(),
                                        TParams, Owned, IsDependent,
                                        SourceLocation(), false,
-                                       clang::TypeResult(), false, false);
+                                       clang::TypeResult(), false, false,OffsetOfState,&SkipBody);
     isInvalid = DS->SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, TagOrTempResult.get(), Owned, Policy);
   }
   else if (T == DeclSpec::TST_typename) {
--- a/llvm/include/llvm/LinkAllPasses.h	Fri Aug 18 12:35:07 2023 +0900
+++ b/llvm/include/llvm/LinkAllPasses.h	Fri Aug 18 18:48:47 2023 +0900
@@ -128,11 +128,7 @@
       (void) llvm::createSafeStackPass();
       (void) llvm::createSROAPass();
       (void) llvm::createSingleLoopExtractorPass();
-#ifndef noCbC
-      (void) llvm::createTailCallEliminationPass(false);
-#else
       (void) llvm::createTailCallEliminationPass();
-#endif
       (void)llvm::createTLSVariableHoistPass();
       (void) llvm::createUnifyFunctionExitNodesPass();
       (void) llvm::createInstCountPass();
--- a/llvm/include/llvm/Transforms/Scalar.h	Fri Aug 18 12:35:07 2023 +0900
+++ b/llvm/include/llvm/Transforms/Scalar.h	Fri Aug 18 18:48:47 2023 +0900
@@ -63,11 +63,7 @@
 //
 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
 //
-#ifndef noCbC
- FunctionPass *createSROAPass(bool PreserveCFG = true);
-#else
- FunctionPass *createSROAPass();
-#endif
+FunctionPass *createSROAPass(bool PreserveCFG = true);
 
 //===----------------------------------------------------------------------===//
 //
@@ -165,11 +161,7 @@
 // TailCallElimination - This pass eliminates call instructions to the current
 // function which occur immediately before return instructions.
 //
-#ifndef noCbC
-FunctionPass *createTailCallEliminationPass(bool isOnlyForCbC);
-#else
- FunctionPass *createTailCallEliminationPass();
-#endif
+FunctionPass *createTailCallEliminationPass();
 
 //===----------------------------------------------------------------------===//
 //
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp	Fri Aug 18 12:35:07 2023 +0900
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp	Fri Aug 18 18:48:47 2023 +0900
@@ -784,7 +784,7 @@
 
 #ifndef noCbC
   FunctionPassManager FPM;
-  FPM.addPass(SROAPass());
+  FPM.addPass(SROAPass(SROAOptions::ModifyCFG));
   FPM.addPass(EarlyCSEPass()); // Catch trivial redundancies.
   FPM.addPass(SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(
       true)));                    // Merge & remove basic blocks.
--- a/llvm/lib/Transforms/Scalar/SROA.cpp	Fri Aug 18 12:35:07 2023 +0900
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp	Fri Aug 18 18:48:47 2023 +0900
@@ -5168,13 +5168,6 @@
     initializeSROALegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
-#ifndef noCbC
-  SROALegacyPass(bool forCbC) : FunctionPass(ID) {
-    onlyForCbC = forCbC;
-    initializeSROALegacyPassPass(*PassRegistry::getPassRegistry());
-  }
-#endif
-
   bool runOnFunction(Function &F) override {
     if (skipFunction(F))
       return false;
@@ -5192,11 +5185,6 @@
     AU.addPreserved<DominatorTreeWrapperPass>();
   }
 
-#ifndef noCbC
-  bool onlyForCbC;
-  bool isOnlyForCbC() { return onlyForCbC; }
-#endif
-
   StringRef getPassName() const override { return "SROA"; }
 };
 
--- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp	Fri Aug 18 12:35:07 2023 +0900
+++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp	Fri Aug 18 18:48:47 2023 +0900
@@ -908,13 +908,6 @@
     initializeTailCallElimPass(*PassRegistry::getPassRegistry());
   }
 
-#ifndef noCbC
-  TailCallElim(bool f) : FunctionPass(ID) {
-    initializeTailCallElimPass(*PassRegistry::getPassRegistry());
-    onlyForCbC = f;
-  }
-#endif
-
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.addRequired<TargetTransformInfoWrapperPass>();
     AU.addRequired<AAResultsWrapperPass>();
@@ -942,12 +935,6 @@
         &getAnalysis<AAResultsWrapperPass>().getAAResults(),
         &getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE(), DTU);
   }
-#ifndef noCbC
-  private:
-    bool onlyForCbC;
-  public:
-    bool isOnlyForCbC();
-#endif
 };
 }
 
@@ -959,16 +946,10 @@
 INITIALIZE_PASS_END(TailCallElim, "tailcallelim", "Tail Call Elimination",
                     false, false)
 
-#ifndef noCbC
 // Public interface to the TailCallElimination pass
-FunctionPass *llvm::createTailCallEliminationPass(bool isOnlyForCbC) {
-  return new TailCallElim(isOnlyForCbC);
-}
-#else
 FunctionPass *llvm::createTailCallEliminationPass() {
   return new TailCallElim();
 }
-#endif
 
 PreservedAnalyses TailCallElimPass::run(Function &F,
                                         FunctionAnalysisManager &AM) {
@@ -992,8 +973,3 @@
   return PA;
 }
 
-#ifndef noCbC
-bool TailCallElim::isOnlyForCbC(){
-   return onlyForCbC;
-}
-#endif