@@ -5203,7 +5203,7 @@ Expression lowerArrayLiteral(ArrayLiteralExp ale, Scope* sc)
52035203{
52045204 const dim = ale.elements ? ale.elements.length : 0;
52055205
5206- Identifier hook = global.params.tracegc ? Id._d_arrayliteralTXTrace : Id._d_arrayliteralTX;
5206+ Identifier hook = Id._d_arrayliteralTX;
52075207 if (!verifyHookExist(ale.loc, *sc, hook, "creating array literals"))
52085208 return null;
52095209
@@ -6425,7 +6425,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
64256425 if (!global.params.useGC || !sc.needsCodegen())
64266426 return;
64276427
6428- auto hook = global.params.tracegc ? Id._d_newitemTTrace : Id._d_newitemT;
6428+ auto hook = Id._d_newitemT;
64296429 if (!verifyHookExist(ne.loc, *sc, hook, "new struct"))
64306430 return;
64316431
@@ -6844,10 +6844,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
68446844 !exp.placement &&
68456845 !exp.onstack && !exp.type.isScopeClass()) // these won't use the GC
68466846 {
6847- /* replace `new T(arguments)` with `core.lifetime._d_newclassT!T(arguments)`
6848- * or `_d_newclassTTrace`
6849- */
6850- auto hook = global.params.tracegc ? Id._d_newclassTTrace : Id._d_newclassT;
6847+ /* replace `new T(arguments)` with `core.lifetime._d_newclassT!T(arguments)` */
6848+ auto hook = Id._d_newclassT;
68516849 if (!verifyHookExist(exp.loc, *sc, hook, "new class"))
68526850 return setError();
68536851
@@ -7032,7 +7030,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
70327030 }
70337031 else if (nargs == 1)
70347032 {
7035- auto hook = global.params.tracegc ? Id._d_newarrayTTrace : Id._d_newarrayT;
7033+ auto hook = Id._d_newarrayT;
70367034 if (!verifyHookExist(exp.loc, *sc, hook, "new array"))
70377035 goto LskipNewArrayLowering;
70387036
@@ -7058,7 +7056,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
70587056 }
70597057 else
70607058 {
7061- auto hook = global.params.tracegc ? Id._d_newarraymTXTrace : Id._d_newarraymTX;
7059+ auto hook = Id._d_newarraymTX;
70627060 if (!verifyHookExist(exp.loc, *sc, hook, "new multi-dimensional array"))
70637061 goto LskipNewArrayLowering;
70647062
@@ -12803,7 +12801,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1280312801 checkDefCtor(ale.loc, tn);
1280412802
1280512803 // Choose correct GC hook
12806- Identifier hook = global.params.tracegc ? Id._d_arraysetlengthTTrace : Id._d_arraysetlengthT;
12804+ Identifier hook = Id._d_arraysetlengthT;
1280712805
1280812806 // Verify the correct hook exists
1280912807 if (!verifyHookExist(exp.loc, *sc, hook, "resizing arrays"))
@@ -13532,12 +13530,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1353213530
1353313531 if (exp.op == EXP.concatenateAssign)
1353413532 {
13535- Identifier hook = global.params.tracegc ? Id._d_arrayappendTTrace : Id._d_arrayappendT;
13533+ Identifier hook = Id._d_arrayappendT;
1353613534
1353713535 if (!verifyHookExist(exp.loc, *sc, hook, "appending array to arrays", Id.object))
1353813536 return setError();
1353913537
13540- // Lower to object._d_arrayappendT{,Trace}({file, line, funcname}, e1, e2)
13538+ // Lower to object._d_arrayappendT( e1, e2)
1354113539 Expression id = new IdentifierExp(exp.loc, Id.empty);
1354213540 id = new DotIdExp(exp.loc, id, Id.object);
1354313541 id = new DotIdExp(exp.loc, id, hook);
@@ -13565,11 +13563,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1356513563 return;
1356613564 }
1356713565
13568- Identifier hook = global.params.tracegc ? Id._d_arrayappendcTXTrace : Id._d_arrayappendcTX;
13566+ Identifier hook = Id._d_arrayappendcTX;
1356913567 if (!verifyHookExist(exp.loc, *sc, hook, "appending element to arrays", Id.object))
1357013568 return setError();
1357113569
13572- // Lower to object._d_arrayappendcTX{,Trace} (e1, 1), e1[$-1]=e2
13570+ // Lower to object._d_arrayappendcTX(e1, 1), e1[$-1]=e2
1357313571 Expression id = new IdentifierExp(exp.loc, Id.empty);
1357413572 id = new DotIdExp(exp.loc, id, Id.object);
1357513573 id = new DotIdExp(exp.loc, id, hook);
@@ -13880,9 +13878,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1388013878 (exp.e2.isStringExp() && (exp.e1.isIntegerExp() || exp.e1.isStringExp())))
1388113879 return exp;
1388213880
13883- bool useTraceGCHook = global.params.tracegc && sc.needsCodegen();
13884-
13885- Identifier hook = useTraceGCHook ? Id._d_arraycatnTXTrace : Id._d_arraycatnTX;
13881+ Identifier hook = Id._d_arraycatnTX;
1388613882 if (!verifyHookExist(exp.loc, *sc, hook, "concatenating arrays"))
1388713883 {
1388813884 setError();
@@ -13903,15 +13899,16 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
1390313899 {
1390413900 Expression lowering = ce.lowering;
1390513901
13906- /* Skip `file`, `line`, and `funcname` if the hook of the parent
13907- * `CatExp` is `_d_arraycatnTXTrace`.
13908- */
1390913902 if (auto callExp = isRuntimeHook(lowering, hook))
1391013903 {
13911- if (hook == Id._d_arraycatnTX)
13912- arguments.pushSlice((*callExp.arguments)[]);
13913- else
13904+ /* Under -profile=gc, the profiling wrapper appends `file`, `line`,
13905+ * and `funcname` default arguments. Strip them when flattening
13906+ * nested concatenations so we don't accumulate stale locations.
13907+ */
13908+ if (global.params.tracegc)
1391413909 arguments.pushSlice((*callExp.arguments)[0 .. $ - 3]);
13910+ else
13911+ arguments.pushSlice((*callExp.arguments)[]);
1391513912 }
1391613913 }
1391713914 else
0 commit comments