From 8da547484e9e4a454230a435127720ce9ebc42ea Mon Sep 17 00:00:00 2001 From: Hernan Ponce de Leon Date: Fri, 16 May 2025 13:31:14 +0200 Subject: [PATCH 01/10] Do not print empty/true filters (#888) Signed-off-by: Hernan Ponce de Leon Co-authored-by: Hernan Ponce de Leon --- dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java b/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java index 9bc3099b87..0345cc35b3 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java @@ -7,6 +7,8 @@ import com.dat3m.dartagnan.encoding.IREvaluator; import com.dat3m.dartagnan.encoding.ProverWithTracker; import com.dat3m.dartagnan.expression.ExpressionPrinter; +import com.dat3m.dartagnan.expression.Expression; +import com.dat3m.dartagnan.expression.booleans.BoolLiteral; import com.dat3m.dartagnan.parsers.cat.ParserCat; import com.dat3m.dartagnan.parsers.program.ProgramParser; import com.dat3m.dartagnan.parsers.witness.ParserWitness; @@ -414,8 +416,9 @@ public static ResultSummary generateResultSummary(VerificationTask task, ProverE summary.append(result).append("\n"); } else { // Litmus-specific output format that matches with Herd7 (as good as it can) - if (p.getFilterSpecification() != null) { - summary.append("Filter ").append(p.getFilterSpecification()).append("\n"); + Expression filterSpec = p.getFilterSpecification(); + if (!(filterSpec instanceof BoolLiteral bLit) || !bLit.getValue()) { + summary.append("Filter ").append(filterSpec).append("\n"); } // NOTE: We cannot produce an output that matches herd7 when checking for both program spec and cat properties. From 1703617bf1d855560476ecc5a24cb2ef4d74412b Mon Sep 17 00:00:00 2001 From: Hernan Ponce de Leon Date: Fri, 16 May 2025 18:51:39 +0200 Subject: [PATCH 02/10] Improve C litmus grammar (#887) Signed-off-by: Hernan Ponce de Leon Co-authored-by: Hernan Ponce de Leon --- dartagnan/src/main/antlr4/C11Lexer.g4 | 4 ++-- dartagnan/src/main/antlr4/LitmusC.g4 | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dartagnan/src/main/antlr4/C11Lexer.g4 b/dartagnan/src/main/antlr4/C11Lexer.g4 index 9497948dd0..8807a9ca40 100644 --- a/dartagnan/src/main/antlr4/C11Lexer.g4 +++ b/dartagnan/src/main/antlr4/C11Lexer.g4 @@ -7,9 +7,9 @@ C11AtomicStore : 'atomic_store'; C11AtomicXchgExplicit : 'atomic_exchange_explicit'; C11AtomicXchg : 'atomic_exchange'; C11AtomicSCASExplicit : 'atomic_compare_exchange_strong_explicit'; -C11AtomicSCAS : 'atomic_compare_exchange_strong'; +C11AtomicSCAS : 'atomic_compare_exchange_strong' | 'SCAS'; C11AtomicWCASExplicit : 'atomic_compare_exchange_weak_explicit'; -C11AtomicWCAS : 'atomic_compare_exchange_weak'; +C11AtomicWCAS : 'atomic_compare_exchange_weak' | 'WCAS'; C11AtomicFence : 'atomic_thread_fence'; C11AtomicAddExplicit : 'atomic_fetch_add_explicit'; C11AtomicAdd : 'atomic_fetch_add'; diff --git a/dartagnan/src/main/antlr4/LitmusC.g4 b/dartagnan/src/main/antlr4/LitmusC.g4 index 95b08d7a5e..f3b7660725 100644 --- a/dartagnan/src/main/antlr4/LitmusC.g4 +++ b/dartagnan/src/main/antlr4/LitmusC.g4 @@ -13,7 +13,7 @@ main ; variableDeclaratorList - : LBrace (globalDeclarator Semi comment?)* RBrace (Semi)? + : LBrace (globalDeclarator Semi comment?)* (globalDeclarator comment?)? RBrace Semi? ; globalDeclarator @@ -193,6 +193,7 @@ nre locals [IntBinaryOp op, String mo, String name] | C11AtomicStore LPar address = re Comma value = re RPar # nreC11Store | Ast? varName Equals re # nreAssignment + | re # reAsNre | typeSpecifier varName (Equals re)? # nreRegDeclaration | SpinLock LPar address = re RPar # nreSpinLock @@ -247,6 +248,8 @@ opCompare returns [IntCmpOp op] opArith returns [IntBinaryOp op] : Plus {$op = IntBinaryOp.ADD;} | Minus {$op = IntBinaryOp.SUB;} + | Ast {$op = IntBinaryOp.MUL;} + | Slash {$op = IntBinaryOp.DIV;} | Amp {$op = IntBinaryOp.AND;} | Bar {$op = IntBinaryOp.OR;} | Circ {$op = IntBinaryOp.XOR;} From ec94ec8a8ae01761c156a63bf2c9fb04685861be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Maseli?= Date: Sat, 17 May 2025 20:43:42 +0200 Subject: [PATCH 03/10] Add warnings for empty pointer sets in FieldSensitiveAndersen and AndersenAliasAnalysis. (#890) --- .../analysis/alias/AndersenAliasAnalysis.java | 8 ++++++++ .../analysis/alias/FieldSensitiveAndersen.java | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/AndersenAliasAnalysis.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/AndersenAliasAnalysis.java index d268a4f256..03a4e37c98 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/AndersenAliasAnalysis.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/AndersenAliasAnalysis.java @@ -5,6 +5,7 @@ import com.dat3m.dartagnan.expression.integers.IntLiteral; import com.dat3m.dartagnan.program.Program; import com.dat3m.dartagnan.program.Register; +import com.dat3m.dartagnan.program.analysis.SyntacticContextAnalysis; import com.dat3m.dartagnan.program.event.MemoryEvent; import com.dat3m.dartagnan.program.event.RegWriter; import com.dat3m.dartagnan.program.event.core.Local; @@ -12,6 +13,8 @@ import com.dat3m.dartagnan.program.event.core.Store; import com.dat3m.dartagnan.program.memory.MemoryObject; import com.google.common.base.Preconditions; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.google.common.base.Verify; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -38,6 +41,9 @@ */ public class AndersenAliasAnalysis implements AliasAnalysis { + // For providing helpful error messages, this analysis prints call-stack and loop information for events. + private final Supplier synContext; + ///When a pointer set gains new content, it is added to this queue private final Queue variables = new ArrayDeque<>(); ///Super set of all pointer sets in this analysis @@ -52,6 +58,7 @@ public class AndersenAliasAnalysis implements AliasAnalysis { private AndersenAliasAnalysis(Program program) { Preconditions.checkArgument(program.isCompiled(), "The program must be compiled first."); + synContext = Suppliers.memoize(() -> SyntacticContextAnalysis.newInstance(program)); ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); for (MemoryObject a : program.getMemory().getObjects()) { if (!a.hasKnownSize()) { @@ -257,6 +264,7 @@ private void processResults(MemoryCoreEvent e) { } } if (addresses.isEmpty()) { + logger.warn("Empty pointer set for {}", synContext.get().getContextInfo(e)); addresses = maxAddressSet; } eventAddressSpaceMap.put(e, ImmutableSet.copyOf(addresses)); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/FieldSensitiveAndersen.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/FieldSensitiveAndersen.java index 679c2ddf61..74cb229123 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/FieldSensitiveAndersen.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/FieldSensitiveAndersen.java @@ -9,12 +9,15 @@ import com.dat3m.dartagnan.expression.misc.ITEExpr; import com.dat3m.dartagnan.program.Program; import com.dat3m.dartagnan.program.Register; +import com.dat3m.dartagnan.program.analysis.SyntacticContextAnalysis; import com.dat3m.dartagnan.program.event.Event; import com.dat3m.dartagnan.program.event.MemoryEvent; import com.dat3m.dartagnan.program.event.RegWriter; import com.dat3m.dartagnan.program.event.core.*; import com.dat3m.dartagnan.program.event.core.threading.ThreadArgument; import com.dat3m.dartagnan.program.memory.MemoryObject; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import org.sosy_lab.common.configuration.Configuration; @@ -45,6 +48,9 @@ */ public class FieldSensitiveAndersen implements AliasAnalysis { + // For providing helpful error messages, this analysis prints call-stack and loop information for events. + private final Supplier synContext; + ///When a pointer set gains new content, it is added to this queue private final LinkedHashSet variables = new LinkedHashSet<>(); @@ -61,12 +67,14 @@ public class FieldSensitiveAndersen implements AliasAnalysis { // ================================ Construction ================================ public static FieldSensitiveAndersen fromConfig(Program program, Configuration config) throws InvalidConfigurationException { - var analysis = new FieldSensitiveAndersen(); + var analysis = new FieldSensitiveAndersen(program); analysis.run(program); return analysis; } - private FieldSensitiveAndersen() { } + private FieldSensitiveAndersen(Program p) { + synContext = Suppliers.memoize(() -> SyntacticContextAnalysis.newInstance(p)); + } // ================================ API ================================ @@ -189,6 +197,10 @@ protected void processResults(MemoryCoreEvent e) { for (Offset r : collector.register()) { addresses.addAll(fields(getAddresses(r.base), r.offset, r.alignment)); } + Set set = addresses.build(); + if (set.isEmpty()) { + logger.warn("Empty pointer set for {}", synContext.get().getContextInfo(e)); + } eventAddressSpaceMap.put(e, addresses.build()); } From ece1b56de4fc2561f610db69cdef143eb1ce098e Mon Sep 17 00:00:00 2001 From: Hernan Ponce de Leon Date: Tue, 20 May 2025 09:26:14 +0200 Subject: [PATCH 04/10] Fixes to cat grammar (#891) Signed-off-by: Hernan Ponce de Leon Co-authored-by: Hernan Ponce de Leon --- dartagnan/src/main/antlr4/Cat.g4 | 11 ++++++----- .../com/dat3m/dartagnan/parsers/cat/VisitorCat.java | 10 +++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dartagnan/src/main/antlr4/Cat.g4 b/dartagnan/src/main/antlr4/Cat.g4 index c5f899f394..d1494b4253 100755 --- a/dartagnan/src/main/antlr4/Cat.g4 +++ b/dartagnan/src/main/antlr4/Cat.g4 @@ -5,7 +5,7 @@ import com.dat3m.dartagnan.wmm.axiom.*; } mcm - : (NAME)? (QUOTED_STRING)? (definition | include | show)+ EOF + : (NAME)* (QUOTED_STRING)? (definition | include | show)+ EOF ; definition @@ -16,9 +16,9 @@ definition ; axiomDefinition locals [Class cls] - : (flag = FLAG)? (negate = NOT)? ACYCLIC { $cls = Acyclicity.class; } e = expression (AS NAME)? - | (flag = FLAG)? (negate = NOT)? IRREFLEXIVE { $cls = Irreflexivity.class; } e = expression (AS NAME)? - | (flag = FLAG)? (negate = NOT)? EMPTY { $cls = Emptiness.class; } e = expression (AS NAME)? + : (flag = FLAG | undef = UNDEFINED)? (negate = NOT)? ACYCLIC { $cls = Acyclicity.class; } e = expression (AS NAME)? + | (flag = FLAG | undef = UNDEFINED)? (negate = NOT)? IRREFLEXIVE { $cls = Irreflexivity.class; } e = expression (AS NAME)? + | (flag = FLAG | undef = UNDEFINED)? (negate = NOT)? EMPTY { $cls = Emptiness.class; } e = expression (AS NAME)? ; letFuncDefinition @@ -62,7 +62,7 @@ include ; show - : SHOW expression (AS NAME)? + : SHOW expression (AS NAME)? (COMMA expression (AS NAME)?)* ; parameterList @@ -108,6 +108,7 @@ RANGE : 'range'; NEW : 'new'; FLAG : 'flag'; +UNDEFINED : 'undefined_unless'; QUOTED_STRING : '"' .*? '"'; diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/cat/VisitorCat.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/cat/VisitorCat.java index 0c1468565a..71a4e8a2d9 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/cat/VisitorCat.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/cat/VisitorCat.java @@ -116,9 +116,13 @@ public Void visitAxiomDefinition(AxiomDefinitionContext ctx) { try { Relation r = parseAsRelation(ctx.e); Constructor constructor = ctx.cls.getConstructor(Relation.class, boolean.class, boolean.class); - Axiom axiom = (Axiom) constructor.newInstance(r, ctx.negate != null, ctx.flag != null); - if (ctx.NAME() != null) { - axiom.setName(ctx.NAME().toString()); + boolean negate = ctx.negate != null ^ ctx.undef != null; + boolean flag = ctx.flag != null || ctx.undef != null; + Axiom axiom = (Axiom) constructor.newInstance(r, negate, flag); + String name = ctx.NAME() != null ? ctx.NAME().toString() : ""; + name += ctx.undef != null ? " (*undef*)" : ""; + if (!name.isEmpty()) { + axiom.setName(name); } wmm.addConstraint(axiom); } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | From 55590d7c7416b9e3075370d45dadcd9999f06a6e Mon Sep 17 00:00:00 2001 From: Thomas Haas Date: Thu, 22 May 2025 12:37:53 +0200 Subject: [PATCH 05/10] SCCP across threads and better allocation of thread-local variables (#892) --- .../SparseConditionalConstantPropagation.java | 6 ++ .../program/processing/ThreadCreation.java | 63 ++++++++++++++----- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/SparseConditionalConstantPropagation.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/SparseConditionalConstantPropagation.java index a0242575dc..4c170c73d7 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/SparseConditionalConstantPropagation.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/SparseConditionalConstantPropagation.java @@ -15,6 +15,7 @@ import com.dat3m.dartagnan.program.event.core.CondJump; import com.dat3m.dartagnan.program.event.core.Label; import com.dat3m.dartagnan.program.event.core.Local; +import com.dat3m.dartagnan.program.event.core.threading.ThreadArgument; import com.dat3m.dartagnan.program.memory.MemoryObject; import com.google.common.base.Preconditions; import org.apache.logging.log4j.LogManager; @@ -133,6 +134,11 @@ public void run(Function func) { final Expression expr = local.getExpr(); final Expression valueToPropagate = checkDoPropagate.test(expr) ? expr : null; propagationMap.compute(local.getResultRegister(), (k, v) -> valueToPropagate); + } else if (cur instanceof ThreadArgument arg) { + // Propagate constant arguments passed across threads + final Expression expr = arg.getCreator().getArguments().get(arg.getIndex()); + final Expression valueToPropagate = expr.getRegs().isEmpty() ? expr : null; + propagationMap.compute(arg.getResultRegister(), (k, v) -> valueToPropagate); } if (cur instanceof CondJump jump) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/ThreadCreation.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/ThreadCreation.java index a50033e4a3..347537bbcb 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/ThreadCreation.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/ThreadCreation.java @@ -271,7 +271,7 @@ private ThreadData createLLVMThreadFromFunction(Function function, int tid, Thre thread.getEntry().insertAfter(body); // ------------------- Create thread-local variables ------------------- - replaceGlobalsByThreadLocals(function.getProgram().getMemory(), thread); + replaceThreadLocalsWithStackalloc(function.getProgram().getMemory(), thread); // ------------------- Add end & return label ------------------- final Register returnRegister = function.hasReturnValue() ? @@ -334,25 +334,60 @@ private ThreadData createLLVMThreadFromFunction(Function function, int tid, Thre return new ThreadData(thread, null); } - private void replaceGlobalsByThreadLocals(Memory memory, Thread thread) { + + private void replaceThreadLocalsWithStackalloc(Memory memory, Thread thread) { + final TypeFactory types = TypeFactory.getInstance(); + final ExpressionFactory exprs = ExpressionFactory.getInstance(); + + // Translate thread-local memory object to local stack allocation + Map toLocalRegister = new HashMap<>(); + for (MemoryObject memoryObject : memory.getObjects()) { + if (!memoryObject.isThreadLocal()) { + continue; + } + Preconditions.checkState(memoryObject.hasKnownSize()); + + // Compute type of memory object based on initial values + final List contentTypes = new ArrayList<>(); + final List offsets = new ArrayList<>(); + for (Integer initOffset : memoryObject.getInitializedFields()) { + contentTypes.add(memoryObject.getInitialValue(initOffset).getType()); + offsets.add(initOffset); + } + final Type memoryType = types.getAggregateType(contentTypes, offsets); + + // Allocate single object of memory type + final Register reg = thread.newUniqueRegister("__threadLocal_" + memoryObject, types.getPointerType()); + final Event localAlloc = EventFactory.newAlloc( + reg, memoryType, expressions.makeOne(types.getArchType()), + false, true + ); + + // Initialize allocated object with regular stores. + final List initialization = new ArrayList<>(); + for (Integer initOffset : memoryObject.getInitializedFields()) { + initialization.add(EventFactory.newStore( + exprs.makeAdd(reg, exprs.makeValue(initOffset, types.getArchType())), + memoryObject.getInitialValue(initOffset) + )); + } + + // Insert new code & update + thread.getEntry().insertAfter(eventSequence(localAlloc, initialization)); + toLocalRegister.put(memoryObject, reg); + } + + // Replace all usages of thread-local memory object by register containing the address to the local allocation. final ExprTransformer transformer = new ExprTransformer() { - final Map global2ThreadLocal = new HashMap<>(); @Override public Expression visitMemoryObject(MemoryObject memObj) { - if (memObj.isThreadLocal() && !global2ThreadLocal.containsKey(memObj)) { - Preconditions.checkState(memObj.hasKnownSize()); - final MemoryObject threadLocalCopy = memory.allocate(memObj.getKnownSize()); - assert memObj.hasName(); - final String varName = String.format("%s@T%s", memObj.getName(), thread.getId()); - threadLocalCopy.setName(varName); - for (int field : memObj.getInitializedFields()) { - threadLocalCopy.setInitialValue(field, memObj.getInitialValue(field)); - } - global2ThreadLocal.put(memObj, threadLocalCopy); + if (toLocalRegister.containsKey(memObj)) { + return toLocalRegister.get(memObj); } - return global2ThreadLocal.getOrDefault(memObj, memObj); + return memObj; } }; + thread.getEvents(RegReader.class).forEach(reader -> reader.transformExpressions(transformer)); // TODO: After creating all thread-local copies, we might want to delete the original variable? } From 4d6e80d54fc2c4a5f4516ab1daeaad7bc2a27e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Maseli?= Date: Fri, 23 May 2025 08:47:51 +0200 Subject: [PATCH 06/10] Generic LKMM Intrinsics (#889) Co-authored-by: Thomas Haas Co-authored-by: Thomas Haas --- .../lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c | 4 +- benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c | 12 +- .../lkmm/C-atomic-op-return-simple-02-2.c | 2 +- dartagnan/src/main/antlr4/LitmusC.g4 | 24 +- .../dat3m/dartagnan/program/event/Tag.java | 32 +- .../program/processing/Intrinsics.java | 135 ++- .../test/resources/lkmm/2+2W+onces+locked.ll | 377 +++---- .../lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.ll | 372 ++++--- .../C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.ll | 919 ++++++++++-------- .../lkmm/C-WWC+o-branch-o+o-branch-o.ll | 482 +++++---- .../lkmm/C-atomic-op-return-simple-02-2.ll | 421 ++++---- .../test/resources/lkmm/CoRR+poonce+Once.ll | 329 ++++--- .../test/resources/lkmm/CoRW+poonce+Once.ll | 317 +++--- .../resources/lkmm/CoWR+poonceonce+Once.ll | 317 +++--- .../lkmm/LB+fencembonceonce+ctrlonceonce.ll | 369 ++++--- .../lkmm/LB+poacquireonce+pooncerelease.ll | 339 ++++--- .../src/test/resources/lkmm/LB+poonceonces.ll | 339 ++++--- .../MP+fencewbonceonce+fencermbonceonce.ll | 347 ++++--- .../test/resources/lkmm/NVR-RMW+Release.ll | 415 ++++---- .../test/resources/lkmm/qspinlock-fixed.ll | 393 ++++---- .../test/resources/lkmm/qspinlock-liveness.ll | 407 ++++---- .../src/test/resources/lkmm/qspinlock.ll | 396 ++++---- .../test/resources/lkmm/rcu+ar-link-short0.ll | 503 +++++----- .../src/test/resources/lkmm/rcu+ar-link0.ll | 661 +++++++------ .../src/test/resources/lkmm/rcu+ar-link20.ll | 505 +++++----- dartagnan/src/test/resources/lkmm/rcu-MP.ll | 327 ++++--- dartagnan/src/test/resources/lkmm/rcu-gp20.ll | 351 ++++--- dartagnan/src/test/resources/lkmm/rcu.ll | 353 ++++--- include/lkmm.h | 175 ++-- 29 files changed, 5447 insertions(+), 4176 deletions(-) diff --git a/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c b/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c index c6bdd1c058..5e6bb2b26a 100644 --- a/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c +++ b/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c @@ -10,7 +10,7 @@ int r0,r1; void *thread_1(void *arg) { - WRITE_ONCE(x, 1); + atomic_set(&x, 1); r0 = atomic_xchg_release(&y, 5); return NULL; } @@ -19,7 +19,7 @@ void *thread_2(void *arg) { atomic_inc(&y); smp_mb(); - r1 = READ_ONCE(x); + r1 = atomic_read(&x); return NULL; } diff --git a/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c b/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c index a4e96e1a4a..83e844d980 100644 --- a/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c +++ b/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c @@ -14,27 +14,27 @@ int r4_1; void *thread_1(void *unused) { - r1_0 = READ_ONCE(x); + r1_0 = atomic_read(&x); r3_0 = (r1_0 != 0); if (r3_0) { - WRITE_ONCE(y, 1); + atomic_set(&y, 1); } return NULL; } void *thread_2(void *unused) { - r2_1 = READ_ONCE(y); + r2_1 = atomic_read(&y); r4_1 = (r2_1 != 0); if (r4_1) { - WRITE_ONCE(x, 1); + atomic_set(&x, 1); } return NULL; } void *thread_3(void *unused) { - WRITE_ONCE(x, 2); + atomic_set(&x, 2); return NULL; } @@ -50,7 +50,7 @@ int main() pthread_join(t2, NULL); pthread_join(t3, NULL); - assert(!(r1_0 == 2 && r2_1 == 1 && READ_ONCE(x) == 2)); + assert(!(r1_0 == 2 && r2_1 == 1 && atomic_read(&x) == 2)); return 0; } diff --git a/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c b/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c index a5e4165626..2d4df33087 100644 --- a/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c +++ b/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c @@ -36,7 +36,7 @@ int main() pthread_join(t1, NULL); pthread_join(t2, NULL); - assert(!(r0_0 == 1 && r1_0 == 0 && r0_1 == 1 && r1_1 == 0 && READ_ONCE(x) == 1 && READ_ONCE(y) == 1)); + assert(!(r0_0 == 1 && r1_0 == 0 && r0_1 == 1 && r1_1 == 0 && atomic_read(&x) == 1 && atomic_read(&y) == 1)); return 0; } diff --git a/dartagnan/src/main/antlr4/LitmusC.g4 b/dartagnan/src/main/antlr4/LitmusC.g4 index f3b7660725..3e80a23e1b 100644 --- a/dartagnan/src/main/antlr4/LitmusC.g4 +++ b/dartagnan/src/main/antlr4/LitmusC.g4 @@ -67,19 +67,19 @@ whileExpression re locals [IntBinaryOp op, String mo] : ( AtomicAddReturn LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_MB;} - | AtomicAddReturnRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELAXED;} + | AtomicAddReturnRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ONCE;} | AtomicAddReturnAcquire LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ACQUIRE;} | AtomicAddReturnRelease LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELEASE;} | AtomicSubReturn LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_MB;} - | AtomicSubReturnRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELAXED;} + | AtomicSubReturnRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ONCE;} | AtomicSubReturnAcquire LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ACQUIRE;} | AtomicSubReturnRelease LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELEASE;} | AtomicIncReturn LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_MB;} - | AtomicIncReturnRelaxed LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELAXED;} + | AtomicIncReturnRelaxed LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ONCE;} | AtomicIncReturnAcquire LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ACQUIRE;} | AtomicIncReturnRelease LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELEASE;} | AtomicDecReturn LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_MB;} - | AtomicDecReturnRelaxed LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELAXED;} + | AtomicDecReturnRelaxed LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ONCE;} | AtomicDecReturnAcquire LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ACQUIRE;} | AtomicDecReturnRelease LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELEASE;}) # reAtomicOpReturn @@ -95,29 +95,29 @@ re locals [IntBinaryOp op, String mo] | C11AtomicAnd LPar address = re Comma value = re RPar {$op = IntBinaryOp.AND;}) # C11AtomicOp | ( AtomicFetchAdd LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_MB;} - | AtomicFetchAddRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELAXED;} + | AtomicFetchAddRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ONCE;} | AtomicFetchAddAcquire LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ACQUIRE;} | AtomicFetchAddRelease LPar value = re Comma address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELEASE;} | AtomicFetchSub LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_MB;} - | AtomicFetchSubRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELAXED;} + | AtomicFetchSubRelaxed LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ONCE;} | AtomicFetchSubAcquire LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ACQUIRE;} | AtomicFetchSubRelease LPar value = re Comma address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELEASE;} | AtomicFetchInc LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_MB;} - | AtomicFetchIncRelaxed LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELAXED;} + | AtomicFetchIncRelaxed LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ONCE;} | AtomicFetchIncAcquire LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_ACQUIRE;} | AtomicFetchIncRelease LPar address = re RPar {$op = IntBinaryOp.ADD; $mo = Linux.MO_RELEASE;} | AtomicFetchDec LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_MB;} - | AtomicFetchDecRelaxed LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELAXED;} + | AtomicFetchDecRelaxed LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ONCE;} | AtomicFetchDecAcquire LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_ACQUIRE;} | AtomicFetchDecRelease LPar address = re RPar {$op = IntBinaryOp.SUB; $mo = Linux.MO_RELEASE;}) # reAtomicFetchOp | ( AtomicXchg LPar address = re Comma value = re RPar {$mo = Linux.MO_MB;} - | AtomicXchgRelaxed LPar address = re Comma value = re RPar {$mo = Linux.MO_RELAXED;} + | AtomicXchgRelaxed LPar address = re Comma value = re RPar {$mo = Linux.MO_ONCE;} | AtomicXchgAcquire LPar address = re Comma value = re RPar {$mo = Linux.MO_ACQUIRE;} | AtomicXchgRelease LPar address = re Comma value = re RPar {$mo = Linux.MO_RELEASE;}) # reXchg | ( Xchg LPar address = re Comma value = re RPar {$mo = Linux.MO_MB;} - | XchgRelaxed LPar address = re Comma value = re RPar {$mo = Linux.MO_RELAXED;} + | XchgRelaxed LPar address = re Comma value = re RPar {$mo = Linux.MO_ONCE;} | XchgAcquire LPar address = re Comma value = re RPar {$mo = Linux.MO_ACQUIRE;} | XchgRelease LPar address = re Comma value = re RPar {$mo = Linux.MO_RELEASE;}) # reXchg @@ -125,7 +125,7 @@ re locals [IntBinaryOp op, String mo] | C11AtomicXchgExplicit LPar address = re Comma value = re Comma c11Mo (Comma openCLScope)? RPar # reC11AtomicXchgExplicit | ( AtomicCmpXchg LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_MB;} - | AtomicCmpXchgRelaxed LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_RELAXED;} + | AtomicCmpXchgRelaxed LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_ONCE;} | AtomicCmpXchgAcquire LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_ACQUIRE;} | AtomicCmpXchgRelease LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_RELEASE;}) # reCmpXchg @@ -135,7 +135,7 @@ re locals [IntBinaryOp op, String mo] | C11AtomicWCAS LPar address = re Comma expectedAdd = re Comma value = re RPar # reC11WCmpXchg | ( CmpXchg LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_MB;} - | CmpXchgRelaxed LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_RELAXED;} + | CmpXchgRelaxed LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_ONCE;} | CmpXchgAcquire LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_ACQUIRE;} | CmpXchgRelease LPar address = re Comma cmp = re Comma value = re RPar {$mo = Linux.MO_RELEASE;}) # reCmpXchg diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/Tag.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/Tag.java index 2fcf9bfe2d..485c8b9400 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/Tag.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/Tag.java @@ -181,7 +181,6 @@ private Linux() { } public static final String MO_RMB = "Rmb"; public static final String MO_WMB = "Wmb"; public static final String BARRIER = "Barrier"; - public static final String MO_RELAXED = "Relaxed"; public static final String MO_RELEASE = "Release"; public static final String MO_ACQUIRE = "Acquire"; public static final String MO_ONCE = "Once"; @@ -207,28 +206,27 @@ public static String storeMO(String mo) { // NOTE: The order below needs to be in sync with /include/lkmm.h public static String intToMo(int i) { return switch (i) { - case 0 -> MO_RELAXED; - case 1 -> MO_ONCE; - case 2 -> MO_ACQUIRE; - case 3 -> MO_RELEASE; - case 4 -> MO_MB; - case 5 -> MO_WMB; - case 6 -> MO_RMB; - case 7 -> RCU_LOCK; - case 8 -> RCU_UNLOCK; - case 9 -> RCU_SYNC; - case 10 -> BEFORE_ATOMIC; - case 11 -> AFTER_ATOMIC; - case 12 -> AFTER_SPINLOCK; - case 13 -> BARRIER; - case 14 -> AFTER_UNLOCK_LOCK; + case 0 -> MO_ONCE; + case 1 -> MO_ACQUIRE; + case 2 -> MO_RELEASE; + case 3 -> MO_MB; + case 4 -> MO_WMB; + case 5 -> MO_RMB; + case 6 -> RCU_LOCK; + case 7 -> RCU_UNLOCK; + case 8 -> RCU_SYNC; + case 9 -> BEFORE_ATOMIC; + case 10 -> AFTER_ATOMIC; + case 11 -> AFTER_SPINLOCK; + case 12 -> BARRIER; + case 13 -> AFTER_UNLOCK_LOCK; default -> throw new UnsupportedOperationException("The memory order is not recognized"); }; } public static String toText(String mo) { return switch (mo) { - case MO_RELAXED -> "_relaxed"; + case MO_ONCE -> "_relaxed"; // The Linux kernel often uses "relaxed" to refer to "once" case MO_ACQUIRE -> "_acquire"; case MO_RELEASE -> "_release"; case MO_MB -> ""; diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java index 1b6d0769cf..e1abb095df 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/Intrinsics.java @@ -203,16 +203,16 @@ public enum Info { LLVM_MEMSET("llvm.memset", true, false, true, false, Intrinsics::inlineMemSet), LLVM_THREADLOCAL("llvm.threadlocal.address.p0", false, false, true, true, Intrinsics::inlineLLVMThreadLocal), // --------------------------- LKMM --------------------------- - LKMM_LOAD("__LKMM_LOAD", false, true, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_STORE("__LKMM_STORE", true, false, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_XCHG("__LKMM_XCHG", true, true, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_CMPXCHG("__LKMM_CMPXCHG", true, true, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_ATOMIC_FETCH_OP("__LKMM_ATOMIC_FETCH_OP", true, true, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_ATOMIC_OP("__LKMM_ATOMIC_OP", true, true, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_ATOMIC_OP_RETURN("__LKMM_ATOMIC_OP_RETURN", true, true, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_LOAD("__LKMM_load", false, true, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_STORE("__LKMM_store", true, false, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_XCHG("__LKMM_xchg", true, true, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_CMPXCHG("__LKMM_cmpxchg", true, true, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_ATOMIC_FETCH_OP("__LKMM_atomic_fetch_op", true, true, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_ATOMIC_OP("__LKMM_atomic_op", true, true, true, true, Intrinsics::handleLKMMIntrinsic), + LKMM_ATOMIC_OP_RETURN("__LKMM_atomic_op_return", true, true, true, true, Intrinsics::handleLKMMIntrinsic), LKMM_SPIN_LOCK("__LKMM_SPIN_LOCK", true, true, false, true, Intrinsics::handleLKMMIntrinsic), LKMM_SPIN_UNLOCK("__LKMM_SPIN_UNLOCK", true, false, true, true, Intrinsics::handleLKMMIntrinsic), - LKMM_FENCE("__LKMM_FENCE", false, false, false, true, Intrinsics::handleLKMMIntrinsic), + LKMM_FENCE("__LKMM_fence", false, false, false, true, Intrinsics::handleLKMMIntrinsic), // --------------------------- Misc --------------------------- STD_MEMCPY("memcpy", true, true, true, false, Intrinsics::inlineMemCpy), STD_MEMCPYS("memcpy_s", true, true, true, false, Intrinsics::inlineMemCpyS), @@ -1312,61 +1312,85 @@ private List handleLKMMIntrinsic(FunctionCall call) { final Expression p1 = args.size() > 1 ? args.get(1) : null; final Expression p2 = args.size() > 2 ? args.get(2) : null; final Expression p3 = args.size() > 3 ? args.get(3) : null; + final Expression p4 = args.size() > 4 ? args.get(4) : null; - final String mo; - final IntBinaryOp op; final List result = new ArrayList<>(); switch (call.getCalledFunction().getName()) { - case "__LKMM_LOAD" -> { - checkArgument(p1 instanceof IntLiteral, "No support for variable memory order."); - mo = Tag.Linux.intToMo(((IntLiteral) p1).getValueAsInt()); - result.add(EventFactory.Linux.newLKMMLoad(reg, p0, mo)); + case "__LKMM_load" -> { + checkArguments(3, call); + final Type bytes = toLKMMAccessSize(p1); + final String mo = toLKMMMemoryOrder(p2); + final Register dummy = call.getFunction().newUniqueRegister("__lkmm_temp", bytes); + result.add(EventFactory.Linux.newLKMMLoad(dummy, p0, mo)); + result.add(EventFactory.newLocal(reg, expressions.makeCast(dummy, reg.getType()))); } - case "__LKMM_STORE" -> { - checkArgument(p2 instanceof IntLiteral, "No support for variable memory order."); - mo = Tag.Linux.intToMo(((IntLiteral) p2).getValueAsInt()); - result.add(EventFactory.Linux.newLKMMStore(p0, p1, mo.equals(Tag.Linux.MO_MB) ? Tag.Linux.MO_ONCE : mo)); + case "__LKMM_store" -> { + checkArguments(4, call); + final Type bytes = toLKMMAccessSize(p1); + final String mo = toLKMMMemoryOrder(p3); + final Expression value = expressions.makeCast(p2, bytes); + result.add(EventFactory.Linux.newLKMMStore(p0, value, mo.equals(Tag.Linux.MO_MB) ? Tag.Linux.MO_ONCE : mo)); if (mo.equals(Tag.Linux.MO_MB)) { result.add(EventFactory.Linux.newMemoryBarrier()); } } - case "__LKMM_XCHG" -> { - checkArgument(p2 instanceof IntLiteral, "No support for variable memory order."); - mo = Tag.Linux.intToMo(((IntLiteral) p2).getValueAsInt()); - result.add(EventFactory.Linux.newRMWExchange(p0, reg, p1, mo)); + case "__LKMM_xchg" -> { + checkArguments(4, call); + final Type bytes = toLKMMAccessSize(p1); + final String mo = toLKMMMemoryOrder(p3); + final Register dummy = call.getFunction().newUniqueRegister("__lkmm_temp", bytes); + final Expression value = expressions.makeCast(p2, bytes); + result.add(EventFactory.Linux.newRMWExchange(p0, dummy, value, mo)); + result.add(EventFactory.newLocal(reg, expressions.makeCast(dummy, reg.getType()))); } - case "__LKMM_CMPXCHG" -> { - checkArgument(p3 instanceof IntLiteral, "No support for variable memory order."); - mo = Tag.Linux.intToMo(((IntLiteral) p3).getValueAsInt()); - result.add(EventFactory.Linux.newRMWCompareExchange(p0, reg, p1, p2, mo)); + case "__LKMM_cmpxchg" -> { + checkArguments(6, call); + final Type bytes = toLKMMAccessSize(p1); + final String mo = toLKMMMemoryOrder(p4); + final Register dummy = call.getFunction().newUniqueRegister("__lkmm_temp", bytes); + final Expression expectation = expressions.makeCast(p2, bytes); + final Expression value = expressions.makeCast(p3, bytes); + result.add(EventFactory.Linux.newRMWCompareExchange(p0, dummy, expectation, value, mo)); + result.add(EventFactory.newLocal(reg, expressions.makeCast(dummy, reg.getType()))); } - case "__LKMM_ATOMIC_FETCH_OP" -> { - checkArgument(p2 instanceof IntLiteral, "No support for variable memory order."); - mo = Tag.Linux.intToMo(((IntLiteral) p2).getValueAsInt()); - checkArgument(p3 instanceof IntLiteral, "No support for variable operator."); - op = IntBinaryOp.intToOp(((IntLiteral) p3).getValueAsInt()); - result.add(EventFactory.Linux.newRMWFetchOp(p0, reg, p1, op, mo)); + case "__LKMM_atomic_fetch_op" -> { + checkArguments(5, call); + final Type bytes = toLKMMAccessSize(p1); + final String mo = toLKMMMemoryOrder(p3); + final IntBinaryOp op = toLKMMOperation(p4); + final Register dummy = call.getFunction().newUniqueRegister("__lkmm_temp", bytes); + final Expression value = expressions.makeCast(p2, bytes); + result.add(EventFactory.Linux.newRMWFetchOp(p0, dummy, value, op, mo)); + result.add(EventFactory.newLocal(reg, expressions.makeCast(dummy, reg.getType()))); } - case "__LKMM_ATOMIC_OP_RETURN" -> { - checkArgument(p2 instanceof IntLiteral, "No support for variable memory order."); - mo = Tag.Linux.intToMo(((IntLiteral) p2).getValueAsInt()); - checkArgument(p3 instanceof IntLiteral, "No support for variable operator."); - op = IntBinaryOp.intToOp(((IntLiteral) p3).getValueAsInt()); - result.add(EventFactory.Linux.newRMWOpReturn(p0, reg, p1, op, mo)); + case "__LKMM_atomic_op_return" -> { + checkArguments(5, call); + final Type bytes = toLKMMAccessSize(p1); + final String mo = toLKMMMemoryOrder(p3); + final IntBinaryOp op = toLKMMOperation(p4); + final Register dummy = call.getFunction().newUniqueRegister("__lkmm_temp", bytes); + final Expression value = expressions.makeCast(p2, bytes); + result.add(EventFactory.Linux.newRMWOpReturn(p0, dummy, value, op, mo)); + result.add(EventFactory.newLocal(reg, expressions.makeCast(dummy, reg.getType()))); } - case "__LKMM_ATOMIC_OP" -> { - checkArgument(p2 instanceof IntLiteral, "No support for variable operator."); - op = IntBinaryOp.intToOp(((IntLiteral) p2).getValueAsInt()); - result.add(EventFactory.Linux.newRMWOp(p0, p1, op)); + case "__LKMM_atomic_op" -> { + checkArguments(4, call); + final Type bytes = toLKMMAccessSize(p1); + final IntBinaryOp op = toLKMMOperation(p3); + final Expression value = expressions.makeCast(p2, bytes); + result.add(EventFactory.Linux.newRMWOp(p0, value, op)); } - case "__LKMM_FENCE" -> { - String fence = Tag.Linux.intToMo(((IntLiteral) p0).getValueAsInt()); - result.add(EventFactory.Linux.newLKMMFence(fence)); + case "__LKMM_fence" -> { + checkArguments(1, call); + final String mo = toLKMMMemoryOrder(p0); + result.add(EventFactory.Linux.newLKMMFence(mo)); } case "__LKMM_SPIN_LOCK" -> { + checkArguments(1, call); result.add(EventFactory.Linux.newLock(p0)); } case "__LKMM_SPIN_UNLOCK" -> { + checkArguments(1, call); result.add(EventFactory.Linux.newUnlock(p0)); } default -> { @@ -1376,6 +1400,27 @@ private List handleLKMMIntrinsic(FunctionCall call) { return result; } + private Type toLKMMAccessSize(Expression argument) { + if (!(argument instanceof IntLiteral literal)) { + throw new UnsupportedOperationException("Variable LKMM access size \"" + argument + "\""); + } + return types.getIntegerType(8 * literal.getValueAsInt()); + } + + private String toLKMMMemoryOrder(Expression argument) { + if (!(argument instanceof IntLiteral literal)) { + throw new UnsupportedOperationException("Variable LKMM memory order \"" + argument + "\""); + } + return Tag.Linux.intToMo(literal.getValueAsInt()); + } + + private IntBinaryOp toLKMMOperation(Expression argument) { + if (!(argument instanceof IntLiteral literal)) { + throw new UnsupportedOperationException("Variable LKMM operation \"" + argument + "\""); + } + return IntBinaryOp.intToOp(literal.getValueAsInt()); + } + // -------------------------------------------------------------------------------------------------------- // Simple late intrinsics diff --git a/dartagnan/src/test/resources/lkmm/2+2W+onces+locked.ll b/dartagnan/src/test/resources/lkmm/2+2W+onces+locked.ll index ef7e1ade96..a44df20b03 100644 --- a/dartagnan/src/test/resources/lkmm/2+2W+onces+locked.ll +++ b/dartagnan/src/test/resources/lkmm/2+2W+onces+locked.ll @@ -1,194 +1,241 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/2+2W+onces+locked.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/2+2W+onces+locked.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/2+2W+onces+locked.c' +source_filename = "benchmarks/lkmm/2+2W+onces+locked.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.spinlock = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @lock_x = dso_local global %struct.spinlock zeroinitializer, align 4, !dbg !0 -@x = dso_local global i32 0, align 4, !dbg !26 -@lock_y = dso_local global %struct.spinlock zeroinitializer, align 4, !dbg !32 -@y = dso_local global i32 0, align 4, !dbg !30 -@.str = private unnamed_addr constant [38 x i8] c"!(READ_ONCE(x)==2 && READ_ONCE(y)==2)\00", align 1 -@.str.1 = private unnamed_addr constant [58 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/2+2W+onces+locked.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@x = dso_local global i32 0, align 4, !dbg !47 +@lock_y = dso_local global %struct.spinlock zeroinitializer, align 4, !dbg !51 +@y = dso_local global i32 0, align 4, !dbg !49 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [20 x i8] c"2+2W+onces+locked.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [38 x i8] c"!(READ_ONCE(x)==2 && READ_ONCE(y)==2)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !46 { - call void @llvm.dbg.value(metadata i8* %0, metadata !50, metadata !DIExpression()), !dbg !51 - %2 = call i32 @__LKMM_SPIN_LOCK(%struct.spinlock* noundef nonnull @lock_x) #5, !dbg !52 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !53 - %3 = call i32 @__LKMM_SPIN_UNLOCK(%struct.spinlock* noundef nonnull @lock_x) #5, !dbg !54 - %4 = call i32 @__LKMM_SPIN_LOCK(%struct.spinlock* noundef nonnull @lock_y) #5, !dbg !55 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !56 - %5 = call i32 @__LKMM_SPIN_UNLOCK(%struct.spinlock* noundef nonnull @lock_y) #5, !dbg !57 - ret i8* null, !dbg !58 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !65 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !69, !DIExpression(), !70) + %3 = call i32 @__LKMM_SPIN_LOCK(ptr noundef @lock_x), !dbg !71 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !72 + %4 = call i32 @__LKMM_SPIN_UNLOCK(ptr noundef @lock_x), !dbg !73 + %5 = call i32 @__LKMM_SPIN_LOCK(ptr noundef @lock_y), !dbg !74 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !75 + %6 = call i32 @__LKMM_SPIN_UNLOCK(ptr noundef @lock_y), !dbg !76 + ret ptr null, !dbg !77 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +declare i32 @__LKMM_SPIN_LOCK(ptr noundef) #1 -declare i32 @__LKMM_SPIN_LOCK(%struct.spinlock* noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 - -declare i32 @__LKMM_SPIN_UNLOCK(%struct.spinlock* noundef) #2 +declare i32 @__LKMM_SPIN_UNLOCK(ptr noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !59 { - call void @llvm.dbg.value(metadata i8* %0, metadata !60, metadata !DIExpression()), !dbg !61 - %2 = call i32 @__LKMM_SPIN_LOCK(%struct.spinlock* noundef nonnull @lock_y) #5, !dbg !62 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !63 - %3 = call i32 @__LKMM_SPIN_UNLOCK(%struct.spinlock* noundef nonnull @lock_y) #5, !dbg !64 - %4 = call i32 @__LKMM_SPIN_LOCK(%struct.spinlock* noundef nonnull @lock_x) #5, !dbg !65 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !66 - %5 = call i32 @__LKMM_SPIN_UNLOCK(%struct.spinlock* noundef nonnull @lock_x) #5, !dbg !67 - ret i8* null, !dbg !68 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !78 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !79, !DIExpression(), !80) + %3 = call i32 @__LKMM_SPIN_LOCK(ptr noundef @lock_y), !dbg !81 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !82 + %4 = call i32 @__LKMM_SPIN_UNLOCK(ptr noundef @lock_y), !dbg !83 + %5 = call i32 @__LKMM_SPIN_LOCK(ptr noundef @lock_x), !dbg !84 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !85 + %6 = call i32 @__LKMM_SPIN_UNLOCK(ptr noundef @lock_x), !dbg !86 + ret ptr null, !dbg !87 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !69 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !72, metadata !DIExpression(DW_OP_deref)), !dbg !76 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !77 - call void @llvm.dbg.value(metadata i64* %2, metadata !78, metadata !DIExpression(DW_OP_deref)), !dbg !76 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !79 - %5 = load i64, i64* %1, align 8, !dbg !80 - call void @llvm.dbg.value(metadata i64 %5, metadata !72, metadata !DIExpression()), !dbg !76 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !81 - %7 = load i64, i64* %2, align 8, !dbg !82 - call void @llvm.dbg.value(metadata i64 %7, metadata !78, metadata !DIExpression()), !dbg !76 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !83 - %9 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !84 - %10 = icmp eq i32 %9, 2, !dbg !84 - br i1 %10, label %11, label %15, !dbg !84 - -11: ; preds = %0 - %12 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !84 - %13 = icmp eq i32 %12, 2, !dbg !84 - br i1 %13, label %14, label %15, !dbg !87 - -14: ; preds = %11 - call void @__assert_fail(i8* noundef getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 noundef 41, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !84 - unreachable, !dbg !84 - -15: ; preds = %0, %11 - ret i32 0, !dbg !88 +define dso_local i32 @main() #0 !dbg !88 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !91, !DIExpression(), !114) + #dbg_declare(ptr %3, !115, !DIExpression(), !116) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !117 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !118 + %6 = load ptr, ptr %2, align 8, !dbg !119 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !120 + %8 = load ptr, ptr %3, align 8, !dbg !121 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !122 + %10 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !123 + %11 = trunc i64 %10 to i32, !dbg !123 + %12 = icmp eq i32 %11, 2, !dbg !123 + br i1 %12, label %13, label %17, !dbg !123 + +13: ; preds = %0 + %14 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !123 + %15 = trunc i64 %14 to i32, !dbg !123 + %16 = icmp eq i32 %15, 2, !dbg !123 + br label %17 + +17: ; preds = %13, %0 + %18 = phi i1 [ false, %0 ], [ %16, %13 ], !dbg !124 + %19 = xor i1 %18, true, !dbg !123 + %20 = xor i1 %19, true, !dbg !123 + %21 = zext i1 %20 to i32, !dbg !123 + %22 = sext i32 %21 to i64, !dbg !123 + %23 = icmp ne i64 %22, 0, !dbg !123 + br i1 %23, label %24, label %26, !dbg !123 + +24: ; preds = %17 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 41, ptr noundef @.str.1) #3, !dbg !123 + unreachable, !dbg !123 + +25: ; No predecessors! + br label %27, !dbg !123 + +26: ; preds = %17 + br label %27, !dbg !123 + +27: ; preds = %26, %25 + ret i32 0, !dbg !125 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!38, !39, !40, !41, !42, !43, !44} -!llvm.ident = !{!45} +!llvm.module.flags = !{!57, !58, !59, !60, !61, !62, !63} +!llvm.ident = !{!64} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "lock_x", scope: !2, file: !28, line: 7, type: !34, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/2+2W+onces+locked.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "06899129241a51c8f91baae86bd7c164") +!1 = distinct !DIGlobalVariable(name: "lock_x", scope: !2, file: !3, line: 7, type: !53, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/2+2W+onces+locked.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "06899129241a51c8f91baae86bd7c164") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!26, !30, !0, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/2+2W+onces+locked.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "06899129241a51c8f91baae86bd7c164") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !47, !49, !0, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "lock_y", scope: !2, file: !28, line: 7, type: !34, isLocal: false, isDefinition: true) -!34 = !DIDerivedType(tag: DW_TAG_typedef, name: "spinlock_t", file: !6, line: 277, baseType: !35) -!35 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "spinlock", file: !6, line: 275, size: 32, elements: !36) -!36 = !{!37} -!37 = !DIDerivedType(tag: DW_TAG_member, name: "unused", scope: !35, file: !6, line: 276, baseType: !29, size: 32) -!38 = !{i32 7, !"Dwarf Version", i32 5} -!39 = !{i32 2, !"Debug Info Version", i32 3} -!40 = !{i32 1, !"wchar_size", i32 4} -!41 = !{i32 7, !"PIC Level", i32 2} -!42 = !{i32 7, !"PIE Level", i32 2} -!43 = !{i32 7, !"uwtable", i32 1} -!44 = !{i32 7, !"frame-pointer", i32 2} -!45 = !{!"Ubuntu clang version 14.0.6"} -!46 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 9, type: !47, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !49) -!47 = !DISubroutineType(types: !48) -!48 = !{!24, !24} -!49 = !{} -!50 = !DILocalVariable(name: "arg", arg: 1, scope: !46, file: !28, line: 9, type: !24) -!51 = !DILocation(line: 0, scope: !46) -!52 = !DILocation(line: 11, column: 2, scope: !46) -!53 = !DILocation(line: 12, column: 2, scope: !46) -!54 = !DILocation(line: 13, column: 2, scope: !46) -!55 = !DILocation(line: 14, column: 2, scope: !46) -!56 = !DILocation(line: 15, column: 2, scope: !46) -!57 = !DILocation(line: 16, column: 2, scope: !46) -!58 = !DILocation(line: 17, column: 2, scope: !46) -!59 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 20, type: !47, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !49) -!60 = !DILocalVariable(name: "arg", arg: 1, scope: !59, file: !28, line: 20, type: !24) -!61 = !DILocation(line: 0, scope: !59) -!62 = !DILocation(line: 22, column: 2, scope: !59) -!63 = !DILocation(line: 23, column: 2, scope: !59) -!64 = !DILocation(line: 24, column: 2, scope: !59) -!65 = !DILocation(line: 25, column: 2, scope: !59) -!66 = !DILocation(line: 26, column: 2, scope: !59) -!67 = !DILocation(line: 27, column: 2, scope: !59) -!68 = !DILocation(line: 28, column: 2, scope: !59) -!69 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 31, type: !70, scopeLine: 32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !49) -!70 = !DISubroutineType(types: !71) -!71 = !{!29} -!72 = !DILocalVariable(name: "t1", scope: !69, file: !28, line: 33, type: !73) -!73 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !74, line: 27, baseType: !75) -!74 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!75 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!76 = !DILocation(line: 0, scope: !69) -!77 = !DILocation(line: 35, column: 2, scope: !69) -!78 = !DILocalVariable(name: "t2", scope: !69, file: !28, line: 33, type: !73) -!79 = !DILocation(line: 36, column: 2, scope: !69) -!80 = !DILocation(line: 38, column: 15, scope: !69) -!81 = !DILocation(line: 38, column: 2, scope: !69) -!82 = !DILocation(line: 39, column: 15, scope: !69) -!83 = !DILocation(line: 39, column: 2, scope: !69) -!84 = !DILocation(line: 41, column: 2, scope: !85) -!85 = distinct !DILexicalBlock(scope: !86, file: !28, line: 41, column: 2) -!86 = distinct !DILexicalBlock(scope: !69, file: !28, line: 41, column: 2) -!87 = !DILocation(line: 41, column: 2, scope: !86) -!88 = !DILocation(line: 43, column: 2, scope: !69) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 41, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 41, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 160, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 20) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 41, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 304, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 38) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !28, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 6, type: !28, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "lock_y", scope: !2, file: !3, line: 7, type: !53, isLocal: false, isDefinition: true) +!53 = !DIDerivedType(tag: DW_TAG_typedef, name: "spinlock_t", file: !6, line: 290, baseType: !54) +!54 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "spinlock", file: !6, line: 288, size: 32, elements: !55) +!55 = !{!56} +!56 = !DIDerivedType(tag: DW_TAG_member, name: "unused", scope: !54, file: !6, line: 289, baseType: !28, size: 32) +!57 = !{i32 7, !"Dwarf Version", i32 5} +!58 = !{i32 2, !"Debug Info Version", i32 3} +!59 = !{i32 1, !"wchar_size", i32 4} +!60 = !{i32 8, !"PIC Level", i32 2} +!61 = !{i32 7, !"PIE Level", i32 2} +!62 = !{i32 7, !"uwtable", i32 2} +!63 = !{i32 7, !"frame-pointer", i32 2} +!64 = !{!"Homebrew clang version 19.1.7"} +!65 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 9, type: !66, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !68) +!66 = !DISubroutineType(types: !67) +!67 = !{!27, !27} +!68 = !{} +!69 = !DILocalVariable(name: "arg", arg: 1, scope: !65, file: !3, line: 9, type: !27) +!70 = !DILocation(line: 9, column: 22, scope: !65) +!71 = !DILocation(line: 11, column: 2, scope: !65) +!72 = !DILocation(line: 12, column: 2, scope: !65) +!73 = !DILocation(line: 13, column: 2, scope: !65) +!74 = !DILocation(line: 14, column: 2, scope: !65) +!75 = !DILocation(line: 15, column: 2, scope: !65) +!76 = !DILocation(line: 16, column: 2, scope: !65) +!77 = !DILocation(line: 17, column: 2, scope: !65) +!78 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 20, type: !66, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !68) +!79 = !DILocalVariable(name: "arg", arg: 1, scope: !78, file: !3, line: 20, type: !27) +!80 = !DILocation(line: 20, column: 22, scope: !78) +!81 = !DILocation(line: 22, column: 2, scope: !78) +!82 = !DILocation(line: 23, column: 2, scope: !78) +!83 = !DILocation(line: 24, column: 2, scope: !78) +!84 = !DILocation(line: 25, column: 2, scope: !78) +!85 = !DILocation(line: 26, column: 2, scope: !78) +!86 = !DILocation(line: 27, column: 2, scope: !78) +!87 = !DILocation(line: 28, column: 2, scope: !78) +!88 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 31, type: !89, scopeLine: 32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !68) +!89 = !DISubroutineType(types: !90) +!90 = !{!28} +!91 = !DILocalVariable(name: "t1", scope: !88, file: !3, line: 33, type: !92) +!92 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !93, line: 31, baseType: !94) +!93 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!94 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !95, line: 118, baseType: !96) +!95 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!96 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !97, size: 64) +!97 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !95, line: 103, size: 65536, elements: !98) +!98 = !{!99, !100, !110} +!99 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !97, file: !95, line: 104, baseType: !26, size: 64) +!100 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !97, file: !95, line: 105, baseType: !101, size: 64, offset: 64) +!101 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !102, size: 64) +!102 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !95, line: 57, size: 192, elements: !103) +!103 = !{!104, !108, !109} +!104 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !102, file: !95, line: 58, baseType: !105, size: 64) +!105 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !106, size: 64) +!106 = !DISubroutineType(types: !107) +!107 = !{null, !27} +!108 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !102, file: !95, line: 59, baseType: !27, size: 64, offset: 64) +!109 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !102, file: !95, line: 60, baseType: !101, size: 64, offset: 128) +!110 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !97, file: !95, line: 106, baseType: !111, size: 65408, offset: 128) +!111 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !112) +!112 = !{!113} +!113 = !DISubrange(count: 8176) +!114 = !DILocation(line: 33, column: 12, scope: !88) +!115 = !DILocalVariable(name: "t2", scope: !88, file: !3, line: 33, type: !92) +!116 = !DILocation(line: 33, column: 16, scope: !88) +!117 = !DILocation(line: 35, column: 2, scope: !88) +!118 = !DILocation(line: 36, column: 2, scope: !88) +!119 = !DILocation(line: 38, column: 15, scope: !88) +!120 = !DILocation(line: 38, column: 2, scope: !88) +!121 = !DILocation(line: 39, column: 15, scope: !88) +!122 = !DILocation(line: 39, column: 2, scope: !88) +!123 = !DILocation(line: 41, column: 2, scope: !88) +!124 = !DILocation(line: 0, scope: !88) +!125 = !DILocation(line: 43, column: 2, scope: !88) diff --git a/dartagnan/src/test/resources/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.ll b/dartagnan/src/test/resources/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.ll index bc526dcc34..ad4233b35b 100644 --- a/dartagnan/src/test/resources/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.ll +++ b/dartagnan/src/test/resources/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.ll @@ -1,189 +1,239 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/C-PaulEMcKenney-MP+o-r+ai-mb-o.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c' +source_filename = "benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !0 -@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !32 -@r0 = dso_local global i32 0, align 4, !dbg !40 -@r1 = dso_local global i32 0, align 4, !dbg !42 -@.str = private unnamed_addr constant [18 x i8] c"!(r0==0 && r1==0)\00", align 1 -@.str.1 = private unnamed_addr constant [71 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !53 +@r0 = dso_local global i32 0, align 4, !dbg !59 +@r1 = dso_local global i32 0, align 4, !dbg !61 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !36 +@.str = private unnamed_addr constant [33 x i8] c"C-PaulEMcKenney-MP+o-r+ai-mb-o.c\00", align 1, !dbg !43 +@.str.1 = private unnamed_addr constant [18 x i8] c"!(r0==0 && r1==0)\00", align 1, !dbg !48 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !52 { - call void @llvm.dbg.value(metadata i8* %0, metadata !56, metadata !DIExpression()), !dbg !57 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !58 - %2 = call i32 @__LKMM_XCHG(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @y, i64 0, i32 0), i32 noundef 5, i32 noundef 3) #5, !dbg !59 - store i32 %2, i32* @r0, align 4, !dbg !60 - ret i8* null, !dbg !61 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !71 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !75, !DIExpression(), !76) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !77 + %3 = call i64 @__LKMM_xchg(ptr noundef @y, i64 noundef 4, i64 noundef 5, i32 noundef 2), !dbg !78 + %4 = trunc i64 %3 to i32, !dbg !78 + store i32 %4, ptr @r0, align 4, !dbg !79 + ret ptr null, !dbg !80 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 - -declare i32 @__LKMM_XCHG(i32* noundef, i32 noundef, i32 noundef) #2 +declare i64 @__LKMM_xchg(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !62 { - call void @llvm.dbg.value(metadata i8* %0, metadata !63, metadata !DIExpression()), !dbg !64 - call void @__LKMM_ATOMIC_OP(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @y, i64 0, i32 0), i32 noundef 1, i32 noundef 0) #5, !dbg !65 - call void @__LKMM_FENCE(i32 noundef 4) #5, !dbg !66 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #5, !dbg !67 - store i32 %2, i32* @r1, align 4, !dbg !68 - ret i8* null, !dbg !69 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !81 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !82, !DIExpression(), !83) + call void @__LKMM_atomic_op(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !84 + call void @__LKMM_fence(i32 noundef 3), !dbg !85 + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !86 + %4 = trunc i64 %3 to i32, !dbg !86 + store i32 %4, ptr @r1, align 4, !dbg !87 + ret ptr null, !dbg !88 } -declare void @__LKMM_ATOMIC_OP(i32* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_atomic_op(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !70 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !73, metadata !DIExpression(DW_OP_deref)), !dbg !77 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !78 - call void @llvm.dbg.value(metadata i64* %2, metadata !79, metadata !DIExpression(DW_OP_deref)), !dbg !77 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !80 - %5 = load i64, i64* %1, align 8, !dbg !81 - call void @llvm.dbg.value(metadata i64 %5, metadata !73, metadata !DIExpression()), !dbg !77 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !82 - %7 = load i64, i64* %2, align 8, !dbg !83 - call void @llvm.dbg.value(metadata i64 %7, metadata !79, metadata !DIExpression()), !dbg !77 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !84 - %9 = load i32, i32* @r0, align 4, !dbg !85 - %10 = icmp eq i32 %9, 0, !dbg !85 - %11 = load i32, i32* @r1, align 4, !dbg !85 - %12 = icmp eq i32 %11, 0, !dbg !85 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !85 - br i1 %or.cond, label %13, label %14, !dbg !85 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 noundef 36, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !85 - unreachable, !dbg !85 - -14: ; preds = %0 - ret i32 0, !dbg !88 +define dso_local i32 @main() #0 !dbg !89 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !92, !DIExpression(), !115) + #dbg_declare(ptr %3, !116, !DIExpression(), !117) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !118 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !119 + %6 = load ptr, ptr %2, align 8, !dbg !120 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !121 + %8 = load ptr, ptr %3, align 8, !dbg !122 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !123 + %10 = load i32, ptr @r0, align 4, !dbg !124 + %11 = icmp eq i32 %10, 0, !dbg !124 + br i1 %11, label %12, label %15, !dbg !124 + +12: ; preds = %0 + %13 = load i32, ptr @r1, align 4, !dbg !124 + %14 = icmp eq i32 %13, 0, !dbg !124 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !125 + %17 = xor i1 %16, true, !dbg !124 + %18 = xor i1 %17, true, !dbg !124 + %19 = zext i1 %18 to i32, !dbg !124 + %20 = sext i32 %19 to i64, !dbg !124 + %21 = icmp ne i64 %20, 0, !dbg !124 + br i1 %21, label %22, label %24, !dbg !124 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 36, ptr noundef @.str.1) #3, !dbg !124 + unreachable, !dbg !124 + +23: ; No predecessors! + br label %25, !dbg !124 + +24: ; preds = %15 + br label %25, !dbg !124 + +25: ; preds = %24, %23 + ret i32 0, !dbg !126 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!44, !45, !46, !47, !48, !49, !50} -!llvm.ident = !{!51} +!llvm.module.flags = !{!63, !64, !65, !66, !67, !68, !69} +!llvm.ident = !{!70} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !34, line: 8, type: !35, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !29, globals: !31, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "1308844795e51ccd8aeabdd44c0d7613") -!4 = !{!5, !23} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 8, type: !55, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !28, globals: !35, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "377543d76e9e8d65f8e25797dc3d9ac2") +!4 = !{!5, !22} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "operation", file: !6, line: 20, baseType: !7, size: 32, elements: !24) -!24 = !{!25, !26, !27, !28} -!25 = !DIEnumerator(name: "op_add", value: 0) -!26 = !DIEnumerator(name: "op_sub", value: 1) -!27 = !DIEnumerator(name: "op_and", value: 2) -!28 = !DIEnumerator(name: "op_or", value: 3) -!29 = !{!30} -!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!31 = !{!0, !32, !40, !42} -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !34, line: 8, type: !35, isLocal: false, isDefinition: true) -!34 = !DIFile(filename: "benchmarks/lkmm/C-PaulEMcKenney-MP+o-r+ai-mb-o.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "1308844795e51ccd8aeabdd44c0d7613") -!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !36) -!36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !37) -!37 = !{!38} -!38 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !36, file: !6, line: 94, baseType: !39, size: 32) -!39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) -!41 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !34, line: 9, type: !39, isLocal: false, isDefinition: true) -!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) -!43 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !34, line: 9, type: !39, isLocal: false, isDefinition: true) -!44 = !{i32 7, !"Dwarf Version", i32 5} -!45 = !{i32 2, !"Debug Info Version", i32 3} -!46 = !{i32 1, !"wchar_size", i32 4} -!47 = !{i32 7, !"PIC Level", i32 2} -!48 = !{i32 7, !"PIE Level", i32 2} -!49 = !{i32 7, !"uwtable", i32 1} -!50 = !{i32 7, !"frame-pointer", i32 2} -!51 = !{!"Ubuntu clang version 14.0.6"} -!52 = distinct !DISubprogram(name: "thread_1", scope: !34, file: !34, line: 11, type: !53, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) -!53 = !DISubroutineType(types: !54) -!54 = !{!30, !30} -!55 = !{} -!56 = !DILocalVariable(name: "arg", arg: 1, scope: !52, file: !34, line: 11, type: !30) -!57 = !DILocation(line: 0, scope: !52) -!58 = !DILocation(line: 13, column: 2, scope: !52) -!59 = !DILocation(line: 14, column: 7, scope: !52) -!60 = !DILocation(line: 14, column: 5, scope: !52) -!61 = !DILocation(line: 15, column: 2, scope: !52) -!62 = distinct !DISubprogram(name: "thread_2", scope: !34, file: !34, line: 18, type: !53, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) -!63 = !DILocalVariable(name: "arg", arg: 1, scope: !62, file: !34, line: 18, type: !30) -!64 = !DILocation(line: 0, scope: !62) -!65 = !DILocation(line: 20, column: 2, scope: !62) -!66 = !DILocation(line: 21, column: 2, scope: !62) -!67 = !DILocation(line: 22, column: 7, scope: !62) -!68 = !DILocation(line: 22, column: 5, scope: !62) -!69 = !DILocation(line: 23, column: 2, scope: !62) -!70 = distinct !DISubprogram(name: "main", scope: !34, file: !34, line: 26, type: !71, scopeLine: 27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) -!71 = !DISubroutineType(types: !72) -!72 = !{!39} -!73 = !DILocalVariable(name: "t1", scope: !70, file: !34, line: 28, type: !74) -!74 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !75, line: 27, baseType: !76) -!75 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!76 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!77 = !DILocation(line: 0, scope: !70) -!78 = !DILocation(line: 30, column: 5, scope: !70) -!79 = !DILocalVariable(name: "t2", scope: !70, file: !34, line: 28, type: !74) -!80 = !DILocation(line: 31, column: 5, scope: !70) -!81 = !DILocation(line: 33, column: 18, scope: !70) -!82 = !DILocation(line: 33, column: 5, scope: !70) -!83 = !DILocation(line: 34, column: 18, scope: !70) -!84 = !DILocation(line: 34, column: 5, scope: !70) -!85 = !DILocation(line: 36, column: 5, scope: !86) -!86 = distinct !DILexicalBlock(scope: !87, file: !34, line: 36, column: 5) -!87 = distinct !DILexicalBlock(scope: !70, file: !34, line: 36, column: 5) -!88 = !DILocation(line: 38, column: 5, scope: !70) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_operation", file: !6, line: 19, baseType: !7, size: 32, elements: !23) +!23 = !{!24, !25, !26, !27} +!24 = !DIEnumerator(name: "__LKMM_op_add", value: 0) +!25 = !DIEnumerator(name: "__LKMM_op_sub", value: 1) +!26 = !DIEnumerator(name: "__LKMM_op_and", value: 2) +!27 = !DIEnumerator(name: "__LKMM_op_or", value: 3) +!28 = !{!29, !33, !34} +!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !30) +!30 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !31, line: 32, baseType: !32) +!31 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!32 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!33 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!35 = !{!36, !43, !48, !0, !53, !59, !61} +!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) +!37 = distinct !DIGlobalVariable(scope: null, file: !3, line: 36, type: !38, isLocal: true, isDefinition: true) +!38 = !DICompositeType(tag: DW_TAG_array_type, baseType: !39, size: 40, elements: !41) +!39 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !40) +!40 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!41 = !{!42} +!42 = !DISubrange(count: 5) +!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression()) +!44 = distinct !DIGlobalVariable(scope: null, file: !3, line: 36, type: !45, isLocal: true, isDefinition: true) +!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 264, elements: !46) +!46 = !{!47} +!47 = !DISubrange(count: 33) +!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) +!49 = distinct !DIGlobalVariable(scope: null, file: !3, line: 36, type: !50, isLocal: true, isDefinition: true) +!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 144, elements: !51) +!51 = !{!52} +!52 = !DISubrange(count: 18) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 8, type: !55, isLocal: false, isDefinition: true) +!55 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !56) +!56 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !57) +!57 = !{!58} +!58 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !56, file: !6, line: 107, baseType: !33, size: 32) +!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression()) +!60 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 9, type: !33, isLocal: false, isDefinition: true) +!61 = !DIGlobalVariableExpression(var: !62, expr: !DIExpression()) +!62 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !3, line: 9, type: !33, isLocal: false, isDefinition: true) +!63 = !{i32 7, !"Dwarf Version", i32 5} +!64 = !{i32 2, !"Debug Info Version", i32 3} +!65 = !{i32 1, !"wchar_size", i32 4} +!66 = !{i32 8, !"PIC Level", i32 2} +!67 = !{i32 7, !"PIE Level", i32 2} +!68 = !{i32 7, !"uwtable", i32 2} +!69 = !{i32 7, !"frame-pointer", i32 2} +!70 = !{!"Homebrew clang version 19.1.7"} +!71 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 11, type: !72, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +!72 = !DISubroutineType(types: !73) +!73 = !{!34, !34} +!74 = !{} +!75 = !DILocalVariable(name: "arg", arg: 1, scope: !71, file: !3, line: 11, type: !34) +!76 = !DILocation(line: 11, column: 22, scope: !71) +!77 = !DILocation(line: 13, column: 2, scope: !71) +!78 = !DILocation(line: 14, column: 7, scope: !71) +!79 = !DILocation(line: 14, column: 5, scope: !71) +!80 = !DILocation(line: 15, column: 2, scope: !71) +!81 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 18, type: !72, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +!82 = !DILocalVariable(name: "arg", arg: 1, scope: !81, file: !3, line: 18, type: !34) +!83 = !DILocation(line: 18, column: 22, scope: !81) +!84 = !DILocation(line: 20, column: 2, scope: !81) +!85 = !DILocation(line: 21, column: 2, scope: !81) +!86 = !DILocation(line: 22, column: 7, scope: !81) +!87 = !DILocation(line: 22, column: 5, scope: !81) +!88 = !DILocation(line: 23, column: 2, scope: !81) +!89 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 26, type: !90, scopeLine: 27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +!90 = !DISubroutineType(types: !91) +!91 = !{!33} +!92 = !DILocalVariable(name: "t1", scope: !89, file: !3, line: 28, type: !93) +!93 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !94, line: 31, baseType: !95) +!94 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!95 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !96, line: 118, baseType: !97) +!96 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!97 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !98, size: 64) +!98 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !96, line: 103, size: 65536, elements: !99) +!99 = !{!100, !101, !111} +!100 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !98, file: !96, line: 104, baseType: !32, size: 64) +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !98, file: !96, line: 105, baseType: !102, size: 64, offset: 64) +!102 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !103, size: 64) +!103 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !96, line: 57, size: 192, elements: !104) +!104 = !{!105, !109, !110} +!105 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !103, file: !96, line: 58, baseType: !106, size: 64) +!106 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !107, size: 64) +!107 = !DISubroutineType(types: !108) +!108 = !{null, !34} +!109 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !103, file: !96, line: 59, baseType: !34, size: 64, offset: 64) +!110 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !103, file: !96, line: 60, baseType: !102, size: 64, offset: 128) +!111 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !98, file: !96, line: 106, baseType: !112, size: 65408, offset: 128) +!112 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 65408, elements: !113) +!113 = !{!114} +!114 = !DISubrange(count: 8176) +!115 = !DILocation(line: 28, column: 15, scope: !89) +!116 = !DILocalVariable(name: "t2", scope: !89, file: !3, line: 28, type: !93) +!117 = !DILocation(line: 28, column: 19, scope: !89) +!118 = !DILocation(line: 30, column: 5, scope: !89) +!119 = !DILocation(line: 31, column: 5, scope: !89) +!120 = !DILocation(line: 33, column: 18, scope: !89) +!121 = !DILocation(line: 33, column: 5, scope: !89) +!122 = !DILocation(line: 34, column: 18, scope: !89) +!123 = !DILocation(line: 34, column: 5, scope: !89) +!124 = !DILocation(line: 36, column: 5, scope: !89) +!125 = !DILocation(line: 0, scope: !89) +!126 = !DILocation(line: 38, column: 5, scope: !89) diff --git a/dartagnan/src/test/resources/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.ll b/dartagnan/src/test/resources/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.ll index cb99a31f90..9d9d122a06 100644 --- a/dartagnan/src/test/resources/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.ll +++ b/dartagnan/src/test/resources/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.ll @@ -1,457 +1,554 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c' +source_filename = "benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x0 = dso_local global i32 0, align 4, !dbg !0 -@r1_1 = dso_local global i32 0, align 4, !dbg !40 -@x1 = dso_local global i32 0, align 4, !dbg !26 -@r2_1 = dso_local global i32 0, align 4, !dbg !42 -@r1_2 = dso_local global i32 0, align 4, !dbg !44 -@x2 = dso_local global i32 0, align 4, !dbg !30 -@r2_2 = dso_local global i32 0, align 4, !dbg !46 -@r1_3 = dso_local global i32 0, align 4, !dbg !48 -@x3 = dso_local global i32 0, align 4, !dbg !32 -@r2_3 = dso_local global i32 0, align 4, !dbg !50 -@r1_4 = dso_local global i32 0, align 4, !dbg !52 -@x4 = dso_local global i32 0, align 4, !dbg !34 -@r2_4 = dso_local global i32 0, align 4, !dbg !54 -@r1_5 = dso_local global i32 0, align 4, !dbg !56 -@x5 = dso_local global i32 0, align 4, !dbg !36 -@r2_5 = dso_local global i32 0, align 4, !dbg !58 -@r1_6 = dso_local global i32 0, align 4, !dbg !60 -@x6 = dso_local global i32 0, align 4, !dbg !38 -@r2_6 = dso_local global i32 0, align 4, !dbg !62 -@r1_7 = dso_local global i32 0, align 4, !dbg !64 -@r2_7 = dso_local global i32 0, align 4, !dbg !66 -@.str = private unnamed_addr constant [184 x i8] c"!((r2_7 == 0 && r1_1 == 1 && r2_1 == 0 && r1_2 == 1 && r2_2 == 0 && r1_3 == 1 && r2_3 == 0 && r1_4 == 1 && r2_4 == 0 && r1_5 == 1 && r2_5 == 0 && r1_6 == 1 && r2_6 == 0 && r1_7 == 1))\00", align 1 -@.str.1 = private unnamed_addr constant [77 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r1_1 = dso_local global i32 0, align 4, !dbg !59 +@x1 = dso_local global i32 0, align 4, !dbg !47 +@r2_1 = dso_local global i32 0, align 4, !dbg !61 +@r1_2 = dso_local global i32 0, align 4, !dbg !63 +@x2 = dso_local global i32 0, align 4, !dbg !49 +@r2_2 = dso_local global i32 0, align 4, !dbg !65 +@r1_3 = dso_local global i32 0, align 4, !dbg !67 +@x3 = dso_local global i32 0, align 4, !dbg !51 +@r2_3 = dso_local global i32 0, align 4, !dbg !69 +@r1_4 = dso_local global i32 0, align 4, !dbg !71 +@x4 = dso_local global i32 0, align 4, !dbg !53 +@r2_4 = dso_local global i32 0, align 4, !dbg !73 +@r1_5 = dso_local global i32 0, align 4, !dbg !75 +@x5 = dso_local global i32 0, align 4, !dbg !55 +@r2_5 = dso_local global i32 0, align 4, !dbg !77 +@r1_6 = dso_local global i32 0, align 4, !dbg !79 +@x6 = dso_local global i32 0, align 4, !dbg !57 +@r2_6 = dso_local global i32 0, align 4, !dbg !81 +@r1_7 = dso_local global i32 0, align 4, !dbg !83 +@r2_7 = dso_local global i32 0, align 4, !dbg !85 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [39 x i8] c"C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [184 x i8] c"!((r2_7 == 0 && r1_1 == 1 && r2_1 == 0 && r1_2 == 1 && r2_2 == 0 && r1_3 == 1 && r2_3 == 0 && r1_4 == 1 && r2_4 == 0 && r1_5 == 1 && r2_5 == 0 && r1_6 == 1 && r2_6 == 0 && r1_7 == 1))\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !76 { - call void @llvm.dbg.value(metadata i8* %0, metadata !80, metadata !DIExpression()), !dbg !81 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x0 to i8*), i32 noundef 1) #5, !dbg !82 - store i32 %2, i32* @r1_1, align 4, !dbg !83 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !84 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x1 to i8*), i32 noundef 1) #5, !dbg !85 - store i32 %3, i32* @r2_1, align 4, !dbg !86 - ret i8* null, !dbg !87 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !95 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !99, !DIExpression(), !100) + %3 = call i64 @__LKMM_load(ptr noundef @x0, i64 noundef 4, i32 noundef 0), !dbg !101 + %4 = trunc i64 %3 to i32, !dbg !101 + store i32 %4, ptr @r1_1, align 4, !dbg !102 + call void @__LKMM_fence(i32 noundef 8), !dbg !103 + %5 = call i64 @__LKMM_load(ptr noundef @x1, i64 noundef 4, i32 noundef 0), !dbg !104 + %6 = trunc i64 %5 to i32, !dbg !104 + store i32 %6, ptr @r2_1, align 4, !dbg !105 + ret ptr null, !dbg !106 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !88 { - call void @llvm.dbg.value(metadata i8* %0, metadata !89, metadata !DIExpression()), !dbg !90 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x1 to i8*), i32 noundef 1) #5, !dbg !91 - store i32 %2, i32* @r1_2, align 4, !dbg !92 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !93 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x2 to i8*), i32 noundef 1) #5, !dbg !94 - store i32 %3, i32* @r2_2, align 4, !dbg !95 - ret i8* null, !dbg !96 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !107 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !108, !DIExpression(), !109) + %3 = call i64 @__LKMM_load(ptr noundef @x1, i64 noundef 4, i32 noundef 0), !dbg !110 + %4 = trunc i64 %3 to i32, !dbg !110 + store i32 %4, ptr @r1_2, align 4, !dbg !111 + call void @__LKMM_fence(i32 noundef 8), !dbg !112 + %5 = call i64 @__LKMM_load(ptr noundef @x2, i64 noundef 4, i32 noundef 0), !dbg !113 + %6 = trunc i64 %5 to i32, !dbg !113 + store i32 %6, ptr @r2_2, align 4, !dbg !114 + ret ptr null, !dbg !115 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_3(i8* noundef %0) #0 !dbg !97 { - call void @llvm.dbg.value(metadata i8* %0, metadata !98, metadata !DIExpression()), !dbg !99 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x2 to i8*), i32 noundef 1) #5, !dbg !100 - store i32 %2, i32* @r1_3, align 4, !dbg !101 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !102 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x3 to i8*), i32 noundef 1) #5, !dbg !103 - store i32 %3, i32* @r2_3, align 4, !dbg !104 - ret i8* null, !dbg !105 +define dso_local ptr @thread_3(ptr noundef %0) #0 !dbg !116 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !117, !DIExpression(), !118) + %3 = call i64 @__LKMM_load(ptr noundef @x2, i64 noundef 4, i32 noundef 0), !dbg !119 + %4 = trunc i64 %3 to i32, !dbg !119 + store i32 %4, ptr @r1_3, align 4, !dbg !120 + call void @__LKMM_fence(i32 noundef 8), !dbg !121 + %5 = call i64 @__LKMM_load(ptr noundef @x3, i64 noundef 4, i32 noundef 0), !dbg !122 + %6 = trunc i64 %5 to i32, !dbg !122 + store i32 %6, ptr @r2_3, align 4, !dbg !123 + ret ptr null, !dbg !124 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_4(i8* noundef %0) #0 !dbg !106 { - call void @llvm.dbg.value(metadata i8* %0, metadata !107, metadata !DIExpression()), !dbg !108 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x3 to i8*), i32 noundef 1) #5, !dbg !109 - store i32 %2, i32* @r1_4, align 4, !dbg !110 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !111 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x4 to i8*), i32 noundef 1) #5, !dbg !112 - store i32 %3, i32* @r2_4, align 4, !dbg !113 - ret i8* null, !dbg !114 +define dso_local ptr @thread_4(ptr noundef %0) #0 !dbg !125 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !126, !DIExpression(), !127) + %3 = call i64 @__LKMM_load(ptr noundef @x3, i64 noundef 4, i32 noundef 0), !dbg !128 + %4 = trunc i64 %3 to i32, !dbg !128 + store i32 %4, ptr @r1_4, align 4, !dbg !129 + call void @__LKMM_fence(i32 noundef 8), !dbg !130 + %5 = call i64 @__LKMM_load(ptr noundef @x4, i64 noundef 4, i32 noundef 0), !dbg !131 + %6 = trunc i64 %5 to i32, !dbg !131 + store i32 %6, ptr @r2_4, align 4, !dbg !132 + ret ptr null, !dbg !133 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_5(i8* noundef %0) #0 !dbg !115 { - call void @llvm.dbg.value(metadata i8* %0, metadata !116, metadata !DIExpression()), !dbg !117 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !118 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x4 to i8*), i32 noundef 1) #5, !dbg !119 - store i32 %2, i32* @r1_5, align 4, !dbg !120 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x5 to i8*), i32 noundef 1) #5, !dbg !121 - store i32 %3, i32* @r2_5, align 4, !dbg !122 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !123 - ret i8* null, !dbg !124 +define dso_local ptr @thread_5(ptr noundef %0) #0 !dbg !134 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !135, !DIExpression(), !136) + call void @__LKMM_fence(i32 noundef 6), !dbg !137 + %3 = call i64 @__LKMM_load(ptr noundef @x4, i64 noundef 4, i32 noundef 0), !dbg !138 + %4 = trunc i64 %3 to i32, !dbg !138 + store i32 %4, ptr @r1_5, align 4, !dbg !139 + %5 = call i64 @__LKMM_load(ptr noundef @x5, i64 noundef 4, i32 noundef 0), !dbg !140 + %6 = trunc i64 %5 to i32, !dbg !140 + store i32 %6, ptr @r2_5, align 4, !dbg !141 + call void @__LKMM_fence(i32 noundef 7), !dbg !142 + ret ptr null, !dbg !143 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_6(i8* noundef %0) #0 !dbg !125 { - call void @llvm.dbg.value(metadata i8* %0, metadata !126, metadata !DIExpression()), !dbg !127 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !128 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x5 to i8*), i32 noundef 1) #5, !dbg !129 - store i32 %2, i32* @r1_6, align 4, !dbg !130 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x6 to i8*), i32 noundef 1) #5, !dbg !131 - store i32 %3, i32* @r2_6, align 4, !dbg !132 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !133 - ret i8* null, !dbg !134 +define dso_local ptr @thread_6(ptr noundef %0) #0 !dbg !144 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !145, !DIExpression(), !146) + call void @__LKMM_fence(i32 noundef 6), !dbg !147 + %3 = call i64 @__LKMM_load(ptr noundef @x5, i64 noundef 4, i32 noundef 0), !dbg !148 + %4 = trunc i64 %3 to i32, !dbg !148 + store i32 %4, ptr @r1_6, align 4, !dbg !149 + %5 = call i64 @__LKMM_load(ptr noundef @x6, i64 noundef 4, i32 noundef 0), !dbg !150 + %6 = trunc i64 %5 to i32, !dbg !150 + store i32 %6, ptr @r2_6, align 4, !dbg !151 + call void @__LKMM_fence(i32 noundef 7), !dbg !152 + ret ptr null, !dbg !153 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_7(i8* noundef %0) #0 !dbg !135 { - call void @llvm.dbg.value(metadata i8* %0, metadata !136, metadata !DIExpression()), !dbg !137 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !138 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x6 to i8*), i32 noundef 1) #5, !dbg !139 - store i32 %2, i32* @r1_7, align 4, !dbg !140 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x0 to i8*), i32 noundef 1) #5, !dbg !141 - store i32 %3, i32* @r2_7, align 4, !dbg !142 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !143 - ret i8* null, !dbg !144 +define dso_local ptr @thread_7(ptr noundef %0) #0 !dbg !154 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !155, !DIExpression(), !156) + call void @__LKMM_fence(i32 noundef 6), !dbg !157 + %3 = call i64 @__LKMM_load(ptr noundef @x6, i64 noundef 4, i32 noundef 0), !dbg !158 + %4 = trunc i64 %3 to i32, !dbg !158 + store i32 %4, ptr @r1_7, align 4, !dbg !159 + %5 = call i64 @__LKMM_load(ptr noundef @x0, i64 noundef 4, i32 noundef 0), !dbg !160 + %6 = trunc i64 %5 to i32, !dbg !160 + store i32 %6, ptr @r2_7, align 4, !dbg !161 + call void @__LKMM_fence(i32 noundef 7), !dbg !162 + ret ptr null, !dbg !163 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_8(i8* noundef %0) #0 !dbg !145 { - call void @llvm.dbg.value(metadata i8* %0, metadata !146, metadata !DIExpression()), !dbg !147 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x0 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !148 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x1 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !149 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x2 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !150 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x3 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !151 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x4 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !152 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x5 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !153 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x6 to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !154 - ret i8* null, !dbg !155 +define dso_local ptr @thread_8(ptr noundef %0) #0 !dbg !164 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !165, !DIExpression(), !166) + call void @__LKMM_store(ptr noundef @x0, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !167 + call void @__LKMM_store(ptr noundef @x1, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !168 + call void @__LKMM_store(ptr noundef @x2, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !169 + call void @__LKMM_store(ptr noundef @x3, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !170 + call void @__LKMM_store(ptr noundef @x4, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !171 + call void @__LKMM_store(ptr noundef @x5, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !172 + call void @__LKMM_store(ptr noundef @x6, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !173 + ret ptr null, !dbg !174 } -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !156 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - %4 = alloca i64, align 8 - %5 = alloca i64, align 8 - %6 = alloca i64, align 8 - %7 = alloca i64, align 8 - %8 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !159, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %9 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !164 - call void @llvm.dbg.value(metadata i64* %2, metadata !165, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %10 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !166 - call void @llvm.dbg.value(metadata i64* %3, metadata !167, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %11 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_3, i8* noundef null) #5, !dbg !168 - call void @llvm.dbg.value(metadata i64* %4, metadata !169, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %12 = call i32 @pthread_create(i64* noundef nonnull %4, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_4, i8* noundef null) #5, !dbg !170 - call void @llvm.dbg.value(metadata i64* %5, metadata !171, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %13 = call i32 @pthread_create(i64* noundef nonnull %5, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_5, i8* noundef null) #5, !dbg !172 - call void @llvm.dbg.value(metadata i64* %6, metadata !173, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %14 = call i32 @pthread_create(i64* noundef nonnull %6, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_6, i8* noundef null) #5, !dbg !174 - call void @llvm.dbg.value(metadata i64* %7, metadata !175, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %15 = call i32 @pthread_create(i64* noundef nonnull %7, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_7, i8* noundef null) #5, !dbg !176 - call void @llvm.dbg.value(metadata i64* %8, metadata !177, metadata !DIExpression(DW_OP_deref)), !dbg !163 - %16 = call i32 @pthread_create(i64* noundef nonnull %8, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_8, i8* noundef null) #5, !dbg !178 - %17 = load i64, i64* %1, align 8, !dbg !179 - call void @llvm.dbg.value(metadata i64 %17, metadata !159, metadata !DIExpression()), !dbg !163 - %18 = call i32 @pthread_join(i64 noundef %17, i8** noundef null) #5, !dbg !180 - %19 = load i64, i64* %2, align 8, !dbg !181 - call void @llvm.dbg.value(metadata i64 %19, metadata !165, metadata !DIExpression()), !dbg !163 - %20 = call i32 @pthread_join(i64 noundef %19, i8** noundef null) #5, !dbg !182 - %21 = load i64, i64* %3, align 8, !dbg !183 - call void @llvm.dbg.value(metadata i64 %21, metadata !167, metadata !DIExpression()), !dbg !163 - %22 = call i32 @pthread_join(i64 noundef %21, i8** noundef null) #5, !dbg !184 - %23 = load i64, i64* %4, align 8, !dbg !185 - call void @llvm.dbg.value(metadata i64 %23, metadata !169, metadata !DIExpression()), !dbg !163 - %24 = call i32 @pthread_join(i64 noundef %23, i8** noundef null) #5, !dbg !186 - %25 = load i64, i64* %5, align 8, !dbg !187 - call void @llvm.dbg.value(metadata i64 %25, metadata !171, metadata !DIExpression()), !dbg !163 - %26 = call i32 @pthread_join(i64 noundef %25, i8** noundef null) #5, !dbg !188 - %27 = load i64, i64* %6, align 8, !dbg !189 - call void @llvm.dbg.value(metadata i64 %27, metadata !173, metadata !DIExpression()), !dbg !163 - %28 = call i32 @pthread_join(i64 noundef %27, i8** noundef null) #5, !dbg !190 - %29 = load i64, i64* %7, align 8, !dbg !191 - call void @llvm.dbg.value(metadata i64 %29, metadata !175, metadata !DIExpression()), !dbg !163 - %30 = call i32 @pthread_join(i64 noundef %29, i8** noundef null) #5, !dbg !192 - %31 = load i64, i64* %8, align 8, !dbg !193 - call void @llvm.dbg.value(metadata i64 %31, metadata !177, metadata !DIExpression()), !dbg !163 - %32 = call i32 @pthread_join(i64 noundef %31, i8** noundef null) #5, !dbg !194 - %33 = load i32, i32* @r2_7, align 4, !dbg !195 - %34 = icmp eq i32 %33, 0, !dbg !195 - %35 = load i32, i32* @r1_1, align 4, !dbg !195 - %36 = icmp eq i32 %35, 1, !dbg !195 - %or.cond = select i1 %34, i1 %36, i1 false, !dbg !195 - %37 = load i32, i32* @r2_1, align 4, !dbg !195 - %38 = icmp eq i32 %37, 0, !dbg !195 - %or.cond3 = select i1 %or.cond, i1 %38, i1 false, !dbg !195 - %39 = load i32, i32* @r1_2, align 4, !dbg !195 - %40 = icmp eq i32 %39, 1, !dbg !195 - %or.cond5 = select i1 %or.cond3, i1 %40, i1 false, !dbg !195 - %41 = load i32, i32* @r2_2, align 4, !dbg !195 - %42 = icmp eq i32 %41, 0, !dbg !195 - %or.cond7 = select i1 %or.cond5, i1 %42, i1 false, !dbg !195 - %43 = load i32, i32* @r1_3, align 4, !dbg !195 - %44 = icmp eq i32 %43, 1, !dbg !195 - %or.cond9 = select i1 %or.cond7, i1 %44, i1 false, !dbg !195 - %45 = load i32, i32* @r2_3, align 4, !dbg !195 - %46 = icmp eq i32 %45, 0, !dbg !195 - %or.cond11 = select i1 %or.cond9, i1 %46, i1 false, !dbg !195 - %47 = load i32, i32* @r1_4, align 4, !dbg !195 - %48 = icmp eq i32 %47, 1, !dbg !195 - %or.cond13 = select i1 %or.cond11, i1 %48, i1 false, !dbg !195 - %49 = load i32, i32* @r2_4, align 4, !dbg !195 - %50 = icmp eq i32 %49, 0, !dbg !195 - %or.cond15 = select i1 %or.cond13, i1 %50, i1 false, !dbg !195 - %51 = load i32, i32* @r1_5, align 4, !dbg !195 - %52 = icmp eq i32 %51, 1, !dbg !195 - %or.cond17 = select i1 %or.cond15, i1 %52, i1 false, !dbg !195 - %53 = load i32, i32* @r2_5, align 4, !dbg !195 - %54 = icmp eq i32 %53, 0, !dbg !195 - %or.cond19 = select i1 %or.cond17, i1 %54, i1 false, !dbg !195 - %55 = load i32, i32* @r1_6, align 4, !dbg !195 - %56 = icmp eq i32 %55, 1, !dbg !195 - %or.cond21 = select i1 %or.cond19, i1 %56, i1 false, !dbg !195 - %57 = load i32, i32* @r2_6, align 4, !dbg !195 - %58 = icmp eq i32 %57, 0, !dbg !195 - %or.cond23 = select i1 %or.cond21, i1 %58, i1 false, !dbg !195 - %59 = load i32, i32* @r1_7, align 4, !dbg !195 - %60 = icmp eq i32 %59, 1, !dbg !195 - %or.cond25 = select i1 %or.cond23, i1 %60, i1 false, !dbg !195 - br i1 %or.cond25, label %61, label %62, !dbg !195 - -61: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([184 x i8], [184 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0), i32 noundef 98, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !195 - unreachable, !dbg !195 - -62: ; preds = %0 - ret i32 0, !dbg !198 -} +define dso_local i32 @main() #0 !dbg !175 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + %5 = alloca ptr, align 8 + %6 = alloca ptr, align 8 + %7 = alloca ptr, align 8 + %8 = alloca ptr, align 8 + %9 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !178, !DIExpression(), !201) + #dbg_declare(ptr %3, !202, !DIExpression(), !203) + #dbg_declare(ptr %4, !204, !DIExpression(), !205) + #dbg_declare(ptr %5, !206, !DIExpression(), !207) + #dbg_declare(ptr %6, !208, !DIExpression(), !209) + #dbg_declare(ptr %7, !210, !DIExpression(), !211) + #dbg_declare(ptr %8, !212, !DIExpression(), !213) + #dbg_declare(ptr %9, !214, !DIExpression(), !215) + %10 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !216 + %11 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !217 + %12 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @thread_3, ptr noundef null), !dbg !218 + %13 = call i32 @pthread_create(ptr noundef %5, ptr noundef null, ptr noundef @thread_4, ptr noundef null), !dbg !219 + %14 = call i32 @pthread_create(ptr noundef %6, ptr noundef null, ptr noundef @thread_5, ptr noundef null), !dbg !220 + %15 = call i32 @pthread_create(ptr noundef %7, ptr noundef null, ptr noundef @thread_6, ptr noundef null), !dbg !221 + %16 = call i32 @pthread_create(ptr noundef %8, ptr noundef null, ptr noundef @thread_7, ptr noundef null), !dbg !222 + %17 = call i32 @pthread_create(ptr noundef %9, ptr noundef null, ptr noundef @thread_8, ptr noundef null), !dbg !223 + %18 = load ptr, ptr %2, align 8, !dbg !224 + %19 = call i32 @_pthread_join(ptr noundef %18, ptr noundef null), !dbg !225 + %20 = load ptr, ptr %3, align 8, !dbg !226 + %21 = call i32 @_pthread_join(ptr noundef %20, ptr noundef null), !dbg !227 + %22 = load ptr, ptr %4, align 8, !dbg !228 + %23 = call i32 @_pthread_join(ptr noundef %22, ptr noundef null), !dbg !229 + %24 = load ptr, ptr %5, align 8, !dbg !230 + %25 = call i32 @_pthread_join(ptr noundef %24, ptr noundef null), !dbg !231 + %26 = load ptr, ptr %6, align 8, !dbg !232 + %27 = call i32 @_pthread_join(ptr noundef %26, ptr noundef null), !dbg !233 + %28 = load ptr, ptr %7, align 8, !dbg !234 + %29 = call i32 @_pthread_join(ptr noundef %28, ptr noundef null), !dbg !235 + %30 = load ptr, ptr %8, align 8, !dbg !236 + %31 = call i32 @_pthread_join(ptr noundef %30, ptr noundef null), !dbg !237 + %32 = load ptr, ptr %9, align 8, !dbg !238 + %33 = call i32 @_pthread_join(ptr noundef %32, ptr noundef null), !dbg !239 + %34 = load i32, ptr @r2_7, align 4, !dbg !240 + %35 = icmp eq i32 %34, 0, !dbg !240 + br i1 %35, label %36, label %75, !dbg !240 + +36: ; preds = %0 + %37 = load i32, ptr @r1_1, align 4, !dbg !240 + %38 = icmp eq i32 %37, 1, !dbg !240 + br i1 %38, label %39, label %75, !dbg !240 + +39: ; preds = %36 + %40 = load i32, ptr @r2_1, align 4, !dbg !240 + %41 = icmp eq i32 %40, 0, !dbg !240 + br i1 %41, label %42, label %75, !dbg !240 + +42: ; preds = %39 + %43 = load i32, ptr @r1_2, align 4, !dbg !240 + %44 = icmp eq i32 %43, 1, !dbg !240 + br i1 %44, label %45, label %75, !dbg !240 + +45: ; preds = %42 + %46 = load i32, ptr @r2_2, align 4, !dbg !240 + %47 = icmp eq i32 %46, 0, !dbg !240 + br i1 %47, label %48, label %75, !dbg !240 + +48: ; preds = %45 + %49 = load i32, ptr @r1_3, align 4, !dbg !240 + %50 = icmp eq i32 %49, 1, !dbg !240 + br i1 %50, label %51, label %75, !dbg !240 + +51: ; preds = %48 + %52 = load i32, ptr @r2_3, align 4, !dbg !240 + %53 = icmp eq i32 %52, 0, !dbg !240 + br i1 %53, label %54, label %75, !dbg !240 + +54: ; preds = %51 + %55 = load i32, ptr @r1_4, align 4, !dbg !240 + %56 = icmp eq i32 %55, 1, !dbg !240 + br i1 %56, label %57, label %75, !dbg !240 + +57: ; preds = %54 + %58 = load i32, ptr @r2_4, align 4, !dbg !240 + %59 = icmp eq i32 %58, 0, !dbg !240 + br i1 %59, label %60, label %75, !dbg !240 -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 +60: ; preds = %57 + %61 = load i32, ptr @r1_5, align 4, !dbg !240 + %62 = icmp eq i32 %61, 1, !dbg !240 + br i1 %62, label %63, label %75, !dbg !240 + +63: ; preds = %60 + %64 = load i32, ptr @r2_5, align 4, !dbg !240 + %65 = icmp eq i32 %64, 0, !dbg !240 + br i1 %65, label %66, label %75, !dbg !240 + +66: ; preds = %63 + %67 = load i32, ptr @r1_6, align 4, !dbg !240 + %68 = icmp eq i32 %67, 1, !dbg !240 + br i1 %68, label %69, label %75, !dbg !240 + +69: ; preds = %66 + %70 = load i32, ptr @r2_6, align 4, !dbg !240 + %71 = icmp eq i32 %70, 0, !dbg !240 + br i1 %71, label %72, label %75, !dbg !240 + +72: ; preds = %69 + %73 = load i32, ptr @r1_7, align 4, !dbg !240 + %74 = icmp eq i32 %73, 1, !dbg !240 + br label %75 + +75: ; preds = %72, %69, %66, %63, %60, %57, %54, %51, %48, %45, %42, %39, %36, %0 + %76 = phi i1 [ false, %69 ], [ false, %66 ], [ false, %63 ], [ false, %60 ], [ false, %57 ], [ false, %54 ], [ false, %51 ], [ false, %48 ], [ false, %45 ], [ false, %42 ], [ false, %39 ], [ false, %36 ], [ false, %0 ], [ %74, %72 ], !dbg !241 + %77 = xor i1 %76, true, !dbg !240 + %78 = xor i1 %77, true, !dbg !240 + %79 = zext i1 %78 to i32, !dbg !240 + %80 = sext i32 %79 to i64, !dbg !240 + %81 = icmp ne i64 %80, 0, !dbg !240 + br i1 %81, label %82, label %84, !dbg !240 + +82: ; preds = %75 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 98, ptr noundef @.str.1) #3, !dbg !240 + unreachable, !dbg !240 + +83: ; No predecessors! + br label %85, !dbg !240 + +84: ; preds = %75 + br label %85, !dbg !240 + +85: ; preds = %84, %83 + ret i32 0, !dbg !242 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!68, !69, !70, !71, !72, !73, !74} -!llvm.ident = !{!75} +!llvm.module.flags = !{!87, !88, !89, !90, !91, !92, !93} +!llvm.ident = !{!94} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "dbafb2cd139d33a606f4c8b7719d2341") +!1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "dbafb2cd139d33a606f4c8b7719d2341") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !24, !25} +!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32, !34, !36, !38, !40, !42, !44, !46, !48, !50, !52, !54, !56, !58, !60, !62, !64, !66} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "x1", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/C-RR-G+RR-G+RR-G+RR-G+RR-R+RR-R+RR-R.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "dbafb2cd139d33a606f4c8b7719d2341") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !26) +!26 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !27, line: 32, baseType: !28) +!27 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!28 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !0, !47, !49, !51, !53, !55, !57, !59, !61, !63, !65, !67, !69, !71, !73, !75, !77, !79, !81, !83, !85} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "x2", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "x3", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) -!35 = distinct !DIGlobalVariable(name: "x4", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) -!37 = distinct !DIGlobalVariable(name: "x5", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!38 = !DIGlobalVariableExpression(var: !39, expr: !DIExpression()) -!39 = distinct !DIGlobalVariable(name: "x6", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) -!41 = distinct !DIGlobalVariable(name: "r1_1", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 98, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 98, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 312, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 39) !42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) -!43 = distinct !DIGlobalVariable(name: "r2_1", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!44 = !DIGlobalVariableExpression(var: !45, expr: !DIExpression()) -!45 = distinct !DIGlobalVariable(name: "r1_2", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression()) -!47 = distinct !DIGlobalVariable(name: "r2_2", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) -!49 = distinct !DIGlobalVariable(name: "r1_3", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression()) -!51 = distinct !DIGlobalVariable(name: "r2_3", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression()) -!53 = distinct !DIGlobalVariable(name: "r1_4", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!54 = !DIGlobalVariableExpression(var: !55, expr: !DIExpression()) -!55 = distinct !DIGlobalVariable(name: "r2_4", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!56 = !DIGlobalVariableExpression(var: !57, expr: !DIExpression()) -!57 = distinct !DIGlobalVariable(name: "r1_5", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!58 = !DIGlobalVariableExpression(var: !59, expr: !DIExpression()) -!59 = distinct !DIGlobalVariable(name: "r2_5", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!60 = !DIGlobalVariableExpression(var: !61, expr: !DIExpression()) -!61 = distinct !DIGlobalVariable(name: "r1_6", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!62 = !DIGlobalVariableExpression(var: !63, expr: !DIExpression()) -!63 = distinct !DIGlobalVariable(name: "r2_6", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!64 = !DIGlobalVariableExpression(var: !65, expr: !DIExpression()) -!65 = distinct !DIGlobalVariable(name: "r1_7", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!66 = !DIGlobalVariableExpression(var: !67, expr: !DIExpression()) -!67 = distinct !DIGlobalVariable(name: "r2_7", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!68 = !{i32 7, !"Dwarf Version", i32 5} -!69 = !{i32 2, !"Debug Info Version", i32 3} -!70 = !{i32 1, !"wchar_size", i32 4} -!71 = !{i32 7, !"PIC Level", i32 2} -!72 = !{i32 7, !"PIE Level", i32 2} -!73 = !{i32 7, !"uwtable", i32 1} -!74 = !{i32 7, !"frame-pointer", i32 2} -!75 = !{!"Ubuntu clang version 14.0.6"} -!76 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 10, type: !77, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!77 = !DISubroutineType(types: !78) -!78 = !{!24, !24} -!79 = !{} -!80 = !DILocalVariable(name: "arg", arg: 1, scope: !76, file: !28, line: 10, type: !24) -!81 = !DILocation(line: 0, scope: !76) -!82 = !DILocation(line: 11, column: 9, scope: !76) -!83 = !DILocation(line: 11, column: 7, scope: !76) -!84 = !DILocation(line: 12, column: 2, scope: !76) -!85 = !DILocation(line: 13, column: 9, scope: !76) -!86 = !DILocation(line: 13, column: 7, scope: !76) -!87 = !DILocation(line: 14, column: 2, scope: !76) -!88 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 17, type: !77, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!89 = !DILocalVariable(name: "arg", arg: 1, scope: !88, file: !28, line: 17, type: !24) -!90 = !DILocation(line: 0, scope: !88) -!91 = !DILocation(line: 18, column: 9, scope: !88) -!92 = !DILocation(line: 18, column: 7, scope: !88) -!93 = !DILocation(line: 19, column: 2, scope: !88) -!94 = !DILocation(line: 20, column: 9, scope: !88) -!95 = !DILocation(line: 20, column: 7, scope: !88) -!96 = !DILocation(line: 21, column: 2, scope: !88) -!97 = distinct !DISubprogram(name: "thread_3", scope: !28, file: !28, line: 24, type: !77, scopeLine: 24, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!98 = !DILocalVariable(name: "arg", arg: 1, scope: !97, file: !28, line: 24, type: !24) -!99 = !DILocation(line: 0, scope: !97) -!100 = !DILocation(line: 25, column: 9, scope: !97) -!101 = !DILocation(line: 25, column: 7, scope: !97) -!102 = !DILocation(line: 26, column: 2, scope: !97) -!103 = !DILocation(line: 27, column: 9, scope: !97) -!104 = !DILocation(line: 27, column: 7, scope: !97) -!105 = !DILocation(line: 28, column: 2, scope: !97) -!106 = distinct !DISubprogram(name: "thread_4", scope: !28, file: !28, line: 31, type: !77, scopeLine: 31, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!107 = !DILocalVariable(name: "arg", arg: 1, scope: !106, file: !28, line: 31, type: !24) -!108 = !DILocation(line: 0, scope: !106) -!109 = !DILocation(line: 32, column: 9, scope: !106) -!110 = !DILocation(line: 32, column: 7, scope: !106) -!111 = !DILocation(line: 33, column: 2, scope: !106) -!112 = !DILocation(line: 34, column: 9, scope: !106) -!113 = !DILocation(line: 34, column: 7, scope: !106) -!114 = !DILocation(line: 35, column: 2, scope: !106) -!115 = distinct !DISubprogram(name: "thread_5", scope: !28, file: !28, line: 38, type: !77, scopeLine: 38, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!116 = !DILocalVariable(name: "arg", arg: 1, scope: !115, file: !28, line: 38, type: !24) -!117 = !DILocation(line: 0, scope: !115) -!118 = !DILocation(line: 39, column: 2, scope: !115) -!119 = !DILocation(line: 40, column: 9, scope: !115) -!120 = !DILocation(line: 40, column: 7, scope: !115) -!121 = !DILocation(line: 41, column: 9, scope: !115) -!122 = !DILocation(line: 41, column: 7, scope: !115) -!123 = !DILocation(line: 42, column: 2, scope: !115) -!124 = !DILocation(line: 43, column: 2, scope: !115) -!125 = distinct !DISubprogram(name: "thread_6", scope: !28, file: !28, line: 46, type: !77, scopeLine: 46, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!126 = !DILocalVariable(name: "arg", arg: 1, scope: !125, file: !28, line: 46, type: !24) -!127 = !DILocation(line: 0, scope: !125) -!128 = !DILocation(line: 47, column: 2, scope: !125) -!129 = !DILocation(line: 48, column: 9, scope: !125) -!130 = !DILocation(line: 48, column: 7, scope: !125) -!131 = !DILocation(line: 49, column: 9, scope: !125) -!132 = !DILocation(line: 49, column: 7, scope: !125) -!133 = !DILocation(line: 50, column: 2, scope: !125) -!134 = !DILocation(line: 51, column: 2, scope: !125) -!135 = distinct !DISubprogram(name: "thread_7", scope: !28, file: !28, line: 54, type: !77, scopeLine: 54, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!136 = !DILocalVariable(name: "arg", arg: 1, scope: !135, file: !28, line: 54, type: !24) -!137 = !DILocation(line: 0, scope: !135) -!138 = !DILocation(line: 55, column: 2, scope: !135) -!139 = !DILocation(line: 56, column: 9, scope: !135) -!140 = !DILocation(line: 56, column: 7, scope: !135) -!141 = !DILocation(line: 57, column: 9, scope: !135) -!142 = !DILocation(line: 57, column: 7, scope: !135) -!143 = !DILocation(line: 58, column: 2, scope: !135) -!144 = !DILocation(line: 59, column: 2, scope: !135) -!145 = distinct !DISubprogram(name: "thread_8", scope: !28, file: !28, line: 62, type: !77, scopeLine: 62, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!146 = !DILocalVariable(name: "arg", arg: 1, scope: !145, file: !28, line: 62, type: !24) -!147 = !DILocation(line: 0, scope: !145) -!148 = !DILocation(line: 63, column: 2, scope: !145) -!149 = !DILocation(line: 64, column: 2, scope: !145) -!150 = !DILocation(line: 65, column: 2, scope: !145) -!151 = !DILocation(line: 66, column: 2, scope: !145) -!152 = !DILocation(line: 67, column: 2, scope: !145) -!153 = !DILocation(line: 68, column: 2, scope: !145) -!154 = !DILocation(line: 69, column: 2, scope: !145) -!155 = !DILocation(line: 70, column: 2, scope: !145) -!156 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 73, type: !157, scopeLine: 74, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) -!157 = !DISubroutineType(types: !158) -!158 = !{!29} -!159 = !DILocalVariable(name: "t1", scope: !156, file: !28, line: 78, type: !160) -!160 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !161, line: 27, baseType: !162) -!161 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!162 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!163 = !DILocation(line: 0, scope: !156) -!164 = !DILocation(line: 80, column: 2, scope: !156) -!165 = !DILocalVariable(name: "t2", scope: !156, file: !28, line: 78, type: !160) -!166 = !DILocation(line: 81, column: 2, scope: !156) -!167 = !DILocalVariable(name: "t3", scope: !156, file: !28, line: 78, type: !160) -!168 = !DILocation(line: 82, column: 2, scope: !156) -!169 = !DILocalVariable(name: "t4", scope: !156, file: !28, line: 78, type: !160) -!170 = !DILocation(line: 83, column: 2, scope: !156) -!171 = !DILocalVariable(name: "t5", scope: !156, file: !28, line: 78, type: !160) -!172 = !DILocation(line: 84, column: 2, scope: !156) -!173 = !DILocalVariable(name: "t6", scope: !156, file: !28, line: 78, type: !160) -!174 = !DILocation(line: 85, column: 2, scope: !156) -!175 = !DILocalVariable(name: "t7", scope: !156, file: !28, line: 78, type: !160) -!176 = !DILocation(line: 86, column: 2, scope: !156) -!177 = !DILocalVariable(name: "t8", scope: !156, file: !28, line: 78, type: !160) -!178 = !DILocation(line: 87, column: 2, scope: !156) -!179 = !DILocation(line: 89, column: 15, scope: !156) -!180 = !DILocation(line: 89, column: 2, scope: !156) -!181 = !DILocation(line: 90, column: 15, scope: !156) -!182 = !DILocation(line: 90, column: 2, scope: !156) -!183 = !DILocation(line: 91, column: 15, scope: !156) -!184 = !DILocation(line: 91, column: 2, scope: !156) -!185 = !DILocation(line: 92, column: 15, scope: !156) -!186 = !DILocation(line: 92, column: 2, scope: !156) -!187 = !DILocation(line: 93, column: 15, scope: !156) -!188 = !DILocation(line: 93, column: 2, scope: !156) -!189 = !DILocation(line: 94, column: 15, scope: !156) -!190 = !DILocation(line: 94, column: 2, scope: !156) -!191 = !DILocation(line: 95, column: 15, scope: !156) -!192 = !DILocation(line: 95, column: 2, scope: !156) -!193 = !DILocation(line: 96, column: 15, scope: !156) -!194 = !DILocation(line: 96, column: 2, scope: !156) -!195 = !DILocation(line: 98, column: 2, scope: !196) -!196 = distinct !DILexicalBlock(scope: !197, file: !28, line: 98, column: 2) -!197 = distinct !DILexicalBlock(scope: !156, file: !28, line: 98, column: 2) -!198 = !DILocation(line: 100, column: 2, scope: !156) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 98, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 1472, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 184) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "x1", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "x2", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "x3", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "x4", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!55 = !DIGlobalVariableExpression(var: !56, expr: !DIExpression()) +!56 = distinct !DIGlobalVariable(name: "x5", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!57 = !DIGlobalVariableExpression(var: !58, expr: !DIExpression()) +!58 = distinct !DIGlobalVariable(name: "x6", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression()) +!60 = distinct !DIGlobalVariable(name: "r1_1", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!61 = !DIGlobalVariableExpression(var: !62, expr: !DIExpression()) +!62 = distinct !DIGlobalVariable(name: "r2_1", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!63 = !DIGlobalVariableExpression(var: !64, expr: !DIExpression()) +!64 = distinct !DIGlobalVariable(name: "r1_2", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!65 = !DIGlobalVariableExpression(var: !66, expr: !DIExpression()) +!66 = distinct !DIGlobalVariable(name: "r2_2", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!67 = !DIGlobalVariableExpression(var: !68, expr: !DIExpression()) +!68 = distinct !DIGlobalVariable(name: "r1_3", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!69 = !DIGlobalVariableExpression(var: !70, expr: !DIExpression()) +!70 = distinct !DIGlobalVariable(name: "r2_3", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!71 = !DIGlobalVariableExpression(var: !72, expr: !DIExpression()) +!72 = distinct !DIGlobalVariable(name: "r1_4", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!73 = !DIGlobalVariableExpression(var: !74, expr: !DIExpression()) +!74 = distinct !DIGlobalVariable(name: "r2_4", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!75 = !DIGlobalVariableExpression(var: !76, expr: !DIExpression()) +!76 = distinct !DIGlobalVariable(name: "r1_5", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!77 = !DIGlobalVariableExpression(var: !78, expr: !DIExpression()) +!78 = distinct !DIGlobalVariable(name: "r2_5", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!79 = !DIGlobalVariableExpression(var: !80, expr: !DIExpression()) +!80 = distinct !DIGlobalVariable(name: "r1_6", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!81 = !DIGlobalVariableExpression(var: !82, expr: !DIExpression()) +!82 = distinct !DIGlobalVariable(name: "r2_6", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!83 = !DIGlobalVariableExpression(var: !84, expr: !DIExpression()) +!84 = distinct !DIGlobalVariable(name: "r1_7", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!85 = !DIGlobalVariableExpression(var: !86, expr: !DIExpression()) +!86 = distinct !DIGlobalVariable(name: "r2_7", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!87 = !{i32 7, !"Dwarf Version", i32 5} +!88 = !{i32 2, !"Debug Info Version", i32 3} +!89 = !{i32 1, !"wchar_size", i32 4} +!90 = !{i32 8, !"PIC Level", i32 2} +!91 = !{i32 7, !"PIE Level", i32 2} +!92 = !{i32 7, !"uwtable", i32 2} +!93 = !{i32 7, !"frame-pointer", i32 2} +!94 = !{!"Homebrew clang version 19.1.7"} +!95 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 10, type: !96, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!96 = !DISubroutineType(types: !97) +!97 = !{!24, !24} +!98 = !{} +!99 = !DILocalVariable(name: "arg", arg: 1, scope: !95, file: !3, line: 10, type: !24) +!100 = !DILocation(line: 10, column: 22, scope: !95) +!101 = !DILocation(line: 11, column: 9, scope: !95) +!102 = !DILocation(line: 11, column: 7, scope: !95) +!103 = !DILocation(line: 12, column: 2, scope: !95) +!104 = !DILocation(line: 13, column: 9, scope: !95) +!105 = !DILocation(line: 13, column: 7, scope: !95) +!106 = !DILocation(line: 14, column: 2, scope: !95) +!107 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 17, type: !96, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!108 = !DILocalVariable(name: "arg", arg: 1, scope: !107, file: !3, line: 17, type: !24) +!109 = !DILocation(line: 17, column: 22, scope: !107) +!110 = !DILocation(line: 18, column: 9, scope: !107) +!111 = !DILocation(line: 18, column: 7, scope: !107) +!112 = !DILocation(line: 19, column: 2, scope: !107) +!113 = !DILocation(line: 20, column: 9, scope: !107) +!114 = !DILocation(line: 20, column: 7, scope: !107) +!115 = !DILocation(line: 21, column: 2, scope: !107) +!116 = distinct !DISubprogram(name: "thread_3", scope: !3, file: !3, line: 24, type: !96, scopeLine: 24, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!117 = !DILocalVariable(name: "arg", arg: 1, scope: !116, file: !3, line: 24, type: !24) +!118 = !DILocation(line: 24, column: 22, scope: !116) +!119 = !DILocation(line: 25, column: 9, scope: !116) +!120 = !DILocation(line: 25, column: 7, scope: !116) +!121 = !DILocation(line: 26, column: 2, scope: !116) +!122 = !DILocation(line: 27, column: 9, scope: !116) +!123 = !DILocation(line: 27, column: 7, scope: !116) +!124 = !DILocation(line: 28, column: 2, scope: !116) +!125 = distinct !DISubprogram(name: "thread_4", scope: !3, file: !3, line: 31, type: !96, scopeLine: 31, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!126 = !DILocalVariable(name: "arg", arg: 1, scope: !125, file: !3, line: 31, type: !24) +!127 = !DILocation(line: 31, column: 22, scope: !125) +!128 = !DILocation(line: 32, column: 9, scope: !125) +!129 = !DILocation(line: 32, column: 7, scope: !125) +!130 = !DILocation(line: 33, column: 2, scope: !125) +!131 = !DILocation(line: 34, column: 9, scope: !125) +!132 = !DILocation(line: 34, column: 7, scope: !125) +!133 = !DILocation(line: 35, column: 2, scope: !125) +!134 = distinct !DISubprogram(name: "thread_5", scope: !3, file: !3, line: 38, type: !96, scopeLine: 38, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!135 = !DILocalVariable(name: "arg", arg: 1, scope: !134, file: !3, line: 38, type: !24) +!136 = !DILocation(line: 38, column: 22, scope: !134) +!137 = !DILocation(line: 39, column: 2, scope: !134) +!138 = !DILocation(line: 40, column: 9, scope: !134) +!139 = !DILocation(line: 40, column: 7, scope: !134) +!140 = !DILocation(line: 41, column: 9, scope: !134) +!141 = !DILocation(line: 41, column: 7, scope: !134) +!142 = !DILocation(line: 42, column: 2, scope: !134) +!143 = !DILocation(line: 43, column: 2, scope: !134) +!144 = distinct !DISubprogram(name: "thread_6", scope: !3, file: !3, line: 46, type: !96, scopeLine: 46, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!145 = !DILocalVariable(name: "arg", arg: 1, scope: !144, file: !3, line: 46, type: !24) +!146 = !DILocation(line: 46, column: 22, scope: !144) +!147 = !DILocation(line: 47, column: 2, scope: !144) +!148 = !DILocation(line: 48, column: 9, scope: !144) +!149 = !DILocation(line: 48, column: 7, scope: !144) +!150 = !DILocation(line: 49, column: 9, scope: !144) +!151 = !DILocation(line: 49, column: 7, scope: !144) +!152 = !DILocation(line: 50, column: 2, scope: !144) +!153 = !DILocation(line: 51, column: 2, scope: !144) +!154 = distinct !DISubprogram(name: "thread_7", scope: !3, file: !3, line: 54, type: !96, scopeLine: 54, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!155 = !DILocalVariable(name: "arg", arg: 1, scope: !154, file: !3, line: 54, type: !24) +!156 = !DILocation(line: 54, column: 22, scope: !154) +!157 = !DILocation(line: 55, column: 2, scope: !154) +!158 = !DILocation(line: 56, column: 9, scope: !154) +!159 = !DILocation(line: 56, column: 7, scope: !154) +!160 = !DILocation(line: 57, column: 9, scope: !154) +!161 = !DILocation(line: 57, column: 7, scope: !154) +!162 = !DILocation(line: 58, column: 2, scope: !154) +!163 = !DILocation(line: 59, column: 2, scope: !154) +!164 = distinct !DISubprogram(name: "thread_8", scope: !3, file: !3, line: 62, type: !96, scopeLine: 62, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!165 = !DILocalVariable(name: "arg", arg: 1, scope: !164, file: !3, line: 62, type: !24) +!166 = !DILocation(line: 62, column: 22, scope: !164) +!167 = !DILocation(line: 63, column: 2, scope: !164) +!168 = !DILocation(line: 64, column: 2, scope: !164) +!169 = !DILocation(line: 65, column: 2, scope: !164) +!170 = !DILocation(line: 66, column: 2, scope: !164) +!171 = !DILocation(line: 67, column: 2, scope: !164) +!172 = !DILocation(line: 68, column: 2, scope: !164) +!173 = !DILocation(line: 69, column: 2, scope: !164) +!174 = !DILocation(line: 70, column: 2, scope: !164) +!175 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 73, type: !176, scopeLine: 74, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !98) +!176 = !DISubroutineType(types: !177) +!177 = !{!23} +!178 = !DILocalVariable(name: "t1", scope: !175, file: !3, line: 78, type: !179) +!179 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !180, line: 31, baseType: !181) +!180 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!181 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !182, line: 118, baseType: !183) +!182 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!183 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !184, size: 64) +!184 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !182, line: 103, size: 65536, elements: !185) +!185 = !{!186, !187, !197} +!186 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !184, file: !182, line: 104, baseType: !28, size: 64) +!187 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !184, file: !182, line: 105, baseType: !188, size: 64, offset: 64) +!188 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !189, size: 64) +!189 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !182, line: 57, size: 192, elements: !190) +!190 = !{!191, !195, !196} +!191 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !189, file: !182, line: 58, baseType: !192, size: 64) +!192 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !193, size: 64) +!193 = !DISubroutineType(types: !194) +!194 = !{null, !24} +!195 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !189, file: !182, line: 59, baseType: !24, size: 64, offset: 64) +!196 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !189, file: !182, line: 60, baseType: !188, size: 64, offset: 128) +!197 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !184, file: !182, line: 106, baseType: !198, size: 65408, offset: 128) +!198 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !199) +!199 = !{!200} +!200 = !DISubrange(count: 8176) +!201 = !DILocation(line: 78, column: 15, scope: !175) +!202 = !DILocalVariable(name: "t2", scope: !175, file: !3, line: 78, type: !179) +!203 = !DILocation(line: 78, column: 19, scope: !175) +!204 = !DILocalVariable(name: "t3", scope: !175, file: !3, line: 78, type: !179) +!205 = !DILocation(line: 78, column: 23, scope: !175) +!206 = !DILocalVariable(name: "t4", scope: !175, file: !3, line: 78, type: !179) +!207 = !DILocation(line: 78, column: 27, scope: !175) +!208 = !DILocalVariable(name: "t5", scope: !175, file: !3, line: 78, type: !179) +!209 = !DILocation(line: 78, column: 31, scope: !175) +!210 = !DILocalVariable(name: "t6", scope: !175, file: !3, line: 78, type: !179) +!211 = !DILocation(line: 78, column: 35, scope: !175) +!212 = !DILocalVariable(name: "t7", scope: !175, file: !3, line: 78, type: !179) +!213 = !DILocation(line: 78, column: 39, scope: !175) +!214 = !DILocalVariable(name: "t8", scope: !175, file: !3, line: 78, type: !179) +!215 = !DILocation(line: 78, column: 43, scope: !175) +!216 = !DILocation(line: 80, column: 2, scope: !175) +!217 = !DILocation(line: 81, column: 2, scope: !175) +!218 = !DILocation(line: 82, column: 2, scope: !175) +!219 = !DILocation(line: 83, column: 2, scope: !175) +!220 = !DILocation(line: 84, column: 2, scope: !175) +!221 = !DILocation(line: 85, column: 2, scope: !175) +!222 = !DILocation(line: 86, column: 2, scope: !175) +!223 = !DILocation(line: 87, column: 2, scope: !175) +!224 = !DILocation(line: 89, column: 15, scope: !175) +!225 = !DILocation(line: 89, column: 2, scope: !175) +!226 = !DILocation(line: 90, column: 15, scope: !175) +!227 = !DILocation(line: 90, column: 2, scope: !175) +!228 = !DILocation(line: 91, column: 15, scope: !175) +!229 = !DILocation(line: 91, column: 2, scope: !175) +!230 = !DILocation(line: 92, column: 15, scope: !175) +!231 = !DILocation(line: 92, column: 2, scope: !175) +!232 = !DILocation(line: 93, column: 15, scope: !175) +!233 = !DILocation(line: 93, column: 2, scope: !175) +!234 = !DILocation(line: 94, column: 15, scope: !175) +!235 = !DILocation(line: 94, column: 2, scope: !175) +!236 = !DILocation(line: 95, column: 15, scope: !175) +!237 = !DILocation(line: 95, column: 2, scope: !175) +!238 = !DILocation(line: 96, column: 15, scope: !175) +!239 = !DILocation(line: 96, column: 2, scope: !175) +!240 = !DILocation(line: 98, column: 2, scope: !175) +!241 = !DILocation(line: 0, scope: !175) +!242 = !DILocation(line: 100, column: 2, scope: !175) diff --git a/dartagnan/src/test/resources/lkmm/C-WWC+o-branch-o+o-branch-o.ll b/dartagnan/src/test/resources/lkmm/C-WWC+o-branch-o+o-branch-o.ll index 76143d3a6f..c16313b84d 100644 --- a/dartagnan/src/test/resources/lkmm/C-WWC+o-branch-o+o-branch-o.ll +++ b/dartagnan/src/test/resources/lkmm/C-WWC+o-branch-o+o-branch-o.ll @@ -1,239 +1,301 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/C-WWC+o-branch-o+o-branch-o.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c' +source_filename = "benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !0 -@r1_0 = dso_local global i32 0, align 4, !dbg !34 -@r3_0 = dso_local global i32 0, align 4, !dbg !36 -@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !26 -@r2_1 = dso_local global i32 0, align 4, !dbg !38 -@r4_1 = dso_local global i32 0, align 4, !dbg !40 -@.str = private unnamed_addr constant [47 x i8] c"!(r1_0 == 2 && r2_1 == 1 && READ_ONCE(x) == 2)\00", align 1 -@.str.1 = private unnamed_addr constant [68 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r1_0 = dso_local global i32 0, align 4, !dbg !53 +@r3_0 = dso_local global i32 0, align 4, !dbg !55 +@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !47 +@r2_1 = dso_local global i32 0, align 4, !dbg !57 +@r4_1 = dso_local global i32 0, align 4, !dbg !59 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [30 x i8] c"C-WWC+o-branch-o+o-branch-o.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [50 x i8] c"!(r1_0 == 2 && r2_1 == 1 && atomic_read(&x) == 2)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !50 { - call void @llvm.dbg.value(metadata i8* %0, metadata !54, metadata !DIExpression()), !dbg !55 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #5, !dbg !56 - store i32 %2, i32* @r1_0, align 4, !dbg !57 - %3 = icmp ne i32 %2, 0, !dbg !58 - %4 = zext i1 %3 to i32, !dbg !58 - store i32 %4, i32* @r3_0, align 4, !dbg !59 - br i1 %3, label %5, label %6, !dbg !60 - -5: ; preds = %1 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !61 - br label %6, !dbg !64 - -6: ; preds = %5, %1 - ret i8* null, !dbg !65 -} +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !69 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !73, !DIExpression(), !74) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !75 + %4 = trunc i64 %3 to i32, !dbg !75 + store i32 %4, ptr @r1_0, align 4, !dbg !76 + %5 = load i32, ptr @r1_0, align 4, !dbg !77 + %6 = icmp ne i32 %5, 0, !dbg !78 + %7 = zext i1 %6 to i32, !dbg !78 + store i32 %7, ptr @r3_0, align 4, !dbg !79 + %8 = load i32, ptr @r3_0, align 4, !dbg !80 + %9 = icmp ne i32 %8, 0, !dbg !80 + br i1 %9, label %10, label %11, !dbg !82 + +10: ; preds = %1 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !83 + br label %11, !dbg !85 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +11: ; preds = %10, %1 + ret ptr null, !dbg !86 +} -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !66 { - call void @llvm.dbg.value(metadata i8* %0, metadata !67, metadata !DIExpression()), !dbg !68 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1) #5, !dbg !69 - store i32 %2, i32* @r2_1, align 4, !dbg !70 - %3 = icmp ne i32 %2, 0, !dbg !71 - %4 = zext i1 %3 to i32, !dbg !71 - store i32 %4, i32* @r4_1, align 4, !dbg !72 - br i1 %3, label %5, label %6, !dbg !73 - -5: ; preds = %1 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !74 - br label %6, !dbg !77 - -6: ; preds = %5, %1 - ret i8* null, !dbg !78 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !87 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !88, !DIExpression(), !89) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !90 + %4 = trunc i64 %3 to i32, !dbg !90 + store i32 %4, ptr @r2_1, align 4, !dbg !91 + %5 = load i32, ptr @r2_1, align 4, !dbg !92 + %6 = icmp ne i32 %5, 0, !dbg !93 + %7 = zext i1 %6 to i32, !dbg !93 + store i32 %7, ptr @r4_1, align 4, !dbg !94 + %8 = load i32, ptr @r4_1, align 4, !dbg !95 + %9 = icmp ne i32 %8, 0, !dbg !95 + br i1 %9, label %10, label %11, !dbg !97 + +10: ; preds = %1 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !98 + br label %11, !dbg !100 + +11: ; preds = %10, %1 + ret ptr null, !dbg !101 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_3(i8* noundef %0) #0 !dbg !79 { - call void @llvm.dbg.value(metadata i8* %0, metadata !80, metadata !DIExpression()), !dbg !81 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !82 - ret i8* null, !dbg !83 +define dso_local ptr @thread_3(ptr noundef %0) #0 !dbg !102 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !103, !DIExpression(), !104) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !105 + ret ptr null, !dbg !106 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !84 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !87, metadata !DIExpression(DW_OP_deref)), !dbg !91 - %4 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !92 - call void @llvm.dbg.value(metadata i64* %2, metadata !93, metadata !DIExpression(DW_OP_deref)), !dbg !91 - %5 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !94 - call void @llvm.dbg.value(metadata i64* %3, metadata !95, metadata !DIExpression(DW_OP_deref)), !dbg !91 - %6 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_3, i8* noundef null) #5, !dbg !96 - %7 = load i64, i64* %1, align 8, !dbg !97 - call void @llvm.dbg.value(metadata i64 %7, metadata !87, metadata !DIExpression()), !dbg !91 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !98 - %9 = load i64, i64* %2, align 8, !dbg !99 - call void @llvm.dbg.value(metadata i64 %9, metadata !93, metadata !DIExpression()), !dbg !91 - %10 = call i32 @pthread_join(i64 noundef %9, i8** noundef null) #5, !dbg !100 - %11 = load i64, i64* %3, align 8, !dbg !101 - call void @llvm.dbg.value(metadata i64 %11, metadata !95, metadata !DIExpression()), !dbg !91 - %12 = call i32 @pthread_join(i64 noundef %11, i8** noundef null) #5, !dbg !102 - %13 = load i32, i32* @r1_0, align 4, !dbg !103 - %14 = icmp eq i32 %13, 2, !dbg !103 - %15 = load i32, i32* @r2_1, align 4, !dbg !103 - %16 = icmp eq i32 %15, 1, !dbg !103 - %or.cond = select i1 %14, i1 %16, i1 false, !dbg !103 - br i1 %or.cond, label %17, label %21, !dbg !103 - -17: ; preds = %0 - %18 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #5, !dbg !103 - %19 = icmp eq i32 %18, 2, !dbg !103 - br i1 %19, label %20, label %21, !dbg !106 - -20: ; preds = %17 - call void @__assert_fail(i8* noundef getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i32 noundef 53, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !103 - unreachable, !dbg !103 - -21: ; preds = %0, %17 - ret i32 0, !dbg !107 -} +define dso_local i32 @main() #0 !dbg !107 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !110, !DIExpression(), !133) + #dbg_declare(ptr %3, !134, !DIExpression(), !135) + #dbg_declare(ptr %4, !136, !DIExpression(), !137) + %5 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !138 + %6 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !139 + %7 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @thread_3, ptr noundef null), !dbg !140 + %8 = load ptr, ptr %2, align 8, !dbg !141 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !142 + %10 = load ptr, ptr %3, align 8, !dbg !143 + %11 = call i32 @_pthread_join(ptr noundef %10, ptr noundef null), !dbg !144 + %12 = load ptr, ptr %4, align 8, !dbg !145 + %13 = call i32 @_pthread_join(ptr noundef %12, ptr noundef null), !dbg !146 + %14 = load i32, ptr @r1_0, align 4, !dbg !147 + %15 = icmp eq i32 %14, 2, !dbg !147 + br i1 %15, label %16, label %23, !dbg !147 + +16: ; preds = %0 + %17 = load i32, ptr @r2_1, align 4, !dbg !147 + %18 = icmp eq i32 %17, 1, !dbg !147 + br i1 %18, label %19, label %23, !dbg !147 -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 +19: ; preds = %16 + %20 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !147 + %21 = trunc i64 %20 to i32, !dbg !147 + %22 = icmp eq i32 %21, 2, !dbg !147 + br label %23 + +23: ; preds = %19, %16, %0 + %24 = phi i1 [ false, %16 ], [ false, %0 ], [ %22, %19 ], !dbg !148 + %25 = xor i1 %24, true, !dbg !147 + %26 = xor i1 %25, true, !dbg !147 + %27 = zext i1 %26 to i32, !dbg !147 + %28 = sext i32 %27 to i64, !dbg !147 + %29 = icmp ne i64 %28, 0, !dbg !147 + br i1 %29, label %30, label %32, !dbg !147 + +30: ; preds = %23 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 53, ptr noundef @.str.1) #3, !dbg !147 + unreachable, !dbg !147 + +31: ; No predecessors! + br label %33, !dbg !147 + +32: ; preds = %23 + br label %33, !dbg !147 + +33: ; preds = %32, %31 + ret i32 0, !dbg !149 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!42, !43, !44, !45, !46, !47, !48} -!llvm.ident = !{!49} +!llvm.module.flags = !{!61, !62, !63, !64, !65, !66, !67} +!llvm.ident = !{!68} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "c3eaf7aa28720acf6f1b88f61df956b8") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !49, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "16822ca6ae1b393a6d3981b1314a6e62") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !34, !36, !38, !40} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/C-WWC+o-branch-o+o-branch-o.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "c3eaf7aa28720acf6f1b88f61df956b8") -!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !30) -!30 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !31) -!31 = !{!32} -!32 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !30, file: !6, line: 94, baseType: !33, size: 32) -!33 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) -!35 = distinct !DIGlobalVariable(name: "r1_0", scope: !2, file: !28, line: 9, type: !33, isLocal: false, isDefinition: true) -!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) -!37 = distinct !DIGlobalVariable(name: "r3_0", scope: !2, file: !28, line: 10, type: !33, isLocal: false, isDefinition: true) -!38 = !DIGlobalVariableExpression(var: !39, expr: !DIExpression()) -!39 = distinct !DIGlobalVariable(name: "r2_1", scope: !2, file: !28, line: 12, type: !33, isLocal: false, isDefinition: true) -!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) -!41 = distinct !DIGlobalVariable(name: "r4_1", scope: !2, file: !28, line: 13, type: !33, isLocal: false, isDefinition: true) -!42 = !{i32 7, !"Dwarf Version", i32 5} -!43 = !{i32 2, !"Debug Info Version", i32 3} -!44 = !{i32 1, !"wchar_size", i32 4} -!45 = !{i32 7, !"PIC Level", i32 2} -!46 = !{i32 7, !"PIE Level", i32 2} -!47 = !{i32 7, !"uwtable", i32 1} -!48 = !{i32 7, !"frame-pointer", i32 2} -!49 = !{!"Ubuntu clang version 14.0.6"} -!50 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 15, type: !51, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!51 = !DISubroutineType(types: !52) -!52 = !{!24, !24} -!53 = !{} -!54 = !DILocalVariable(name: "unused", arg: 1, scope: !50, file: !28, line: 15, type: !24) -!55 = !DILocation(line: 0, scope: !50) -!56 = !DILocation(line: 17, column: 9, scope: !50) -!57 = !DILocation(line: 17, column: 7, scope: !50) -!58 = !DILocation(line: 18, column: 15, scope: !50) -!59 = !DILocation(line: 18, column: 7, scope: !50) -!60 = !DILocation(line: 19, column: 6, scope: !50) -!61 = !DILocation(line: 20, column: 3, scope: !62) -!62 = distinct !DILexicalBlock(scope: !63, file: !28, line: 19, column: 12) -!63 = distinct !DILexicalBlock(scope: !50, file: !28, line: 19, column: 6) -!64 = !DILocation(line: 21, column: 2, scope: !62) -!65 = !DILocation(line: 22, column: 5, scope: !50) -!66 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 25, type: !51, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!67 = !DILocalVariable(name: "unused", arg: 1, scope: !66, file: !28, line: 25, type: !24) -!68 = !DILocation(line: 0, scope: !66) -!69 = !DILocation(line: 27, column: 9, scope: !66) -!70 = !DILocation(line: 27, column: 7, scope: !66) -!71 = !DILocation(line: 28, column: 15, scope: !66) -!72 = !DILocation(line: 28, column: 7, scope: !66) -!73 = !DILocation(line: 29, column: 6, scope: !66) -!74 = !DILocation(line: 30, column: 3, scope: !75) -!75 = distinct !DILexicalBlock(scope: !76, file: !28, line: 29, column: 12) -!76 = distinct !DILexicalBlock(scope: !66, file: !28, line: 29, column: 6) -!77 = !DILocation(line: 31, column: 2, scope: !75) -!78 = !DILocation(line: 32, column: 5, scope: !66) -!79 = distinct !DISubprogram(name: "thread_3", scope: !28, file: !28, line: 35, type: !51, scopeLine: 36, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!80 = !DILocalVariable(name: "unused", arg: 1, scope: !79, file: !28, line: 35, type: !24) -!81 = !DILocation(line: 0, scope: !79) -!82 = !DILocation(line: 37, column: 2, scope: !79) -!83 = !DILocation(line: 38, column: 5, scope: !79) -!84 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 41, type: !85, scopeLine: 42, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!85 = !DISubroutineType(types: !86) -!86 = !{!33} -!87 = !DILocalVariable(name: "t1", scope: !84, file: !28, line: 43, type: !88) -!88 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !89, line: 27, baseType: !90) -!89 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!90 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!91 = !DILocation(line: 0, scope: !84) -!92 = !DILocation(line: 45, column: 2, scope: !84) -!93 = !DILocalVariable(name: "t2", scope: !84, file: !28, line: 43, type: !88) -!94 = !DILocation(line: 46, column: 2, scope: !84) -!95 = !DILocalVariable(name: "t3", scope: !84, file: !28, line: 43, type: !88) -!96 = !DILocation(line: 47, column: 2, scope: !84) -!97 = !DILocation(line: 49, column: 15, scope: !84) -!98 = !DILocation(line: 49, column: 2, scope: !84) -!99 = !DILocation(line: 50, column: 15, scope: !84) -!100 = !DILocation(line: 50, column: 2, scope: !84) -!101 = !DILocation(line: 51, column: 15, scope: !84) -!102 = !DILocation(line: 51, column: 2, scope: !84) -!103 = !DILocation(line: 53, column: 2, scope: !104) -!104 = distinct !DILexicalBlock(scope: !105, file: !28, line: 53, column: 2) -!105 = distinct !DILexicalBlock(scope: !84, file: !28, line: 53, column: 2) -!106 = !DILocation(line: 53, column: 2, scope: !105) -!107 = !DILocation(line: 55, column: 2, scope: !84) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !24, !28} +!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !25) +!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !26, line: 32, baseType: !27) +!26 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!27 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47, !53, !55, !57, !59} +!30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 53, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 53, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 240, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 30) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 53, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 400, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 50) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !49, isLocal: false, isDefinition: true) +!49 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !50) +!50 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !51) +!51 = !{!52} +!52 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !50, file: !6, line: 107, baseType: !23, size: 32) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "r1_0", scope: !2, file: !3, line: 9, type: !23, isLocal: false, isDefinition: true) +!55 = !DIGlobalVariableExpression(var: !56, expr: !DIExpression()) +!56 = distinct !DIGlobalVariable(name: "r3_0", scope: !2, file: !3, line: 10, type: !23, isLocal: false, isDefinition: true) +!57 = !DIGlobalVariableExpression(var: !58, expr: !DIExpression()) +!58 = distinct !DIGlobalVariable(name: "r2_1", scope: !2, file: !3, line: 12, type: !23, isLocal: false, isDefinition: true) +!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression()) +!60 = distinct !DIGlobalVariable(name: "r4_1", scope: !2, file: !3, line: 13, type: !23, isLocal: false, isDefinition: true) +!61 = !{i32 7, !"Dwarf Version", i32 5} +!62 = !{i32 2, !"Debug Info Version", i32 3} +!63 = !{i32 1, !"wchar_size", i32 4} +!64 = !{i32 8, !"PIC Level", i32 2} +!65 = !{i32 7, !"PIE Level", i32 2} +!66 = !{i32 7, !"uwtable", i32 2} +!67 = !{i32 7, !"frame-pointer", i32 2} +!68 = !{!"Homebrew clang version 19.1.7"} +!69 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 15, type: !70, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !72) +!70 = !DISubroutineType(types: !71) +!71 = !{!28, !28} +!72 = !{} +!73 = !DILocalVariable(name: "unused", arg: 1, scope: !69, file: !3, line: 15, type: !28) +!74 = !DILocation(line: 15, column: 22, scope: !69) +!75 = !DILocation(line: 17, column: 9, scope: !69) +!76 = !DILocation(line: 17, column: 7, scope: !69) +!77 = !DILocation(line: 18, column: 10, scope: !69) +!78 = !DILocation(line: 18, column: 15, scope: !69) +!79 = !DILocation(line: 18, column: 7, scope: !69) +!80 = !DILocation(line: 19, column: 6, scope: !81) +!81 = distinct !DILexicalBlock(scope: !69, file: !3, line: 19, column: 6) +!82 = !DILocation(line: 19, column: 6, scope: !69) +!83 = !DILocation(line: 20, column: 3, scope: !84) +!84 = distinct !DILexicalBlock(scope: !81, file: !3, line: 19, column: 12) +!85 = !DILocation(line: 21, column: 2, scope: !84) +!86 = !DILocation(line: 22, column: 5, scope: !69) +!87 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 25, type: !70, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !72) +!88 = !DILocalVariable(name: "unused", arg: 1, scope: !87, file: !3, line: 25, type: !28) +!89 = !DILocation(line: 25, column: 22, scope: !87) +!90 = !DILocation(line: 27, column: 9, scope: !87) +!91 = !DILocation(line: 27, column: 7, scope: !87) +!92 = !DILocation(line: 28, column: 10, scope: !87) +!93 = !DILocation(line: 28, column: 15, scope: !87) +!94 = !DILocation(line: 28, column: 7, scope: !87) +!95 = !DILocation(line: 29, column: 6, scope: !96) +!96 = distinct !DILexicalBlock(scope: !87, file: !3, line: 29, column: 6) +!97 = !DILocation(line: 29, column: 6, scope: !87) +!98 = !DILocation(line: 30, column: 3, scope: !99) +!99 = distinct !DILexicalBlock(scope: !96, file: !3, line: 29, column: 12) +!100 = !DILocation(line: 31, column: 2, scope: !99) +!101 = !DILocation(line: 32, column: 5, scope: !87) +!102 = distinct !DISubprogram(name: "thread_3", scope: !3, file: !3, line: 35, type: !70, scopeLine: 36, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !72) +!103 = !DILocalVariable(name: "unused", arg: 1, scope: !102, file: !3, line: 35, type: !28) +!104 = !DILocation(line: 35, column: 22, scope: !102) +!105 = !DILocation(line: 37, column: 2, scope: !102) +!106 = !DILocation(line: 38, column: 5, scope: !102) +!107 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 41, type: !108, scopeLine: 42, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !72) +!108 = !DISubroutineType(types: !109) +!109 = !{!23} +!110 = !DILocalVariable(name: "t1", scope: !107, file: !3, line: 43, type: !111) +!111 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !112, line: 31, baseType: !113) +!112 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!113 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !114, line: 118, baseType: !115) +!114 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!115 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !116, size: 64) +!116 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !114, line: 103, size: 65536, elements: !117) +!117 = !{!118, !119, !129} +!118 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !116, file: !114, line: 104, baseType: !27, size: 64) +!119 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !116, file: !114, line: 105, baseType: !120, size: 64, offset: 64) +!120 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !121, size: 64) +!121 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !114, line: 57, size: 192, elements: !122) +!122 = !{!123, !127, !128} +!123 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !121, file: !114, line: 58, baseType: !124, size: 64) +!124 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !125, size: 64) +!125 = !DISubroutineType(types: !126) +!126 = !{null, !28} +!127 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !121, file: !114, line: 59, baseType: !28, size: 64, offset: 64) +!128 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !121, file: !114, line: 60, baseType: !120, size: 64, offset: 128) +!129 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !116, file: !114, line: 106, baseType: !130, size: 65408, offset: 128) +!130 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !131) +!131 = !{!132} +!132 = !DISubrange(count: 8176) +!133 = !DILocation(line: 43, column: 12, scope: !107) +!134 = !DILocalVariable(name: "t2", scope: !107, file: !3, line: 43, type: !111) +!135 = !DILocation(line: 43, column: 16, scope: !107) +!136 = !DILocalVariable(name: "t3", scope: !107, file: !3, line: 43, type: !111) +!137 = !DILocation(line: 43, column: 20, scope: !107) +!138 = !DILocation(line: 45, column: 2, scope: !107) +!139 = !DILocation(line: 46, column: 2, scope: !107) +!140 = !DILocation(line: 47, column: 2, scope: !107) +!141 = !DILocation(line: 49, column: 15, scope: !107) +!142 = !DILocation(line: 49, column: 2, scope: !107) +!143 = !DILocation(line: 50, column: 15, scope: !107) +!144 = !DILocation(line: 50, column: 2, scope: !107) +!145 = !DILocation(line: 51, column: 15, scope: !107) +!146 = !DILocation(line: 51, column: 2, scope: !107) +!147 = !DILocation(line: 53, column: 2, scope: !107) +!148 = !DILocation(line: 0, scope: !107) +!149 = !DILocation(line: 55, column: 2, scope: !107) diff --git a/dartagnan/src/test/resources/lkmm/C-atomic-op-return-simple-02-2.ll b/dartagnan/src/test/resources/lkmm/C-atomic-op-return-simple-02-2.ll index 84051f6cfa..109d2af705 100644 --- a/dartagnan/src/test/resources/lkmm/C-atomic-op-return-simple-02-2.ll +++ b/dartagnan/src/test/resources/lkmm/C-atomic-op-return-simple-02-2.ll @@ -1,208 +1,265 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/C-atomic-op-return-simple-02-2.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/C-atomic-op-return-simple-02-2.c' +source_filename = "benchmarks/lkmm/C-atomic-op-return-simple-02-2.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !0 -@r0_0 = dso_local global i32 0, align 4, !dbg !40 -@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !32 -@r1_0 = dso_local global i32 0, align 4, !dbg !42 -@r0_1 = dso_local global i32 0, align 4, !dbg !44 -@r1_1 = dso_local global i32 0, align 4, !dbg !46 -@.str = private unnamed_addr constant [94 x i8] c"!(r0_0 == 1 && r1_0 == 0 && r0_1 == 1 && r1_1 == 0 && READ_ONCE(x) == 1 && READ_ONCE(y) == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [71 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r0_0 = dso_local global i32 0, align 4, !dbg !59 +@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !53 +@r1_0 = dso_local global i32 0, align 4, !dbg !61 +@r0_1 = dso_local global i32 0, align 4, !dbg !63 +@r1_1 = dso_local global i32 0, align 4, !dbg !65 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !36 +@.str = private unnamed_addr constant [33 x i8] c"C-atomic-op-return-simple-02-2.c\00", align 1, !dbg !43 +@.str.1 = private unnamed_addr constant [100 x i8] c"!(r0_0 == 1 && r1_0 == 0 && r0_1 == 1 && r1_1 == 0 && atomic_read(&x) == 1 && atomic_read(&y) == 1)\00", align 1, !dbg !48 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !56 { - call void @llvm.dbg.value(metadata i8* %0, metadata !60, metadata !DIExpression()), !dbg !61 - %2 = call i32 @__LKMM_ATOMIC_OP_RETURN(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @x, i64 0, i32 0), i32 noundef 1, i32 noundef 0, i32 noundef 0) #5, !dbg !62 - store i32 %2, i32* @r0_0, align 4, !dbg !63 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1) #5, !dbg !64 - store i32 %3, i32* @r1_0, align 4, !dbg !65 - ret i8* null, !dbg !66 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !75 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !79, !DIExpression(), !80) + %3 = call i64 @__LKMM_atomic_op_return(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0, i32 noundef 0), !dbg !81 + %4 = trunc i64 %3 to i32, !dbg !81 + store i32 %4, ptr @r0_0, align 4, !dbg !82 + %5 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !83 + %6 = trunc i64 %5 to i32, !dbg !83 + store i32 %6, ptr @r1_0, align 4, !dbg !84 + ret ptr null, !dbg !85 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +declare i64 @__LKMM_atomic_op_return(ptr noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #1 -declare i32 @__LKMM_ATOMIC_OP_RETURN(i32* noundef, i32 noundef, i32 noundef, i32 noundef) #2 - -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !67 { - call void @llvm.dbg.value(metadata i8* %0, metadata !68, metadata !DIExpression()), !dbg !69 - %2 = call i32 @__LKMM_ATOMIC_OP_RETURN(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @y, i64 0, i32 0), i32 noundef 1, i32 noundef 0, i32 noundef 0) #5, !dbg !70 - store i32 %2, i32* @r0_1, align 4, !dbg !71 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #5, !dbg !72 - store i32 %3, i32* @r1_1, align 4, !dbg !73 - ret i8* null, !dbg !74 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !86 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !87, !DIExpression(), !88) + %3 = call i64 @__LKMM_atomic_op_return(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0, i32 noundef 0), !dbg !89 + %4 = trunc i64 %3 to i32, !dbg !89 + store i32 %4, ptr @r0_1, align 4, !dbg !90 + %5 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !91 + %6 = trunc i64 %5 to i32, !dbg !91 + store i32 %6, ptr @r1_1, align 4, !dbg !92 + ret ptr null, !dbg !93 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !75 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !78, metadata !DIExpression(DW_OP_deref)), !dbg !82 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !83 - call void @llvm.dbg.value(metadata i64* %2, metadata !84, metadata !DIExpression(DW_OP_deref)), !dbg !82 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !85 - %5 = load i64, i64* %1, align 8, !dbg !86 - call void @llvm.dbg.value(metadata i64 %5, metadata !78, metadata !DIExpression()), !dbg !82 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !87 - %7 = load i64, i64* %2, align 8, !dbg !88 - call void @llvm.dbg.value(metadata i64 %7, metadata !84, metadata !DIExpression()), !dbg !82 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !89 - %9 = load i32, i32* @r0_0, align 4, !dbg !90 - %10 = icmp eq i32 %9, 1, !dbg !90 - %11 = load i32, i32* @r1_0, align 4, !dbg !90 - %12 = icmp eq i32 %11, 0, !dbg !90 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !90 - %13 = load i32, i32* @r0_1, align 4, !dbg !90 - %14 = icmp eq i32 %13, 1, !dbg !90 - %or.cond3 = select i1 %or.cond, i1 %14, i1 false, !dbg !90 - %15 = load i32, i32* @r1_1, align 4, !dbg !90 - %16 = icmp eq i32 %15, 0, !dbg !90 - %or.cond5 = select i1 %or.cond3, i1 %16, i1 false, !dbg !90 - br i1 %or.cond5, label %17, label %24, !dbg !90 - -17: ; preds = %0 - %18 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #5, !dbg !90 - %19 = icmp eq i32 %18, 1, !dbg !90 - br i1 %19, label %20, label %24, !dbg !90 - -20: ; preds = %17 - %21 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1) #5, !dbg !90 - %22 = icmp eq i32 %21, 1, !dbg !90 - br i1 %22, label %23, label %24, !dbg !93 - -23: ; preds = %20 - call void @__assert_fail(i8* noundef getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 noundef 39, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !90 - unreachable, !dbg !90 - -24: ; preds = %0, %17, %20 - ret i32 0, !dbg !94 -} +define dso_local i32 @main() #0 !dbg !94 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !97, !DIExpression(), !120) + #dbg_declare(ptr %3, !121, !DIExpression(), !122) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !123 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !124 + %6 = load ptr, ptr %2, align 8, !dbg !125 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !126 + %8 = load ptr, ptr %3, align 8, !dbg !127 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !128 + %10 = load i32, ptr @r0_0, align 4, !dbg !129 + %11 = icmp eq i32 %10, 1, !dbg !129 + br i1 %11, label %12, label %29, !dbg !129 + +12: ; preds = %0 + %13 = load i32, ptr @r1_0, align 4, !dbg !129 + %14 = icmp eq i32 %13, 0, !dbg !129 + br i1 %14, label %15, label %29, !dbg !129 + +15: ; preds = %12 + %16 = load i32, ptr @r0_1, align 4, !dbg !129 + %17 = icmp eq i32 %16, 1, !dbg !129 + br i1 %17, label %18, label %29, !dbg !129 + +18: ; preds = %15 + %19 = load i32, ptr @r1_1, align 4, !dbg !129 + %20 = icmp eq i32 %19, 0, !dbg !129 + br i1 %20, label %21, label %29, !dbg !129 + +21: ; preds = %18 + %22 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !129 + %23 = trunc i64 %22 to i32, !dbg !129 + %24 = icmp eq i32 %23, 1, !dbg !129 + br i1 %24, label %25, label %29, !dbg !129 -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 +25: ; preds = %21 + %26 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !129 + %27 = trunc i64 %26 to i32, !dbg !129 + %28 = icmp eq i32 %27, 1, !dbg !129 + br label %29 + +29: ; preds = %25, %21, %18, %15, %12, %0 + %30 = phi i1 [ false, %21 ], [ false, %18 ], [ false, %15 ], [ false, %12 ], [ false, %0 ], [ %28, %25 ], !dbg !130 + %31 = xor i1 %30, true, !dbg !129 + %32 = xor i1 %31, true, !dbg !129 + %33 = zext i1 %32 to i32, !dbg !129 + %34 = sext i32 %33 to i64, !dbg !129 + %35 = icmp ne i64 %34, 0, !dbg !129 + br i1 %35, label %36, label %38, !dbg !129 + +36: ; preds = %29 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 39, ptr noundef @.str.1) #3, !dbg !129 + unreachable, !dbg !129 + +37: ; No predecessors! + br label %39, !dbg !129 + +38: ; preds = %29 + br label %39, !dbg !129 + +39: ; preds = %38, %37 + ret i32 0, !dbg !131 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!48, !49, !50, !51, !52, !53, !54} -!llvm.ident = !{!55} +!llvm.module.flags = !{!67, !68, !69, !70, !71, !72, !73} +!llvm.ident = !{!74} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !34, line: 6, type: !35, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !29, globals: !31, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/C-atomic-op-return-simple-02-2.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "aa1c03cb7d3550e8de080af0e114e743") -!4 = !{!5, !23} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !55, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !28, globals: !35, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/C-atomic-op-return-simple-02-2.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "f54fd217313dd14571d84f0acd77daab") +!4 = !{!5, !22} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "operation", file: !6, line: 20, baseType: !7, size: 32, elements: !24) -!24 = !{!25, !26, !27, !28} -!25 = !DIEnumerator(name: "op_add", value: 0) -!26 = !DIEnumerator(name: "op_sub", value: 1) -!27 = !DIEnumerator(name: "op_and", value: 2) -!28 = !DIEnumerator(name: "op_or", value: 3) -!29 = !{!30} -!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!31 = !{!0, !32, !40, !42, !44, !46} -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !34, line: 7, type: !35, isLocal: false, isDefinition: true) -!34 = !DIFile(filename: "benchmarks/lkmm/C-atomic-op-return-simple-02-2.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "aa1c03cb7d3550e8de080af0e114e743") -!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !36) -!36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !37) -!37 = !{!38} -!38 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !36, file: !6, line: 94, baseType: !39, size: 32) -!39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) -!41 = distinct !DIGlobalVariable(name: "r0_0", scope: !2, file: !34, line: 9, type: !39, isLocal: false, isDefinition: true) -!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) -!43 = distinct !DIGlobalVariable(name: "r1_0", scope: !2, file: !34, line: 10, type: !39, isLocal: false, isDefinition: true) -!44 = !DIGlobalVariableExpression(var: !45, expr: !DIExpression()) -!45 = distinct !DIGlobalVariable(name: "r0_1", scope: !2, file: !34, line: 12, type: !39, isLocal: false, isDefinition: true) -!46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression()) -!47 = distinct !DIGlobalVariable(name: "r1_1", scope: !2, file: !34, line: 13, type: !39, isLocal: false, isDefinition: true) -!48 = !{i32 7, !"Dwarf Version", i32 5} -!49 = !{i32 2, !"Debug Info Version", i32 3} -!50 = !{i32 1, !"wchar_size", i32 4} -!51 = !{i32 7, !"PIC Level", i32 2} -!52 = !{i32 7, !"PIE Level", i32 2} -!53 = !{i32 7, !"uwtable", i32 1} -!54 = !{i32 7, !"frame-pointer", i32 2} -!55 = !{!"Ubuntu clang version 14.0.6"} -!56 = distinct !DISubprogram(name: "thread_1", scope: !34, file: !34, line: 15, type: !57, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !59) -!57 = !DISubroutineType(types: !58) -!58 = !{!30, !30} -!59 = !{} -!60 = !DILocalVariable(name: "unused", arg: 1, scope: !56, file: !34, line: 15, type: !30) -!61 = !DILocation(line: 0, scope: !56) -!62 = !DILocation(line: 17, column: 10, scope: !56) -!63 = !DILocation(line: 17, column: 8, scope: !56) -!64 = !DILocation(line: 18, column: 10, scope: !56) -!65 = !DILocation(line: 18, column: 8, scope: !56) -!66 = !DILocation(line: 19, column: 3, scope: !56) -!67 = distinct !DISubprogram(name: "thread_2", scope: !34, file: !34, line: 22, type: !57, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !59) -!68 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !34, line: 22, type: !30) -!69 = !DILocation(line: 0, scope: !67) -!70 = !DILocation(line: 24, column: 10, scope: !67) -!71 = !DILocation(line: 24, column: 8, scope: !67) -!72 = !DILocation(line: 25, column: 10, scope: !67) -!73 = !DILocation(line: 25, column: 8, scope: !67) -!74 = !DILocation(line: 26, column: 3, scope: !67) -!75 = distinct !DISubprogram(name: "main", scope: !34, file: !34, line: 29, type: !76, scopeLine: 30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !59) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_operation", file: !6, line: 19, baseType: !7, size: 32, elements: !23) +!23 = !{!24, !25, !26, !27} +!24 = !DIEnumerator(name: "__LKMM_op_add", value: 0) +!25 = !DIEnumerator(name: "__LKMM_op_sub", value: 1) +!26 = !DIEnumerator(name: "__LKMM_op_and", value: 2) +!27 = !DIEnumerator(name: "__LKMM_op_or", value: 3) +!28 = !{!29, !30, !34} +!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!30 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !31) +!31 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !32, line: 32, baseType: !33) +!32 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!33 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!35 = !{!36, !43, !48, !0, !53, !59, !61, !63, !65} +!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) +!37 = distinct !DIGlobalVariable(scope: null, file: !3, line: 39, type: !38, isLocal: true, isDefinition: true) +!38 = !DICompositeType(tag: DW_TAG_array_type, baseType: !39, size: 40, elements: !41) +!39 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !40) +!40 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!41 = !{!42} +!42 = !DISubrange(count: 5) +!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression()) +!44 = distinct !DIGlobalVariable(scope: null, file: !3, line: 39, type: !45, isLocal: true, isDefinition: true) +!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 264, elements: !46) +!46 = !{!47} +!47 = !DISubrange(count: 33) +!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) +!49 = distinct !DIGlobalVariable(scope: null, file: !3, line: 39, type: !50, isLocal: true, isDefinition: true) +!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 800, elements: !51) +!51 = !{!52} +!52 = !DISubrange(count: 100) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !55, isLocal: false, isDefinition: true) +!55 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !56) +!56 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !57) +!57 = !{!58} +!58 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !56, file: !6, line: 107, baseType: !29, size: 32) +!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression()) +!60 = distinct !DIGlobalVariable(name: "r0_0", scope: !2, file: !3, line: 9, type: !29, isLocal: false, isDefinition: true) +!61 = !DIGlobalVariableExpression(var: !62, expr: !DIExpression()) +!62 = distinct !DIGlobalVariable(name: "r1_0", scope: !2, file: !3, line: 10, type: !29, isLocal: false, isDefinition: true) +!63 = !DIGlobalVariableExpression(var: !64, expr: !DIExpression()) +!64 = distinct !DIGlobalVariable(name: "r0_1", scope: !2, file: !3, line: 12, type: !29, isLocal: false, isDefinition: true) +!65 = !DIGlobalVariableExpression(var: !66, expr: !DIExpression()) +!66 = distinct !DIGlobalVariable(name: "r1_1", scope: !2, file: !3, line: 13, type: !29, isLocal: false, isDefinition: true) +!67 = !{i32 7, !"Dwarf Version", i32 5} +!68 = !{i32 2, !"Debug Info Version", i32 3} +!69 = !{i32 1, !"wchar_size", i32 4} +!70 = !{i32 8, !"PIC Level", i32 2} +!71 = !{i32 7, !"PIE Level", i32 2} +!72 = !{i32 7, !"uwtable", i32 2} +!73 = !{i32 7, !"frame-pointer", i32 2} +!74 = !{!"Homebrew clang version 19.1.7"} +!75 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 15, type: !76, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) !76 = !DISubroutineType(types: !77) -!77 = !{!39} -!78 = !DILocalVariable(name: "t1", scope: !75, file: !34, line: 31, type: !79) -!79 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !80, line: 27, baseType: !81) -!80 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!81 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!82 = !DILocation(line: 0, scope: !75) -!83 = !DILocation(line: 33, column: 2, scope: !75) -!84 = !DILocalVariable(name: "t2", scope: !75, file: !34, line: 31, type: !79) -!85 = !DILocation(line: 34, column: 2, scope: !75) -!86 = !DILocation(line: 36, column: 15, scope: !75) -!87 = !DILocation(line: 36, column: 2, scope: !75) -!88 = !DILocation(line: 37, column: 15, scope: !75) -!89 = !DILocation(line: 37, column: 2, scope: !75) -!90 = !DILocation(line: 39, column: 2, scope: !91) -!91 = distinct !DILexicalBlock(scope: !92, file: !34, line: 39, column: 2) -!92 = distinct !DILexicalBlock(scope: !75, file: !34, line: 39, column: 2) -!93 = !DILocation(line: 39, column: 2, scope: !92) -!94 = !DILocation(line: 41, column: 2, scope: !75) +!77 = !{!34, !34} +!78 = !{} +!79 = !DILocalVariable(name: "unused", arg: 1, scope: !75, file: !3, line: 15, type: !34) +!80 = !DILocation(line: 15, column: 22, scope: !75) +!81 = !DILocation(line: 17, column: 10, scope: !75) +!82 = !DILocation(line: 17, column: 8, scope: !75) +!83 = !DILocation(line: 18, column: 10, scope: !75) +!84 = !DILocation(line: 18, column: 8, scope: !75) +!85 = !DILocation(line: 19, column: 3, scope: !75) +!86 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 22, type: !76, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) +!87 = !DILocalVariable(name: "unused", arg: 1, scope: !86, file: !3, line: 22, type: !34) +!88 = !DILocation(line: 22, column: 22, scope: !86) +!89 = !DILocation(line: 24, column: 10, scope: !86) +!90 = !DILocation(line: 24, column: 8, scope: !86) +!91 = !DILocation(line: 25, column: 10, scope: !86) +!92 = !DILocation(line: 25, column: 8, scope: !86) +!93 = !DILocation(line: 26, column: 3, scope: !86) +!94 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 29, type: !95, scopeLine: 30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) +!95 = !DISubroutineType(types: !96) +!96 = !{!29} +!97 = !DILocalVariable(name: "t1", scope: !94, file: !3, line: 31, type: !98) +!98 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !99, line: 31, baseType: !100) +!99 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!100 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !101, line: 118, baseType: !102) +!101 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!102 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !103, size: 64) +!103 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !101, line: 103, size: 65536, elements: !104) +!104 = !{!105, !106, !116} +!105 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !103, file: !101, line: 104, baseType: !33, size: 64) +!106 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !103, file: !101, line: 105, baseType: !107, size: 64, offset: 64) +!107 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !108, size: 64) +!108 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !101, line: 57, size: 192, elements: !109) +!109 = !{!110, !114, !115} +!110 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !108, file: !101, line: 58, baseType: !111, size: 64) +!111 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !112, size: 64) +!112 = !DISubroutineType(types: !113) +!113 = !{null, !34} +!114 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !108, file: !101, line: 59, baseType: !34, size: 64, offset: 64) +!115 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !108, file: !101, line: 60, baseType: !107, size: 64, offset: 128) +!116 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !103, file: !101, line: 106, baseType: !117, size: 65408, offset: 128) +!117 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 65408, elements: !118) +!118 = !{!119} +!119 = !DISubrange(count: 8176) +!120 = !DILocation(line: 31, column: 12, scope: !94) +!121 = !DILocalVariable(name: "t2", scope: !94, file: !3, line: 31, type: !98) +!122 = !DILocation(line: 31, column: 16, scope: !94) +!123 = !DILocation(line: 33, column: 2, scope: !94) +!124 = !DILocation(line: 34, column: 2, scope: !94) +!125 = !DILocation(line: 36, column: 15, scope: !94) +!126 = !DILocation(line: 36, column: 2, scope: !94) +!127 = !DILocation(line: 37, column: 15, scope: !94) +!128 = !DILocation(line: 37, column: 2, scope: !94) +!129 = !DILocation(line: 39, column: 2, scope: !94) +!130 = !DILocation(line: 0, scope: !94) +!131 = !DILocation(line: 41, column: 2, scope: !94) diff --git a/dartagnan/src/test/resources/lkmm/CoRR+poonce+Once.ll b/dartagnan/src/test/resources/lkmm/CoRR+poonce+Once.ll index 6b2083c1ef..24a5e0a731 100644 --- a/dartagnan/src/test/resources/lkmm/CoRR+poonce+Once.ll +++ b/dartagnan/src/test/resources/lkmm/CoRR+poonce+Once.ll @@ -1,165 +1,214 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/CoRR+poonce+Once.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/CoRR+poonce+Once.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/CoRR+poonce+Once.c' +source_filename = "benchmarks/lkmm/CoRR+poonce+Once.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@r0 = dso_local global i32 0, align 4, !dbg !26 -@r1 = dso_local global i32 0, align 4, !dbg !30 -@.str = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 0)\00", align 1 -@.str.1 = private unnamed_addr constant [57 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/CoRR+poonce+Once.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r0 = dso_local global i32 0, align 4, !dbg !47 +@r1 = dso_local global i32 0, align 4, !dbg !49 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [19 x i8] c"CoRR+poonce+Once.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 0)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !40 { - call void @llvm.dbg.value(metadata i8* %0, metadata !44, metadata !DIExpression()), !dbg !45 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !46 - ret i8* null, !dbg !47 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !59 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !63, !DIExpression(), !64) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !65 + ret ptr null, !dbg !66 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !49, metadata !DIExpression()), !dbg !50 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !51 - store i32 %2, i32* @r0, align 4, !dbg !52 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !53 - store i32 %3, i32* @r1, align 4, !dbg !54 - ret i8* null, !dbg !55 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !67 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !68, !DIExpression(), !69) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !70 + %4 = trunc i64 %3 to i32, !dbg !70 + store i32 %4, ptr @r0, align 4, !dbg !71 + %5 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !72 + %6 = trunc i64 %5 to i32, !dbg !72 + store i32 %6, ptr @r1, align 4, !dbg !73 + ret ptr null, !dbg !74 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !56 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !59, metadata !DIExpression(DW_OP_deref)), !dbg !63 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !64 - call void @llvm.dbg.value(metadata i64* %2, metadata !65, metadata !DIExpression(DW_OP_deref)), !dbg !63 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !66 - %5 = load i64, i64* %1, align 8, !dbg !67 - call void @llvm.dbg.value(metadata i64 %5, metadata !59, metadata !DIExpression()), !dbg !63 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !68 - %7 = load i64, i64* %2, align 8, !dbg !69 - call void @llvm.dbg.value(metadata i64 %7, metadata !65, metadata !DIExpression()), !dbg !63 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !70 - %9 = load i32, i32* @r0, align 4, !dbg !71 - %10 = icmp eq i32 %9, 1, !dbg !71 - %11 = load i32, i32* @r1, align 4, !dbg !71 - %12 = icmp eq i32 %11, 0, !dbg !71 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !71 - br i1 %or.cond, label %13, label %14, !dbg !71 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 noundef 33, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !71 - unreachable, !dbg !71 - -14: ; preds = %0 - ret i32 0, !dbg !74 +define dso_local i32 @main() #0 !dbg !75 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !78, !DIExpression(), !101) + #dbg_declare(ptr %3, !102, !DIExpression(), !103) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !104 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !105 + %6 = load ptr, ptr %2, align 8, !dbg !106 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !107 + %8 = load ptr, ptr %3, align 8, !dbg !108 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !109 + %10 = load i32, ptr @r0, align 4, !dbg !110 + %11 = icmp eq i32 %10, 1, !dbg !110 + br i1 %11, label %12, label %15, !dbg !110 + +12: ; preds = %0 + %13 = load i32, ptr @r1, align 4, !dbg !110 + %14 = icmp eq i32 %13, 0, !dbg !110 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !111 + %17 = xor i1 %16, true, !dbg !110 + %18 = xor i1 %17, true, !dbg !110 + %19 = zext i1 %18 to i32, !dbg !110 + %20 = sext i32 %19 to i64, !dbg !110 + %21 = icmp ne i64 %20, 0, !dbg !110 + br i1 %21, label %22, label %24, !dbg !110 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 33, ptr noundef @.str.1) #3, !dbg !110 + unreachable, !dbg !110 + +23: ; No predecessors! + br label %25, !dbg !110 + +24: ; preds = %15 + br label %25, !dbg !110 + +25: ; preds = %24, %23 + ret i32 0, !dbg !112 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!32, !33, !34, !35, !36, !37, !38} -!llvm.ident = !{!39} +!llvm.module.flags = !{!51, !52, !53, !54, !55, !56, !57} +!llvm.ident = !{!58} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/CoRR+poonce+Once.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "973bb56baa7a0c404651e434a54de408") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !28, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/CoRR+poonce+Once.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "973bb56baa7a0c404651e434a54de408") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/CoRR+poonce+Once.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "973bb56baa7a0c404651e434a54de408") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !0, !47, !49} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!32 = !{i32 7, !"Dwarf Version", i32 5} -!33 = !{i32 2, !"Debug Info Version", i32 3} -!34 = !{i32 1, !"wchar_size", i32 4} -!35 = !{i32 7, !"PIC Level", i32 2} -!36 = !{i32 7, !"PIE Level", i32 2} -!37 = !{i32 7, !"uwtable", i32 1} -!38 = !{i32 7, !"frame-pointer", i32 2} -!39 = !{!"Ubuntu clang version 14.0.6"} -!40 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 10, type: !41, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) -!41 = !DISubroutineType(types: !42) -!42 = !{!24, !24} -!43 = !{} -!44 = !DILocalVariable(name: "unused", arg: 1, scope: !40, file: !28, line: 10, type: !24) -!45 = !DILocation(line: 0, scope: !40) -!46 = !DILocation(line: 12, column: 2, scope: !40) -!47 = !DILocation(line: 13, column: 2, scope: !40) -!48 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 16, type: !41, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) -!49 = !DILocalVariable(name: "unused", arg: 1, scope: !48, file: !28, line: 16, type: !24) -!50 = !DILocation(line: 0, scope: !48) -!51 = !DILocation(line: 18, column: 7, scope: !48) -!52 = !DILocation(line: 18, column: 5, scope: !48) -!53 = !DILocation(line: 19, column: 7, scope: !48) -!54 = !DILocation(line: 19, column: 5, scope: !48) -!55 = !DILocation(line: 20, column: 2, scope: !48) -!56 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 23, type: !57, scopeLine: 24, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) -!57 = !DISubroutineType(types: !58) -!58 = !{!29} -!59 = !DILocalVariable(name: "t1", scope: !56, file: !28, line: 25, type: !60) -!60 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !61, line: 27, baseType: !62) -!61 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!62 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!63 = !DILocation(line: 0, scope: !56) -!64 = !DILocation(line: 27, column: 2, scope: !56) -!65 = !DILocalVariable(name: "t2", scope: !56, file: !28, line: 25, type: !60) -!66 = !DILocation(line: 28, column: 2, scope: !56) -!67 = !DILocation(line: 30, column: 15, scope: !56) -!68 = !DILocation(line: 30, column: 2, scope: !56) -!69 = !DILocation(line: 31, column: 15, scope: !56) -!70 = !DILocation(line: 31, column: 2, scope: !56) -!71 = !DILocation(line: 33, column: 2, scope: !72) -!72 = distinct !DILexicalBlock(scope: !73, file: !28, line: 33, column: 2) -!73 = distinct !DILexicalBlock(scope: !56, file: !28, line: 33, column: 2) -!74 = !DILocation(line: 35, column: 2, scope: !56) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 33, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 33, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 152, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 19) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 33, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 176, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 22) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 8, type: !28, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !3, line: 8, type: !28, isLocal: false, isDefinition: true) +!51 = !{i32 7, !"Dwarf Version", i32 5} +!52 = !{i32 2, !"Debug Info Version", i32 3} +!53 = !{i32 1, !"wchar_size", i32 4} +!54 = !{i32 8, !"PIC Level", i32 2} +!55 = !{i32 7, !"PIE Level", i32 2} +!56 = !{i32 7, !"uwtable", i32 2} +!57 = !{i32 7, !"frame-pointer", i32 2} +!58 = !{!"Homebrew clang version 19.1.7"} +!59 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 10, type: !60, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !62) +!60 = !DISubroutineType(types: !61) +!61 = !{!27, !27} +!62 = !{} +!63 = !DILocalVariable(name: "unused", arg: 1, scope: !59, file: !3, line: 10, type: !27) +!64 = !DILocation(line: 10, column: 22, scope: !59) +!65 = !DILocation(line: 12, column: 2, scope: !59) +!66 = !DILocation(line: 13, column: 2, scope: !59) +!67 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 16, type: !60, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !62) +!68 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !3, line: 16, type: !27) +!69 = !DILocation(line: 16, column: 22, scope: !67) +!70 = !DILocation(line: 18, column: 7, scope: !67) +!71 = !DILocation(line: 18, column: 5, scope: !67) +!72 = !DILocation(line: 19, column: 7, scope: !67) +!73 = !DILocation(line: 19, column: 5, scope: !67) +!74 = !DILocation(line: 20, column: 2, scope: !67) +!75 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 23, type: !76, scopeLine: 24, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !62) +!76 = !DISubroutineType(types: !77) +!77 = !{!28} +!78 = !DILocalVariable(name: "t1", scope: !75, file: !3, line: 25, type: !79) +!79 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !80, line: 31, baseType: !81) +!80 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!81 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !82, line: 118, baseType: !83) +!82 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!83 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !84, size: 64) +!84 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !82, line: 103, size: 65536, elements: !85) +!85 = !{!86, !87, !97} +!86 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !84, file: !82, line: 104, baseType: !26, size: 64) +!87 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !84, file: !82, line: 105, baseType: !88, size: 64, offset: 64) +!88 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !89, size: 64) +!89 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !82, line: 57, size: 192, elements: !90) +!90 = !{!91, !95, !96} +!91 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !89, file: !82, line: 58, baseType: !92, size: 64) +!92 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !93, size: 64) +!93 = !DISubroutineType(types: !94) +!94 = !{null, !27} +!95 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !89, file: !82, line: 59, baseType: !27, size: 64, offset: 64) +!96 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !89, file: !82, line: 60, baseType: !88, size: 64, offset: 128) +!97 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !84, file: !82, line: 106, baseType: !98, size: 65408, offset: 128) +!98 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !99) +!99 = !{!100} +!100 = !DISubrange(count: 8176) +!101 = !DILocation(line: 25, column: 12, scope: !75) +!102 = !DILocalVariable(name: "t2", scope: !75, file: !3, line: 25, type: !79) +!103 = !DILocation(line: 25, column: 16, scope: !75) +!104 = !DILocation(line: 27, column: 2, scope: !75) +!105 = !DILocation(line: 28, column: 2, scope: !75) +!106 = !DILocation(line: 30, column: 15, scope: !75) +!107 = !DILocation(line: 30, column: 2, scope: !75) +!108 = !DILocation(line: 31, column: 15, scope: !75) +!109 = !DILocation(line: 31, column: 2, scope: !75) +!110 = !DILocation(line: 33, column: 2, scope: !75) +!111 = !DILocation(line: 0, scope: !75) +!112 = !DILocation(line: 35, column: 2, scope: !75) diff --git a/dartagnan/src/test/resources/lkmm/CoRW+poonce+Once.ll b/dartagnan/src/test/resources/lkmm/CoRW+poonce+Once.ll index 8e455214f6..6aeaaaeae0 100644 --- a/dartagnan/src/test/resources/lkmm/CoRW+poonce+Once.ll +++ b/dartagnan/src/test/resources/lkmm/CoRW+poonce+Once.ll @@ -1,160 +1,209 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/CoRW+poonce+Once.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/CoRW+poonce+Once.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/CoRW+poonce+Once.c' +source_filename = "benchmarks/lkmm/CoRW+poonce+Once.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@r0 = dso_local global i32 0, align 4, !dbg !26 -@.str = private unnamed_addr constant [32 x i8] c"!(READ_ONCE(x) == 2 && r0 == 2)\00", align 1 -@.str.1 = private unnamed_addr constant [57 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/CoRW+poonce+Once.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r0 = dso_local global i32 0, align 4, !dbg !47 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [19 x i8] c"CoRW+poonce+Once.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [32 x i8] c"!(READ_ONCE(x) == 2 && r0 == 2)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !38 { - call void @llvm.dbg.value(metadata i8* %0, metadata !42, metadata !DIExpression()), !dbg !43 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !44 - store i32 %2, i32* @r0, align 4, !dbg !45 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !46 - ret i8* null, !dbg !47 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !57 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !61, !DIExpression(), !62) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !63 + %4 = trunc i64 %3 to i32, !dbg !63 + store i32 %4, ptr @r0, align 4, !dbg !64 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !65 + ret ptr null, !dbg !66 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !49, metadata !DIExpression()), !dbg !50 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !51 - ret i8* null, !dbg !52 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !67 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !68, !DIExpression(), !69) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !70 + ret ptr null, !dbg !71 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !53 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !56, metadata !DIExpression(DW_OP_deref)), !dbg !60 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !61 - call void @llvm.dbg.value(metadata i64* %2, metadata !62, metadata !DIExpression(DW_OP_deref)), !dbg !60 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !63 - %5 = load i64, i64* %1, align 8, !dbg !64 - call void @llvm.dbg.value(metadata i64 %5, metadata !56, metadata !DIExpression()), !dbg !60 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !65 - %7 = load i64, i64* %2, align 8, !dbg !66 - call void @llvm.dbg.value(metadata i64 %7, metadata !62, metadata !DIExpression()), !dbg !60 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !67 - %9 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !68 - %10 = icmp eq i32 %9, 2, !dbg !68 - %11 = load i32, i32* @r0, align 4, !dbg !68 - %12 = icmp eq i32 %11, 2, !dbg !68 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !68 - br i1 %or.cond, label %13, label %14, !dbg !68 +define dso_local i32 @main() #0 !dbg !72 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !75, !DIExpression(), !98) + #dbg_declare(ptr %3, !99, !DIExpression(), !100) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !101 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !102 + %6 = load ptr, ptr %2, align 8, !dbg !103 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !104 + %8 = load ptr, ptr %3, align 8, !dbg !105 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !106 + %10 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !107 + %11 = trunc i64 %10 to i32, !dbg !107 + %12 = icmp eq i32 %11, 2, !dbg !107 + br i1 %12, label %13, label %16, !dbg !107 13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 noundef 32, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !68 - unreachable, !dbg !68 - -14: ; preds = %0 - ret i32 0, !dbg !71 + %14 = load i32, ptr @r0, align 4, !dbg !107 + %15 = icmp eq i32 %14, 2, !dbg !107 + br label %16 + +16: ; preds = %13, %0 + %17 = phi i1 [ false, %0 ], [ %15, %13 ], !dbg !108 + %18 = xor i1 %17, true, !dbg !107 + %19 = xor i1 %18, true, !dbg !107 + %20 = zext i1 %19 to i32, !dbg !107 + %21 = sext i32 %20 to i64, !dbg !107 + %22 = icmp ne i64 %21, 0, !dbg !107 + br i1 %22, label %23, label %25, !dbg !107 + +23: ; preds = %16 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 32, ptr noundef @.str.1) #3, !dbg !107 + unreachable, !dbg !107 + +24: ; No predecessors! + br label %26, !dbg !107 + +25: ; preds = %16 + br label %26, !dbg !107 + +26: ; preds = %25, %24 + ret i32 0, !dbg !109 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!30, !31, !32, !33, !34, !35, !36} -!llvm.ident = !{!37} +!llvm.module.flags = !{!49, !50, !51, !52, !53, !54, !55} +!llvm.ident = !{!56} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/CoRW+poonce+Once.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "7ba65203ffa8596e0a368dd8dfc16793") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !23, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/CoRW+poonce+Once.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "7ba65203ffa8596e0a368dd8dfc16793") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/CoRW+poonce+Once.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "7ba65203ffa8596e0a368dd8dfc16793") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!30 = !{i32 7, !"Dwarf Version", i32 5} -!31 = !{i32 2, !"Debug Info Version", i32 3} -!32 = !{i32 1, !"wchar_size", i32 4} -!33 = !{i32 7, !"PIC Level", i32 2} -!34 = !{i32 7, !"PIE Level", i32 2} -!35 = !{i32 7, !"uwtable", i32 1} -!36 = !{i32 7, !"frame-pointer", i32 2} -!37 = !{!"Ubuntu clang version 14.0.6"} -!38 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 9, type: !39, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!39 = !DISubroutineType(types: !40) -!40 = !{!24, !24} -!41 = !{} -!42 = !DILocalVariable(name: "unused", arg: 1, scope: !38, file: !28, line: 9, type: !24) -!43 = !DILocation(line: 0, scope: !38) -!44 = !DILocation(line: 11, column: 7, scope: !38) -!45 = !DILocation(line: 11, column: 5, scope: !38) -!46 = !DILocation(line: 12, column: 2, scope: !38) -!47 = !DILocation(line: 13, column: 2, scope: !38) -!48 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 16, type: !39, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!49 = !DILocalVariable(name: "unused", arg: 1, scope: !48, file: !28, line: 16, type: !24) -!50 = !DILocation(line: 0, scope: !48) -!51 = !DILocation(line: 18, column: 2, scope: !48) -!52 = !DILocation(line: 19, column: 2, scope: !48) -!53 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 22, type: !54, scopeLine: 23, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!54 = !DISubroutineType(types: !55) -!55 = !{!29} -!56 = !DILocalVariable(name: "t1", scope: !53, file: !28, line: 24, type: !57) -!57 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !58, line: 27, baseType: !59) -!58 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!59 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!60 = !DILocation(line: 0, scope: !53) -!61 = !DILocation(line: 26, column: 2, scope: !53) -!62 = !DILocalVariable(name: "t2", scope: !53, file: !28, line: 24, type: !57) -!63 = !DILocation(line: 27, column: 2, scope: !53) -!64 = !DILocation(line: 29, column: 15, scope: !53) -!65 = !DILocation(line: 29, column: 2, scope: !53) -!66 = !DILocation(line: 30, column: 15, scope: !53) -!67 = !DILocation(line: 30, column: 2, scope: !53) -!68 = !DILocation(line: 32, column: 2, scope: !69) -!69 = distinct !DILexicalBlock(scope: !70, file: !28, line: 32, column: 2) -!70 = distinct !DILexicalBlock(scope: !53, file: !28, line: 32, column: 2) -!71 = !DILocation(line: 34, column: 2, scope: !53) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !24, !28} +!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !25) +!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !26, line: 32, baseType: !27) +!26 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!27 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47} +!30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 32, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 32, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 152, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 19) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 32, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 256, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 32) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!49 = !{i32 7, !"Dwarf Version", i32 5} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = !{i32 1, !"wchar_size", i32 4} +!52 = !{i32 8, !"PIC Level", i32 2} +!53 = !{i32 7, !"PIE Level", i32 2} +!54 = !{i32 7, !"uwtable", i32 2} +!55 = !{i32 7, !"frame-pointer", i32 2} +!56 = !{!"Homebrew clang version 19.1.7"} +!57 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 9, type: !58, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!58 = !DISubroutineType(types: !59) +!59 = !{!28, !28} +!60 = !{} +!61 = !DILocalVariable(name: "unused", arg: 1, scope: !57, file: !3, line: 9, type: !28) +!62 = !DILocation(line: 9, column: 22, scope: !57) +!63 = !DILocation(line: 11, column: 7, scope: !57) +!64 = !DILocation(line: 11, column: 5, scope: !57) +!65 = !DILocation(line: 12, column: 2, scope: !57) +!66 = !DILocation(line: 13, column: 2, scope: !57) +!67 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 16, type: !58, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!68 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !3, line: 16, type: !28) +!69 = !DILocation(line: 16, column: 22, scope: !67) +!70 = !DILocation(line: 18, column: 2, scope: !67) +!71 = !DILocation(line: 19, column: 2, scope: !67) +!72 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 22, type: !73, scopeLine: 23, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!73 = !DISubroutineType(types: !74) +!74 = !{!23} +!75 = !DILocalVariable(name: "t1", scope: !72, file: !3, line: 24, type: !76) +!76 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !77, line: 31, baseType: !78) +!77 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!78 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !79, line: 118, baseType: !80) +!79 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!80 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !81, size: 64) +!81 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !79, line: 103, size: 65536, elements: !82) +!82 = !{!83, !84, !94} +!83 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !81, file: !79, line: 104, baseType: !27, size: 64) +!84 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !81, file: !79, line: 105, baseType: !85, size: 64, offset: 64) +!85 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !86, size: 64) +!86 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !79, line: 57, size: 192, elements: !87) +!87 = !{!88, !92, !93} +!88 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !86, file: !79, line: 58, baseType: !89, size: 64) +!89 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !90, size: 64) +!90 = !DISubroutineType(types: !91) +!91 = !{null, !28} +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !86, file: !79, line: 59, baseType: !28, size: 64, offset: 64) +!93 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !86, file: !79, line: 60, baseType: !85, size: 64, offset: 128) +!94 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !81, file: !79, line: 106, baseType: !95, size: 65408, offset: 128) +!95 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !96) +!96 = !{!97} +!97 = !DISubrange(count: 8176) +!98 = !DILocation(line: 24, column: 12, scope: !72) +!99 = !DILocalVariable(name: "t2", scope: !72, file: !3, line: 24, type: !76) +!100 = !DILocation(line: 24, column: 16, scope: !72) +!101 = !DILocation(line: 26, column: 2, scope: !72) +!102 = !DILocation(line: 27, column: 2, scope: !72) +!103 = !DILocation(line: 29, column: 15, scope: !72) +!104 = !DILocation(line: 29, column: 2, scope: !72) +!105 = !DILocation(line: 30, column: 15, scope: !72) +!106 = !DILocation(line: 30, column: 2, scope: !72) +!107 = !DILocation(line: 32, column: 2, scope: !72) +!108 = !DILocation(line: 0, scope: !72) +!109 = !DILocation(line: 34, column: 2, scope: !72) diff --git a/dartagnan/src/test/resources/lkmm/CoWR+poonceonce+Once.ll b/dartagnan/src/test/resources/lkmm/CoWR+poonceonce+Once.ll index ef5fca9c0a..3759781b77 100644 --- a/dartagnan/src/test/resources/lkmm/CoWR+poonceonce+Once.ll +++ b/dartagnan/src/test/resources/lkmm/CoWR+poonceonce+Once.ll @@ -1,160 +1,209 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/CoWR+poonceonce+Once.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/CoWR+poonceonce+Once.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/CoWR+poonceonce+Once.c' +source_filename = "benchmarks/lkmm/CoWR+poonceonce+Once.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@r0 = dso_local global i32 0, align 4, !dbg !26 -@.str = private unnamed_addr constant [32 x i8] c"!(READ_ONCE(x) == 1 && r0 == 2)\00", align 1 -@.str.1 = private unnamed_addr constant [61 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/CoWR+poonceonce+Once.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r0 = dso_local global i32 0, align 4, !dbg !47 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [23 x i8] c"CoWR+poonceonce+Once.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [32 x i8] c"!(READ_ONCE(x) == 1 && r0 == 2)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !38 { - call void @llvm.dbg.value(metadata i8* %0, metadata !42, metadata !DIExpression()), !dbg !43 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !44 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !45 - store i32 %2, i32* @r0, align 4, !dbg !46 - ret i8* null, !dbg !47 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !57 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !61, !DIExpression(), !62) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !63 + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !64 + %4 = trunc i64 %3 to i32, !dbg !64 + store i32 %4, ptr @r0, align 4, !dbg !65 + ret ptr null, !dbg !66 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !49, metadata !DIExpression()), !dbg !50 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !51 - ret i8* null, !dbg !52 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !67 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !68, !DIExpression(), !69) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !70 + ret ptr null, !dbg !71 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !53 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !56, metadata !DIExpression(DW_OP_deref)), !dbg !60 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !61 - call void @llvm.dbg.value(metadata i64* %2, metadata !62, metadata !DIExpression(DW_OP_deref)), !dbg !60 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !63 - %5 = load i64, i64* %1, align 8, !dbg !64 - call void @llvm.dbg.value(metadata i64 %5, metadata !56, metadata !DIExpression()), !dbg !60 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !65 - %7 = load i64, i64* %2, align 8, !dbg !66 - call void @llvm.dbg.value(metadata i64 %7, metadata !62, metadata !DIExpression()), !dbg !60 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !67 - %9 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !68 - %10 = icmp eq i32 %9, 1, !dbg !68 - %11 = load i32, i32* @r0, align 4, !dbg !68 - %12 = icmp eq i32 %11, 2, !dbg !68 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !68 - br i1 %or.cond, label %13, label %14, !dbg !68 +define dso_local i32 @main() #0 !dbg !72 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !75, !DIExpression(), !98) + #dbg_declare(ptr %3, !99, !DIExpression(), !100) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !101 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !102 + %6 = load ptr, ptr %2, align 8, !dbg !103 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !104 + %8 = load ptr, ptr %3, align 8, !dbg !105 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !106 + %10 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !107 + %11 = trunc i64 %10 to i32, !dbg !107 + %12 = icmp eq i32 %11, 1, !dbg !107 + br i1 %12, label %13, label %16, !dbg !107 13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 noundef 32, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !68 - unreachable, !dbg !68 - -14: ; preds = %0 - ret i32 0, !dbg !71 + %14 = load i32, ptr @r0, align 4, !dbg !107 + %15 = icmp eq i32 %14, 2, !dbg !107 + br label %16 + +16: ; preds = %13, %0 + %17 = phi i1 [ false, %0 ], [ %15, %13 ], !dbg !108 + %18 = xor i1 %17, true, !dbg !107 + %19 = xor i1 %18, true, !dbg !107 + %20 = zext i1 %19 to i32, !dbg !107 + %21 = sext i32 %20 to i64, !dbg !107 + %22 = icmp ne i64 %21, 0, !dbg !107 + br i1 %22, label %23, label %25, !dbg !107 + +23: ; preds = %16 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 32, ptr noundef @.str.1) #3, !dbg !107 + unreachable, !dbg !107 + +24: ; No predecessors! + br label %26, !dbg !107 + +25: ; preds = %16 + br label %26, !dbg !107 + +26: ; preds = %25, %24 + ret i32 0, !dbg !109 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!30, !31, !32, !33, !34, !35, !36} -!llvm.ident = !{!37} +!llvm.module.flags = !{!49, !50, !51, !52, !53, !54, !55} +!llvm.ident = !{!56} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/CoWR+poonceonce+Once.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "d522da5fecbd37dabc41d97e03f28b0d") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !27, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/CoWR+poonceonce+Once.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "d522da5fecbd37dabc41d97e03f28b0d") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/CoWR+poonceonce+Once.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "d522da5fecbd37dabc41d97e03f28b0d") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!30 = !{i32 7, !"Dwarf Version", i32 5} -!31 = !{i32 2, !"Debug Info Version", i32 3} -!32 = !{i32 1, !"wchar_size", i32 4} -!33 = !{i32 7, !"PIC Level", i32 2} -!34 = !{i32 7, !"PIE Level", i32 2} -!35 = !{i32 7, !"uwtable", i32 1} -!36 = !{i32 7, !"frame-pointer", i32 2} -!37 = !{!"Ubuntu clang version 14.0.6"} -!38 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 9, type: !39, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!39 = !DISubroutineType(types: !40) -!40 = !{!24, !24} -!41 = !{} -!42 = !DILocalVariable(name: "unused", arg: 1, scope: !38, file: !28, line: 9, type: !24) -!43 = !DILocation(line: 0, scope: !38) -!44 = !DILocation(line: 11, column: 2, scope: !38) -!45 = !DILocation(line: 12, column: 7, scope: !38) -!46 = !DILocation(line: 12, column: 5, scope: !38) -!47 = !DILocation(line: 13, column: 2, scope: !38) -!48 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 16, type: !39, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!49 = !DILocalVariable(name: "unused", arg: 1, scope: !48, file: !28, line: 16, type: !24) -!50 = !DILocation(line: 0, scope: !48) -!51 = !DILocation(line: 18, column: 2, scope: !48) -!52 = !DILocation(line: 19, column: 2, scope: !48) -!53 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 22, type: !54, scopeLine: 23, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!54 = !DISubroutineType(types: !55) -!55 = !{!29} -!56 = !DILocalVariable(name: "t1", scope: !53, file: !28, line: 24, type: !57) -!57 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !58, line: 27, baseType: !59) -!58 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!59 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!60 = !DILocation(line: 0, scope: !53) -!61 = !DILocation(line: 26, column: 2, scope: !53) -!62 = !DILocalVariable(name: "t2", scope: !53, file: !28, line: 24, type: !57) -!63 = !DILocation(line: 27, column: 2, scope: !53) -!64 = !DILocation(line: 29, column: 15, scope: !53) -!65 = !DILocation(line: 29, column: 2, scope: !53) -!66 = !DILocation(line: 30, column: 15, scope: !53) -!67 = !DILocation(line: 30, column: 2, scope: !53) -!68 = !DILocation(line: 32, column: 2, scope: !69) -!69 = distinct !DILexicalBlock(scope: !70, file: !28, line: 32, column: 2) -!70 = distinct !DILexicalBlock(scope: !53, file: !28, line: 32, column: 2) -!71 = !DILocation(line: 34, column: 2, scope: !53) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47} +!30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 32, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 32, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 184, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 23) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 32, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 256, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 32) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 7, type: !27, isLocal: false, isDefinition: true) +!49 = !{i32 7, !"Dwarf Version", i32 5} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = !{i32 1, !"wchar_size", i32 4} +!52 = !{i32 8, !"PIC Level", i32 2} +!53 = !{i32 7, !"PIE Level", i32 2} +!54 = !{i32 7, !"uwtable", i32 2} +!55 = !{i32 7, !"frame-pointer", i32 2} +!56 = !{!"Homebrew clang version 19.1.7"} +!57 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 9, type: !58, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!58 = !DISubroutineType(types: !59) +!59 = !{!28, !28} +!60 = !{} +!61 = !DILocalVariable(name: "unused", arg: 1, scope: !57, file: !3, line: 9, type: !28) +!62 = !DILocation(line: 9, column: 22, scope: !57) +!63 = !DILocation(line: 11, column: 2, scope: !57) +!64 = !DILocation(line: 12, column: 7, scope: !57) +!65 = !DILocation(line: 12, column: 5, scope: !57) +!66 = !DILocation(line: 13, column: 2, scope: !57) +!67 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 16, type: !58, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!68 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !3, line: 16, type: !28) +!69 = !DILocation(line: 16, column: 22, scope: !67) +!70 = !DILocation(line: 18, column: 2, scope: !67) +!71 = !DILocation(line: 19, column: 2, scope: !67) +!72 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 22, type: !73, scopeLine: 23, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!73 = !DISubroutineType(types: !74) +!74 = !{!27} +!75 = !DILocalVariable(name: "t1", scope: !72, file: !3, line: 24, type: !76) +!76 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !77, line: 31, baseType: !78) +!77 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!78 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !79, line: 118, baseType: !80) +!79 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!80 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !81, size: 64) +!81 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !79, line: 103, size: 65536, elements: !82) +!82 = !{!83, !84, !94} +!83 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !81, file: !79, line: 104, baseType: !26, size: 64) +!84 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !81, file: !79, line: 105, baseType: !85, size: 64, offset: 64) +!85 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !86, size: 64) +!86 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !79, line: 57, size: 192, elements: !87) +!87 = !{!88, !92, !93} +!88 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !86, file: !79, line: 58, baseType: !89, size: 64) +!89 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !90, size: 64) +!90 = !DISubroutineType(types: !91) +!91 = !{null, !28} +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !86, file: !79, line: 59, baseType: !28, size: 64, offset: 64) +!93 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !86, file: !79, line: 60, baseType: !85, size: 64, offset: 128) +!94 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !81, file: !79, line: 106, baseType: !95, size: 65408, offset: 128) +!95 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !96) +!96 = !{!97} +!97 = !DISubrange(count: 8176) +!98 = !DILocation(line: 24, column: 12, scope: !72) +!99 = !DILocalVariable(name: "t2", scope: !72, file: !3, line: 24, type: !76) +!100 = !DILocation(line: 24, column: 16, scope: !72) +!101 = !DILocation(line: 26, column: 2, scope: !72) +!102 = !DILocation(line: 27, column: 2, scope: !72) +!103 = !DILocation(line: 29, column: 15, scope: !72) +!104 = !DILocation(line: 29, column: 2, scope: !72) +!105 = !DILocation(line: 30, column: 15, scope: !72) +!106 = !DILocation(line: 30, column: 2, scope: !72) +!107 = !DILocation(line: 32, column: 2, scope: !72) +!108 = !DILocation(line: 0, scope: !72) +!109 = !DILocation(line: 34, column: 2, scope: !72) diff --git a/dartagnan/src/test/resources/lkmm/LB+fencembonceonce+ctrlonceonce.ll b/dartagnan/src/test/resources/lkmm/LB+fencembonceonce+ctrlonceonce.ll index d480235a7f..a453f1916f 100644 --- a/dartagnan/src/test/resources/lkmm/LB+fencembonceonce+ctrlonceonce.ll +++ b/dartagnan/src/test/resources/lkmm/LB+fencembonceonce+ctrlonceonce.ll @@ -1,186 +1,237 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/LB+fencembonceonce+ctrlonceonce.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c' +source_filename = "benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @r0 = dso_local global i32 0, align 4, !dbg !0 -@x = dso_local global i32 0, align 4, !dbg !26 -@y = dso_local global i32 0, align 4, !dbg !30 -@r1 = dso_local global i32 0, align 4, !dbg !32 -@.str = private unnamed_addr constant [44 x i8] c"!(READ_ONCE(r0) == 1 && READ_ONCE(r1) == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [72 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@x = dso_local global i32 0, align 4, !dbg !47 +@y = dso_local global i32 0, align 4, !dbg !49 +@r1 = dso_local global i32 0, align 4, !dbg !51 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [34 x i8] c"LB+fencembonceonce+ctrlonceonce.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [44 x i8] c"!(READ_ONCE(r0) == 1 && READ_ONCE(r1) == 1)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !42 { - call void @llvm.dbg.value(metadata i8* %0, metadata !46, metadata !DIExpression()), !dbg !47 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !48 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @r0 to i8*), i32 noundef %2, i32 noundef 1) #5, !dbg !48 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @r0 to i8*), i32 noundef 1) #5, !dbg !49 - %.not = icmp eq i32 %3, 0, !dbg !49 - br i1 %.not, label %5, label %4, !dbg !51 - -4: ; preds = %1 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !52 - br label %5, !dbg !52 - -5: ; preds = %4, %1 - ret i8* null, !dbg !53 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !61 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !65, !DIExpression(), !66) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !67 + %4 = trunc i64 %3 to i32, !dbg !67 + %5 = sext i32 %4 to i64, !dbg !67 + call void @__LKMM_store(ptr noundef @r0, i64 noundef 4, i64 noundef %5, i32 noundef 0), !dbg !67 + %6 = call i64 @__LKMM_load(ptr noundef @r0, i64 noundef 4, i32 noundef 0), !dbg !68 + %7 = trunc i64 %6 to i32, !dbg !68 + %8 = icmp ne i32 %7, 0, !dbg !68 + br i1 %8, label %9, label %10, !dbg !70 + +9: ; preds = %1 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !71 + br label %10, !dbg !71 + +10: ; preds = %9, %1 + ret ptr null, !dbg !72 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !54 { - call void @llvm.dbg.value(metadata i8* %0, metadata !55, metadata !DIExpression()), !dbg !56 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !57 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @r1 to i8*), i32 noundef %2, i32 noundef 1) #5, !dbg !57 - call void @__LKMM_FENCE(i32 noundef 4) #5, !dbg !58 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !59 - ret i8* null, !dbg !60 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !73 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !74, !DIExpression(), !75) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !76 + %4 = trunc i64 %3 to i32, !dbg !76 + %5 = sext i32 %4 to i64, !dbg !76 + call void @__LKMM_store(ptr noundef @r1, i64 noundef 4, i64 noundef %5, i32 noundef 0), !dbg !76 + call void @__LKMM_fence(i32 noundef 3), !dbg !77 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !78 + ret ptr null, !dbg !79 } -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !61 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !64, metadata !DIExpression(DW_OP_deref)), !dbg !68 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !69 - call void @llvm.dbg.value(metadata i64* %2, metadata !70, metadata !DIExpression(DW_OP_deref)), !dbg !68 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !71 - %5 = load i64, i64* %1, align 8, !dbg !72 - call void @llvm.dbg.value(metadata i64 %5, metadata !64, metadata !DIExpression()), !dbg !68 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !73 - %7 = load i64, i64* %2, align 8, !dbg !74 - call void @llvm.dbg.value(metadata i64 %7, metadata !70, metadata !DIExpression()), !dbg !68 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !75 - %9 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @r0 to i8*), i32 noundef 1) #5, !dbg !76 - %10 = icmp eq i32 %9, 1, !dbg !76 - br i1 %10, label %11, label %15, !dbg !76 - -11: ; preds = %0 - %12 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @r1 to i8*), i32 noundef 1) #5, !dbg !76 - %13 = icmp eq i32 %12, 1, !dbg !76 - br i1 %13, label %14, label %15, !dbg !79 - -14: ; preds = %11 - call void @__assert_fail(i8* noundef getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i32 noundef 37, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !76 - unreachable, !dbg !76 - -15: ; preds = %0, %11 - ret i32 0, !dbg !80 +define dso_local i32 @main() #0 !dbg !80 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !83, !DIExpression(), !106) + #dbg_declare(ptr %3, !107, !DIExpression(), !108) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !109 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !110 + %6 = load ptr, ptr %2, align 8, !dbg !111 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !112 + %8 = load ptr, ptr %3, align 8, !dbg !113 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !114 + %10 = call i64 @__LKMM_load(ptr noundef @r0, i64 noundef 4, i32 noundef 0), !dbg !115 + %11 = trunc i64 %10 to i32, !dbg !115 + %12 = icmp eq i32 %11, 1, !dbg !115 + br i1 %12, label %13, label %17, !dbg !115 + +13: ; preds = %0 + %14 = call i64 @__LKMM_load(ptr noundef @r1, i64 noundef 4, i32 noundef 0), !dbg !115 + %15 = trunc i64 %14 to i32, !dbg !115 + %16 = icmp eq i32 %15, 1, !dbg !115 + br label %17 + +17: ; preds = %13, %0 + %18 = phi i1 [ false, %0 ], [ %16, %13 ], !dbg !116 + %19 = xor i1 %18, true, !dbg !115 + %20 = xor i1 %19, true, !dbg !115 + %21 = zext i1 %20 to i32, !dbg !115 + %22 = sext i32 %21 to i64, !dbg !115 + %23 = icmp ne i64 %22, 0, !dbg !115 + br i1 %23, label %24, label %26, !dbg !115 + +24: ; preds = %17 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 37, ptr noundef @.str.1) #3, !dbg !115 + unreachable, !dbg !115 + +25: ; No predecessors! + br label %27, !dbg !115 + +26: ; preds = %17 + br label %27, !dbg !115 + +27: ; preds = %26, %25 + ret i32 0, !dbg !117 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40} -!llvm.ident = !{!41} +!llvm.module.flags = !{!53, !54, !55, !56, !57, !58, !59} +!llvm.ident = !{!60} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "e04735b1ad6e052c08fd1ecbe5dcff13") +!1 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 9, type: !27, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "e04735b1ad6e052c08fd1ecbe5dcff13") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!26, !30, !0, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/LB+fencembonceonce+ctrlonceonce.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "e04735b1ad6e052c08fd1ecbe5dcff13") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !47, !49, !0, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!34 = !{i32 7, !"Dwarf Version", i32 5} -!35 = !{i32 2, !"Debug Info Version", i32 3} -!36 = !{i32 1, !"wchar_size", i32 4} -!37 = !{i32 7, !"PIC Level", i32 2} -!38 = !{i32 7, !"PIE Level", i32 2} -!39 = !{i32 7, !"uwtable", i32 1} -!40 = !{i32 7, !"frame-pointer", i32 2} -!41 = !{!"Ubuntu clang version 14.0.6"} -!42 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 11, type: !43, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!43 = !DISubroutineType(types: !44) -!44 = !{!24, !24} -!45 = !{} -!46 = !DILocalVariable(name: "unused", arg: 1, scope: !42, file: !28, line: 11, type: !24) -!47 = !DILocation(line: 0, scope: !42) -!48 = !DILocation(line: 13, column: 2, scope: !42) -!49 = !DILocation(line: 14, column: 6, scope: !50) -!50 = distinct !DILexicalBlock(scope: !42, file: !28, line: 14, column: 6) -!51 = !DILocation(line: 14, column: 6, scope: !42) -!52 = !DILocation(line: 15, column: 3, scope: !50) -!53 = !DILocation(line: 16, column: 2, scope: !42) -!54 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 19, type: !43, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!55 = !DILocalVariable(name: "unused", arg: 1, scope: !54, file: !28, line: 19, type: !24) -!56 = !DILocation(line: 0, scope: !54) -!57 = !DILocation(line: 21, column: 2, scope: !54) -!58 = !DILocation(line: 22, column: 2, scope: !54) -!59 = !DILocation(line: 23, column: 2, scope: !54) -!60 = !DILocation(line: 24, column: 2, scope: !54) -!61 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 27, type: !62, scopeLine: 28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 37, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 37, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 272, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 34) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 37, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 352, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 44) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !27, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !27, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !3, line: 9, type: !27, isLocal: false, isDefinition: true) +!53 = !{i32 7, !"Dwarf Version", i32 5} +!54 = !{i32 2, !"Debug Info Version", i32 3} +!55 = !{i32 1, !"wchar_size", i32 4} +!56 = !{i32 8, !"PIC Level", i32 2} +!57 = !{i32 7, !"PIE Level", i32 2} +!58 = !{i32 7, !"uwtable", i32 2} +!59 = !{i32 7, !"frame-pointer", i32 2} +!60 = !{!"Homebrew clang version 19.1.7"} +!61 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 11, type: !62, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) !62 = !DISubroutineType(types: !63) -!63 = !{!29} -!64 = !DILocalVariable(name: "t1", scope: !61, file: !28, line: 29, type: !65) -!65 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !66, line: 27, baseType: !67) -!66 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!67 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!68 = !DILocation(line: 0, scope: !61) -!69 = !DILocation(line: 31, column: 2, scope: !61) -!70 = !DILocalVariable(name: "t2", scope: !61, file: !28, line: 29, type: !65) -!71 = !DILocation(line: 32, column: 2, scope: !61) -!72 = !DILocation(line: 34, column: 15, scope: !61) -!73 = !DILocation(line: 34, column: 2, scope: !61) -!74 = !DILocation(line: 35, column: 15, scope: !61) -!75 = !DILocation(line: 35, column: 2, scope: !61) -!76 = !DILocation(line: 37, column: 2, scope: !77) -!77 = distinct !DILexicalBlock(scope: !78, file: !28, line: 37, column: 2) -!78 = distinct !DILexicalBlock(scope: !61, file: !28, line: 37, column: 2) -!79 = !DILocation(line: 37, column: 2, scope: !78) -!80 = !DILocation(line: 39, column: 2, scope: !61) +!63 = !{!28, !28} +!64 = !{} +!65 = !DILocalVariable(name: "unused", arg: 1, scope: !61, file: !3, line: 11, type: !28) +!66 = !DILocation(line: 11, column: 22, scope: !61) +!67 = !DILocation(line: 13, column: 2, scope: !61) +!68 = !DILocation(line: 14, column: 6, scope: !69) +!69 = distinct !DILexicalBlock(scope: !61, file: !3, line: 14, column: 6) +!70 = !DILocation(line: 14, column: 6, scope: !61) +!71 = !DILocation(line: 15, column: 3, scope: !69) +!72 = !DILocation(line: 16, column: 2, scope: !61) +!73 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 19, type: !62, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!74 = !DILocalVariable(name: "unused", arg: 1, scope: !73, file: !3, line: 19, type: !28) +!75 = !DILocation(line: 19, column: 22, scope: !73) +!76 = !DILocation(line: 21, column: 2, scope: !73) +!77 = !DILocation(line: 22, column: 2, scope: !73) +!78 = !DILocation(line: 23, column: 2, scope: !73) +!79 = !DILocation(line: 24, column: 2, scope: !73) +!80 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 27, type: !81, scopeLine: 28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!81 = !DISubroutineType(types: !82) +!82 = !{!27} +!83 = !DILocalVariable(name: "t1", scope: !80, file: !3, line: 29, type: !84) +!84 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !85, line: 31, baseType: !86) +!85 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!86 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !87, line: 118, baseType: !88) +!87 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!88 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !89, size: 64) +!89 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !87, line: 103, size: 65536, elements: !90) +!90 = !{!91, !92, !102} +!91 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !89, file: !87, line: 104, baseType: !26, size: 64) +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !89, file: !87, line: 105, baseType: !93, size: 64, offset: 64) +!93 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !94, size: 64) +!94 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !87, line: 57, size: 192, elements: !95) +!95 = !{!96, !100, !101} +!96 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !94, file: !87, line: 58, baseType: !97, size: 64) +!97 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !98, size: 64) +!98 = !DISubroutineType(types: !99) +!99 = !{null, !28} +!100 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !94, file: !87, line: 59, baseType: !28, size: 64, offset: 64) +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !94, file: !87, line: 60, baseType: !93, size: 64, offset: 128) +!102 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !89, file: !87, line: 106, baseType: !103, size: 65408, offset: 128) +!103 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !104) +!104 = !{!105} +!105 = !DISubrange(count: 8176) +!106 = !DILocation(line: 29, column: 12, scope: !80) +!107 = !DILocalVariable(name: "t2", scope: !80, file: !3, line: 29, type: !84) +!108 = !DILocation(line: 29, column: 16, scope: !80) +!109 = !DILocation(line: 31, column: 2, scope: !80) +!110 = !DILocation(line: 32, column: 2, scope: !80) +!111 = !DILocation(line: 34, column: 15, scope: !80) +!112 = !DILocation(line: 34, column: 2, scope: !80) +!113 = !DILocation(line: 35, column: 15, scope: !80) +!114 = !DILocation(line: 35, column: 2, scope: !80) +!115 = !DILocation(line: 37, column: 2, scope: !80) +!116 = !DILocation(line: 0, scope: !80) +!117 = !DILocation(line: 39, column: 2, scope: !80) diff --git a/dartagnan/src/test/resources/lkmm/LB+poacquireonce+pooncerelease.ll b/dartagnan/src/test/resources/lkmm/LB+poacquireonce+pooncerelease.ll index 2ab37c7541..60503af292 100644 --- a/dartagnan/src/test/resources/lkmm/LB+poacquireonce+pooncerelease.ll +++ b/dartagnan/src/test/resources/lkmm/LB+poacquireonce+pooncerelease.ll @@ -1,170 +1,219 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/LB+poacquireonce+pooncerelease.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/LB+poacquireonce+pooncerelease.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/LB+poacquireonce+pooncerelease.c' +source_filename = "benchmarks/lkmm/LB+poacquireonce+pooncerelease.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@r0 = dso_local global i32 0, align 4, !dbg !30 -@y = dso_local global i32 0, align 4, !dbg !26 -@r1 = dso_local global i32 0, align 4, !dbg !32 -@.str = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [71 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/LB+poacquireonce+pooncerelease.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r0 = dso_local global i32 0, align 4, !dbg !49 +@y = dso_local global i32 0, align 4, !dbg !47 +@r1 = dso_local global i32 0, align 4, !dbg !51 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [33 x i8] c"LB+poacquireonce+pooncerelease.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 1)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !42 { - call void @llvm.dbg.value(metadata i8* %0, metadata !46, metadata !DIExpression()), !dbg !47 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !48 - store i32 %2, i32* @r0, align 4, !dbg !49 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 3) #5, !dbg !50 - ret i8* null, !dbg !51 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !61 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !65, !DIExpression(), !66) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !67 + %4 = trunc i64 %3 to i32, !dbg !67 + store i32 %4, ptr @r0, align 4, !dbg !68 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 2), !dbg !69 + ret ptr null, !dbg !70 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !52 { - call void @llvm.dbg.value(metadata i8* %0, metadata !53, metadata !DIExpression()), !dbg !54 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 2) #5, !dbg !55 - store i32 %2, i32* @r1, align 4, !dbg !56 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !57 - ret i8* null, !dbg !58 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !71 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !72, !DIExpression(), !73) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 1), !dbg !74 + %4 = trunc i64 %3 to i32, !dbg !74 + store i32 %4, ptr @r1, align 4, !dbg !75 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !76 + ret ptr null, !dbg !77 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !59 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !62, metadata !DIExpression(DW_OP_deref)), !dbg !66 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !67 - call void @llvm.dbg.value(metadata i64* %2, metadata !68, metadata !DIExpression(DW_OP_deref)), !dbg !66 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !69 - %5 = load i64, i64* %1, align 8, !dbg !70 - call void @llvm.dbg.value(metadata i64 %5, metadata !62, metadata !DIExpression()), !dbg !66 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !71 - %7 = load i64, i64* %2, align 8, !dbg !72 - call void @llvm.dbg.value(metadata i64 %7, metadata !68, metadata !DIExpression()), !dbg !66 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !73 - %9 = load i32, i32* @r0, align 4, !dbg !74 - %10 = icmp eq i32 %9, 1, !dbg !74 - %11 = load i32, i32* @r1, align 4, !dbg !74 - %12 = icmp eq i32 %11, 1, !dbg !74 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !74 - br i1 %or.cond, label %13, label %14, !dbg !74 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 noundef 35, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !74 - unreachable, !dbg !74 - -14: ; preds = %0 - ret i32 0, !dbg !77 +define dso_local i32 @main() #0 !dbg !78 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !81, !DIExpression(), !104) + #dbg_declare(ptr %3, !105, !DIExpression(), !106) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !107 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !108 + %6 = load ptr, ptr %2, align 8, !dbg !109 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !110 + %8 = load ptr, ptr %3, align 8, !dbg !111 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !112 + %10 = load i32, ptr @r0, align 4, !dbg !113 + %11 = icmp eq i32 %10, 1, !dbg !113 + br i1 %11, label %12, label %15, !dbg !113 + +12: ; preds = %0 + %13 = load i32, ptr @r1, align 4, !dbg !113 + %14 = icmp eq i32 %13, 1, !dbg !113 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !114 + %17 = xor i1 %16, true, !dbg !113 + %18 = xor i1 %17, true, !dbg !113 + %19 = zext i1 %18 to i32, !dbg !113 + %20 = sext i32 %19 to i64, !dbg !113 + %21 = icmp ne i64 %20, 0, !dbg !113 + br i1 %21, label %22, label %24, !dbg !113 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 35, ptr noundef @.str.1) #3, !dbg !113 + unreachable, !dbg !113 + +23: ; No predecessors! + br label %25, !dbg !113 + +24: ; preds = %15 + br label %25, !dbg !113 + +25: ; preds = %24, %23 + ret i32 0, !dbg !115 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40} -!llvm.ident = !{!41} +!llvm.module.flags = !{!53, !54, !55, !56, !57, !58, !59} +!llvm.ident = !{!60} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/LB+poacquireonce+pooncerelease.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "273f0308996bdd503c288ed473fb0e4c") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !23, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/LB+poacquireonce+pooncerelease.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "273f0308996bdd503c288ed473fb0e4c") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/LB+poacquireonce+pooncerelease.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "273f0308996bdd503c288ed473fb0e4c") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !24, !28} +!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !25) +!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !26, line: 32, baseType: !27) +!26 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!27 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47, !49, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!34 = !{i32 7, !"Dwarf Version", i32 5} -!35 = !{i32 2, !"Debug Info Version", i32 3} -!36 = !{i32 1, !"wchar_size", i32 4} -!37 = !{i32 7, !"PIC Level", i32 2} -!38 = !{i32 7, !"PIE Level", i32 2} -!39 = !{i32 7, !"uwtable", i32 1} -!40 = !{i32 7, !"frame-pointer", i32 2} -!41 = !{!"Ubuntu clang version 14.0.6"} -!42 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 11, type: !43, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!43 = !DISubroutineType(types: !44) -!44 = !{!24, !24} -!45 = !{} -!46 = !DILocalVariable(name: "unused", arg: 1, scope: !42, file: !28, line: 11, type: !24) -!47 = !DILocation(line: 0, scope: !42) -!48 = !DILocation(line: 13, column: 7, scope: !42) -!49 = !DILocation(line: 13, column: 5, scope: !42) -!50 = !DILocation(line: 14, column: 2, scope: !42) -!51 = !DILocation(line: 15, column: 2, scope: !42) -!52 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 18, type: !43, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!53 = !DILocalVariable(name: "unused", arg: 1, scope: !52, file: !28, line: 18, type: !24) -!54 = !DILocation(line: 0, scope: !52) -!55 = !DILocation(line: 20, column: 7, scope: !52) -!56 = !DILocation(line: 20, column: 5, scope: !52) -!57 = !DILocation(line: 21, column: 2, scope: !52) -!58 = !DILocation(line: 22, column: 2, scope: !52) -!59 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 25, type: !60, scopeLine: 26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!60 = !DISubroutineType(types: !61) -!61 = !{!29} -!62 = !DILocalVariable(name: "t1", scope: !59, file: !28, line: 27, type: !63) -!63 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !64, line: 27, baseType: !65) -!64 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!65 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!66 = !DILocation(line: 0, scope: !59) -!67 = !DILocation(line: 29, column: 2, scope: !59) -!68 = !DILocalVariable(name: "t2", scope: !59, file: !28, line: 27, type: !63) -!69 = !DILocation(line: 30, column: 2, scope: !59) -!70 = !DILocation(line: 32, column: 15, scope: !59) -!71 = !DILocation(line: 32, column: 2, scope: !59) -!72 = !DILocation(line: 33, column: 15, scope: !59) -!73 = !DILocation(line: 33, column: 2, scope: !59) -!74 = !DILocation(line: 35, column: 2, scope: !75) -!75 = distinct !DILexicalBlock(scope: !76, file: !28, line: 35, column: 2) -!76 = distinct !DILexicalBlock(scope: !59, file: !28, line: 35, column: 2) -!77 = !DILocation(line: 37, column: 2, scope: !59) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 35, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 35, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 264, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 33) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 35, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 176, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 22) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 9, type: !23, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !3, line: 9, type: !23, isLocal: false, isDefinition: true) +!53 = !{i32 7, !"Dwarf Version", i32 5} +!54 = !{i32 2, !"Debug Info Version", i32 3} +!55 = !{i32 1, !"wchar_size", i32 4} +!56 = !{i32 8, !"PIC Level", i32 2} +!57 = !{i32 7, !"PIE Level", i32 2} +!58 = !{i32 7, !"uwtable", i32 2} +!59 = !{i32 7, !"frame-pointer", i32 2} +!60 = !{!"Homebrew clang version 19.1.7"} +!61 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 11, type: !62, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!62 = !DISubroutineType(types: !63) +!63 = !{!28, !28} +!64 = !{} +!65 = !DILocalVariable(name: "unused", arg: 1, scope: !61, file: !3, line: 11, type: !28) +!66 = !DILocation(line: 11, column: 22, scope: !61) +!67 = !DILocation(line: 13, column: 7, scope: !61) +!68 = !DILocation(line: 13, column: 5, scope: !61) +!69 = !DILocation(line: 14, column: 2, scope: !61) +!70 = !DILocation(line: 15, column: 2, scope: !61) +!71 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 18, type: !62, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!72 = !DILocalVariable(name: "unused", arg: 1, scope: !71, file: !3, line: 18, type: !28) +!73 = !DILocation(line: 18, column: 22, scope: !71) +!74 = !DILocation(line: 20, column: 7, scope: !71) +!75 = !DILocation(line: 20, column: 5, scope: !71) +!76 = !DILocation(line: 21, column: 2, scope: !71) +!77 = !DILocation(line: 22, column: 2, scope: !71) +!78 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 25, type: !79, scopeLine: 26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!79 = !DISubroutineType(types: !80) +!80 = !{!23} +!81 = !DILocalVariable(name: "t1", scope: !78, file: !3, line: 27, type: !82) +!82 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !83, line: 31, baseType: !84) +!83 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!84 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !85, line: 118, baseType: !86) +!85 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!86 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !87, size: 64) +!87 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !85, line: 103, size: 65536, elements: !88) +!88 = !{!89, !90, !100} +!89 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !87, file: !85, line: 104, baseType: !27, size: 64) +!90 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !87, file: !85, line: 105, baseType: !91, size: 64, offset: 64) +!91 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !92, size: 64) +!92 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !85, line: 57, size: 192, elements: !93) +!93 = !{!94, !98, !99} +!94 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !92, file: !85, line: 58, baseType: !95, size: 64) +!95 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !96, size: 64) +!96 = !DISubroutineType(types: !97) +!97 = !{null, !28} +!98 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !92, file: !85, line: 59, baseType: !28, size: 64, offset: 64) +!99 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !92, file: !85, line: 60, baseType: !91, size: 64, offset: 128) +!100 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !87, file: !85, line: 106, baseType: !101, size: 65408, offset: 128) +!101 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !102) +!102 = !{!103} +!103 = !DISubrange(count: 8176) +!104 = !DILocation(line: 27, column: 12, scope: !78) +!105 = !DILocalVariable(name: "t2", scope: !78, file: !3, line: 27, type: !82) +!106 = !DILocation(line: 27, column: 16, scope: !78) +!107 = !DILocation(line: 29, column: 2, scope: !78) +!108 = !DILocation(line: 30, column: 2, scope: !78) +!109 = !DILocation(line: 32, column: 15, scope: !78) +!110 = !DILocation(line: 32, column: 2, scope: !78) +!111 = !DILocation(line: 33, column: 15, scope: !78) +!112 = !DILocation(line: 33, column: 2, scope: !78) +!113 = !DILocation(line: 35, column: 2, scope: !78) +!114 = !DILocation(line: 0, scope: !78) +!115 = !DILocation(line: 37, column: 2, scope: !78) diff --git a/dartagnan/src/test/resources/lkmm/LB+poonceonces.ll b/dartagnan/src/test/resources/lkmm/LB+poonceonces.ll index bc9ea346fb..6eb659c6a8 100644 --- a/dartagnan/src/test/resources/lkmm/LB+poonceonces.ll +++ b/dartagnan/src/test/resources/lkmm/LB+poonceonces.ll @@ -1,170 +1,219 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/LB+poonceonces.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/LB+poonceonces.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/LB+poonceonces.c' +source_filename = "benchmarks/lkmm/LB+poonceonces.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@r0 = dso_local global i32 0, align 4, !dbg !30 -@y = dso_local global i32 0, align 4, !dbg !26 -@r1 = dso_local global i32 0, align 4, !dbg !32 -@.str = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [55 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/LB+poonceonces.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r0 = dso_local global i32 0, align 4, !dbg !49 +@y = dso_local global i32 0, align 4, !dbg !47 +@r1 = dso_local global i32 0, align 4, !dbg !51 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [17 x i8] c"LB+poonceonces.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 1)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !42 { - call void @llvm.dbg.value(metadata i8* %0, metadata !46, metadata !DIExpression()), !dbg !47 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !48 - store i32 %2, i32* @r0, align 4, !dbg !49 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !50 - ret i8* null, !dbg !51 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !61 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !65, !DIExpression(), !66) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !67 + %4 = trunc i64 %3 to i32, !dbg !67 + store i32 %4, ptr @r0, align 4, !dbg !68 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !69 + ret ptr null, !dbg !70 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !52 { - call void @llvm.dbg.value(metadata i8* %0, metadata !53, metadata !DIExpression()), !dbg !54 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !55 - store i32 %2, i32* @r1, align 4, !dbg !56 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !57 - ret i8* null, !dbg !58 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !71 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !72, !DIExpression(), !73) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !74 + %4 = trunc i64 %3 to i32, !dbg !74 + store i32 %4, ptr @r1, align 4, !dbg !75 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !76 + ret ptr null, !dbg !77 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !59 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !62, metadata !DIExpression(DW_OP_deref)), !dbg !66 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !67 - call void @llvm.dbg.value(metadata i64* %2, metadata !68, metadata !DIExpression(DW_OP_deref)), !dbg !66 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !69 - %5 = load i64, i64* %1, align 8, !dbg !70 - call void @llvm.dbg.value(metadata i64 %5, metadata !62, metadata !DIExpression()), !dbg !66 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !71 - %7 = load i64, i64* %2, align 8, !dbg !72 - call void @llvm.dbg.value(metadata i64 %7, metadata !68, metadata !DIExpression()), !dbg !66 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !73 - %9 = load i32, i32* @r0, align 4, !dbg !74 - %10 = icmp eq i32 %9, 1, !dbg !74 - %11 = load i32, i32* @r1, align 4, !dbg !74 - %12 = icmp eq i32 %11, 1, !dbg !74 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !74 - br i1 %or.cond, label %13, label %14, !dbg !74 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 noundef 35, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !74 - unreachable, !dbg !74 - -14: ; preds = %0 - ret i32 0, !dbg !77 +define dso_local i32 @main() #0 !dbg !78 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !81, !DIExpression(), !104) + #dbg_declare(ptr %3, !105, !DIExpression(), !106) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !107 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !108 + %6 = load ptr, ptr %2, align 8, !dbg !109 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !110 + %8 = load ptr, ptr %3, align 8, !dbg !111 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !112 + %10 = load i32, ptr @r0, align 4, !dbg !113 + %11 = icmp eq i32 %10, 1, !dbg !113 + br i1 %11, label %12, label %15, !dbg !113 + +12: ; preds = %0 + %13 = load i32, ptr @r1, align 4, !dbg !113 + %14 = icmp eq i32 %13, 1, !dbg !113 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !114 + %17 = xor i1 %16, true, !dbg !113 + %18 = xor i1 %17, true, !dbg !113 + %19 = zext i1 %18 to i32, !dbg !113 + %20 = sext i32 %19 to i64, !dbg !113 + %21 = icmp ne i64 %20, 0, !dbg !113 + br i1 %21, label %22, label %24, !dbg !113 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 35, ptr noundef @.str.1) #3, !dbg !113 + unreachable, !dbg !113 + +23: ; No predecessors! + br label %25, !dbg !113 + +24: ; preds = %15 + br label %25, !dbg !113 + +25: ; preds = %24, %23 + ret i32 0, !dbg !115 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40} -!llvm.ident = !{!41} +!llvm.module.flags = !{!53, !54, !55, !56, !57, !58, !59} +!llvm.ident = !{!60} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/LB+poonceonces.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "596b7c853e97a0391e55914691d22b8f") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !23, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/LB+poonceonces.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "596b7c853e97a0391e55914691d22b8f") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/LB+poonceonces.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "596b7c853e97a0391e55914691d22b8f") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !24, !28} +!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !25) +!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !26, line: 32, baseType: !27) +!26 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!27 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47, !49, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!34 = !{i32 7, !"Dwarf Version", i32 5} -!35 = !{i32 2, !"Debug Info Version", i32 3} -!36 = !{i32 1, !"wchar_size", i32 4} -!37 = !{i32 7, !"PIC Level", i32 2} -!38 = !{i32 7, !"PIE Level", i32 2} -!39 = !{i32 7, !"uwtable", i32 1} -!40 = !{i32 7, !"frame-pointer", i32 2} -!41 = !{!"Ubuntu clang version 14.0.6"} -!42 = distinct !DISubprogram(name: "thread_1", scope: !28, file: !28, line: 11, type: !43, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!43 = !DISubroutineType(types: !44) -!44 = !{!24, !24} -!45 = !{} -!46 = !DILocalVariable(name: "unused", arg: 1, scope: !42, file: !28, line: 11, type: !24) -!47 = !DILocation(line: 0, scope: !42) -!48 = !DILocation(line: 13, column: 7, scope: !42) -!49 = !DILocation(line: 13, column: 5, scope: !42) -!50 = !DILocation(line: 14, column: 2, scope: !42) -!51 = !DILocation(line: 15, column: 2, scope: !42) -!52 = distinct !DISubprogram(name: "thread_2", scope: !28, file: !28, line: 18, type: !43, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!53 = !DILocalVariable(name: "unused", arg: 1, scope: !52, file: !28, line: 18, type: !24) -!54 = !DILocation(line: 0, scope: !52) -!55 = !DILocation(line: 20, column: 7, scope: !52) -!56 = !DILocation(line: 20, column: 5, scope: !52) -!57 = !DILocation(line: 21, column: 2, scope: !52) -!58 = !DILocation(line: 22, column: 2, scope: !52) -!59 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 25, type: !60, scopeLine: 26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!60 = !DISubroutineType(types: !61) -!61 = !{!29} -!62 = !DILocalVariable(name: "t1", scope: !59, file: !28, line: 27, type: !63) -!63 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !64, line: 27, baseType: !65) -!64 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!65 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!66 = !DILocation(line: 0, scope: !59) -!67 = !DILocation(line: 29, column: 2, scope: !59) -!68 = !DILocalVariable(name: "t2", scope: !59, file: !28, line: 27, type: !63) -!69 = !DILocation(line: 30, column: 2, scope: !59) -!70 = !DILocation(line: 32, column: 15, scope: !59) -!71 = !DILocation(line: 32, column: 2, scope: !59) -!72 = !DILocation(line: 33, column: 15, scope: !59) -!73 = !DILocation(line: 33, column: 2, scope: !59) -!74 = !DILocation(line: 35, column: 2, scope: !75) -!75 = distinct !DILexicalBlock(scope: !76, file: !28, line: 35, column: 2) -!76 = distinct !DILexicalBlock(scope: !59, file: !28, line: 35, column: 2) -!77 = !DILocation(line: 37, column: 2, scope: !59) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 35, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 35, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 136, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 17) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 35, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 176, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 22) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 9, type: !23, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !3, line: 9, type: !23, isLocal: false, isDefinition: true) +!53 = !{i32 7, !"Dwarf Version", i32 5} +!54 = !{i32 2, !"Debug Info Version", i32 3} +!55 = !{i32 1, !"wchar_size", i32 4} +!56 = !{i32 8, !"PIC Level", i32 2} +!57 = !{i32 7, !"PIE Level", i32 2} +!58 = !{i32 7, !"uwtable", i32 2} +!59 = !{i32 7, !"frame-pointer", i32 2} +!60 = !{!"Homebrew clang version 19.1.7"} +!61 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 11, type: !62, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!62 = !DISubroutineType(types: !63) +!63 = !{!28, !28} +!64 = !{} +!65 = !DILocalVariable(name: "unused", arg: 1, scope: !61, file: !3, line: 11, type: !28) +!66 = !DILocation(line: 11, column: 22, scope: !61) +!67 = !DILocation(line: 13, column: 7, scope: !61) +!68 = !DILocation(line: 13, column: 5, scope: !61) +!69 = !DILocation(line: 14, column: 2, scope: !61) +!70 = !DILocation(line: 15, column: 2, scope: !61) +!71 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 18, type: !62, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!72 = !DILocalVariable(name: "unused", arg: 1, scope: !71, file: !3, line: 18, type: !28) +!73 = !DILocation(line: 18, column: 22, scope: !71) +!74 = !DILocation(line: 20, column: 7, scope: !71) +!75 = !DILocation(line: 20, column: 5, scope: !71) +!76 = !DILocation(line: 21, column: 2, scope: !71) +!77 = !DILocation(line: 22, column: 2, scope: !71) +!78 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 25, type: !79, scopeLine: 26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!79 = !DISubroutineType(types: !80) +!80 = !{!23} +!81 = !DILocalVariable(name: "t1", scope: !78, file: !3, line: 27, type: !82) +!82 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !83, line: 31, baseType: !84) +!83 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!84 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !85, line: 118, baseType: !86) +!85 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!86 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !87, size: 64) +!87 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !85, line: 103, size: 65536, elements: !88) +!88 = !{!89, !90, !100} +!89 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !87, file: !85, line: 104, baseType: !27, size: 64) +!90 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !87, file: !85, line: 105, baseType: !91, size: 64, offset: 64) +!91 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !92, size: 64) +!92 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !85, line: 57, size: 192, elements: !93) +!93 = !{!94, !98, !99} +!94 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !92, file: !85, line: 58, baseType: !95, size: 64) +!95 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !96, size: 64) +!96 = !DISubroutineType(types: !97) +!97 = !{null, !28} +!98 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !92, file: !85, line: 59, baseType: !28, size: 64, offset: 64) +!99 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !92, file: !85, line: 60, baseType: !91, size: 64, offset: 128) +!100 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !87, file: !85, line: 106, baseType: !101, size: 65408, offset: 128) +!101 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !102) +!102 = !{!103} +!103 = !DISubrange(count: 8176) +!104 = !DILocation(line: 27, column: 12, scope: !78) +!105 = !DILocalVariable(name: "t2", scope: !78, file: !3, line: 27, type: !82) +!106 = !DILocation(line: 27, column: 16, scope: !78) +!107 = !DILocation(line: 29, column: 2, scope: !78) +!108 = !DILocation(line: 30, column: 2, scope: !78) +!109 = !DILocation(line: 32, column: 15, scope: !78) +!110 = !DILocation(line: 32, column: 2, scope: !78) +!111 = !DILocation(line: 33, column: 15, scope: !78) +!112 = !DILocation(line: 33, column: 2, scope: !78) +!113 = !DILocation(line: 35, column: 2, scope: !78) +!114 = !DILocation(line: 0, scope: !78) +!115 = !DILocation(line: 37, column: 2, scope: !78) diff --git a/dartagnan/src/test/resources/lkmm/MP+fencewbonceonce+fencermbonceonce.ll b/dartagnan/src/test/resources/lkmm/MP+fencewbonceonce+fencermbonceonce.ll index 404a2f88d2..950a53c94d 100644 --- a/dartagnan/src/test/resources/lkmm/MP+fencewbonceonce+fencermbonceonce.ll +++ b/dartagnan/src/test/resources/lkmm/MP+fencewbonceonce+fencermbonceonce.ll @@ -1,176 +1,225 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/MP+fencewbonceonce+fencermbonceonce.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c' +source_filename = "benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global i32 0, align 4, !dbg !26 -@r0 = dso_local global i32 0, align 4, !dbg !30 -@r1 = dso_local global i32 0, align 4, !dbg !32 -@.str = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 0)\00", align 1 -@.str.1 = private unnamed_addr constant [76 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@y = dso_local global i32 0, align 4, !dbg !47 +@r0 = dso_local global i32 0, align 4, !dbg !49 +@r1 = dso_local global i32 0, align 4, !dbg !51 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [38 x i8] c"MP+fencewbonceonce+fencermbonceonce.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [22 x i8] c"!(r0 == 1 && r1 == 0)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !42 { - call void @llvm.dbg.value(metadata i8* %0, metadata !46, metadata !DIExpression()), !dbg !47 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !48 - call void @__LKMM_FENCE(i32 noundef 5) #5, !dbg !49 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !50 - ret i8* null, !dbg !51 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !61 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !65, !DIExpression(), !66) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !67 + call void @__LKMM_fence(i32 noundef 4), !dbg !68 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !69 + ret ptr null, !dbg !70 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !52 { - call void @llvm.dbg.value(metadata i8* %0, metadata !53, metadata !DIExpression()), !dbg !54 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !55 - store i32 %2, i32* @r0, align 4, !dbg !56 - call void @__LKMM_FENCE(i32 noundef 6) #5, !dbg !57 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !58 - store i32 %3, i32* @r1, align 4, !dbg !59 - ret i8* null, !dbg !60 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !71 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !72, !DIExpression(), !73) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !74 + %4 = trunc i64 %3 to i32, !dbg !74 + store i32 %4, ptr @r0, align 4, !dbg !75 + call void @__LKMM_fence(i32 noundef 5), !dbg !76 + %5 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !77 + %6 = trunc i64 %5 to i32, !dbg !77 + store i32 %6, ptr @r1, align 4, !dbg !78 + ret ptr null, !dbg !79 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !61 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !64, metadata !DIExpression(DW_OP_deref)), !dbg !68 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !69 - call void @llvm.dbg.value(metadata i64* %2, metadata !70, metadata !DIExpression(DW_OP_deref)), !dbg !68 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !71 - %5 = load i64, i64* %1, align 8, !dbg !72 - call void @llvm.dbg.value(metadata i64 %5, metadata !64, metadata !DIExpression()), !dbg !68 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !73 - %7 = load i64, i64* %2, align 8, !dbg !74 - call void @llvm.dbg.value(metadata i64 %7, metadata !70, metadata !DIExpression()), !dbg !68 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !75 - %9 = load i32, i32* @r0, align 4, !dbg !76 - %10 = icmp eq i32 %9, 1, !dbg !76 - %11 = load i32, i32* @r1, align 4, !dbg !76 - %12 = icmp eq i32 %11, 0, !dbg !76 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !76 - br i1 %or.cond, label %13, label %14, !dbg !76 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i32 noundef 37, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !76 - unreachable, !dbg !76 - -14: ; preds = %0 - ret i32 0, !dbg !79 +define dso_local i32 @main() #0 !dbg !80 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !83, !DIExpression(), !106) + #dbg_declare(ptr %3, !107, !DIExpression(), !108) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !109 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !110 + %6 = load ptr, ptr %2, align 8, !dbg !111 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !112 + %8 = load ptr, ptr %3, align 8, !dbg !113 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !114 + %10 = load i32, ptr @r0, align 4, !dbg !115 + %11 = icmp eq i32 %10, 1, !dbg !115 + br i1 %11, label %12, label %15, !dbg !115 + +12: ; preds = %0 + %13 = load i32, ptr @r1, align 4, !dbg !115 + %14 = icmp eq i32 %13, 0, !dbg !115 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !116 + %17 = xor i1 %16, true, !dbg !115 + %18 = xor i1 %17, true, !dbg !115 + %19 = zext i1 %18 to i32, !dbg !115 + %20 = sext i32 %19 to i64, !dbg !115 + %21 = icmp ne i64 %20, 0, !dbg !115 + br i1 %21, label %22, label %24, !dbg !115 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 37, ptr noundef @.str.1) #3, !dbg !115 + unreachable, !dbg !115 + +23: ; No predecessors! + br label %25, !dbg !115 + +24: ; preds = %15 + br label %25, !dbg !115 + +25: ; preds = %24, %23 + ret i32 0, !dbg !117 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40} -!llvm.ident = !{!41} +!llvm.module.flags = !{!53, !54, !55, !56, !57, !58, !59} +!llvm.ident = !{!60} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 6, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "2b7c98fd1e06930505446ce803f974f8") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !28, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "2b7c98fd1e06930505446ce803f974f8") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/MP+fencewbonceonce+fencermbonceonce.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "2b7c98fd1e06930505446ce803f974f8") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !0, !47, !49, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!34 = !{i32 7, !"Dwarf Version", i32 5} -!35 = !{i32 2, !"Debug Info Version", i32 3} -!36 = !{i32 1, !"wchar_size", i32 4} -!37 = !{i32 7, !"PIC Level", i32 2} -!38 = !{i32 7, !"PIE Level", i32 2} -!39 = !{i32 7, !"uwtable", i32 1} -!40 = !{i32 7, !"frame-pointer", i32 2} -!41 = !{!"Ubuntu clang version 14.0.6"} -!42 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 11, type: !43, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!43 = !DISubroutineType(types: !44) -!44 = !{!24, !24} -!45 = !{} -!46 = !DILocalVariable(name: "unused", arg: 1, scope: !42, file: !28, line: 11, type: !24) -!47 = !DILocation(line: 0, scope: !42) -!48 = !DILocation(line: 13, column: 2, scope: !42) -!49 = !DILocation(line: 14, column: 2, scope: !42) -!50 = !DILocation(line: 15, column: 2, scope: !42) -!51 = !DILocation(line: 16, column: 2, scope: !42) -!52 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 19, type: !43, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!53 = !DILocalVariable(name: "unused", arg: 1, scope: !52, file: !28, line: 19, type: !24) -!54 = !DILocation(line: 0, scope: !52) -!55 = !DILocation(line: 21, column: 7, scope: !52) -!56 = !DILocation(line: 21, column: 5, scope: !52) -!57 = !DILocation(line: 22, column: 2, scope: !52) -!58 = !DILocation(line: 23, column: 7, scope: !52) -!59 = !DILocation(line: 23, column: 5, scope: !52) -!60 = !DILocation(line: 24, column: 2, scope: !52) -!61 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 27, type: !62, scopeLine: 28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 37, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 37, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 304, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 38) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 37, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 176, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 22) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !28, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 9, type: !28, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r1", scope: !2, file: !3, line: 9, type: !28, isLocal: false, isDefinition: true) +!53 = !{i32 7, !"Dwarf Version", i32 5} +!54 = !{i32 2, !"Debug Info Version", i32 3} +!55 = !{i32 1, !"wchar_size", i32 4} +!56 = !{i32 8, !"PIC Level", i32 2} +!57 = !{i32 7, !"PIE Level", i32 2} +!58 = !{i32 7, !"uwtable", i32 2} +!59 = !{i32 7, !"frame-pointer", i32 2} +!60 = !{!"Homebrew clang version 19.1.7"} +!61 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 11, type: !62, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) !62 = !DISubroutineType(types: !63) -!63 = !{!29} -!64 = !DILocalVariable(name: "t1", scope: !61, file: !28, line: 29, type: !65) -!65 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !66, line: 27, baseType: !67) -!66 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!67 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!68 = !DILocation(line: 0, scope: !61) -!69 = !DILocation(line: 31, column: 2, scope: !61) -!70 = !DILocalVariable(name: "t2", scope: !61, file: !28, line: 29, type: !65) -!71 = !DILocation(line: 32, column: 2, scope: !61) -!72 = !DILocation(line: 34, column: 15, scope: !61) -!73 = !DILocation(line: 34, column: 2, scope: !61) -!74 = !DILocation(line: 35, column: 15, scope: !61) -!75 = !DILocation(line: 35, column: 2, scope: !61) -!76 = !DILocation(line: 37, column: 2, scope: !77) -!77 = distinct !DILexicalBlock(scope: !78, file: !28, line: 37, column: 2) -!78 = distinct !DILexicalBlock(scope: !61, file: !28, line: 37, column: 2) -!79 = !DILocation(line: 39, column: 2, scope: !61) +!63 = !{!27, !27} +!64 = !{} +!65 = !DILocalVariable(name: "unused", arg: 1, scope: !61, file: !3, line: 11, type: !27) +!66 = !DILocation(line: 11, column: 16, scope: !61) +!67 = !DILocation(line: 13, column: 2, scope: !61) +!68 = !DILocation(line: 14, column: 2, scope: !61) +!69 = !DILocation(line: 15, column: 2, scope: !61) +!70 = !DILocation(line: 16, column: 2, scope: !61) +!71 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 19, type: !62, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!72 = !DILocalVariable(name: "unused", arg: 1, scope: !71, file: !3, line: 19, type: !27) +!73 = !DILocation(line: 19, column: 16, scope: !71) +!74 = !DILocation(line: 21, column: 7, scope: !71) +!75 = !DILocation(line: 21, column: 5, scope: !71) +!76 = !DILocation(line: 22, column: 2, scope: !71) +!77 = !DILocation(line: 23, column: 7, scope: !71) +!78 = !DILocation(line: 23, column: 5, scope: !71) +!79 = !DILocation(line: 24, column: 2, scope: !71) +!80 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 27, type: !81, scopeLine: 28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!81 = !DISubroutineType(types: !82) +!82 = !{!28} +!83 = !DILocalVariable(name: "t1", scope: !80, file: !3, line: 29, type: !84) +!84 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !85, line: 31, baseType: !86) +!85 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!86 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !87, line: 118, baseType: !88) +!87 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!88 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !89, size: 64) +!89 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !87, line: 103, size: 65536, elements: !90) +!90 = !{!91, !92, !102} +!91 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !89, file: !87, line: 104, baseType: !26, size: 64) +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !89, file: !87, line: 105, baseType: !93, size: 64, offset: 64) +!93 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !94, size: 64) +!94 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !87, line: 57, size: 192, elements: !95) +!95 = !{!96, !100, !101} +!96 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !94, file: !87, line: 58, baseType: !97, size: 64) +!97 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !98, size: 64) +!98 = !DISubroutineType(types: !99) +!99 = !{null, !27} +!100 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !94, file: !87, line: 59, baseType: !27, size: 64, offset: 64) +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !94, file: !87, line: 60, baseType: !93, size: 64, offset: 128) +!102 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !89, file: !87, line: 106, baseType: !103, size: 65408, offset: 128) +!103 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !104) +!104 = !{!105} +!105 = !DISubrange(count: 8176) +!106 = !DILocation(line: 29, column: 12, scope: !80) +!107 = !DILocalVariable(name: "t2", scope: !80, file: !3, line: 29, type: !84) +!108 = !DILocation(line: 29, column: 16, scope: !80) +!109 = !DILocation(line: 31, column: 2, scope: !80) +!110 = !DILocation(line: 32, column: 2, scope: !80) +!111 = !DILocation(line: 34, column: 15, scope: !80) +!112 = !DILocation(line: 34, column: 2, scope: !80) +!113 = !DILocation(line: 35, column: 15, scope: !80) +!114 = !DILocation(line: 35, column: 2, scope: !80) +!115 = !DILocation(line: 37, column: 2, scope: !80) +!116 = !DILocation(line: 0, scope: !80) +!117 = !DILocation(line: 39, column: 2, scope: !80) diff --git a/dartagnan/src/test/resources/lkmm/NVR-RMW+Release.ll b/dartagnan/src/test/resources/lkmm/NVR-RMW+Release.ll index edef717c6b..7349ef036c 100644 --- a/dartagnan/src/test/resources/lkmm/NVR-RMW+Release.ll +++ b/dartagnan/src/test/resources/lkmm/NVR-RMW+Release.ll @@ -1,202 +1,259 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/NVR-RMW+Release.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/NVR-RMW+Release.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/NVR-RMW+Release.c' +source_filename = "benchmarks/lkmm/NVR-RMW+Release.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !35 -@.str = private unnamed_addr constant [7 x i8] c"x == 1\00", align 1 -@.str.1 = private unnamed_addr constant [56 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/NVR-RMW+Release.c\00", align 1 -@__PRETTY_FUNCTION__.run = private unnamed_addr constant [18 x i8] c"void *run(void *)\00", align 1 +@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !57 +@__func__.run = private unnamed_addr constant [4 x i8] c"run\00", align 1, !dbg !40 +@.str = private unnamed_addr constant [18 x i8] c"NVR-RMW+Release.c\00", align 1, !dbg !47 +@.str.1 = private unnamed_addr constant [7 x i8] c"x == 1\00", align 1, !dbg !52 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @run(i8* noundef %0) #0 !dbg !51 { - call void @llvm.dbg.value(metadata i8* %0, metadata !55, metadata !DIExpression()), !dbg !56 - %2 = ptrtoint i8* %0 to i64, !dbg !57 - %3 = trunc i64 %2 to i32, !dbg !58 - call void @llvm.dbg.value(metadata i32 %3, metadata !59, metadata !DIExpression()), !dbg !56 - switch i32 %3, label %12 [ - i32 0, label %4 - i32 1, label %5 - i32 2, label %6 - ], !dbg !60 - -4: ; preds = %1 - store i32 1, i32* @x, align 4, !dbg !61 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 3, i32 noundef 3) #5, !dbg !63 - br label %12, !dbg !64 - -5: ; preds = %1 - call void @__LKMM_ATOMIC_OP(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @y, i64 0, i32 0), i32 noundef -3, i32 noundef 2) #5, !dbg !65 - br label %12, !dbg !66 - -6: ; preds = %1 - %7 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 2) #5, !dbg !67 - %8 = icmp ne i32 %7, 1, !dbg !69 - %9 = load i32, i32* @x, align 4 - %10 = icmp eq i32 %9, 1 - %or.cond = select i1 %8, i1 true, i1 %10, !dbg !70 - br i1 %or.cond, label %12, label %11, !dbg !70 - -11: ; preds = %6 - call void @__assert_fail(i8* noundef getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 noundef 28, i8* noundef getelementptr inbounds ([18 x i8], [18 x i8]* @__PRETTY_FUNCTION__.run, i64 0, i64 0)) #6, !dbg !71 - unreachable, !dbg !71 - -12: ; preds = %6, %5, %4, %1 - ret i8* null, !dbg !75 -} +define dso_local ptr @run(ptr noundef %0) #0 !dbg !71 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !75, !DIExpression(), !76) + #dbg_declare(ptr %3, !77, !DIExpression(), !78) + %4 = load ptr, ptr %2, align 8, !dbg !79 + %5 = ptrtoint ptr %4 to i64, !dbg !80 + %6 = trunc i64 %5 to i32, !dbg !81 + store i32 %6, ptr %3, align 4, !dbg !78 + %7 = load i32, ptr %3, align 4, !dbg !82 + switch i32 %7, label %26 [ + i32 0, label %8 + i32 1, label %9 + i32 2, label %10 + ], !dbg !83 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +8: ; preds = %1 + store i32 1, ptr @x, align 4, !dbg !84 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 3, i32 noundef 2), !dbg !86 + br label %26, !dbg !87 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +9: ; preds = %1 + call void @__LKMM_atomic_op(ptr noundef @y, i64 noundef 4, i64 noundef -3, i32 noundef 2), !dbg !88 + br label %26, !dbg !89 -declare void @__LKMM_ATOMIC_OP(i32* noundef, i32 noundef, i32 noundef) #2 +10: ; preds = %1 + %11 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 1), !dbg !90 + %12 = trunc i64 %11 to i32, !dbg !90 + %13 = icmp eq i32 %12, 1, !dbg !92 + br i1 %13, label %14, label %25, !dbg !93 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +14: ; preds = %10 + %15 = load i32, ptr @x, align 4, !dbg !94 + %16 = icmp eq i32 %15, 1, !dbg !94 + %17 = xor i1 %16, true, !dbg !94 + %18 = zext i1 %17 to i32, !dbg !94 + %19 = sext i32 %18 to i64, !dbg !94 + %20 = icmp ne i64 %19, 0, !dbg !94 + br i1 %20, label %21, label %23, !dbg !94 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #3 +21: ; preds = %14 + call void @__assert_rtn(ptr noundef @__func__.run, ptr noundef @.str, i32 noundef 28, ptr noundef @.str.1) #3, !dbg !94 + unreachable, !dbg !94 -; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !76 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !79, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %4 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @run, i8* noundef null) #5, !dbg !84 - call void @llvm.dbg.value(metadata i64* %2, metadata !85, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %5 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @run, i8* noundef nonnull inttoptr (i64 1 to i8*)) #5, !dbg !86 - call void @llvm.dbg.value(metadata i64* %3, metadata !87, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %6 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @run, i8* noundef nonnull inttoptr (i64 2 to i8*)) #5, !dbg !88 - %7 = load i64, i64* %1, align 8, !dbg !89 - call void @llvm.dbg.value(metadata i64 %7, metadata !79, metadata !DIExpression()), !dbg !83 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !90 - %9 = load i64, i64* %2, align 8, !dbg !91 - call void @llvm.dbg.value(metadata i64 %9, metadata !85, metadata !DIExpression()), !dbg !83 - %10 = call i32 @pthread_join(i64 noundef %9, i8** noundef null) #5, !dbg !92 - %11 = load i64, i64* %3, align 8, !dbg !93 - call void @llvm.dbg.value(metadata i64 %11, metadata !87, metadata !DIExpression()), !dbg !83 - %12 = call i32 @pthread_join(i64 noundef %11, i8** noundef null) #5, !dbg !94 - ret i32 0, !dbg !95 +22: ; No predecessors! + br label %24, !dbg !94 + +23: ; preds = %14 + br label %24, !dbg !94 + +24: ; preds = %23, %22 + br label %25, !dbg !96 + +25: ; preds = %24, %10 + br label %26, !dbg !97 + +26: ; preds = %1, %25, %9, %8 + ret ptr null, !dbg !98 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #4 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 + +declare void @__LKMM_atomic_op(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 + +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 + +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 + +; Function Attrs: noinline nounwind uwtable +define dso_local i32 @main() #0 !dbg !99 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !102, !DIExpression(), !125) + #dbg_declare(ptr %3, !126, !DIExpression(), !127) + #dbg_declare(ptr %4, !128, !DIExpression(), !129) + %5 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @run, ptr noundef null), !dbg !130 + %6 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @run, ptr noundef inttoptr (i64 1 to ptr)), !dbg !131 + %7 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @run, ptr noundef inttoptr (i64 2 to ptr)), !dbg !132 + %8 = load ptr, ptr %2, align 8, !dbg !133 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !134 + %10 = load ptr, ptr %3, align 8, !dbg !135 + %11 = call i32 @_pthread_join(ptr noundef %10, ptr noundef null), !dbg !136 + %12 = load ptr, ptr %4, align 8, !dbg !137 + %13 = call i32 @_pthread_join(ptr noundef %12, ptr noundef null), !dbg !138 + ret i32 0, !dbg !139 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!43, !44, !45, !46, !47, !48, !49} -!llvm.ident = !{!50} +!llvm.module.flags = !{!63, !64, !65, !66, !67, !68, !69} +!llvm.ident = !{!70} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !37, line: 5, type: !42, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !29, globals: !34, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/NVR-RMW+Release.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "288212c519a14c4a96e909a8b480bc52") -!4 = !{!5, !23} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 5, type: !37, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !28, globals: !39, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/NVR-RMW+Release.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "288212c519a14c4a96e909a8b480bc52") +!4 = !{!5, !22} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "operation", file: !6, line: 20, baseType: !7, size: 32, elements: !24) -!24 = !{!25, !26, !27, !28} -!25 = !DIEnumerator(name: "op_add", value: 0) -!26 = !DIEnumerator(name: "op_sub", value: 1) -!27 = !DIEnumerator(name: "op_and", value: 2) -!28 = !DIEnumerator(name: "op_or", value: 3) -!29 = !{!30, !33} -!30 = !DIDerivedType(tag: DW_TAG_typedef, name: "intptr_t", file: !31, line: 87, baseType: !32) -!31 = !DIFile(filename: "/usr/include/stdint.h", directory: "", checksumkind: CSK_MD5, checksum: "24103e292ae21916e87130b926c8d2f8") -!32 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) -!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!34 = !{!0, !35} -!35 = !DIGlobalVariableExpression(var: !36, expr: !DIExpression()) -!36 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !37, line: 6, type: !38, isLocal: false, isDefinition: true) -!37 = !DIFile(filename: "benchmarks/lkmm/NVR-RMW+Release.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "288212c519a14c4a96e909a8b480bc52") -!38 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !39) -!39 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !40) -!40 = !{!41} -!41 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !39, file: !6, line: 94, baseType: !42, size: 32) -!42 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!43 = !{i32 7, !"Dwarf Version", i32 5} -!44 = !{i32 2, !"Debug Info Version", i32 3} -!45 = !{i32 1, !"wchar_size", i32 4} -!46 = !{i32 7, !"PIC Level", i32 2} -!47 = !{i32 7, !"PIE Level", i32 2} -!48 = !{i32 7, !"uwtable", i32 1} -!49 = !{i32 7, !"frame-pointer", i32 2} -!50 = !{!"Ubuntu clang version 14.0.6"} -!51 = distinct !DISubprogram(name: "run", scope: !37, file: !37, line: 15, type: !52, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !54) -!52 = !DISubroutineType(types: !53) -!53 = !{!33, !33} -!54 = !{} -!55 = !DILocalVariable(name: "arg", arg: 1, scope: !51, file: !37, line: 15, type: !33) -!56 = !DILocation(line: 0, scope: !51) -!57 = !DILocation(line: 17, column: 16, scope: !51) -!58 = !DILocation(line: 17, column: 15, scope: !51) -!59 = !DILocalVariable(name: "tid", scope: !51, file: !37, line: 17, type: !42) -!60 = !DILocation(line: 18, column: 5, scope: !51) -!61 = !DILocation(line: 20, column: 11, scope: !62) -!62 = distinct !DILexicalBlock(scope: !51, file: !37, line: 18, column: 18) -!63 = !DILocation(line: 21, column: 9, scope: !62) -!64 = !DILocation(line: 22, column: 9, scope: !62) -!65 = !DILocation(line: 24, column: 9, scope: !62) -!66 = !DILocation(line: 25, column: 9, scope: !62) -!67 = !DILocation(line: 27, column: 13, scope: !68) -!68 = distinct !DILexicalBlock(scope: !62, file: !37, line: 27, column: 13) -!69 = !DILocation(line: 27, column: 42, scope: !68) -!70 = !DILocation(line: 27, column: 13, scope: !62) -!71 = !DILocation(line: 28, column: 13, scope: !72) -!72 = distinct !DILexicalBlock(scope: !73, file: !37, line: 28, column: 13) -!73 = distinct !DILexicalBlock(scope: !74, file: !37, line: 28, column: 13) -!74 = distinct !DILexicalBlock(scope: !68, file: !37, line: 27, column: 50) -!75 = !DILocation(line: 32, column: 5, scope: !51) -!76 = distinct !DISubprogram(name: "main", scope: !37, file: !37, line: 34, type: !77, scopeLine: 35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !54) -!77 = !DISubroutineType(types: !78) -!78 = !{!42} -!79 = !DILocalVariable(name: "t0", scope: !76, file: !37, line: 36, type: !80) -!80 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !81, line: 27, baseType: !82) -!81 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!82 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!83 = !DILocation(line: 0, scope: !76) -!84 = !DILocation(line: 37, column: 5, scope: !76) -!85 = !DILocalVariable(name: "t1", scope: !76, file: !37, line: 36, type: !80) -!86 = !DILocation(line: 38, column: 5, scope: !76) -!87 = !DILocalVariable(name: "t2", scope: !76, file: !37, line: 36, type: !80) -!88 = !DILocation(line: 39, column: 5, scope: !76) -!89 = !DILocation(line: 41, column: 18, scope: !76) -!90 = !DILocation(line: 41, column: 5, scope: !76) -!91 = !DILocation(line: 42, column: 18, scope: !76) -!92 = !DILocation(line: 42, column: 5, scope: !76) -!93 = !DILocation(line: 43, column: 18, scope: !76) -!94 = !DILocation(line: 43, column: 5, scope: !76) -!95 = !DILocation(line: 45, column: 5, scope: !76) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_operation", file: !6, line: 19, baseType: !7, size: 32, elements: !23) +!23 = !{!24, !25, !26, !27} +!24 = !DIEnumerator(name: "__LKMM_op_add", value: 0) +!25 = !DIEnumerator(name: "__LKMM_op_sub", value: 1) +!26 = !DIEnumerator(name: "__LKMM_op_and", value: 2) +!27 = !DIEnumerator(name: "__LKMM_op_or", value: 3) +!28 = !{!29, !34, !37, !38} +!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "intptr_t", file: !30, line: 32, baseType: !31) +!30 = !DIFile(filename: "/usr/local/include/sys/_types/_intptr_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e478ba47270923b1cca6659f19f02db1") +!31 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_intptr_t", file: !32, line: 64, baseType: !33) +!32 = !DIFile(filename: "/usr/local/include/i386/_types.h", directory: "", checksumkind: CSK_MD5, checksum: "eb9e401b3b97107c79f668bcc91916e5") +!33 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!34 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !35) +!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !36, line: 32, baseType: !33) +!36 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!37 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!38 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!39 = !{!40, !47, !52, !0, !57} +!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) +!41 = distinct !DIGlobalVariable(scope: null, file: !3, line: 28, type: !42, isLocal: true, isDefinition: true) +!42 = !DICompositeType(tag: DW_TAG_array_type, baseType: !43, size: 32, elements: !45) +!43 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !44) +!44 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!45 = !{!46} +!46 = !DISubrange(count: 4) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(scope: null, file: !3, line: 28, type: !49, isLocal: true, isDefinition: true) +!49 = !DICompositeType(tag: DW_TAG_array_type, baseType: !44, size: 144, elements: !50) +!50 = !{!51} +!51 = !DISubrange(count: 18) +!52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression()) +!53 = distinct !DIGlobalVariable(scope: null, file: !3, line: 28, type: !54, isLocal: true, isDefinition: true) +!54 = !DICompositeType(tag: DW_TAG_array_type, baseType: !44, size: 56, elements: !55) +!55 = !{!56} +!56 = !DISubrange(count: 7) +!57 = !DIGlobalVariableExpression(var: !58, expr: !DIExpression()) +!58 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 6, type: !59, isLocal: false, isDefinition: true) +!59 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !60) +!60 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !61) +!61 = !{!62} +!62 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !60, file: !6, line: 107, baseType: !37, size: 32) +!63 = !{i32 7, !"Dwarf Version", i32 5} +!64 = !{i32 2, !"Debug Info Version", i32 3} +!65 = !{i32 1, !"wchar_size", i32 4} +!66 = !{i32 8, !"PIC Level", i32 2} +!67 = !{i32 7, !"PIE Level", i32 2} +!68 = !{i32 7, !"uwtable", i32 2} +!69 = !{i32 7, !"frame-pointer", i32 2} +!70 = !{!"Homebrew clang version 19.1.7"} +!71 = distinct !DISubprogram(name: "run", scope: !3, file: !3, line: 15, type: !72, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +!72 = !DISubroutineType(types: !73) +!73 = !{!38, !38} +!74 = !{} +!75 = !DILocalVariable(name: "arg", arg: 1, scope: !71, file: !3, line: 15, type: !38) +!76 = !DILocation(line: 15, column: 17, scope: !71) +!77 = !DILocalVariable(name: "tid", scope: !71, file: !3, line: 17, type: !37) +!78 = !DILocation(line: 17, column: 9, scope: !71) +!79 = !DILocation(line: 17, column: 27, scope: !71) +!80 = !DILocation(line: 17, column: 16, scope: !71) +!81 = !DILocation(line: 17, column: 15, scope: !71) +!82 = !DILocation(line: 18, column: 13, scope: !71) +!83 = !DILocation(line: 18, column: 5, scope: !71) +!84 = !DILocation(line: 20, column: 11, scope: !85) +!85 = distinct !DILexicalBlock(scope: !71, file: !3, line: 18, column: 18) +!86 = !DILocation(line: 21, column: 9, scope: !85) +!87 = !DILocation(line: 22, column: 9, scope: !85) +!88 = !DILocation(line: 24, column: 9, scope: !85) +!89 = !DILocation(line: 25, column: 9, scope: !85) +!90 = !DILocation(line: 27, column: 13, scope: !91) +!91 = distinct !DILexicalBlock(scope: !85, file: !3, line: 27, column: 13) +!92 = !DILocation(line: 27, column: 42, scope: !91) +!93 = !DILocation(line: 27, column: 13, scope: !85) +!94 = !DILocation(line: 28, column: 13, scope: !95) +!95 = distinct !DILexicalBlock(scope: !91, file: !3, line: 27, column: 50) +!96 = !DILocation(line: 29, column: 9, scope: !95) +!97 = !DILocation(line: 30, column: 9, scope: !85) +!98 = !DILocation(line: 32, column: 5, scope: !71) +!99 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 34, type: !100, scopeLine: 35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +!100 = !DISubroutineType(types: !101) +!101 = !{!37} +!102 = !DILocalVariable(name: "t0", scope: !99, file: !3, line: 36, type: !103) +!103 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !104, line: 31, baseType: !105) +!104 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!105 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !106, line: 118, baseType: !107) +!106 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!107 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !108, size: 64) +!108 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !106, line: 103, size: 65536, elements: !109) +!109 = !{!110, !111, !121} +!110 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !108, file: !106, line: 104, baseType: !33, size: 64) +!111 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !108, file: !106, line: 105, baseType: !112, size: 64, offset: 64) +!112 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !113, size: 64) +!113 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !106, line: 57, size: 192, elements: !114) +!114 = !{!115, !119, !120} +!115 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !113, file: !106, line: 58, baseType: !116, size: 64) +!116 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !117, size: 64) +!117 = !DISubroutineType(types: !118) +!118 = !{null, !38} +!119 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !113, file: !106, line: 59, baseType: !38, size: 64, offset: 64) +!120 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !113, file: !106, line: 60, baseType: !112, size: 64, offset: 128) +!121 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !108, file: !106, line: 106, baseType: !122, size: 65408, offset: 128) +!122 = !DICompositeType(tag: DW_TAG_array_type, baseType: !44, size: 65408, elements: !123) +!123 = !{!124} +!124 = !DISubrange(count: 8176) +!125 = !DILocation(line: 36, column: 15, scope: !99) +!126 = !DILocalVariable(name: "t1", scope: !99, file: !3, line: 36, type: !103) +!127 = !DILocation(line: 36, column: 19, scope: !99) +!128 = !DILocalVariable(name: "t2", scope: !99, file: !3, line: 36, type: !103) +!129 = !DILocation(line: 36, column: 23, scope: !99) +!130 = !DILocation(line: 37, column: 5, scope: !99) +!131 = !DILocation(line: 38, column: 5, scope: !99) +!132 = !DILocation(line: 39, column: 5, scope: !99) +!133 = !DILocation(line: 41, column: 18, scope: !99) +!134 = !DILocation(line: 41, column: 5, scope: !99) +!135 = !DILocation(line: 42, column: 18, scope: !99) +!136 = !DILocation(line: 42, column: 5, scope: !99) +!137 = !DILocation(line: 43, column: 18, scope: !99) +!138 = !DILocation(line: 43, column: 5, scope: !99) +!139 = !DILocation(line: 45, column: 5, scope: !99) diff --git a/dartagnan/src/test/resources/lkmm/qspinlock-fixed.ll b/dartagnan/src/test/resources/lkmm/qspinlock-fixed.ll index dd253b25ad..e95265fdcf 100644 --- a/dartagnan/src/test/resources/lkmm/qspinlock-fixed.ll +++ b/dartagnan/src/test/resources/lkmm/qspinlock-fixed.ll @@ -1,204 +1,249 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/qspinlock-fixed.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock-fixed.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/qspinlock-fixed.c' +source_filename = "benchmarks/lkmm/qspinlock-fixed.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !32 -@.str = private unnamed_addr constant [18 x i8] c"READ_ONCE(x) == 1\00", align 1 -@.str.1 = private unnamed_addr constant [56 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock-fixed.c\00", align 1 -@__PRETTY_FUNCTION__.thread_3 = private unnamed_addr constant [23 x i8] c"void *thread_3(void *)\00", align 1 +@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !50 +@__func__.thread_3 = private unnamed_addr constant [9 x i8] c"thread_3\00", align 1, !dbg !36 +@.str = private unnamed_addr constant [18 x i8] c"qspinlock-fixed.c\00", align 1, !dbg !43 +@.str.1 = private unnamed_addr constant [18 x i8] c"READ_ONCE(x) == 1\00", align 1, !dbg !48 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !52, metadata !DIExpression()), !dbg !53 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !54 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1, i32 noundef 3) #5, !dbg !55 - ret i8* null, !dbg !56 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !64 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !68, !DIExpression(), !69) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !70 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 2), !dbg !71 + ret ptr null, !dbg !72 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !57 { - call void @llvm.dbg.value(metadata i8* %0, metadata !58, metadata !DIExpression()), !dbg !59 - %2 = call i32 @__LKMM_ATOMIC_FETCH_OP(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @y, i64 0, i32 0), i32 noundef 2, i32 noundef 3, i32 noundef 3) #5, !dbg !60 - ret i8* null, !dbg !61 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !73 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !74, !DIExpression(), !75) + %3 = call i64 @__LKMM_atomic_fetch_op(ptr noundef @y, i64 noundef 4, i64 noundef 2, i32 noundef 2, i32 noundef 3), !dbg !76 + %4 = trunc i64 %3 to i32, !dbg !76 + ret ptr null, !dbg !77 } -declare i32 @__LKMM_ATOMIC_FETCH_OP(i32* noundef, i32 noundef, i32 noundef, i32 noundef) #2 +declare i64 @__LKMM_atomic_fetch_op(ptr noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_3(i8* noundef %0) #0 !dbg !62 { - call void @llvm.dbg.value(metadata i8* %0, metadata !63, metadata !DIExpression()), !dbg !64 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1) #5, !dbg !65 - %3 = and i32 %2, 1, !dbg !67 - %.not = icmp eq i32 %3, 0, !dbg !67 - br i1 %.not, label %8, label %4, !dbg !68 - -4: ; preds = %1 - call void @__LKMM_FENCE(i32 noundef 6) #5, !dbg !69 - %5 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !71 - %6 = icmp eq i32 %5, 1, !dbg !71 - br i1 %6, label %8, label %7, !dbg !74 - -7: ; preds = %4 - call void @__assert_fail(i8* noundef getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 noundef 26, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.thread_3, i64 0, i64 0)) #6, !dbg !71 - unreachable, !dbg !71 - -8: ; preds = %4, %1 - ret i8* null, !dbg !75 +define dso_local ptr @thread_3(ptr noundef %0) #0 !dbg !78 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !79, !DIExpression(), !80) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !81 + %4 = trunc i64 %3 to i32, !dbg !81 + %5 = and i32 %4, 1, !dbg !83 + %6 = icmp ne i32 %5, 0, !dbg !83 + br i1 %6, label %7, label %19, !dbg !84 + +7: ; preds = %1 + call void @__LKMM_fence(i32 noundef 5), !dbg !85 + %8 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !87 + %9 = trunc i64 %8 to i32, !dbg !87 + %10 = icmp eq i32 %9, 1, !dbg !87 + %11 = xor i1 %10, true, !dbg !87 + %12 = zext i1 %11 to i32, !dbg !87 + %13 = sext i32 %12 to i64, !dbg !87 + %14 = icmp ne i64 %13, 0, !dbg !87 + br i1 %14, label %15, label %17, !dbg !87 + +15: ; preds = %7 + call void @__assert_rtn(ptr noundef @__func__.thread_3, ptr noundef @.str, i32 noundef 26, ptr noundef @.str.1) #3, !dbg !87 + unreachable, !dbg !87 + +16: ; No predecessors! + br label %18, !dbg !87 + +17: ; preds = %7 + br label %18, !dbg !87 + +18: ; preds = %17, %16 + br label %19, !dbg !88 + +19: ; preds = %18, %1 + ret ptr null, !dbg !89 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #3 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !76 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !79, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %4 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !84 - call void @llvm.dbg.value(metadata i64* %2, metadata !85, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %5 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !86 - call void @llvm.dbg.value(metadata i64* %3, metadata !87, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %6 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_3, i8* noundef null) #5, !dbg !88 - %7 = load i64, i64* %1, align 8, !dbg !89 - call void @llvm.dbg.value(metadata i64 %7, metadata !79, metadata !DIExpression()), !dbg !83 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !90 - %9 = load i64, i64* %2, align 8, !dbg !91 - call void @llvm.dbg.value(metadata i64 %9, metadata !85, metadata !DIExpression()), !dbg !83 - %10 = call i32 @pthread_join(i64 noundef %9, i8** noundef null) #5, !dbg !92 - %11 = load i64, i64* %3, align 8, !dbg !93 - call void @llvm.dbg.value(metadata i64 %11, metadata !87, metadata !DIExpression()), !dbg !83 - %12 = call i32 @pthread_join(i64 noundef %11, i8** noundef null) #5, !dbg !94 - ret i32 0, !dbg !95 +define dso_local i32 @main() #0 !dbg !90 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !93, !DIExpression(), !116) + #dbg_declare(ptr %3, !117, !DIExpression(), !118) + #dbg_declare(ptr %4, !119, !DIExpression(), !120) + %5 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !121 + %6 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !122 + %7 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @thread_3, ptr noundef null), !dbg !123 + %8 = load ptr, ptr %2, align 8, !dbg !124 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !125 + %10 = load ptr, ptr %3, align 8, !dbg !126 + %11 = call i32 @_pthread_join(ptr noundef %10, ptr noundef null), !dbg !127 + %12 = load ptr, ptr %4, align 8, !dbg !128 + %13 = call i32 @_pthread_join(ptr noundef %12, ptr noundef null), !dbg !129 + ret i32 0, !dbg !130 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #4 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!40, !41, !42, !43, !44, !45, !46} -!llvm.ident = !{!47} +!llvm.module.flags = !{!56, !57, !58, !59, !60, !61, !62} +!llvm.ident = !{!63} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !34, line: 6, type: !39, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !29, globals: !31, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock-fixed.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "e1f25ad8da1f6f799a5136ed5427fdb3") -!4 = !{!5, !23} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !34, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !28, globals: !35, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/qspinlock-fixed.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "e1f25ad8da1f6f799a5136ed5427fdb3") +!4 = !{!5, !22} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "operation", file: !6, line: 20, baseType: !7, size: 32, elements: !24) -!24 = !{!25, !26, !27, !28} -!25 = !DIEnumerator(name: "op_add", value: 0) -!26 = !DIEnumerator(name: "op_sub", value: 1) -!27 = !DIEnumerator(name: "op_and", value: 2) -!28 = !DIEnumerator(name: "op_or", value: 3) -!29 = !{!30} -!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!31 = !{!0, !32} -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !34, line: 7, type: !35, isLocal: false, isDefinition: true) -!34 = !DIFile(filename: "benchmarks/lkmm/qspinlock-fixed.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "e1f25ad8da1f6f799a5136ed5427fdb3") -!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !36) -!36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !37) -!37 = !{!38} -!38 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !36, file: !6, line: 94, baseType: !39, size: 32) -!39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!40 = !{i32 7, !"Dwarf Version", i32 5} -!41 = !{i32 2, !"Debug Info Version", i32 3} -!42 = !{i32 1, !"wchar_size", i32 4} -!43 = !{i32 7, !"PIC Level", i32 2} -!44 = !{i32 7, !"PIE Level", i32 2} -!45 = !{i32 7, !"uwtable", i32 1} -!46 = !{i32 7, !"frame-pointer", i32 2} -!47 = !{!"Ubuntu clang version 14.0.6"} -!48 = distinct !DISubprogram(name: "thread_1", scope: !34, file: !34, line: 9, type: !49, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!49 = !DISubroutineType(types: !50) -!50 = !{!30, !30} -!51 = !{} -!52 = !DILocalVariable(name: "unused", arg: 1, scope: !48, file: !34, line: 9, type: !30) -!53 = !DILocation(line: 0, scope: !48) -!54 = !DILocation(line: 11, column: 2, scope: !48) -!55 = !DILocation(line: 12, column: 2, scope: !48) -!56 = !DILocation(line: 13, column: 2, scope: !48) -!57 = distinct !DISubprogram(name: "thread_2", scope: !34, file: !34, line: 16, type: !49, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!58 = !DILocalVariable(name: "unused", arg: 1, scope: !57, file: !34, line: 16, type: !30) -!59 = !DILocation(line: 0, scope: !57) -!60 = !DILocation(line: 18, column: 2, scope: !57) -!61 = !DILocation(line: 19, column: 2, scope: !57) -!62 = distinct !DISubprogram(name: "thread_3", scope: !34, file: !34, line: 22, type: !49, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!63 = !DILocalVariable(name: "unused", arg: 1, scope: !62, file: !34, line: 22, type: !30) -!64 = !DILocation(line: 0, scope: !62) -!65 = !DILocation(line: 24, column: 7, scope: !66) -!66 = distinct !DILexicalBlock(scope: !62, file: !34, line: 24, column: 7) -!67 = !DILocation(line: 24, column: 23, scope: !66) -!68 = !DILocation(line: 24, column: 7, scope: !62) -!69 = !DILocation(line: 25, column: 4, scope: !70) -!70 = distinct !DILexicalBlock(scope: !66, file: !34, line: 24, column: 28) -!71 = !DILocation(line: 26, column: 4, scope: !72) -!72 = distinct !DILexicalBlock(scope: !73, file: !34, line: 26, column: 4) -!73 = distinct !DILexicalBlock(scope: !70, file: !34, line: 26, column: 4) -!74 = !DILocation(line: 26, column: 4, scope: !73) -!75 = !DILocation(line: 28, column: 2, scope: !62) -!76 = distinct !DISubprogram(name: "main", scope: !34, file: !34, line: 31, type: !77, scopeLine: 32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!77 = !DISubroutineType(types: !78) -!78 = !{!39} -!79 = !DILocalVariable(name: "t1", scope: !76, file: !34, line: 33, type: !80) -!80 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !81, line: 27, baseType: !82) -!81 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!82 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!83 = !DILocation(line: 0, scope: !76) -!84 = !DILocation(line: 35, column: 2, scope: !76) -!85 = !DILocalVariable(name: "t2", scope: !76, file: !34, line: 33, type: !80) -!86 = !DILocation(line: 36, column: 2, scope: !76) -!87 = !DILocalVariable(name: "t3", scope: !76, file: !34, line: 33, type: !80) -!88 = !DILocation(line: 37, column: 2, scope: !76) -!89 = !DILocation(line: 39, column: 15, scope: !76) -!90 = !DILocation(line: 39, column: 2, scope: !76) -!91 = !DILocation(line: 40, column: 15, scope: !76) -!92 = !DILocation(line: 40, column: 2, scope: !76) -!93 = !DILocation(line: 41, column: 15, scope: !76) -!94 = !DILocation(line: 41, column: 2, scope: !76) -!95 = !DILocation(line: 43, column: 2, scope: !76) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_operation", file: !6, line: 19, baseType: !7, size: 32, elements: !23) +!23 = !{!24, !25, !26, !27} +!24 = !DIEnumerator(name: "__LKMM_op_add", value: 0) +!25 = !DIEnumerator(name: "__LKMM_op_sub", value: 1) +!26 = !DIEnumerator(name: "__LKMM_op_and", value: 2) +!27 = !DIEnumerator(name: "__LKMM_op_or", value: 3) +!28 = !{!29, !33, !34} +!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !30) +!30 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !31, line: 32, baseType: !32) +!31 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!32 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!34 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!35 = !{!36, !43, !48, !0, !50} +!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) +!37 = distinct !DIGlobalVariable(scope: null, file: !3, line: 26, type: !38, isLocal: true, isDefinition: true) +!38 = !DICompositeType(tag: DW_TAG_array_type, baseType: !39, size: 72, elements: !41) +!39 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !40) +!40 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!41 = !{!42} +!42 = !DISubrange(count: 9) +!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression()) +!44 = distinct !DIGlobalVariable(scope: null, file: !3, line: 26, type: !45, isLocal: true, isDefinition: true) +!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 144, elements: !46) +!46 = !{!47} +!47 = !DISubrange(count: 18) +!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) +!49 = distinct !DIGlobalVariable(scope: null, file: !3, line: 26, type: !45, isLocal: true, isDefinition: true) +!50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression()) +!51 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !52, isLocal: false, isDefinition: true) +!52 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !53) +!53 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !54) +!54 = !{!55} +!55 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !53, file: !6, line: 107, baseType: !34, size: 32) +!56 = !{i32 7, !"Dwarf Version", i32 5} +!57 = !{i32 2, !"Debug Info Version", i32 3} +!58 = !{i32 1, !"wchar_size", i32 4} +!59 = !{i32 8, !"PIC Level", i32 2} +!60 = !{i32 7, !"PIE Level", i32 2} +!61 = !{i32 7, !"uwtable", i32 2} +!62 = !{i32 7, !"frame-pointer", i32 2} +!63 = !{!"Homebrew clang version 19.1.7"} +!64 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 9, type: !65, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) +!65 = !DISubroutineType(types: !66) +!66 = !{!33, !33} +!67 = !{} +!68 = !DILocalVariable(name: "unused", arg: 1, scope: !64, file: !3, line: 9, type: !33) +!69 = !DILocation(line: 9, column: 22, scope: !64) +!70 = !DILocation(line: 11, column: 2, scope: !64) +!71 = !DILocation(line: 12, column: 2, scope: !64) +!72 = !DILocation(line: 13, column: 2, scope: !64) +!73 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 16, type: !65, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) +!74 = !DILocalVariable(name: "unused", arg: 1, scope: !73, file: !3, line: 16, type: !33) +!75 = !DILocation(line: 16, column: 22, scope: !73) +!76 = !DILocation(line: 18, column: 2, scope: !73) +!77 = !DILocation(line: 19, column: 2, scope: !73) +!78 = distinct !DISubprogram(name: "thread_3", scope: !3, file: !3, line: 22, type: !65, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) +!79 = !DILocalVariable(name: "unused", arg: 1, scope: !78, file: !3, line: 22, type: !33) +!80 = !DILocation(line: 22, column: 22, scope: !78) +!81 = !DILocation(line: 24, column: 7, scope: !82) +!82 = distinct !DILexicalBlock(scope: !78, file: !3, line: 24, column: 7) +!83 = !DILocation(line: 24, column: 23, scope: !82) +!84 = !DILocation(line: 24, column: 7, scope: !78) +!85 = !DILocation(line: 25, column: 4, scope: !86) +!86 = distinct !DILexicalBlock(scope: !82, file: !3, line: 24, column: 28) +!87 = !DILocation(line: 26, column: 4, scope: !86) +!88 = !DILocation(line: 27, column: 3, scope: !86) +!89 = !DILocation(line: 28, column: 2, scope: !78) +!90 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 31, type: !91, scopeLine: 32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) +!91 = !DISubroutineType(types: !92) +!92 = !{!34} +!93 = !DILocalVariable(name: "t1", scope: !90, file: !3, line: 33, type: !94) +!94 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !95, line: 31, baseType: !96) +!95 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!96 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !97, line: 118, baseType: !98) +!97 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!98 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !99, size: 64) +!99 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !97, line: 103, size: 65536, elements: !100) +!100 = !{!101, !102, !112} +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !99, file: !97, line: 104, baseType: !32, size: 64) +!102 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !99, file: !97, line: 105, baseType: !103, size: 64, offset: 64) +!103 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !104, size: 64) +!104 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !97, line: 57, size: 192, elements: !105) +!105 = !{!106, !110, !111} +!106 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !104, file: !97, line: 58, baseType: !107, size: 64) +!107 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !108, size: 64) +!108 = !DISubroutineType(types: !109) +!109 = !{null, !33} +!110 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !104, file: !97, line: 59, baseType: !33, size: 64, offset: 64) +!111 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !104, file: !97, line: 60, baseType: !103, size: 64, offset: 128) +!112 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !99, file: !97, line: 106, baseType: !113, size: 65408, offset: 128) +!113 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 65408, elements: !114) +!114 = !{!115} +!115 = !DISubrange(count: 8176) +!116 = !DILocation(line: 33, column: 12, scope: !90) +!117 = !DILocalVariable(name: "t2", scope: !90, file: !3, line: 33, type: !94) +!118 = !DILocation(line: 33, column: 16, scope: !90) +!119 = !DILocalVariable(name: "t3", scope: !90, file: !3, line: 33, type: !94) +!120 = !DILocation(line: 33, column: 20, scope: !90) +!121 = !DILocation(line: 35, column: 2, scope: !90) +!122 = !DILocation(line: 36, column: 2, scope: !90) +!123 = !DILocation(line: 37, column: 2, scope: !90) +!124 = !DILocation(line: 39, column: 15, scope: !90) +!125 = !DILocation(line: 39, column: 2, scope: !90) +!126 = !DILocation(line: 40, column: 15, scope: !90) +!127 = !DILocation(line: 40, column: 2, scope: !90) +!128 = !DILocation(line: 41, column: 15, scope: !90) +!129 = !DILocation(line: 41, column: 2, scope: !90) +!130 = !DILocation(line: 43, column: 2, scope: !90) diff --git a/dartagnan/src/test/resources/lkmm/qspinlock-liveness.ll b/dartagnan/src/test/resources/lkmm/qspinlock-liveness.ll index 3b2de9a04e..3bbe43a8ba 100644 --- a/dartagnan/src/test/resources/lkmm/qspinlock-liveness.ll +++ b/dartagnan/src/test/resources/lkmm/qspinlock-liveness.ll @@ -1,206 +1,261 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/qspinlock-liveness.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock-liveness.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/qspinlock-liveness.c' +source_filename = "benchmarks/lkmm/qspinlock-liveness.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !0 -@y = dso_local global i32 0, align 4, !dbg !32 -@z = dso_local global i32 0, align 4, !dbg !36 +@y = dso_local global i32 0, align 4, !dbg !36 +@z = dso_local global i32 0, align 4, !dbg !38 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !50 { - call void @llvm.dbg.value(metadata i8* %0, metadata !54, metadata !DIExpression()), !dbg !55 - %2 = call i32 @__LKMM_ATOMIC_FETCH_OP(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @x, i64 0, i32 0), i32 noundef 2, i32 noundef 4, i32 noundef 0) #4, !dbg !56 - call void @llvm.dbg.value(metadata i32 %2, metadata !57, metadata !DIExpression()), !dbg !55 - ret i8* null, !dbg !58 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !52 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !56, !DIExpression(), !57) + #dbg_declare(ptr %3, !58, !DIExpression(), !59) + %4 = call i64 @__LKMM_atomic_fetch_op(ptr noundef @x, i64 noundef 4, i64 noundef 2, i32 noundef 3, i32 noundef 0), !dbg !60 + %5 = trunc i64 %4 to i32, !dbg !60 + store i32 %5, ptr %3, align 4, !dbg !59 + ret ptr null, !dbg !61 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare i32 @__LKMM_ATOMIC_FETCH_OP(i32* noundef, i32 noundef, i32 noundef, i32 noundef) #2 +declare i64 @__LKMM_atomic_fetch_op(ptr noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !59 { - call void @llvm.dbg.value(metadata i8* %0, metadata !60, metadata !DIExpression()), !dbg !61 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #4, !dbg !62 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #4, !dbg !63 - call void @llvm.dbg.value(metadata i32 %2, metadata !64, metadata !DIExpression()), !dbg !61 - call void @__LKMM_FENCE(i32 noundef 5) #4, !dbg !65 - %3 = call i32 @__LKMM_CMPXCHG(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @x, i64 0, i32 0), i32 noundef %2, i32 noundef 42, i32 noundef 0, i32 noundef 0) #4, !dbg !66 - call void @llvm.dbg.value(metadata i32 %3, metadata !67, metadata !DIExpression()), !dbg !61 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @z to i8*), i32 noundef 1, i32 noundef 1) #4, !dbg !68 - ret i8* null, !dbg !69 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !62 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + %4 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !63, !DIExpression(), !64) + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !65 + #dbg_declare(ptr %3, !66, !DIExpression(), !67) + %5 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !68 + %6 = trunc i64 %5 to i32, !dbg !68 + store i32 %6, ptr %3, align 4, !dbg !67 + call void @__LKMM_fence(i32 noundef 4), !dbg !69 + #dbg_declare(ptr %4, !70, !DIExpression(), !71) + %7 = load i32, ptr %3, align 4, !dbg !72 + %8 = sext i32 %7 to i64, !dbg !72 + %9 = call i64 @__LKMM_cmpxchg(ptr noundef @x, i64 noundef 4, i64 noundef %8, i64 noundef 42, i32 noundef 0, i32 noundef 0), !dbg !72 + %10 = trunc i64 %9 to i32, !dbg !72 + store i32 %10, ptr %4, align 4, !dbg !71 + call void @__LKMM_store(ptr noundef @z, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !73 + ret ptr null, !dbg !74 } -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare i32 @__LKMM_CMPXCHG(i32* noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2 +declare i64 @__LKMM_cmpxchg(ptr noundef, i64 noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_3(i8* noundef %0) #0 !dbg !70 { - call void @llvm.dbg.value(metadata i8* %0, metadata !71, metadata !DIExpression()), !dbg !72 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @z to i8*), i32 noundef 2, i32 noundef 1) #4, !dbg !73 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @x to i8*), i32 noundef 1) #4, !dbg !74 - call void @llvm.dbg.value(metadata i32 %2, metadata !75, metadata !DIExpression()), !dbg !72 - call void @__LKMM_FENCE(i32 noundef 5) #4, !dbg !76 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 0, i32 noundef 1) #4, !dbg !77 - %3 = call i32 @__LKMM_CMPXCHG(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @x, i64 0, i32 0), i32 noundef %2, i32 noundef 24, i32 noundef 0, i32 noundef 0) #4, !dbg !78 - call void @llvm.dbg.value(metadata i32 %3, metadata !79, metadata !DIExpression()), !dbg !72 - br label %4, !dbg !80 - -4: ; preds = %7, %1 - %5 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #4, !dbg !81 - %6 = icmp eq i32 %5, 1, !dbg !82 - br i1 %6, label %7, label %.critedge, !dbg !83 - -7: ; preds = %4 - %8 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @z to i8*), i32 noundef 1) #4, !dbg !84 - %9 = icmp eq i32 %8, 2, !dbg !85 - br i1 %9, label %4, label %.critedge, !dbg !80, !llvm.loop !86 - -.critedge: ; preds = %4, %7 - ret i8* null, !dbg !89 +define dso_local ptr @thread_3(ptr noundef %0) #0 !dbg !75 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + %4 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !76, !DIExpression(), !77) + call void @__LKMM_store(ptr noundef @z, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !78 + #dbg_declare(ptr %3, !79, !DIExpression(), !80) + %5 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !81 + %6 = trunc i64 %5 to i32, !dbg !81 + store i32 %6, ptr %3, align 4, !dbg !80 + call void @__LKMM_fence(i32 noundef 4), !dbg !82 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 0, i32 noundef 0), !dbg !83 + #dbg_declare(ptr %4, !84, !DIExpression(), !85) + %7 = load i32, ptr %3, align 4, !dbg !86 + %8 = sext i32 %7 to i64, !dbg !86 + %9 = call i64 @__LKMM_cmpxchg(ptr noundef @x, i64 noundef 4, i64 noundef %8, i64 noundef 24, i32 noundef 0, i32 noundef 0), !dbg !86 + %10 = trunc i64 %9 to i32, !dbg !86 + store i32 %10, ptr %4, align 4, !dbg !85 + br label %11, !dbg !87 + +11: ; preds = %21, %1 + %12 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !88 + %13 = trunc i64 %12 to i32, !dbg !88 + %14 = icmp eq i32 %13, 1, !dbg !89 + br i1 %14, label %15, label %19, !dbg !90 + +15: ; preds = %11 + %16 = call i64 @__LKMM_load(ptr noundef @z, i64 noundef 4, i32 noundef 0), !dbg !91 + %17 = trunc i64 %16 to i32, !dbg !91 + %18 = icmp eq i32 %17, 2, !dbg !92 + br label %19 + +19: ; preds = %15, %11 + %20 = phi i1 [ false, %11 ], [ %18, %15 ], !dbg !93 + br i1 %20, label %21, label %22, !dbg !87 + +21: ; preds = %19 + br label %11, !dbg !87, !llvm.loop !94 + +22: ; preds = %19 + ret ptr null, !dbg !97 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !90 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !93, metadata !DIExpression(DW_OP_deref)), !dbg !97 - %4 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #4, !dbg !98 - call void @llvm.dbg.value(metadata i64* %2, metadata !99, metadata !DIExpression(DW_OP_deref)), !dbg !97 - %5 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #4, !dbg !100 - call void @llvm.dbg.value(metadata i64* %3, metadata !101, metadata !DIExpression(DW_OP_deref)), !dbg !97 - %6 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_3, i8* noundef null) #4, !dbg !102 - ret i32 0, !dbg !103 +define dso_local i32 @main() #0 !dbg !98 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !101, !DIExpression(), !125) + #dbg_declare(ptr %3, !126, !DIExpression(), !127) + #dbg_declare(ptr %4, !128, !DIExpression(), !129) + %5 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !130 + %6 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !131 + %7 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @thread_3, ptr noundef null), !dbg !132 + ret i32 0, !dbg !133 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!42, !43, !44, !45, !46, !47, !48} -!llvm.ident = !{!49} +!llvm.module.flags = !{!44, !45, !46, !47, !48, !49, !50} +!llvm.ident = !{!51} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !34, line: 7, type: !38, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !29, globals: !31, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock-liveness.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "62cffcfdbbfe2e2b84cb01226603616c") -!4 = !{!5, !23} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 7, type: !40, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !28, globals: !35, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/qspinlock-liveness.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "62cffcfdbbfe2e2b84cb01226603616c") +!4 = !{!5, !22} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "operation", file: !6, line: 20, baseType: !7, size: 32, elements: !24) -!24 = !{!25, !26, !27, !28} -!25 = !DIEnumerator(name: "op_add", value: 0) -!26 = !DIEnumerator(name: "op_sub", value: 1) -!27 = !DIEnumerator(name: "op_and", value: 2) -!28 = !DIEnumerator(name: "op_or", value: 3) -!29 = !{!30} -!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!31 = !{!32, !36, !0} -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !34, line: 6, type: !35, isLocal: false, isDefinition: true) -!34 = !DIFile(filename: "benchmarks/lkmm/qspinlock-liveness.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "62cffcfdbbfe2e2b84cb01226603616c") -!35 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_operation", file: !6, line: 19, baseType: !7, size: 32, elements: !23) +!23 = !{!24, !25, !26, !27} +!24 = !DIEnumerator(name: "__LKMM_op_add", value: 0) +!25 = !DIEnumerator(name: "__LKMM_op_sub", value: 1) +!26 = !DIEnumerator(name: "__LKMM_op_and", value: 2) +!27 = !DIEnumerator(name: "__LKMM_op_or", value: 3) +!28 = !{!29, !30, !34} +!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!30 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !31) +!31 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !32, line: 32, baseType: !33) +!32 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!33 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!35 = !{!36, !38, !0} !36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) -!37 = distinct !DIGlobalVariable(name: "z", scope: !2, file: !34, line: 6, type: !35, isLocal: false, isDefinition: true) -!38 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !39) -!39 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !40) -!40 = !{!41} -!41 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !39, file: !6, line: 94, baseType: !35, size: 32) -!42 = !{i32 7, !"Dwarf Version", i32 5} -!43 = !{i32 2, !"Debug Info Version", i32 3} -!44 = !{i32 1, !"wchar_size", i32 4} -!45 = !{i32 7, !"PIC Level", i32 2} -!46 = !{i32 7, !"PIE Level", i32 2} -!47 = !{i32 7, !"uwtable", i32 1} -!48 = !{i32 7, !"frame-pointer", i32 2} -!49 = !{!"Ubuntu clang version 14.0.6"} -!50 = distinct !DISubprogram(name: "thread_1", scope: !34, file: !34, line: 9, type: !51, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!51 = !DISubroutineType(types: !52) -!52 = !{!30, !30} -!53 = !{} -!54 = !DILocalVariable(name: "unused", arg: 1, scope: !50, file: !34, line: 9, type: !30) -!55 = !DILocation(line: 0, scope: !50) -!56 = !DILocation(line: 12, column: 14, scope: !50) -!57 = !DILocalVariable(name: "r0", scope: !50, file: !34, line: 12, type: !35) -!58 = !DILocation(line: 13, column: 5, scope: !50) -!59 = distinct !DISubprogram(name: "thread_2", scope: !34, file: !34, line: 16, type: !51, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!60 = !DILocalVariable(name: "unused", arg: 1, scope: !59, file: !34, line: 16, type: !30) -!61 = !DILocation(line: 0, scope: !59) -!62 = !DILocation(line: 19, column: 5, scope: !59) -!63 = !DILocation(line: 21, column: 14, scope: !59) -!64 = !DILocalVariable(name: "r0", scope: !59, file: !34, line: 21, type: !35) -!65 = !DILocation(line: 23, column: 5, scope: !59) -!66 = !DILocation(line: 25, column: 14, scope: !59) -!67 = !DILocalVariable(name: "r1", scope: !59, file: !34, line: 25, type: !35) -!68 = !DILocation(line: 27, column: 5, scope: !59) -!69 = !DILocation(line: 28, column: 5, scope: !59) -!70 = distinct !DISubprogram(name: "thread_3", scope: !34, file: !34, line: 31, type: !51, scopeLine: 32, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!71 = !DILocalVariable(name: "unused", arg: 1, scope: !70, file: !34, line: 31, type: !30) -!72 = !DILocation(line: 0, scope: !70) -!73 = !DILocation(line: 34, column: 5, scope: !70) -!74 = !DILocation(line: 36, column: 14, scope: !70) -!75 = !DILocalVariable(name: "r0", scope: !70, file: !34, line: 36, type: !35) -!76 = !DILocation(line: 38, column: 5, scope: !70) -!77 = !DILocation(line: 40, column: 5, scope: !70) -!78 = !DILocation(line: 42, column: 14, scope: !70) -!79 = !DILocalVariable(name: "r1", scope: !70, file: !34, line: 42, type: !35) -!80 = !DILocation(line: 44, column: 5, scope: !70) -!81 = !DILocation(line: 44, column: 11, scope: !70) -!82 = !DILocation(line: 44, column: 24, scope: !70) -!83 = !DILocation(line: 44, column: 29, scope: !70) -!84 = !DILocation(line: 44, column: 33, scope: !70) -!85 = !DILocation(line: 44, column: 46, scope: !70) -!86 = distinct !{!86, !80, !87, !88} -!87 = !DILocation(line: 44, column: 54, scope: !70) -!88 = !{!"llvm.loop.mustprogress"} -!89 = !DILocation(line: 45, column: 5, scope: !70) -!90 = distinct !DISubprogram(name: "main", scope: !34, file: !34, line: 48, type: !91, scopeLine: 49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !53) -!91 = !DISubroutineType(types: !92) -!92 = !{!35} -!93 = !DILocalVariable(name: "t1", scope: !90, file: !34, line: 50, type: !94) -!94 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !95, line: 27, baseType: !96) -!95 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!96 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!97 = !DILocation(line: 0, scope: !90) -!98 = !DILocation(line: 52, column: 2, scope: !90) -!99 = !DILocalVariable(name: "t2", scope: !90, file: !34, line: 50, type: !94) -!100 = !DILocation(line: 53, column: 2, scope: !90) -!101 = !DILocalVariable(name: "t3", scope: !90, file: !34, line: 50, type: !94) -!102 = !DILocation(line: 54, column: 2, scope: !90) -!103 = !DILocation(line: 56, column: 2, scope: !90) +!37 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 6, type: !29, isLocal: false, isDefinition: true) +!38 = !DIGlobalVariableExpression(var: !39, expr: !DIExpression()) +!39 = distinct !DIGlobalVariable(name: "z", scope: !2, file: !3, line: 6, type: !29, isLocal: false, isDefinition: true) +!40 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !41) +!41 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !42) +!42 = !{!43} +!43 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !41, file: !6, line: 107, baseType: !29, size: 32) +!44 = !{i32 7, !"Dwarf Version", i32 5} +!45 = !{i32 2, !"Debug Info Version", i32 3} +!46 = !{i32 1, !"wchar_size", i32 4} +!47 = !{i32 8, !"PIC Level", i32 2} +!48 = !{i32 7, !"PIE Level", i32 2} +!49 = !{i32 7, !"uwtable", i32 2} +!50 = !{i32 7, !"frame-pointer", i32 2} +!51 = !{!"Homebrew clang version 19.1.7"} +!52 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 9, type: !53, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) +!53 = !DISubroutineType(types: !54) +!54 = !{!34, !34} +!55 = !{} +!56 = !DILocalVariable(name: "unused", arg: 1, scope: !52, file: !3, line: 9, type: !34) +!57 = !DILocation(line: 9, column: 22, scope: !52) +!58 = !DILocalVariable(name: "r0", scope: !52, file: !3, line: 12, type: !29) +!59 = !DILocation(line: 12, column: 9, scope: !52) +!60 = !DILocation(line: 12, column: 14, scope: !52) +!61 = !DILocation(line: 13, column: 5, scope: !52) +!62 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 16, type: !53, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) +!63 = !DILocalVariable(name: "unused", arg: 1, scope: !62, file: !3, line: 16, type: !34) +!64 = !DILocation(line: 16, column: 22, scope: !62) +!65 = !DILocation(line: 19, column: 5, scope: !62) +!66 = !DILocalVariable(name: "r0", scope: !62, file: !3, line: 21, type: !29) +!67 = !DILocation(line: 21, column: 9, scope: !62) +!68 = !DILocation(line: 21, column: 14, scope: !62) +!69 = !DILocation(line: 23, column: 5, scope: !62) +!70 = !DILocalVariable(name: "r1", scope: !62, file: !3, line: 25, type: !29) +!71 = !DILocation(line: 25, column: 9, scope: !62) +!72 = !DILocation(line: 25, column: 14, scope: !62) +!73 = !DILocation(line: 27, column: 5, scope: !62) +!74 = !DILocation(line: 28, column: 5, scope: !62) +!75 = distinct !DISubprogram(name: "thread_3", scope: !3, file: !3, line: 31, type: !53, scopeLine: 32, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) +!76 = !DILocalVariable(name: "unused", arg: 1, scope: !75, file: !3, line: 31, type: !34) +!77 = !DILocation(line: 31, column: 22, scope: !75) +!78 = !DILocation(line: 34, column: 5, scope: !75) +!79 = !DILocalVariable(name: "r0", scope: !75, file: !3, line: 36, type: !29) +!80 = !DILocation(line: 36, column: 9, scope: !75) +!81 = !DILocation(line: 36, column: 14, scope: !75) +!82 = !DILocation(line: 38, column: 5, scope: !75) +!83 = !DILocation(line: 40, column: 5, scope: !75) +!84 = !DILocalVariable(name: "r1", scope: !75, file: !3, line: 42, type: !29) +!85 = !DILocation(line: 42, column: 9, scope: !75) +!86 = !DILocation(line: 42, column: 14, scope: !75) +!87 = !DILocation(line: 44, column: 5, scope: !75) +!88 = !DILocation(line: 44, column: 11, scope: !75) +!89 = !DILocation(line: 44, column: 24, scope: !75) +!90 = !DILocation(line: 44, column: 29, scope: !75) +!91 = !DILocation(line: 44, column: 33, scope: !75) +!92 = !DILocation(line: 44, column: 46, scope: !75) +!93 = !DILocation(line: 0, scope: !75) +!94 = distinct !{!94, !87, !95, !96} +!95 = !DILocation(line: 44, column: 54, scope: !75) +!96 = !{!"llvm.loop.mustprogress"} +!97 = !DILocation(line: 45, column: 5, scope: !75) +!98 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 48, type: !99, scopeLine: 49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !55) +!99 = !DISubroutineType(types: !100) +!100 = !{!29} +!101 = !DILocalVariable(name: "t1", scope: !98, file: !3, line: 50, type: !102) +!102 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !103, line: 31, baseType: !104) +!103 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!104 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !105, line: 118, baseType: !106) +!105 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!106 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !107, size: 64) +!107 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !105, line: 103, size: 65536, elements: !108) +!108 = !{!109, !110, !120} +!109 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !107, file: !105, line: 104, baseType: !33, size: 64) +!110 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !107, file: !105, line: 105, baseType: !111, size: 64, offset: 64) +!111 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !112, size: 64) +!112 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !105, line: 57, size: 192, elements: !113) +!113 = !{!114, !118, !119} +!114 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !112, file: !105, line: 58, baseType: !115, size: 64) +!115 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !116, size: 64) +!116 = !DISubroutineType(types: !117) +!117 = !{null, !34} +!118 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !112, file: !105, line: 59, baseType: !34, size: 64, offset: 64) +!119 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !112, file: !105, line: 60, baseType: !111, size: 64, offset: 128) +!120 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !107, file: !105, line: 106, baseType: !121, size: 65408, offset: 128) +!121 = !DICompositeType(tag: DW_TAG_array_type, baseType: !122, size: 65408, elements: !123) +!122 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!123 = !{!124} +!124 = !DISubrange(count: 8176) +!125 = !DILocation(line: 50, column: 12, scope: !98) +!126 = !DILocalVariable(name: "t2", scope: !98, file: !3, line: 50, type: !102) +!127 = !DILocation(line: 50, column: 16, scope: !98) +!128 = !DILocalVariable(name: "t3", scope: !98, file: !3, line: 50, type: !102) +!129 = !DILocation(line: 50, column: 20, scope: !98) +!130 = !DILocation(line: 52, column: 2, scope: !98) +!131 = !DILocation(line: 53, column: 2, scope: !98) +!132 = !DILocation(line: 54, column: 2, scope: !98) +!133 = !DILocation(line: 56, column: 2, scope: !98) diff --git a/dartagnan/src/test/resources/lkmm/qspinlock.ll b/dartagnan/src/test/resources/lkmm/qspinlock.ll index af25834125..8456029d14 100644 --- a/dartagnan/src/test/resources/lkmm/qspinlock.ll +++ b/dartagnan/src/test/resources/lkmm/qspinlock.ll @@ -1,204 +1,252 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/qspinlock.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/qspinlock.c' +source_filename = "benchmarks/lkmm/qspinlock.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" %struct.atomic_t = type { i32 } -%union.pthread_attr_t = type { i64, [48 x i8] } @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !32 -@.str = private unnamed_addr constant [18 x i8] c"READ_ONCE(x) == 1\00", align 1 -@.str.1 = private unnamed_addr constant [50 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock.c\00", align 1 -@__PRETTY_FUNCTION__.thread_3 = private unnamed_addr constant [23 x i8] c"void *thread_3(void *)\00", align 1 +@y = dso_local global %struct.atomic_t zeroinitializer, align 4, !dbg !53 +@__func__.thread_3 = private unnamed_addr constant [9 x i8] c"thread_3\00", align 1, !dbg !36 +@.str = private unnamed_addr constant [12 x i8] c"qspinlock.c\00", align 1, !dbg !43 +@.str.1 = private unnamed_addr constant [18 x i8] c"READ_ONCE(x) == 1\00", align 1, !dbg !48 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_1(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !52, metadata !DIExpression()), !dbg !53 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !54 - call void @__LKMM_STORE(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1, i32 noundef 3) #5, !dbg !55 - ret i8* null, !dbg !56 +define dso_local ptr @thread_1(ptr noundef %0) #0 !dbg !67 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !71, !DIExpression(), !72) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !73 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 2), !dbg !74 + ret ptr null, !dbg !75 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_2(i8* noundef %0) #0 !dbg !57 { - call void @llvm.dbg.value(metadata i8* %0, metadata !58, metadata !DIExpression()), !dbg !59 - %2 = call i32 @__LKMM_ATOMIC_FETCH_OP(i32* noundef getelementptr inbounds (%struct.atomic_t, %struct.atomic_t* @y, i64 0, i32 0), i32 noundef 2, i32 noundef 0, i32 noundef 3) #5, !dbg !60 - ret i8* null, !dbg !61 +define dso_local ptr @thread_2(ptr noundef %0) #0 !dbg !76 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !77, !DIExpression(), !78) + %3 = call i64 @__LKMM_atomic_fetch_op(ptr noundef @y, i64 noundef 4, i64 noundef 2, i32 noundef 0, i32 noundef 3), !dbg !79 + %4 = trunc i64 %3 to i32, !dbg !79 + ret ptr null, !dbg !80 } -declare i32 @__LKMM_ATOMIC_FETCH_OP(i32* noundef, i32 noundef, i32 noundef, i32 noundef) #2 +declare i64 @__LKMM_atomic_fetch_op(ptr noundef, i64 noundef, i64 noundef, i32 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @thread_3(i8* noundef %0) #0 !dbg !62 { - call void @llvm.dbg.value(metadata i8* %0, metadata !63, metadata !DIExpression()), !dbg !64 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (%struct.atomic_t* @y to i8*), i32 noundef 1) #5, !dbg !65 - %3 = and i32 %2, 1, !dbg !67 - %.not = icmp eq i32 %3, 0, !dbg !67 - br i1 %.not, label %8, label %4, !dbg !68 - -4: ; preds = %1 - call void @__LKMM_FENCE(i32 noundef 6) #5, !dbg !69 - %5 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !71 - %6 = icmp eq i32 %5, 1, !dbg !71 - br i1 %6, label %8, label %7, !dbg !74 - -7: ; preds = %4 - call void @__assert_fail(i8* noundef getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 noundef 26, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.thread_3, i64 0, i64 0)) #6, !dbg !71 - unreachable, !dbg !71 - -8: ; preds = %4, %1 - ret i8* null, !dbg !75 +define dso_local ptr @thread_3(ptr noundef %0) #0 !dbg !81 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !82, !DIExpression(), !83) + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !84 + %4 = trunc i64 %3 to i32, !dbg !84 + %5 = and i32 %4, 1, !dbg !86 + %6 = icmp ne i32 %5, 0, !dbg !86 + br i1 %6, label %7, label %19, !dbg !87 + +7: ; preds = %1 + call void @__LKMM_fence(i32 noundef 5), !dbg !88 + %8 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !90 + %9 = trunc i64 %8 to i32, !dbg !90 + %10 = icmp eq i32 %9, 1, !dbg !90 + %11 = xor i1 %10, true, !dbg !90 + %12 = zext i1 %11 to i32, !dbg !90 + %13 = sext i32 %12 to i64, !dbg !90 + %14 = icmp ne i64 %13, 0, !dbg !90 + br i1 %14, label %15, label %17, !dbg !90 + +15: ; preds = %7 + call void @__assert_rtn(ptr noundef @__func__.thread_3, ptr noundef @.str, i32 noundef 26, ptr noundef @.str.1) #3, !dbg !90 + unreachable, !dbg !90 + +16: ; No predecessors! + br label %18, !dbg !90 + +17: ; preds = %7 + br label %18, !dbg !90 + +18: ; preds = %17, %16 + br label %19, !dbg !91 + +19: ; preds = %18, %1 + ret ptr null, !dbg !92 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #3 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !76 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !79, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %4 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_1, i8* noundef null) #5, !dbg !84 - call void @llvm.dbg.value(metadata i64* %2, metadata !85, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %5 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_2, i8* noundef null) #5, !dbg !86 - call void @llvm.dbg.value(metadata i64* %3, metadata !87, metadata !DIExpression(DW_OP_deref)), !dbg !83 - %6 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @thread_3, i8* noundef null) #5, !dbg !88 - %7 = load i64, i64* %1, align 8, !dbg !89 - call void @llvm.dbg.value(metadata i64 %7, metadata !79, metadata !DIExpression()), !dbg !83 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !90 - %9 = load i64, i64* %2, align 8, !dbg !91 - call void @llvm.dbg.value(metadata i64 %9, metadata !85, metadata !DIExpression()), !dbg !83 - %10 = call i32 @pthread_join(i64 noundef %9, i8** noundef null) #5, !dbg !92 - %11 = load i64, i64* %3, align 8, !dbg !93 - call void @llvm.dbg.value(metadata i64 %11, metadata !87, metadata !DIExpression()), !dbg !83 - %12 = call i32 @pthread_join(i64 noundef %11, i8** noundef null) #5, !dbg !94 - ret i32 0, !dbg !95 +define dso_local i32 @main() #0 !dbg !93 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !96, !DIExpression(), !119) + #dbg_declare(ptr %3, !120, !DIExpression(), !121) + #dbg_declare(ptr %4, !122, !DIExpression(), !123) + %5 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @thread_1, ptr noundef null), !dbg !124 + %6 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @thread_2, ptr noundef null), !dbg !125 + %7 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @thread_3, ptr noundef null), !dbg !126 + %8 = load ptr, ptr %2, align 8, !dbg !127 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !128 + %10 = load ptr, ptr %3, align 8, !dbg !129 + %11 = call i32 @_pthread_join(ptr noundef %10, ptr noundef null), !dbg !130 + %12 = load ptr, ptr %4, align 8, !dbg !131 + %13 = call i32 @_pthread_join(ptr noundef %12, ptr noundef null), !dbg !132 + ret i32 0, !dbg !133 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #4 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!40, !41, !42, !43, !44, !45, !46} -!llvm.ident = !{!47} +!llvm.module.flags = !{!59, !60, !61, !62, !63, !64, !65} +!llvm.ident = !{!66} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !34, line: 6, type: !39, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !29, globals: !31, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/qspinlock.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "c600e4091a20e0f808017d68911496eb") -!4 = !{!5, !23} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 6, type: !34, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !28, globals: !35, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/qspinlock.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "c600e4091a20e0f808017d68911496eb") +!4 = !{!5, !22} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "operation", file: !6, line: 20, baseType: !7, size: 32, elements: !24) -!24 = !{!25, !26, !27, !28} -!25 = !DIEnumerator(name: "op_add", value: 0) -!26 = !DIEnumerator(name: "op_sub", value: 1) -!27 = !DIEnumerator(name: "op_and", value: 2) -!28 = !DIEnumerator(name: "op_or", value: 3) -!29 = !{!30} -!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!31 = !{!0, !32} -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !34, line: 7, type: !35, isLocal: false, isDefinition: true) -!34 = !DIFile(filename: "benchmarks/lkmm/qspinlock.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "c600e4091a20e0f808017d68911496eb") -!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 95, baseType: !36) -!36 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 93, size: 32, elements: !37) -!37 = !{!38} -!38 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !36, file: !6, line: 94, baseType: !39, size: 32) -!39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!40 = !{i32 7, !"Dwarf Version", i32 5} -!41 = !{i32 2, !"Debug Info Version", i32 3} -!42 = !{i32 1, !"wchar_size", i32 4} -!43 = !{i32 7, !"PIC Level", i32 2} -!44 = !{i32 7, !"PIE Level", i32 2} -!45 = !{i32 7, !"uwtable", i32 1} -!46 = !{i32 7, !"frame-pointer", i32 2} -!47 = !{!"Ubuntu clang version 14.0.6"} -!48 = distinct !DISubprogram(name: "thread_1", scope: !34, file: !34, line: 9, type: !49, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!49 = !DISubroutineType(types: !50) -!50 = !{!30, !30} -!51 = !{} -!52 = !DILocalVariable(name: "unused", arg: 1, scope: !48, file: !34, line: 9, type: !30) -!53 = !DILocation(line: 0, scope: !48) -!54 = !DILocation(line: 11, column: 2, scope: !48) -!55 = !DILocation(line: 12, column: 2, scope: !48) -!56 = !DILocation(line: 13, column: 2, scope: !48) -!57 = distinct !DISubprogram(name: "thread_2", scope: !34, file: !34, line: 16, type: !49, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!58 = !DILocalVariable(name: "unused", arg: 1, scope: !57, file: !34, line: 16, type: !30) -!59 = !DILocation(line: 0, scope: !57) -!60 = !DILocation(line: 18, column: 2, scope: !57) -!61 = !DILocation(line: 19, column: 2, scope: !57) -!62 = distinct !DISubprogram(name: "thread_3", scope: !34, file: !34, line: 22, type: !49, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!63 = !DILocalVariable(name: "unused", arg: 1, scope: !62, file: !34, line: 22, type: !30) -!64 = !DILocation(line: 0, scope: !62) -!65 = !DILocation(line: 24, column: 7, scope: !66) -!66 = distinct !DILexicalBlock(scope: !62, file: !34, line: 24, column: 7) -!67 = !DILocation(line: 24, column: 23, scope: !66) -!68 = !DILocation(line: 24, column: 7, scope: !62) -!69 = !DILocation(line: 25, column: 4, scope: !70) -!70 = distinct !DILexicalBlock(scope: !66, file: !34, line: 24, column: 28) -!71 = !DILocation(line: 26, column: 4, scope: !72) -!72 = distinct !DILexicalBlock(scope: !73, file: !34, line: 26, column: 4) -!73 = distinct !DILexicalBlock(scope: !70, file: !34, line: 26, column: 4) -!74 = !DILocation(line: 26, column: 4, scope: !73) -!75 = !DILocation(line: 28, column: 2, scope: !62) -!76 = distinct !DISubprogram(name: "main", scope: !34, file: !34, line: 31, type: !77, scopeLine: 32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!77 = !DISubroutineType(types: !78) -!78 = !{!39} -!79 = !DILocalVariable(name: "t1", scope: !76, file: !34, line: 33, type: !80) -!80 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !81, line: 27, baseType: !82) -!81 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!82 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!83 = !DILocation(line: 0, scope: !76) -!84 = !DILocation(line: 35, column: 2, scope: !76) -!85 = !DILocalVariable(name: "t2", scope: !76, file: !34, line: 33, type: !80) -!86 = !DILocation(line: 36, column: 2, scope: !76) -!87 = !DILocalVariable(name: "t3", scope: !76, file: !34, line: 33, type: !80) -!88 = !DILocation(line: 37, column: 2, scope: !76) -!89 = !DILocation(line: 39, column: 15, scope: !76) -!90 = !DILocation(line: 39, column: 2, scope: !76) -!91 = !DILocation(line: 40, column: 15, scope: !76) -!92 = !DILocation(line: 40, column: 2, scope: !76) -!93 = !DILocation(line: 41, column: 15, scope: !76) -!94 = !DILocation(line: 41, column: 2, scope: !76) -!95 = !DILocation(line: 43, column: 2, scope: !76) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_operation", file: !6, line: 19, baseType: !7, size: 32, elements: !23) +!23 = !{!24, !25, !26, !27} +!24 = !DIEnumerator(name: "__LKMM_op_add", value: 0) +!25 = !DIEnumerator(name: "__LKMM_op_sub", value: 1) +!26 = !DIEnumerator(name: "__LKMM_op_and", value: 2) +!27 = !DIEnumerator(name: "__LKMM_op_or", value: 3) +!28 = !{!29, !33, !34} +!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !30) +!30 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !31, line: 32, baseType: !32) +!31 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!32 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!34 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!35 = !{!36, !43, !48, !0, !53} +!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) +!37 = distinct !DIGlobalVariable(scope: null, file: !3, line: 26, type: !38, isLocal: true, isDefinition: true) +!38 = !DICompositeType(tag: DW_TAG_array_type, baseType: !39, size: 72, elements: !41) +!39 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !40) +!40 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!41 = !{!42} +!42 = !DISubrange(count: 9) +!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression()) +!44 = distinct !DIGlobalVariable(scope: null, file: !3, line: 26, type: !45, isLocal: true, isDefinition: true) +!45 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 96, elements: !46) +!46 = !{!47} +!47 = !DISubrange(count: 12) +!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) +!49 = distinct !DIGlobalVariable(scope: null, file: !3, line: 26, type: !50, isLocal: true, isDefinition: true) +!50 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 144, elements: !51) +!51 = !{!52} +!52 = !DISubrange(count: 18) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 7, type: !55, isLocal: false, isDefinition: true) +!55 = !DIDerivedType(tag: DW_TAG_typedef, name: "atomic_t", file: !6, line: 108, baseType: !56) +!56 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !6, line: 106, size: 32, elements: !57) +!57 = !{!58} +!58 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !56, file: !6, line: 107, baseType: !34, size: 32) +!59 = !{i32 7, !"Dwarf Version", i32 5} +!60 = !{i32 2, !"Debug Info Version", i32 3} +!61 = !{i32 1, !"wchar_size", i32 4} +!62 = !{i32 8, !"PIC Level", i32 2} +!63 = !{i32 7, !"PIE Level", i32 2} +!64 = !{i32 7, !"uwtable", i32 2} +!65 = !{i32 7, !"frame-pointer", i32 2} +!66 = !{!"Homebrew clang version 19.1.7"} +!67 = distinct !DISubprogram(name: "thread_1", scope: !3, file: !3, line: 9, type: !68, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!68 = !DISubroutineType(types: !69) +!69 = !{!33, !33} +!70 = !{} +!71 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !3, line: 9, type: !33) +!72 = !DILocation(line: 9, column: 22, scope: !67) +!73 = !DILocation(line: 11, column: 2, scope: !67) +!74 = !DILocation(line: 12, column: 2, scope: !67) +!75 = !DILocation(line: 13, column: 2, scope: !67) +!76 = distinct !DISubprogram(name: "thread_2", scope: !3, file: !3, line: 16, type: !68, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!77 = !DILocalVariable(name: "unused", arg: 1, scope: !76, file: !3, line: 16, type: !33) +!78 = !DILocation(line: 16, column: 22, scope: !76) +!79 = !DILocation(line: 18, column: 2, scope: !76) +!80 = !DILocation(line: 19, column: 2, scope: !76) +!81 = distinct !DISubprogram(name: "thread_3", scope: !3, file: !3, line: 22, type: !68, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!82 = !DILocalVariable(name: "unused", arg: 1, scope: !81, file: !3, line: 22, type: !33) +!83 = !DILocation(line: 22, column: 22, scope: !81) +!84 = !DILocation(line: 24, column: 7, scope: !85) +!85 = distinct !DILexicalBlock(scope: !81, file: !3, line: 24, column: 7) +!86 = !DILocation(line: 24, column: 23, scope: !85) +!87 = !DILocation(line: 24, column: 7, scope: !81) +!88 = !DILocation(line: 25, column: 4, scope: !89) +!89 = distinct !DILexicalBlock(scope: !85, file: !3, line: 24, column: 28) +!90 = !DILocation(line: 26, column: 4, scope: !89) +!91 = !DILocation(line: 27, column: 3, scope: !89) +!92 = !DILocation(line: 28, column: 2, scope: !81) +!93 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 31, type: !94, scopeLine: 32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!94 = !DISubroutineType(types: !95) +!95 = !{!34} +!96 = !DILocalVariable(name: "t1", scope: !93, file: !3, line: 33, type: !97) +!97 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !98, line: 31, baseType: !99) +!98 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!99 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !100, line: 118, baseType: !101) +!100 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!101 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !102, size: 64) +!102 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !100, line: 103, size: 65536, elements: !103) +!103 = !{!104, !105, !115} +!104 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !102, file: !100, line: 104, baseType: !32, size: 64) +!105 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !102, file: !100, line: 105, baseType: !106, size: 64, offset: 64) +!106 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !107, size: 64) +!107 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !100, line: 57, size: 192, elements: !108) +!108 = !{!109, !113, !114} +!109 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !107, file: !100, line: 58, baseType: !110, size: 64) +!110 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !111, size: 64) +!111 = !DISubroutineType(types: !112) +!112 = !{null, !33} +!113 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !107, file: !100, line: 59, baseType: !33, size: 64, offset: 64) +!114 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !107, file: !100, line: 60, baseType: !106, size: 64, offset: 128) +!115 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !102, file: !100, line: 106, baseType: !116, size: 65408, offset: 128) +!116 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 65408, elements: !117) +!117 = !{!118} +!118 = !DISubrange(count: 8176) +!119 = !DILocation(line: 33, column: 12, scope: !93) +!120 = !DILocalVariable(name: "t2", scope: !93, file: !3, line: 33, type: !97) +!121 = !DILocation(line: 33, column: 16, scope: !93) +!122 = !DILocalVariable(name: "t3", scope: !93, file: !3, line: 33, type: !97) +!123 = !DILocation(line: 33, column: 20, scope: !93) +!124 = !DILocation(line: 35, column: 2, scope: !93) +!125 = !DILocation(line: 36, column: 2, scope: !93) +!126 = !DILocation(line: 37, column: 2, scope: !93) +!127 = !DILocation(line: 39, column: 15, scope: !93) +!128 = !DILocation(line: 39, column: 2, scope: !93) +!129 = !DILocation(line: 40, column: 15, scope: !93) +!130 = !DILocation(line: 40, column: 2, scope: !93) +!131 = !DILocation(line: 41, column: 15, scope: !93) +!132 = !DILocation(line: 41, column: 2, scope: !93) +!133 = !DILocation(line: 43, column: 2, scope: !93) diff --git a/dartagnan/src/test/resources/lkmm/rcu+ar-link-short0.ll b/dartagnan/src/test/resources/lkmm/rcu+ar-link-short0.ll index c37d144954..80581bf456 100644 --- a/dartagnan/src/test/resources/lkmm/rcu+ar-link-short0.ll +++ b/dartagnan/src/test/resources/lkmm/rcu+ar-link-short0.ll @@ -1,259 +1,316 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/rcu+ar-link-short0.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link-short0.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/rcu+ar-link-short0.c' +source_filename = "benchmarks/lkmm/rcu+ar-link-short0.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @w = dso_local global [2 x i32] [i32 0, i32 1], align 4, !dbg !0 -@x = dso_local global i32 0, align 4, !dbg !26 -@y = dso_local global i32 0, align 4, !dbg !30 -@s = dso_local global i32 0, align 4, !dbg !36 -@r_s = dso_local global i32 0, align 4, !dbg !38 -@r_w = dso_local global i32 0, align 4, !dbg !40 -@r_y = dso_local global i32 0, align 4, !dbg !34 -@.str = private unnamed_addr constant [36 x i8] c"!(r_y == 0 && r_s == 1 && r_w == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [59 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link-short0.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 -@r_x = dso_local global i32 0, align 4, !dbg !32 +@x = dso_local global i32 0, align 4, !dbg !47 +@y = dso_local global i32 0, align 4, !dbg !49 +@s = dso_local global i32 0, align 4, !dbg !55 +@r_s = dso_local global i32 0, align 4, !dbg !57 +@r_w = dso_local global i32 0, align 4, !dbg !59 +@r_y = dso_local global i32 0, align 4, !dbg !53 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [21 x i8] c"rcu+ar-link-short0.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [36 x i8] c"!(r_y == 0 && r_s == 1 && r_w == 1)\00", align 1, !dbg !42 +@r_x = dso_local global i32 0, align 4, !dbg !51 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !53 { - call void @llvm.dbg.value(metadata i8* %0, metadata !57, metadata !DIExpression()), !dbg !58 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !59 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !60 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !61 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !62 - ret i8* null, !dbg !63 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !72 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !76, !DIExpression(), !77) + call void @__LKMM_fence(i32 noundef 6), !dbg !78 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !79 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !80 + call void @__LKMM_fence(i32 noundef 7), !dbg !81 + ret ptr null, !dbg !82 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !64 { - call void @llvm.dbg.value(metadata i8* %0, metadata !65, metadata !DIExpression()), !dbg !66 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !67 - %3 = icmp eq i32 %2, 1, !dbg !69 - br i1 %3, label %4, label %5, !dbg !70 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !83 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !84, !DIExpression(), !85) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !86 + %4 = trunc i64 %3 to i32, !dbg !86 + %5 = icmp eq i32 %4, 1, !dbg !88 + br i1 %5, label %6, label %7, !dbg !89 -4: ; preds = %1 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @s to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !71 - br label %5, !dbg !71 +6: ; preds = %1 + call void @__LKMM_store(ptr noundef @s, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !90 + br label %7, !dbg !90 -5: ; preds = %4, %1 - ret i8* null, !dbg !72 +7: ; preds = %6, %1 + ret ptr null, !dbg !91 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P2(i8* noundef %0) #0 !dbg !73 { - call void @llvm.dbg.value(metadata i8* %0, metadata !74, metadata !DIExpression()), !dbg !75 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @s to i8*), i32 noundef 1) #5, !dbg !76 - store i32 %2, i32* @r_s, align 4, !dbg !77 - %3 = sext i32 %2 to i64, !dbg !78 - %4 = getelementptr inbounds [2 x i32], [2 x i32]* @w, i64 0, i64 %3, !dbg !78 - %5 = bitcast i32* %4 to i8*, !dbg !78 - %6 = call i32 @__LKMM_LOAD(i8* noundef nonnull %5, i32 noundef 1) #5, !dbg !78 - store i32 %6, i32* @r_w, align 4, !dbg !79 - ret i8* null, !dbg !80 +define dso_local ptr @P2(ptr noundef %0) #0 !dbg !92 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !93, !DIExpression(), !94) + %3 = call i64 @__LKMM_load(ptr noundef @s, i64 noundef 4, i32 noundef 0), !dbg !95 + %4 = trunc i64 %3 to i32, !dbg !95 + store i32 %4, ptr @r_s, align 4, !dbg !96 + %5 = load i32, ptr @r_s, align 4, !dbg !97 + %6 = sext i32 %5 to i64, !dbg !97 + %7 = getelementptr inbounds [2 x i32], ptr @w, i64 0, i64 %6, !dbg !97 + %8 = call i64 @__LKMM_load(ptr noundef %7, i64 noundef 4, i32 noundef 0), !dbg !97 + %9 = trunc i64 %8 to i32, !dbg !97 + store i32 %9, ptr @r_w, align 4, !dbg !98 + ret ptr null, !dbg !99 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P3(i8* noundef %0) #0 !dbg !81 { - call void @llvm.dbg.value(metadata i8* %0, metadata !82, metadata !DIExpression()), !dbg !83 - call void @__LKMM_STORE(i8* noundef bitcast (i32* getelementptr inbounds ([2 x i32], [2 x i32]* @w, i64 0, i64 1) to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !84 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !85 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !86 - store i32 %2, i32* @r_y, align 4, !dbg !87 - ret i8* null, !dbg !88 +define dso_local ptr @P3(ptr noundef %0) #0 !dbg !100 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !101, !DIExpression(), !102) + call void @__LKMM_store(ptr noundef getelementptr inbounds ([2 x i32], ptr @w, i64 0, i64 1), i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !103 + call void @__LKMM_fence(i32 noundef 8), !dbg !104 + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !105 + %4 = trunc i64 %3 to i32, !dbg !105 + store i32 %4, ptr @r_y, align 4, !dbg !106 + ret ptr null, !dbg !107 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !89 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - %4 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !92, metadata !DIExpression(DW_OP_deref)), !dbg !96 - %5 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !97 - call void @llvm.dbg.value(metadata i64* %2, metadata !98, metadata !DIExpression(DW_OP_deref)), !dbg !96 - %6 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !99 - call void @llvm.dbg.value(metadata i64* %3, metadata !100, metadata !DIExpression(DW_OP_deref)), !dbg !96 - %7 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P2, i8* noundef null) #5, !dbg !101 - call void @llvm.dbg.value(metadata i64* %4, metadata !102, metadata !DIExpression(DW_OP_deref)), !dbg !96 - %8 = call i32 @pthread_create(i64* noundef nonnull %4, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P3, i8* noundef null) #5, !dbg !103 - %9 = load i64, i64* %1, align 8, !dbg !104 - call void @llvm.dbg.value(metadata i64 %9, metadata !92, metadata !DIExpression()), !dbg !96 - %10 = call i32 @pthread_join(i64 noundef %9, i8** noundef null) #5, !dbg !105 - %11 = load i64, i64* %2, align 8, !dbg !106 - call void @llvm.dbg.value(metadata i64 %11, metadata !98, metadata !DIExpression()), !dbg !96 - %12 = call i32 @pthread_join(i64 noundef %11, i8** noundef null) #5, !dbg !107 - %13 = load i64, i64* %3, align 8, !dbg !108 - call void @llvm.dbg.value(metadata i64 %13, metadata !100, metadata !DIExpression()), !dbg !96 - %14 = call i32 @pthread_join(i64 noundef %13, i8** noundef null) #5, !dbg !109 - %15 = load i64, i64* %4, align 8, !dbg !110 - call void @llvm.dbg.value(metadata i64 %15, metadata !102, metadata !DIExpression()), !dbg !96 - %16 = call i32 @pthread_join(i64 noundef %15, i8** noundef null) #5, !dbg !111 - %17 = load i32, i32* @r_y, align 4, !dbg !112 - %18 = icmp eq i32 %17, 0, !dbg !112 - %19 = load i32, i32* @r_s, align 4, !dbg !112 - %20 = icmp eq i32 %19, 1, !dbg !112 - %or.cond = select i1 %18, i1 %20, i1 false, !dbg !112 - %21 = load i32, i32* @r_w, align 4, !dbg !112 - %22 = icmp eq i32 %21, 1, !dbg !112 - %or.cond3 = select i1 %or.cond, i1 %22, i1 false, !dbg !112 - br i1 %or.cond3, label %23, label %24, !dbg !112 +define dso_local i32 @main() #0 !dbg !108 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + %5 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !111, !DIExpression(), !134) + #dbg_declare(ptr %3, !135, !DIExpression(), !136) + #dbg_declare(ptr %4, !137, !DIExpression(), !138) + #dbg_declare(ptr %5, !139, !DIExpression(), !140) + %6 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !141 + %7 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !142 + %8 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @P2, ptr noundef null), !dbg !143 + %9 = call i32 @pthread_create(ptr noundef %5, ptr noundef null, ptr noundef @P3, ptr noundef null), !dbg !144 + %10 = load ptr, ptr %2, align 8, !dbg !145 + %11 = call i32 @_pthread_join(ptr noundef %10, ptr noundef null), !dbg !146 + %12 = load ptr, ptr %3, align 8, !dbg !147 + %13 = call i32 @_pthread_join(ptr noundef %12, ptr noundef null), !dbg !148 + %14 = load ptr, ptr %4, align 8, !dbg !149 + %15 = call i32 @_pthread_join(ptr noundef %14, ptr noundef null), !dbg !150 + %16 = load ptr, ptr %5, align 8, !dbg !151 + %17 = call i32 @_pthread_join(ptr noundef %16, ptr noundef null), !dbg !152 + %18 = load i32, ptr @r_y, align 4, !dbg !153 + %19 = icmp eq i32 %18, 0, !dbg !153 + br i1 %19, label %20, label %26, !dbg !153 -23: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i32 noundef 82, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !112 - unreachable, !dbg !112 +20: ; preds = %0 + %21 = load i32, ptr @r_s, align 4, !dbg !153 + %22 = icmp eq i32 %21, 1, !dbg !153 + br i1 %22, label %23, label %26, !dbg !153 -24: ; preds = %0 - ret i32 0, !dbg !115 -} +23: ; preds = %20 + %24 = load i32, ptr @r_w, align 4, !dbg !153 + %25 = icmp eq i32 %24, 1, !dbg !153 + br label %26 + +26: ; preds = %23, %20, %0 + %27 = phi i1 [ false, %20 ], [ false, %0 ], [ %25, %23 ], !dbg !154 + %28 = xor i1 %27, true, !dbg !153 + %29 = xor i1 %28, true, !dbg !153 + %30 = zext i1 %29 to i32, !dbg !153 + %31 = sext i32 %30 to i64, !dbg !153 + %32 = icmp ne i64 %31, 0, !dbg !153 + br i1 %32, label %33, label %35, !dbg !153 -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 +33: ; preds = %26 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 82, ptr noundef @.str.1) #3, !dbg !153 + unreachable, !dbg !153 + +34: ; No predecessors! + br label %36, !dbg !153 + +35: ; preds = %26 + br label %36, !dbg !153 + +36: ; preds = %35, %34 + ret i32 0, !dbg !155 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!45, !46, !47, !48, !49, !50, !51} -!llvm.ident = !{!52} +!llvm.module.flags = !{!64, !65, !66, !67, !68, !69, !70} +!llvm.ident = !{!71} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "w", scope: !2, file: !28, line: 29, type: !42, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link-short0.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "75fba3f93246ceba8ebd1225e5ca1dff") +!1 = distinct !DIGlobalVariable(name: "w", scope: !2, file: !3, line: 29, type: !61, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/rcu+ar-link-short0.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "75fba3f93246ceba8ebd1225e5ca1dff") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32, !34, !36, !38, !40} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 21, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/rcu+ar-link-short0.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "75fba3f93246ceba8ebd1225e5ca1dff") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!29 = !{!0, !30, !37, !42, !47, !49, !51, !53, !55, !57, !59} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 22, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !28, line: 24, type: !29, isLocal: false, isDefinition: true) -!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) -!35 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !28, line: 25, type: !29, isLocal: false, isDefinition: true) -!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) -!37 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !28, line: 28, type: !29, isLocal: false, isDefinition: true) -!38 = !DIGlobalVariableExpression(var: !39, expr: !DIExpression()) -!39 = distinct !DIGlobalVariable(name: "r_s", scope: !2, file: !28, line: 31, type: !29, isLocal: false, isDefinition: true) -!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) -!41 = distinct !DIGlobalVariable(name: "r_w", scope: !2, file: !28, line: 32, type: !29, isLocal: false, isDefinition: true) -!42 = !DICompositeType(tag: DW_TAG_array_type, baseType: !29, size: 64, elements: !43) -!43 = !{!44} -!44 = !DISubrange(count: 2) -!45 = !{i32 7, !"Dwarf Version", i32 5} -!46 = !{i32 2, !"Debug Info Version", i32 3} -!47 = !{i32 1, !"wchar_size", i32 4} -!48 = !{i32 7, !"PIC Level", i32 2} -!49 = !{i32 7, !"PIE Level", i32 2} -!50 = !{i32 7, !"uwtable", i32 1} -!51 = !{i32 7, !"frame-pointer", i32 2} -!52 = !{!"Ubuntu clang version 14.0.6"} -!53 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 34, type: !54, scopeLine: 35, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) -!54 = !DISubroutineType(types: !55) -!55 = !{!24, !24} -!56 = !{} -!57 = !DILocalVariable(name: "unused", arg: 1, scope: !53, file: !28, line: 34, type: !24) -!58 = !DILocation(line: 0, scope: !53) -!59 = !DILocation(line: 36, column: 2, scope: !53) -!60 = !DILocation(line: 37, column: 2, scope: !53) -!61 = !DILocation(line: 38, column: 2, scope: !53) -!62 = !DILocation(line: 39, column: 2, scope: !53) -!63 = !DILocation(line: 40, column: 2, scope: !53) -!64 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 43, type: !54, scopeLine: 44, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) -!65 = !DILocalVariable(name: "unused", arg: 1, scope: !64, file: !28, line: 43, type: !24) -!66 = !DILocation(line: 0, scope: !64) -!67 = !DILocation(line: 45, column: 6, scope: !68) -!68 = distinct !DILexicalBlock(scope: !64, file: !28, line: 45, column: 6) -!69 = !DILocation(line: 45, column: 19, scope: !68) -!70 = !DILocation(line: 45, column: 6, scope: !64) -!71 = !DILocation(line: 46, column: 3, scope: !68) -!72 = !DILocation(line: 47, column: 2, scope: !64) -!73 = distinct !DISubprogram(name: "P2", scope: !28, file: !28, line: 50, type: !54, scopeLine: 51, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) -!74 = !DILocalVariable(name: "unused", arg: 1, scope: !73, file: !28, line: 50, type: !24) -!75 = !DILocation(line: 0, scope: !73) -!76 = !DILocation(line: 52, column: 8, scope: !73) -!77 = !DILocation(line: 52, column: 6, scope: !73) -!78 = !DILocation(line: 53, column: 8, scope: !73) -!79 = !DILocation(line: 53, column: 6, scope: !73) -!80 = !DILocation(line: 54, column: 2, scope: !73) -!81 = distinct !DISubprogram(name: "P3", scope: !28, file: !28, line: 57, type: !54, scopeLine: 58, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) -!82 = !DILocalVariable(name: "unused", arg: 1, scope: !81, file: !28, line: 57, type: !24) -!83 = !DILocation(line: 0, scope: !81) -!84 = !DILocation(line: 59, column: 2, scope: !81) -!85 = !DILocation(line: 60, column: 2, scope: !81) -!86 = !DILocation(line: 61, column: 8, scope: !81) -!87 = !DILocation(line: 61, column: 6, scope: !81) -!88 = !DILocation(line: 62, column: 2, scope: !81) -!89 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 65, type: !90, scopeLine: 66, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) -!90 = !DISubroutineType(types: !91) -!91 = !{!29} -!92 = !DILocalVariable(name: "t0", scope: !89, file: !28, line: 70, type: !93) -!93 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !94, line: 27, baseType: !95) -!94 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!95 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!96 = !DILocation(line: 0, scope: !89) -!97 = !DILocation(line: 72, column: 2, scope: !89) -!98 = !DILocalVariable(name: "t1", scope: !89, file: !28, line: 70, type: !93) -!99 = !DILocation(line: 73, column: 2, scope: !89) -!100 = !DILocalVariable(name: "t2", scope: !89, file: !28, line: 70, type: !93) -!101 = !DILocation(line: 74, column: 2, scope: !89) -!102 = !DILocalVariable(name: "t3", scope: !89, file: !28, line: 70, type: !93) -!103 = !DILocation(line: 75, column: 2, scope: !89) -!104 = !DILocation(line: 77, column: 15, scope: !89) -!105 = !DILocation(line: 77, column: 2, scope: !89) -!106 = !DILocation(line: 78, column: 15, scope: !89) -!107 = !DILocation(line: 78, column: 2, scope: !89) -!108 = !DILocation(line: 79, column: 15, scope: !89) -!109 = !DILocation(line: 79, column: 2, scope: !89) -!110 = !DILocation(line: 80, column: 15, scope: !89) -!111 = !DILocation(line: 80, column: 2, scope: !89) -!112 = !DILocation(line: 82, column: 2, scope: !113) -!113 = distinct !DILexicalBlock(scope: !114, file: !28, line: 82, column: 2) -!114 = distinct !DILexicalBlock(scope: !89, file: !28, line: 82, column: 2) -!115 = !DILocation(line: 84, column: 2, scope: !89) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 82, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 82, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 168, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 21) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 82, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 288, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 36) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 21, type: !28, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 22, type: !28, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !3, line: 24, type: !28, isLocal: false, isDefinition: true) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !3, line: 25, type: !28, isLocal: false, isDefinition: true) +!55 = !DIGlobalVariableExpression(var: !56, expr: !DIExpression()) +!56 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 28, type: !28, isLocal: false, isDefinition: true) +!57 = !DIGlobalVariableExpression(var: !58, expr: !DIExpression()) +!58 = distinct !DIGlobalVariable(name: "r_s", scope: !2, file: !3, line: 31, type: !28, isLocal: false, isDefinition: true) +!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression()) +!60 = distinct !DIGlobalVariable(name: "r_w", scope: !2, file: !3, line: 32, type: !28, isLocal: false, isDefinition: true) +!61 = !DICompositeType(tag: DW_TAG_array_type, baseType: !28, size: 64, elements: !62) +!62 = !{!63} +!63 = !DISubrange(count: 2) +!64 = !{i32 7, !"Dwarf Version", i32 5} +!65 = !{i32 2, !"Debug Info Version", i32 3} +!66 = !{i32 1, !"wchar_size", i32 4} +!67 = !{i32 8, !"PIC Level", i32 2} +!68 = !{i32 7, !"PIE Level", i32 2} +!69 = !{i32 7, !"uwtable", i32 2} +!70 = !{i32 7, !"frame-pointer", i32 2} +!71 = !{!"Homebrew clang version 19.1.7"} +!72 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 34, type: !73, scopeLine: 35, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !75) +!73 = !DISubroutineType(types: !74) +!74 = !{!27, !27} +!75 = !{} +!76 = !DILocalVariable(name: "unused", arg: 1, scope: !72, file: !3, line: 34, type: !27) +!77 = !DILocation(line: 34, column: 16, scope: !72) +!78 = !DILocation(line: 36, column: 2, scope: !72) +!79 = !DILocation(line: 37, column: 2, scope: !72) +!80 = !DILocation(line: 38, column: 2, scope: !72) +!81 = !DILocation(line: 39, column: 2, scope: !72) +!82 = !DILocation(line: 40, column: 2, scope: !72) +!83 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 43, type: !73, scopeLine: 44, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !75) +!84 = !DILocalVariable(name: "unused", arg: 1, scope: !83, file: !3, line: 43, type: !27) +!85 = !DILocation(line: 43, column: 16, scope: !83) +!86 = !DILocation(line: 45, column: 6, scope: !87) +!87 = distinct !DILexicalBlock(scope: !83, file: !3, line: 45, column: 6) +!88 = !DILocation(line: 45, column: 19, scope: !87) +!89 = !DILocation(line: 45, column: 6, scope: !83) +!90 = !DILocation(line: 46, column: 3, scope: !87) +!91 = !DILocation(line: 47, column: 2, scope: !83) +!92 = distinct !DISubprogram(name: "P2", scope: !3, file: !3, line: 50, type: !73, scopeLine: 51, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !75) +!93 = !DILocalVariable(name: "unused", arg: 1, scope: !92, file: !3, line: 50, type: !27) +!94 = !DILocation(line: 50, column: 16, scope: !92) +!95 = !DILocation(line: 52, column: 8, scope: !92) +!96 = !DILocation(line: 52, column: 6, scope: !92) +!97 = !DILocation(line: 53, column: 8, scope: !92) +!98 = !DILocation(line: 53, column: 6, scope: !92) +!99 = !DILocation(line: 54, column: 2, scope: !92) +!100 = distinct !DISubprogram(name: "P3", scope: !3, file: !3, line: 57, type: !73, scopeLine: 58, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !75) +!101 = !DILocalVariable(name: "unused", arg: 1, scope: !100, file: !3, line: 57, type: !27) +!102 = !DILocation(line: 57, column: 16, scope: !100) +!103 = !DILocation(line: 59, column: 2, scope: !100) +!104 = !DILocation(line: 60, column: 2, scope: !100) +!105 = !DILocation(line: 61, column: 8, scope: !100) +!106 = !DILocation(line: 61, column: 6, scope: !100) +!107 = !DILocation(line: 62, column: 2, scope: !100) +!108 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 65, type: !109, scopeLine: 66, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !75) +!109 = !DISubroutineType(types: !110) +!110 = !{!28} +!111 = !DILocalVariable(name: "t0", scope: !108, file: !3, line: 70, type: !112) +!112 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !113, line: 31, baseType: !114) +!113 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!114 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !115, line: 118, baseType: !116) +!115 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!116 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !117, size: 64) +!117 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !115, line: 103, size: 65536, elements: !118) +!118 = !{!119, !120, !130} +!119 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !117, file: !115, line: 104, baseType: !26, size: 64) +!120 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !117, file: !115, line: 105, baseType: !121, size: 64, offset: 64) +!121 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !122, size: 64) +!122 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !115, line: 57, size: 192, elements: !123) +!123 = !{!124, !128, !129} +!124 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !122, file: !115, line: 58, baseType: !125, size: 64) +!125 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !126, size: 64) +!126 = !DISubroutineType(types: !127) +!127 = !{null, !27} +!128 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !122, file: !115, line: 59, baseType: !27, size: 64, offset: 64) +!129 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !122, file: !115, line: 60, baseType: !121, size: 64, offset: 128) +!130 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !117, file: !115, line: 106, baseType: !131, size: 65408, offset: 128) +!131 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !132) +!132 = !{!133} +!133 = !DISubrange(count: 8176) +!134 = !DILocation(line: 70, column: 12, scope: !108) +!135 = !DILocalVariable(name: "t1", scope: !108, file: !3, line: 70, type: !112) +!136 = !DILocation(line: 70, column: 16, scope: !108) +!137 = !DILocalVariable(name: "t2", scope: !108, file: !3, line: 70, type: !112) +!138 = !DILocation(line: 70, column: 20, scope: !108) +!139 = !DILocalVariable(name: "t3", scope: !108, file: !3, line: 70, type: !112) +!140 = !DILocation(line: 70, column: 24, scope: !108) +!141 = !DILocation(line: 72, column: 2, scope: !108) +!142 = !DILocation(line: 73, column: 2, scope: !108) +!143 = !DILocation(line: 74, column: 2, scope: !108) +!144 = !DILocation(line: 75, column: 2, scope: !108) +!145 = !DILocation(line: 77, column: 15, scope: !108) +!146 = !DILocation(line: 77, column: 2, scope: !108) +!147 = !DILocation(line: 78, column: 15, scope: !108) +!148 = !DILocation(line: 78, column: 2, scope: !108) +!149 = !DILocation(line: 79, column: 15, scope: !108) +!150 = !DILocation(line: 79, column: 2, scope: !108) +!151 = !DILocation(line: 80, column: 15, scope: !108) +!152 = !DILocation(line: 80, column: 2, scope: !108) +!153 = !DILocation(line: 82, column: 2, scope: !108) +!154 = !DILocation(line: 0, scope: !108) +!155 = !DILocation(line: 84, column: 2, scope: !108) diff --git a/dartagnan/src/test/resources/lkmm/rcu+ar-link0.ll b/dartagnan/src/test/resources/lkmm/rcu+ar-link0.ll index e0d93258da..dcf9bba725 100644 --- a/dartagnan/src/test/resources/lkmm/rcu+ar-link0.ll +++ b/dartagnan/src/test/resources/lkmm/rcu+ar-link0.ll @@ -1,336 +1,411 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/rcu+ar-link0.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link0.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/rcu+ar-link0.c' +source_filename = "benchmarks/lkmm/rcu+ar-link0.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global i32 0, align 4, !dbg !26 -@r_y = dso_local global i32 0, align 4, !dbg !32 -@s = dso_local global i32 0, align 4, !dbg !34 -@r_s = dso_local global i32 0, align 4, !dbg !46 -@w = dso_local global i32 0, align 4, !dbg !36 -@z = dso_local global i32 0, align 4, !dbg !38 -@a = dso_local global i32 0, align 4, !dbg !40 -@r_a = dso_local global i32 0, align 4, !dbg !48 -@b = dso_local global i32 0, align 4, !dbg !42 -@r_b = dso_local global i32 0, align 4, !dbg !50 -@c = dso_local global i32 0, align 4, !dbg !44 -@r_c = dso_local global i32 0, align 4, !dbg !52 -@.str = private unnamed_addr constant [60 x i8] c"!(r_y == 1 && r_s == 1 && r_a == 1 && r_b == 1 && r_c == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [53 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link0.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 -@r_x = dso_local global i32 0, align 4, !dbg !30 +@y = dso_local global i32 0, align 4, !dbg !47 +@r_y = dso_local global i32 0, align 4, !dbg !51 +@s = dso_local global i32 0, align 4, !dbg !53 +@r_s = dso_local global i32 0, align 4, !dbg !65 +@w = dso_local global i32 0, align 4, !dbg !55 +@z = dso_local global i32 0, align 4, !dbg !57 +@a = dso_local global i32 0, align 4, !dbg !59 +@r_a = dso_local global i32 0, align 4, !dbg !67 +@b = dso_local global i32 0, align 4, !dbg !61 +@r_b = dso_local global i32 0, align 4, !dbg !69 +@c = dso_local global i32 0, align 4, !dbg !63 +@r_c = dso_local global i32 0, align 4, !dbg !71 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [15 x i8] c"rcu+ar-link0.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [60 x i8] c"!(r_y == 1 && r_s == 1 && r_a == 1 && r_b == 1 && r_c == 1)\00", align 1, !dbg !42 +@r_x = dso_local global i32 0, align 4, !dbg !49 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !62 { - call void @llvm.dbg.value(metadata i8* %0, metadata !66, metadata !DIExpression()), !dbg !67 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !68 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !69 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !70 - store i32 %2, i32* @r_y, align 4, !dbg !71 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !72 - ret i8* null, !dbg !73 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !81 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !85, !DIExpression(), !86) + call void @__LKMM_fence(i32 noundef 6), !dbg !87 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !88 + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !89 + %4 = trunc i64 %3 to i32, !dbg !89 + store i32 %4, ptr @r_y, align 4, !dbg !90 + call void @__LKMM_fence(i32 noundef 7), !dbg !91 + ret ptr null, !dbg !92 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !74 { - call void @llvm.dbg.value(metadata i8* %0, metadata !75, metadata !DIExpression()), !dbg !76 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !77 - %3 = icmp eq i32 %2, 1, !dbg !79 - br i1 %3, label %4, label %5, !dbg !80 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !93 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !94, !DIExpression(), !95) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !96 + %4 = trunc i64 %3 to i32, !dbg !96 + %5 = icmp eq i32 %4, 1, !dbg !98 + br i1 %5, label %6, label %7, !dbg !99 -4: ; preds = %1 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @s to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !81 - br label %5, !dbg !81 +6: ; preds = %1 + call void @__LKMM_store(ptr noundef @s, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !100 + br label %7, !dbg !100 -5: ; preds = %4, %1 - ret i8* null, !dbg !82 +7: ; preds = %6, %1 + ret ptr null, !dbg !101 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P2(i8* noundef %0) #0 !dbg !83 { - call void @llvm.dbg.value(metadata i8* %0, metadata !84, metadata !DIExpression()), !dbg !85 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @s to i8*), i32 noundef 1) #5, !dbg !86 - store i32 %2, i32* @r_s, align 4, !dbg !87 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @w to i8*), i32 noundef 1, i32 noundef 3) #5, !dbg !88 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @z to i8*), i32 noundef 1) #5, !dbg !89 - call void @llvm.dbg.value(metadata i32 %3, metadata !90, metadata !DIExpression()), !dbg !85 - %4 = add nsw i32 %3, 1, !dbg !91 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @a to i8*), i32 noundef %4, i32 noundef 1) #5, !dbg !91 - ret i8* null, !dbg !92 +define dso_local ptr @P2(ptr noundef %0) #0 !dbg !102 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !103, !DIExpression(), !104) + %4 = call i64 @__LKMM_load(ptr noundef @s, i64 noundef 4, i32 noundef 0), !dbg !105 + %5 = trunc i64 %4 to i32, !dbg !105 + store i32 %5, ptr @r_s, align 4, !dbg !106 + call void @__LKMM_store(ptr noundef @w, i64 noundef 4, i64 noundef 1, i32 noundef 2), !dbg !107 + #dbg_declare(ptr %3, !108, !DIExpression(), !109) + %6 = call i64 @__LKMM_load(ptr noundef @z, i64 noundef 4, i32 noundef 0), !dbg !110 + %7 = trunc i64 %6 to i32, !dbg !110 + store i32 %7, ptr %3, align 4, !dbg !109 + %8 = load i32, ptr %3, align 4, !dbg !111 + %9 = add nsw i32 %8, 1, !dbg !111 + %10 = sext i32 %9 to i64, !dbg !111 + call void @__LKMM_store(ptr noundef @a, i64 noundef 4, i64 noundef %10, i32 noundef 0), !dbg !111 + ret ptr null, !dbg !112 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P3(i8* noundef %0) #0 !dbg !93 { - call void @llvm.dbg.value(metadata i8* %0, metadata !94, metadata !DIExpression()), !dbg !95 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @a to i8*), i32 noundef 1) #5, !dbg !96 - store i32 %2, i32* @r_a, align 4, !dbg !97 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @b to i8*), i32 noundef %2, i32 noundef 1) #5, !dbg !98 - ret i8* null, !dbg !99 +define dso_local ptr @P3(ptr noundef %0) #0 !dbg !113 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !114, !DIExpression(), !115) + %3 = call i64 @__LKMM_load(ptr noundef @a, i64 noundef 4, i32 noundef 0), !dbg !116 + %4 = trunc i64 %3 to i32, !dbg !116 + store i32 %4, ptr @r_a, align 4, !dbg !117 + %5 = load i32, ptr @r_a, align 4, !dbg !118 + %6 = sext i32 %5 to i64, !dbg !118 + call void @__LKMM_store(ptr noundef @b, i64 noundef 4, i64 noundef %6, i32 noundef 0), !dbg !118 + ret ptr null, !dbg !119 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P4(i8* noundef %0) #0 !dbg !100 { - call void @llvm.dbg.value(metadata i8* %0, metadata !101, metadata !DIExpression()), !dbg !102 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @b to i8*), i32 noundef 1) #5, !dbg !103 - store i32 %2, i32* @r_b, align 4, !dbg !104 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @c to i8*), i32 noundef 1, i32 noundef 3) #5, !dbg !105 - ret i8* null, !dbg !106 +define dso_local ptr @P4(ptr noundef %0) #0 !dbg !120 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !121, !DIExpression(), !122) + %3 = call i64 @__LKMM_load(ptr noundef @b, i64 noundef 4, i32 noundef 0), !dbg !123 + %4 = trunc i64 %3 to i32, !dbg !123 + store i32 %4, ptr @r_b, align 4, !dbg !124 + call void @__LKMM_store(ptr noundef @c, i64 noundef 4, i64 noundef 1, i32 noundef 2), !dbg !125 + ret ptr null, !dbg !126 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P5(i8* noundef %0) #0 !dbg !107 { - call void @llvm.dbg.value(metadata i8* %0, metadata !108, metadata !DIExpression()), !dbg !109 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @c to i8*), i32 noundef 1) #5, !dbg !110 - store i32 %2, i32* @r_c, align 4, !dbg !111 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !112 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !113 - ret i8* null, !dbg !114 +define dso_local ptr @P5(ptr noundef %0) #0 !dbg !127 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !128, !DIExpression(), !129) + %3 = call i64 @__LKMM_load(ptr noundef @c, i64 noundef 4, i32 noundef 0), !dbg !130 + %4 = trunc i64 %3 to i32, !dbg !130 + store i32 %4, ptr @r_c, align 4, !dbg !131 + call void @__LKMM_fence(i32 noundef 8), !dbg !132 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !133 + ret ptr null, !dbg !134 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !115 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - %4 = alloca i64, align 8 - %5 = alloca i64, align 8 - %6 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !118, metadata !DIExpression(DW_OP_deref)), !dbg !122 - %7 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !123 - call void @llvm.dbg.value(metadata i64* %2, metadata !124, metadata !DIExpression(DW_OP_deref)), !dbg !122 - %8 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !125 - call void @llvm.dbg.value(metadata i64* %3, metadata !126, metadata !DIExpression(DW_OP_deref)), !dbg !122 - %9 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P2, i8* noundef null) #5, !dbg !127 - call void @llvm.dbg.value(metadata i64* %4, metadata !128, metadata !DIExpression(DW_OP_deref)), !dbg !122 - %10 = call i32 @pthread_create(i64* noundef nonnull %4, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P3, i8* noundef null) #5, !dbg !129 - call void @llvm.dbg.value(metadata i64* %5, metadata !130, metadata !DIExpression(DW_OP_deref)), !dbg !122 - %11 = call i32 @pthread_create(i64* noundef nonnull %5, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P4, i8* noundef null) #5, !dbg !131 - call void @llvm.dbg.value(metadata i64* %6, metadata !132, metadata !DIExpression(DW_OP_deref)), !dbg !122 - %12 = call i32 @pthread_create(i64* noundef nonnull %6, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P5, i8* noundef null) #5, !dbg !133 - %13 = load i64, i64* %1, align 8, !dbg !134 - call void @llvm.dbg.value(metadata i64 %13, metadata !118, metadata !DIExpression()), !dbg !122 - %14 = call i32 @pthread_join(i64 noundef %13, i8** noundef null) #5, !dbg !135 - %15 = load i64, i64* %2, align 8, !dbg !136 - call void @llvm.dbg.value(metadata i64 %15, metadata !124, metadata !DIExpression()), !dbg !122 - %16 = call i32 @pthread_join(i64 noundef %15, i8** noundef null) #5, !dbg !137 - %17 = load i64, i64* %3, align 8, !dbg !138 - call void @llvm.dbg.value(metadata i64 %17, metadata !126, metadata !DIExpression()), !dbg !122 - %18 = call i32 @pthread_join(i64 noundef %17, i8** noundef null) #5, !dbg !139 - %19 = load i64, i64* %4, align 8, !dbg !140 - call void @llvm.dbg.value(metadata i64 %19, metadata !128, metadata !DIExpression()), !dbg !122 - %20 = call i32 @pthread_join(i64 noundef %19, i8** noundef null) #5, !dbg !141 - %21 = load i64, i64* %5, align 8, !dbg !142 - call void @llvm.dbg.value(metadata i64 %21, metadata !130, metadata !DIExpression()), !dbg !122 - %22 = call i32 @pthread_join(i64 noundef %21, i8** noundef null) #5, !dbg !143 - %23 = load i64, i64* %6, align 8, !dbg !144 - call void @llvm.dbg.value(metadata i64 %23, metadata !132, metadata !DIExpression()), !dbg !122 - %24 = call i32 @pthread_join(i64 noundef %23, i8** noundef null) #5, !dbg !145 - %25 = load i32, i32* @r_y, align 4, !dbg !146 - %26 = icmp eq i32 %25, 1, !dbg !146 - %27 = load i32, i32* @r_s, align 4, !dbg !146 - %28 = icmp eq i32 %27, 1, !dbg !146 - %or.cond = select i1 %26, i1 %28, i1 false, !dbg !146 - %29 = load i32, i32* @r_a, align 4, !dbg !146 - %30 = icmp eq i32 %29, 1, !dbg !146 - %or.cond3 = select i1 %or.cond, i1 %30, i1 false, !dbg !146 - %31 = load i32, i32* @r_b, align 4, !dbg !146 - %32 = icmp eq i32 %31, 1, !dbg !146 - %or.cond5 = select i1 %or.cond3, i1 %32, i1 false, !dbg !146 - %33 = load i32, i32* @r_c, align 4, !dbg !146 - %34 = icmp eq i32 %33, 1, !dbg !146 - %or.cond7 = select i1 %or.cond5, i1 %34, i1 false, !dbg !146 - br i1 %or.cond7, label %35, label %36, !dbg !146 +define dso_local i32 @main() #0 !dbg !135 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + %5 = alloca ptr, align 8 + %6 = alloca ptr, align 8 + %7 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !138, !DIExpression(), !161) + #dbg_declare(ptr %3, !162, !DIExpression(), !163) + #dbg_declare(ptr %4, !164, !DIExpression(), !165) + #dbg_declare(ptr %5, !166, !DIExpression(), !167) + #dbg_declare(ptr %6, !168, !DIExpression(), !169) + #dbg_declare(ptr %7, !170, !DIExpression(), !171) + %8 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !172 + %9 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !173 + %10 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @P2, ptr noundef null), !dbg !174 + %11 = call i32 @pthread_create(ptr noundef %5, ptr noundef null, ptr noundef @P3, ptr noundef null), !dbg !175 + %12 = call i32 @pthread_create(ptr noundef %6, ptr noundef null, ptr noundef @P4, ptr noundef null), !dbg !176 + %13 = call i32 @pthread_create(ptr noundef %7, ptr noundef null, ptr noundef @P5, ptr noundef null), !dbg !177 + %14 = load ptr, ptr %2, align 8, !dbg !178 + %15 = call i32 @_pthread_join(ptr noundef %14, ptr noundef null), !dbg !179 + %16 = load ptr, ptr %3, align 8, !dbg !180 + %17 = call i32 @_pthread_join(ptr noundef %16, ptr noundef null), !dbg !181 + %18 = load ptr, ptr %4, align 8, !dbg !182 + %19 = call i32 @_pthread_join(ptr noundef %18, ptr noundef null), !dbg !183 + %20 = load ptr, ptr %5, align 8, !dbg !184 + %21 = call i32 @_pthread_join(ptr noundef %20, ptr noundef null), !dbg !185 + %22 = load ptr, ptr %6, align 8, !dbg !186 + %23 = call i32 @_pthread_join(ptr noundef %22, ptr noundef null), !dbg !187 + %24 = load ptr, ptr %7, align 8, !dbg !188 + %25 = call i32 @_pthread_join(ptr noundef %24, ptr noundef null), !dbg !189 + %26 = load i32, ptr @r_y, align 4, !dbg !190 + %27 = icmp eq i32 %26, 1, !dbg !190 + br i1 %27, label %28, label %40, !dbg !190 -35: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 noundef 105, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !146 - unreachable, !dbg !146 +28: ; preds = %0 + %29 = load i32, ptr @r_s, align 4, !dbg !190 + %30 = icmp eq i32 %29, 1, !dbg !190 + br i1 %30, label %31, label %40, !dbg !190 -36: ; preds = %0 - ret i32 0, !dbg !149 -} +31: ; preds = %28 + %32 = load i32, ptr @r_a, align 4, !dbg !190 + %33 = icmp eq i32 %32, 1, !dbg !190 + br i1 %33, label %34, label %40, !dbg !190 + +34: ; preds = %31 + %35 = load i32, ptr @r_b, align 4, !dbg !190 + %36 = icmp eq i32 %35, 1, !dbg !190 + br i1 %36, label %37, label %40, !dbg !190 + +37: ; preds = %34 + %38 = load i32, ptr @r_c, align 4, !dbg !190 + %39 = icmp eq i32 %38, 1, !dbg !190 + br label %40 -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 +40: ; preds = %37, %34, %31, %28, %0 + %41 = phi i1 [ false, %34 ], [ false, %31 ], [ false, %28 ], [ false, %0 ], [ %39, %37 ], !dbg !191 + %42 = xor i1 %41, true, !dbg !190 + %43 = xor i1 %42, true, !dbg !190 + %44 = zext i1 %43 to i32, !dbg !190 + %45 = sext i32 %44 to i64, !dbg !190 + %46 = icmp ne i64 %45, 0, !dbg !190 + br i1 %46, label %47, label %49, !dbg !190 + +47: ; preds = %40 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 105, ptr noundef @.str.1) #3, !dbg !190 + unreachable, !dbg !190 + +48: ; No predecessors! + br label %50, !dbg !190 + +49: ; preds = %40 + br label %50, !dbg !190 + +50: ; preds = %49, %48 + ret i32 0, !dbg !192 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!54, !55, !56, !57, !58, !59, !60} -!llvm.ident = !{!61} +!llvm.module.flags = !{!73, !74, !75, !76, !77, !78, !79} +!llvm.ident = !{!80} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 16, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link0.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "6b13efe8b5bb64ba02860a374c43853f") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 16, type: !27, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/rcu+ar-link0.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "6b13efe8b5bb64ba02860a374c43853f") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32, !34, !36, !38, !40, !42, !44, !46, !48, !50, !52} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 17, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/rcu+ar-link0.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "6b13efe8b5bb64ba02860a374c43853f") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47, !49, !51, !53, !55, !57, !59, !61, !63, !65, !67, !69, !71} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !28, line: 19, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !28, line: 20, type: !29, isLocal: false, isDefinition: true) -!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) -!35 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !28, line: 23, type: !29, isLocal: false, isDefinition: true) -!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) -!37 = distinct !DIGlobalVariable(name: "w", scope: !2, file: !28, line: 24, type: !29, isLocal: false, isDefinition: true) -!38 = !DIGlobalVariableExpression(var: !39, expr: !DIExpression()) -!39 = distinct !DIGlobalVariable(name: "z", scope: !2, file: !28, line: 25, type: !29, isLocal: false, isDefinition: true) -!40 = !DIGlobalVariableExpression(var: !41, expr: !DIExpression()) -!41 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !28, line: 27, type: !29, isLocal: false, isDefinition: true) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 105, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 105, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 120, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 15) !42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) -!43 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !28, line: 28, type: !29, isLocal: false, isDefinition: true) -!44 = !DIGlobalVariableExpression(var: !45, expr: !DIExpression()) -!45 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !28, line: 29, type: !29, isLocal: false, isDefinition: true) -!46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression()) -!47 = distinct !DIGlobalVariable(name: "r_s", scope: !2, file: !28, line: 31, type: !29, isLocal: false, isDefinition: true) -!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) -!49 = distinct !DIGlobalVariable(name: "r_a", scope: !2, file: !28, line: 32, type: !29, isLocal: false, isDefinition: true) -!50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression()) -!51 = distinct !DIGlobalVariable(name: "r_b", scope: !2, file: !28, line: 33, type: !29, isLocal: false, isDefinition: true) -!52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression()) -!53 = distinct !DIGlobalVariable(name: "r_c", scope: !2, file: !28, line: 34, type: !29, isLocal: false, isDefinition: true) -!54 = !{i32 7, !"Dwarf Version", i32 5} -!55 = !{i32 2, !"Debug Info Version", i32 3} -!56 = !{i32 1, !"wchar_size", i32 4} -!57 = !{i32 7, !"PIC Level", i32 2} -!58 = !{i32 7, !"PIE Level", i32 2} -!59 = !{i32 7, !"uwtable", i32 1} -!60 = !{i32 7, !"frame-pointer", i32 2} -!61 = !{!"Ubuntu clang version 14.0.6"} -!62 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 36, type: !63, scopeLine: 37, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!63 = !DISubroutineType(types: !64) -!64 = !{!24, !24} -!65 = !{} -!66 = !DILocalVariable(name: "unused", arg: 1, scope: !62, file: !28, line: 36, type: !24) -!67 = !DILocation(line: 0, scope: !62) -!68 = !DILocation(line: 38, column: 2, scope: !62) -!69 = !DILocation(line: 39, column: 2, scope: !62) -!70 = !DILocation(line: 40, column: 8, scope: !62) -!71 = !DILocation(line: 40, column: 6, scope: !62) -!72 = !DILocation(line: 41, column: 2, scope: !62) -!73 = !DILocation(line: 42, column: 2, scope: !62) -!74 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 45, type: !63, scopeLine: 46, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!75 = !DILocalVariable(name: "unused", arg: 1, scope: !74, file: !28, line: 45, type: !24) -!76 = !DILocation(line: 0, scope: !74) -!77 = !DILocation(line: 47, column: 6, scope: !78) -!78 = distinct !DILexicalBlock(scope: !74, file: !28, line: 47, column: 6) -!79 = !DILocation(line: 47, column: 19, scope: !78) -!80 = !DILocation(line: 47, column: 6, scope: !74) -!81 = !DILocation(line: 48, column: 3, scope: !78) -!82 = !DILocation(line: 49, column: 2, scope: !74) -!83 = distinct !DISubprogram(name: "P2", scope: !28, file: !28, line: 52, type: !63, scopeLine: 53, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!84 = !DILocalVariable(name: "unused", arg: 1, scope: !83, file: !28, line: 52, type: !24) -!85 = !DILocation(line: 0, scope: !83) -!86 = !DILocation(line: 54, column: 8, scope: !83) -!87 = !DILocation(line: 54, column: 6, scope: !83) -!88 = !DILocation(line: 55, column: 2, scope: !83) -!89 = !DILocation(line: 57, column: 10, scope: !83) -!90 = !DILocalVariable(name: "r", scope: !83, file: !28, line: 57, type: !29) -!91 = !DILocation(line: 58, column: 2, scope: !83) -!92 = !DILocation(line: 59, column: 2, scope: !83) -!93 = distinct !DISubprogram(name: "P3", scope: !28, file: !28, line: 62, type: !63, scopeLine: 63, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!94 = !DILocalVariable(name: "unused", arg: 1, scope: !93, file: !28, line: 62, type: !24) -!95 = !DILocation(line: 0, scope: !93) -!96 = !DILocation(line: 64, column: 8, scope: !93) -!97 = !DILocation(line: 64, column: 6, scope: !93) -!98 = !DILocation(line: 65, column: 2, scope: !93) -!99 = !DILocation(line: 66, column: 2, scope: !93) -!100 = distinct !DISubprogram(name: "P4", scope: !28, file: !28, line: 69, type: !63, scopeLine: 70, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!101 = !DILocalVariable(name: "unused", arg: 1, scope: !100, file: !28, line: 69, type: !24) -!102 = !DILocation(line: 0, scope: !100) -!103 = !DILocation(line: 71, column: 8, scope: !100) -!104 = !DILocation(line: 71, column: 6, scope: !100) -!105 = !DILocation(line: 72, column: 2, scope: !100) -!106 = !DILocation(line: 73, column: 2, scope: !100) -!107 = distinct !DISubprogram(name: "P5", scope: !28, file: !28, line: 76, type: !63, scopeLine: 77, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!108 = !DILocalVariable(name: "unused", arg: 1, scope: !107, file: !28, line: 76, type: !24) -!109 = !DILocation(line: 0, scope: !107) -!110 = !DILocation(line: 78, column: 8, scope: !107) -!111 = !DILocation(line: 78, column: 6, scope: !107) -!112 = !DILocation(line: 79, column: 2, scope: !107) -!113 = !DILocation(line: 80, column: 2, scope: !107) -!114 = !DILocation(line: 81, column: 2, scope: !107) -!115 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 84, type: !116, scopeLine: 85, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !65) -!116 = !DISubroutineType(types: !117) -!117 = !{!29} -!118 = !DILocalVariable(name: "t0", scope: !115, file: !28, line: 89, type: !119) -!119 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !120, line: 27, baseType: !121) -!120 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!121 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!122 = !DILocation(line: 0, scope: !115) -!123 = !DILocation(line: 91, column: 2, scope: !115) -!124 = !DILocalVariable(name: "t1", scope: !115, file: !28, line: 89, type: !119) -!125 = !DILocation(line: 92, column: 2, scope: !115) -!126 = !DILocalVariable(name: "t2", scope: !115, file: !28, line: 89, type: !119) -!127 = !DILocation(line: 93, column: 2, scope: !115) -!128 = !DILocalVariable(name: "t3", scope: !115, file: !28, line: 89, type: !119) -!129 = !DILocation(line: 94, column: 2, scope: !115) -!130 = !DILocalVariable(name: "t4", scope: !115, file: !28, line: 89, type: !119) -!131 = !DILocation(line: 95, column: 2, scope: !115) -!132 = !DILocalVariable(name: "t5", scope: !115, file: !28, line: 89, type: !119) -!133 = !DILocation(line: 96, column: 2, scope: !115) -!134 = !DILocation(line: 98, column: 15, scope: !115) -!135 = !DILocation(line: 98, column: 2, scope: !115) -!136 = !DILocation(line: 99, column: 15, scope: !115) -!137 = !DILocation(line: 99, column: 2, scope: !115) -!138 = !DILocation(line: 100, column: 15, scope: !115) -!139 = !DILocation(line: 100, column: 2, scope: !115) -!140 = !DILocation(line: 101, column: 15, scope: !115) -!141 = !DILocation(line: 101, column: 2, scope: !115) -!142 = !DILocation(line: 102, column: 15, scope: !115) -!143 = !DILocation(line: 102, column: 2, scope: !115) -!144 = !DILocation(line: 103, column: 15, scope: !115) -!145 = !DILocation(line: 103, column: 2, scope: !115) -!146 = !DILocation(line: 105, column: 2, scope: !147) -!147 = distinct !DILexicalBlock(scope: !148, file: !28, line: 105, column: 2) -!148 = distinct !DILexicalBlock(scope: !115, file: !28, line: 105, column: 2) -!149 = !DILocation(line: 107, column: 2, scope: !115) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 105, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 480, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 60) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 17, type: !27, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !3, line: 19, type: !27, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !3, line: 20, type: !27, isLocal: false, isDefinition: true) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 23, type: !27, isLocal: false, isDefinition: true) +!55 = !DIGlobalVariableExpression(var: !56, expr: !DIExpression()) +!56 = distinct !DIGlobalVariable(name: "w", scope: !2, file: !3, line: 24, type: !27, isLocal: false, isDefinition: true) +!57 = !DIGlobalVariableExpression(var: !58, expr: !DIExpression()) +!58 = distinct !DIGlobalVariable(name: "z", scope: !2, file: !3, line: 25, type: !27, isLocal: false, isDefinition: true) +!59 = !DIGlobalVariableExpression(var: !60, expr: !DIExpression()) +!60 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 27, type: !27, isLocal: false, isDefinition: true) +!61 = !DIGlobalVariableExpression(var: !62, expr: !DIExpression()) +!62 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 28, type: !27, isLocal: false, isDefinition: true) +!63 = !DIGlobalVariableExpression(var: !64, expr: !DIExpression()) +!64 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 29, type: !27, isLocal: false, isDefinition: true) +!65 = !DIGlobalVariableExpression(var: !66, expr: !DIExpression()) +!66 = distinct !DIGlobalVariable(name: "r_s", scope: !2, file: !3, line: 31, type: !27, isLocal: false, isDefinition: true) +!67 = !DIGlobalVariableExpression(var: !68, expr: !DIExpression()) +!68 = distinct !DIGlobalVariable(name: "r_a", scope: !2, file: !3, line: 32, type: !27, isLocal: false, isDefinition: true) +!69 = !DIGlobalVariableExpression(var: !70, expr: !DIExpression()) +!70 = distinct !DIGlobalVariable(name: "r_b", scope: !2, file: !3, line: 33, type: !27, isLocal: false, isDefinition: true) +!71 = !DIGlobalVariableExpression(var: !72, expr: !DIExpression()) +!72 = distinct !DIGlobalVariable(name: "r_c", scope: !2, file: !3, line: 34, type: !27, isLocal: false, isDefinition: true) +!73 = !{i32 7, !"Dwarf Version", i32 5} +!74 = !{i32 2, !"Debug Info Version", i32 3} +!75 = !{i32 1, !"wchar_size", i32 4} +!76 = !{i32 8, !"PIC Level", i32 2} +!77 = !{i32 7, !"PIE Level", i32 2} +!78 = !{i32 7, !"uwtable", i32 2} +!79 = !{i32 7, !"frame-pointer", i32 2} +!80 = !{!"Homebrew clang version 19.1.7"} +!81 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 36, type: !82, scopeLine: 37, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!82 = !DISubroutineType(types: !83) +!83 = !{!28, !28} +!84 = !{} +!85 = !DILocalVariable(name: "unused", arg: 1, scope: !81, file: !3, line: 36, type: !28) +!86 = !DILocation(line: 36, column: 16, scope: !81) +!87 = !DILocation(line: 38, column: 2, scope: !81) +!88 = !DILocation(line: 39, column: 2, scope: !81) +!89 = !DILocation(line: 40, column: 8, scope: !81) +!90 = !DILocation(line: 40, column: 6, scope: !81) +!91 = !DILocation(line: 41, column: 2, scope: !81) +!92 = !DILocation(line: 42, column: 2, scope: !81) +!93 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 45, type: !82, scopeLine: 46, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!94 = !DILocalVariable(name: "unused", arg: 1, scope: !93, file: !3, line: 45, type: !28) +!95 = !DILocation(line: 45, column: 16, scope: !93) +!96 = !DILocation(line: 47, column: 6, scope: !97) +!97 = distinct !DILexicalBlock(scope: !93, file: !3, line: 47, column: 6) +!98 = !DILocation(line: 47, column: 19, scope: !97) +!99 = !DILocation(line: 47, column: 6, scope: !93) +!100 = !DILocation(line: 48, column: 3, scope: !97) +!101 = !DILocation(line: 49, column: 2, scope: !93) +!102 = distinct !DISubprogram(name: "P2", scope: !3, file: !3, line: 52, type: !82, scopeLine: 53, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!103 = !DILocalVariable(name: "unused", arg: 1, scope: !102, file: !3, line: 52, type: !28) +!104 = !DILocation(line: 52, column: 16, scope: !102) +!105 = !DILocation(line: 54, column: 8, scope: !102) +!106 = !DILocation(line: 54, column: 6, scope: !102) +!107 = !DILocation(line: 55, column: 2, scope: !102) +!108 = !DILocalVariable(name: "r", scope: !102, file: !3, line: 57, type: !27) +!109 = !DILocation(line: 57, column: 6, scope: !102) +!110 = !DILocation(line: 57, column: 10, scope: !102) +!111 = !DILocation(line: 58, column: 2, scope: !102) +!112 = !DILocation(line: 59, column: 2, scope: !102) +!113 = distinct !DISubprogram(name: "P3", scope: !3, file: !3, line: 62, type: !82, scopeLine: 63, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!114 = !DILocalVariable(name: "unused", arg: 1, scope: !113, file: !3, line: 62, type: !28) +!115 = !DILocation(line: 62, column: 16, scope: !113) +!116 = !DILocation(line: 64, column: 8, scope: !113) +!117 = !DILocation(line: 64, column: 6, scope: !113) +!118 = !DILocation(line: 65, column: 2, scope: !113) +!119 = !DILocation(line: 66, column: 2, scope: !113) +!120 = distinct !DISubprogram(name: "P4", scope: !3, file: !3, line: 69, type: !82, scopeLine: 70, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!121 = !DILocalVariable(name: "unused", arg: 1, scope: !120, file: !3, line: 69, type: !28) +!122 = !DILocation(line: 69, column: 16, scope: !120) +!123 = !DILocation(line: 71, column: 8, scope: !120) +!124 = !DILocation(line: 71, column: 6, scope: !120) +!125 = !DILocation(line: 72, column: 2, scope: !120) +!126 = !DILocation(line: 73, column: 2, scope: !120) +!127 = distinct !DISubprogram(name: "P5", scope: !3, file: !3, line: 76, type: !82, scopeLine: 77, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!128 = !DILocalVariable(name: "unused", arg: 1, scope: !127, file: !3, line: 76, type: !28) +!129 = !DILocation(line: 76, column: 16, scope: !127) +!130 = !DILocation(line: 78, column: 8, scope: !127) +!131 = !DILocation(line: 78, column: 6, scope: !127) +!132 = !DILocation(line: 79, column: 2, scope: !127) +!133 = !DILocation(line: 80, column: 2, scope: !127) +!134 = !DILocation(line: 81, column: 2, scope: !127) +!135 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 84, type: !136, scopeLine: 85, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +!136 = !DISubroutineType(types: !137) +!137 = !{!27} +!138 = !DILocalVariable(name: "t0", scope: !135, file: !3, line: 89, type: !139) +!139 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !140, line: 31, baseType: !141) +!140 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!141 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !142, line: 118, baseType: !143) +!142 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!143 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !144, size: 64) +!144 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !142, line: 103, size: 65536, elements: !145) +!145 = !{!146, !147, !157} +!146 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !144, file: !142, line: 104, baseType: !26, size: 64) +!147 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !144, file: !142, line: 105, baseType: !148, size: 64, offset: 64) +!148 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !149, size: 64) +!149 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !142, line: 57, size: 192, elements: !150) +!150 = !{!151, !155, !156} +!151 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !149, file: !142, line: 58, baseType: !152, size: 64) +!152 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !153, size: 64) +!153 = !DISubroutineType(types: !154) +!154 = !{null, !28} +!155 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !149, file: !142, line: 59, baseType: !28, size: 64, offset: 64) +!156 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !149, file: !142, line: 60, baseType: !148, size: 64, offset: 128) +!157 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !144, file: !142, line: 106, baseType: !158, size: 65408, offset: 128) +!158 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !159) +!159 = !{!160} +!160 = !DISubrange(count: 8176) +!161 = !DILocation(line: 89, column: 12, scope: !135) +!162 = !DILocalVariable(name: "t1", scope: !135, file: !3, line: 89, type: !139) +!163 = !DILocation(line: 89, column: 16, scope: !135) +!164 = !DILocalVariable(name: "t2", scope: !135, file: !3, line: 89, type: !139) +!165 = !DILocation(line: 89, column: 20, scope: !135) +!166 = !DILocalVariable(name: "t3", scope: !135, file: !3, line: 89, type: !139) +!167 = !DILocation(line: 89, column: 24, scope: !135) +!168 = !DILocalVariable(name: "t4", scope: !135, file: !3, line: 89, type: !139) +!169 = !DILocation(line: 89, column: 28, scope: !135) +!170 = !DILocalVariable(name: "t5", scope: !135, file: !3, line: 89, type: !139) +!171 = !DILocation(line: 89, column: 32, scope: !135) +!172 = !DILocation(line: 91, column: 2, scope: !135) +!173 = !DILocation(line: 92, column: 2, scope: !135) +!174 = !DILocation(line: 93, column: 2, scope: !135) +!175 = !DILocation(line: 94, column: 2, scope: !135) +!176 = !DILocation(line: 95, column: 2, scope: !135) +!177 = !DILocation(line: 96, column: 2, scope: !135) +!178 = !DILocation(line: 98, column: 15, scope: !135) +!179 = !DILocation(line: 98, column: 2, scope: !135) +!180 = !DILocation(line: 99, column: 15, scope: !135) +!181 = !DILocation(line: 99, column: 2, scope: !135) +!182 = !DILocation(line: 100, column: 15, scope: !135) +!183 = !DILocation(line: 100, column: 2, scope: !135) +!184 = !DILocation(line: 101, column: 15, scope: !135) +!185 = !DILocation(line: 101, column: 2, scope: !135) +!186 = !DILocation(line: 102, column: 15, scope: !135) +!187 = !DILocation(line: 102, column: 2, scope: !135) +!188 = !DILocation(line: 103, column: 15, scope: !135) +!189 = !DILocation(line: 103, column: 2, scope: !135) +!190 = !DILocation(line: 105, column: 2, scope: !135) +!191 = !DILocation(line: 0, scope: !135) +!192 = !DILocation(line: 107, column: 2, scope: !135) diff --git a/dartagnan/src/test/resources/lkmm/rcu+ar-link20.ll b/dartagnan/src/test/resources/lkmm/rcu+ar-link20.ll index 2e0ff253b1..85c5dd34d1 100644 --- a/dartagnan/src/test/resources/lkmm/rcu+ar-link20.ll +++ b/dartagnan/src/test/resources/lkmm/rcu+ar-link20.ll @@ -1,257 +1,320 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/rcu+ar-link20.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link20.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/rcu+ar-link20.c' +source_filename = "benchmarks/lkmm/rcu+ar-link20.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global i32 0, align 4, !dbg !26 -@r0 = dso_local global i32 0, align 4, !dbg !34 -@s = dso_local global i32 0, align 4, !dbg !32 -@r2 = dso_local global i32 0, align 4, !dbg !36 -@a = dso_local global i32 0, align 4, !dbg !30 -@.str = private unnamed_addr constant [42 x i8] c"!(r0 == 1 && r2 == 1 && a == 1 && x == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [54 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link20.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 -@r6 = dso_local global i32 0, align 4, !dbg !38 +@y = dso_local global i32 0, align 4, !dbg !47 +@r0 = dso_local global i32 0, align 4, !dbg !53 +@s = dso_local global i32 0, align 4, !dbg !51 +@r2 = dso_local global i32 0, align 4, !dbg !55 +@a = dso_local global i32 0, align 4, !dbg !49 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [16 x i8] c"rcu+ar-link20.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [42 x i8] c"!(r0 == 1 && r2 == 1 && a == 1 && x == 1)\00", align 1, !dbg !42 +@r6 = dso_local global i32 0, align 4, !dbg !57 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !52, metadata !DIExpression()), !dbg !53 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !54 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !55 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !56 - store i32 %2, i32* @r0, align 4, !dbg !57 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !58 - ret i8* null, !dbg !59 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !67 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !71, !DIExpression(), !72) + call void @__LKMM_fence(i32 noundef 6), !dbg !73 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !74 + %3 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !75 + %4 = trunc i64 %3 to i32, !dbg !75 + store i32 %4, ptr @r0, align 4, !dbg !76 + call void @__LKMM_fence(i32 noundef 7), !dbg !77 + ret ptr null, !dbg !78 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !60 { - call void @llvm.dbg.value(metadata i8* %0, metadata !61, metadata !DIExpression()), !dbg !62 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !63 - call void @__LKMM_FENCE(i32 noundef 4) #5, !dbg !64 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @s to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !65 - ret i8* null, !dbg !66 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !79 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !80, !DIExpression(), !81) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !82 + call void @__LKMM_fence(i32 noundef 3), !dbg !83 + call void @__LKMM_store(ptr noundef @s, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !84 + ret ptr null, !dbg !85 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P2(i8* noundef %0) #0 !dbg !67 { - call void @llvm.dbg.value(metadata i8* %0, metadata !68, metadata !DIExpression()), !dbg !69 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @s to i8*), i32 noundef 1) #5, !dbg !70 - call void @llvm.dbg.value(metadata i32 %2, metadata !71, metadata !DIExpression()), !dbg !69 - %.not = icmp eq i32 %2, 0, !dbg !72 - br i1 %.not, label %4, label %3, !dbg !74 +define dso_local ptr @P2(ptr noundef %0) #0 !dbg !86 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !87, !DIExpression(), !88) + #dbg_declare(ptr %3, !89, !DIExpression(), !90) + %4 = call i64 @__LKMM_load(ptr noundef @s, i64 noundef 4, i32 noundef 0), !dbg !91 + %5 = trunc i64 %4 to i32, !dbg !91 + store i32 %5, ptr %3, align 4, !dbg !90 + %6 = load i32, ptr %3, align 4, !dbg !92 + %7 = icmp ne i32 %6, 0, !dbg !92 + br i1 %7, label %8, label %10, !dbg !94 -3: ; preds = %1 - store i32 %2, i32* @r2, align 4, !dbg !75 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @a to i8*), i32 noundef 2, i32 noundef 1) #5, !dbg !77 - br label %4, !dbg !78 +8: ; preds = %1 + %9 = load i32, ptr %3, align 4, !dbg !95 + store i32 %9, ptr @r2, align 4, !dbg !97 + call void @__LKMM_store(ptr noundef @a, i64 noundef 4, i64 noundef 2, i32 noundef 0), !dbg !98 + br label %10, !dbg !99 -4: ; preds = %3, %1 - ret i8* null, !dbg !79 +10: ; preds = %8, %1 + ret ptr null, !dbg !100 } ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P3(i8* noundef %0) #0 !dbg !80 { - call void @llvm.dbg.value(metadata i8* %0, metadata !81, metadata !DIExpression()), !dbg !82 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @a to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !83 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !84 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !85 - ret i8* null, !dbg !86 +define dso_local ptr @P3(ptr noundef %0) #0 !dbg !101 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !102, !DIExpression(), !103) + call void @__LKMM_store(ptr noundef @a, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !104 + call void @__LKMM_fence(i32 noundef 8), !dbg !105 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !106 + ret ptr null, !dbg !107 } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !87 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - %3 = alloca i64, align 8 - %4 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !90, metadata !DIExpression(DW_OP_deref)), !dbg !94 - %5 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !95 - call void @llvm.dbg.value(metadata i64* %2, metadata !96, metadata !DIExpression(DW_OP_deref)), !dbg !94 - %6 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !97 - call void @llvm.dbg.value(metadata i64* %3, metadata !98, metadata !DIExpression(DW_OP_deref)), !dbg !94 - %7 = call i32 @pthread_create(i64* noundef nonnull %3, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P2, i8* noundef null) #5, !dbg !99 - call void @llvm.dbg.value(metadata i64* %4, metadata !100, metadata !DIExpression(DW_OP_deref)), !dbg !94 - %8 = call i32 @pthread_create(i64* noundef nonnull %4, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P3, i8* noundef null) #5, !dbg !101 - %9 = load i64, i64* %1, align 8, !dbg !102 - call void @llvm.dbg.value(metadata i64 %9, metadata !90, metadata !DIExpression()), !dbg !94 - %10 = call i32 @pthread_join(i64 noundef %9, i8** noundef null) #5, !dbg !103 - %11 = load i64, i64* %2, align 8, !dbg !104 - call void @llvm.dbg.value(metadata i64 %11, metadata !96, metadata !DIExpression()), !dbg !94 - %12 = call i32 @pthread_join(i64 noundef %11, i8** noundef null) #5, !dbg !105 - %13 = load i64, i64* %3, align 8, !dbg !106 - call void @llvm.dbg.value(metadata i64 %13, metadata !98, metadata !DIExpression()), !dbg !94 - %14 = call i32 @pthread_join(i64 noundef %13, i8** noundef null) #5, !dbg !107 - %15 = load i64, i64* %4, align 8, !dbg !108 - call void @llvm.dbg.value(metadata i64 %15, metadata !100, metadata !DIExpression()), !dbg !94 - %16 = call i32 @pthread_join(i64 noundef %15, i8** noundef null) #5, !dbg !109 - %17 = load i32, i32* @r0, align 4, !dbg !110 - %18 = icmp eq i32 %17, 1, !dbg !110 - %19 = load i32, i32* @r2, align 4, !dbg !110 - %20 = icmp eq i32 %19, 1, !dbg !110 - %or.cond = select i1 %18, i1 %20, i1 false, !dbg !110 - %21 = load i32, i32* @a, align 4, !dbg !110 - %22 = icmp eq i32 %21, 1, !dbg !110 - %or.cond3 = select i1 %or.cond, i1 %22, i1 false, !dbg !110 - %23 = load i32, i32* @x, align 4, !dbg !110 - %24 = icmp eq i32 %23, 1, !dbg !110 - %or.cond5 = select i1 %or.cond3, i1 %24, i1 false, !dbg !110 - br i1 %or.cond5, label %25, label %26, !dbg !110 +define dso_local i32 @main() #0 !dbg !108 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + %5 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !111, !DIExpression(), !134) + #dbg_declare(ptr %3, !135, !DIExpression(), !136) + #dbg_declare(ptr %4, !137, !DIExpression(), !138) + #dbg_declare(ptr %5, !139, !DIExpression(), !140) + %6 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !141 + %7 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !142 + %8 = call i32 @pthread_create(ptr noundef %4, ptr noundef null, ptr noundef @P2, ptr noundef null), !dbg !143 + %9 = call i32 @pthread_create(ptr noundef %5, ptr noundef null, ptr noundef @P3, ptr noundef null), !dbg !144 + %10 = load ptr, ptr %2, align 8, !dbg !145 + %11 = call i32 @_pthread_join(ptr noundef %10, ptr noundef null), !dbg !146 + %12 = load ptr, ptr %3, align 8, !dbg !147 + %13 = call i32 @_pthread_join(ptr noundef %12, ptr noundef null), !dbg !148 + %14 = load ptr, ptr %4, align 8, !dbg !149 + %15 = call i32 @_pthread_join(ptr noundef %14, ptr noundef null), !dbg !150 + %16 = load ptr, ptr %5, align 8, !dbg !151 + %17 = call i32 @_pthread_join(ptr noundef %16, ptr noundef null), !dbg !152 + %18 = load i32, ptr @r0, align 4, !dbg !153 + %19 = icmp eq i32 %18, 1, !dbg !153 + br i1 %19, label %20, label %29, !dbg !153 -25: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 noundef 68, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !110 - unreachable, !dbg !110 +20: ; preds = %0 + %21 = load i32, ptr @r2, align 4, !dbg !153 + %22 = icmp eq i32 %21, 1, !dbg !153 + br i1 %22, label %23, label %29, !dbg !153 -26: ; preds = %0 - ret i32 0, !dbg !113 -} +23: ; preds = %20 + %24 = load i32, ptr @a, align 4, !dbg !153 + %25 = icmp eq i32 %24, 1, !dbg !153 + br i1 %25, label %26, label %29, !dbg !153 + +26: ; preds = %23 + %27 = load i32, ptr @x, align 4, !dbg !153 + %28 = icmp eq i32 %27, 1, !dbg !153 + br label %29 + +29: ; preds = %26, %23, %20, %0 + %30 = phi i1 [ false, %23 ], [ false, %20 ], [ false, %0 ], [ %28, %26 ], !dbg !154 + %31 = xor i1 %30, true, !dbg !153 + %32 = xor i1 %31, true, !dbg !153 + %33 = zext i1 %32 to i32, !dbg !153 + %34 = sext i32 %33 to i64, !dbg !153 + %35 = icmp ne i64 %34, 0, !dbg !153 + br i1 %35, label %36, label %38, !dbg !153 -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 +36: ; preds = %29 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 68, ptr noundef @.str.1) #3, !dbg !153 + unreachable, !dbg !153 + +37: ; No predecessors! + br label %39, !dbg !153 + +38: ; preds = %29 + br label %39, !dbg !153 + +39: ; preds = %38, %37 + ret i32 0, !dbg !155 +} -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!40, !41, !42, !43, !44, !45, !46} -!llvm.ident = !{!47} +!llvm.module.flags = !{!59, !60, !61, !62, !63, !64, !65} +!llvm.ident = !{!66} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu+ar-link20.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "04db98ea4c002dca60e5a54977930ea2") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 7, type: !27, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/rcu+ar-link20.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "04db98ea4c002dca60e5a54977930ea2") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32, !34, !36, !38} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/rcu+ar-link20.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "04db98ea4c002dca60e5a54977930ea2") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!29 = !{!30, !37, !42, !0, !47, !49, !51, !53, !55, !57} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !28, line: 9, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !28, line: 10, type: !29, isLocal: false, isDefinition: true) -!34 = !DIGlobalVariableExpression(var: !35, expr: !DIExpression()) -!35 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !28, line: 12, type: !29, isLocal: false, isDefinition: true) -!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression()) -!37 = distinct !DIGlobalVariable(name: "r2", scope: !2, file: !28, line: 13, type: !29, isLocal: false, isDefinition: true) -!38 = !DIGlobalVariableExpression(var: !39, expr: !DIExpression()) -!39 = distinct !DIGlobalVariable(name: "r6", scope: !2, file: !28, line: 14, type: !29, isLocal: false, isDefinition: true) -!40 = !{i32 7, !"Dwarf Version", i32 5} -!41 = !{i32 2, !"Debug Info Version", i32 3} -!42 = !{i32 1, !"wchar_size", i32 4} -!43 = !{i32 7, !"PIC Level", i32 2} -!44 = !{i32 7, !"PIE Level", i32 2} -!45 = !{i32 7, !"uwtable", i32 1} -!46 = !{i32 7, !"frame-pointer", i32 2} -!47 = !{!"Ubuntu clang version 14.0.6"} -!48 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 16, type: !49, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!49 = !DISubroutineType(types: !50) -!50 = !{!24, !24} -!51 = !{} -!52 = !DILocalVariable(name: "unused", arg: 1, scope: !48, file: !28, line: 16, type: !24) -!53 = !DILocation(line: 0, scope: !48) -!54 = !DILocation(line: 18, column: 2, scope: !48) -!55 = !DILocation(line: 19, column: 2, scope: !48) -!56 = !DILocation(line: 20, column: 7, scope: !48) -!57 = !DILocation(line: 20, column: 5, scope: !48) -!58 = !DILocation(line: 21, column: 2, scope: !48) -!59 = !DILocation(line: 22, column: 2, scope: !48) -!60 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 25, type: !49, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!61 = !DILocalVariable(name: "unused", arg: 1, scope: !60, file: !28, line: 25, type: !24) -!62 = !DILocation(line: 0, scope: !60) -!63 = !DILocation(line: 27, column: 2, scope: !60) -!64 = !DILocation(line: 28, column: 2, scope: !60) -!65 = !DILocation(line: 29, column: 2, scope: !60) -!66 = !DILocation(line: 30, column: 2, scope: !60) -!67 = distinct !DISubprogram(name: "P2", scope: !28, file: !28, line: 33, type: !49, scopeLine: 34, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!68 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !28, line: 33, type: !24) -!69 = !DILocation(line: 0, scope: !67) -!70 = !DILocation(line: 35, column: 10, scope: !67) -!71 = !DILocalVariable(name: "r", scope: !67, file: !28, line: 35, type: !29) -!72 = !DILocation(line: 36, column: 6, scope: !73) -!73 = distinct !DILexicalBlock(scope: !67, file: !28, line: 36, column: 6) -!74 = !DILocation(line: 36, column: 6, scope: !67) -!75 = !DILocation(line: 37, column: 6, scope: !76) -!76 = distinct !DILexicalBlock(scope: !73, file: !28, line: 36, column: 9) -!77 = !DILocation(line: 38, column: 3, scope: !76) -!78 = !DILocation(line: 39, column: 2, scope: !76) -!79 = !DILocation(line: 40, column: 2, scope: !67) -!80 = distinct !DISubprogram(name: "P3", scope: !28, file: !28, line: 43, type: !49, scopeLine: 44, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!81 = !DILocalVariable(name: "unused", arg: 1, scope: !80, file: !28, line: 43, type: !24) -!82 = !DILocation(line: 0, scope: !80) -!83 = !DILocation(line: 45, column: 2, scope: !80) -!84 = !DILocation(line: 46, column: 2, scope: !80) -!85 = !DILocation(line: 47, column: 2, scope: !80) -!86 = !DILocation(line: 48, column: 2, scope: !80) -!87 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 51, type: !88, scopeLine: 52, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) -!88 = !DISubroutineType(types: !89) -!89 = !{!29} -!90 = !DILocalVariable(name: "t0", scope: !87, file: !28, line: 56, type: !91) -!91 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !92, line: 27, baseType: !93) -!92 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!93 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!94 = !DILocation(line: 0, scope: !87) -!95 = !DILocation(line: 58, column: 2, scope: !87) -!96 = !DILocalVariable(name: "t1", scope: !87, file: !28, line: 56, type: !91) -!97 = !DILocation(line: 59, column: 2, scope: !87) -!98 = !DILocalVariable(name: "t2", scope: !87, file: !28, line: 56, type: !91) -!99 = !DILocation(line: 60, column: 2, scope: !87) -!100 = !DILocalVariable(name: "t3", scope: !87, file: !28, line: 56, type: !91) -!101 = !DILocation(line: 61, column: 2, scope: !87) -!102 = !DILocation(line: 63, column: 15, scope: !87) -!103 = !DILocation(line: 63, column: 2, scope: !87) -!104 = !DILocation(line: 64, column: 15, scope: !87) -!105 = !DILocation(line: 64, column: 2, scope: !87) -!106 = !DILocation(line: 65, column: 15, scope: !87) -!107 = !DILocation(line: 65, column: 2, scope: !87) -!108 = !DILocation(line: 66, column: 15, scope: !87) -!109 = !DILocation(line: 66, column: 2, scope: !87) -!110 = !DILocation(line: 68, column: 2, scope: !111) -!111 = distinct !DILexicalBlock(scope: !112, file: !28, line: 68, column: 2) -!112 = distinct !DILexicalBlock(scope: !87, file: !28, line: 68, column: 2) -!113 = !DILocation(line: 70, column: 2, scope: !87) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 68, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 68, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 128, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 16) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 68, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 336, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 42) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 8, type: !27, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 9, type: !27, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 10, type: !27, isLocal: false, isDefinition: true) +!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression()) +!54 = distinct !DIGlobalVariable(name: "r0", scope: !2, file: !3, line: 12, type: !27, isLocal: false, isDefinition: true) +!55 = !DIGlobalVariableExpression(var: !56, expr: !DIExpression()) +!56 = distinct !DIGlobalVariable(name: "r2", scope: !2, file: !3, line: 13, type: !27, isLocal: false, isDefinition: true) +!57 = !DIGlobalVariableExpression(var: !58, expr: !DIExpression()) +!58 = distinct !DIGlobalVariable(name: "r6", scope: !2, file: !3, line: 14, type: !27, isLocal: false, isDefinition: true) +!59 = !{i32 7, !"Dwarf Version", i32 5} +!60 = !{i32 2, !"Debug Info Version", i32 3} +!61 = !{i32 1, !"wchar_size", i32 4} +!62 = !{i32 8, !"PIC Level", i32 2} +!63 = !{i32 7, !"PIE Level", i32 2} +!64 = !{i32 7, !"uwtable", i32 2} +!65 = !{i32 7, !"frame-pointer", i32 2} +!66 = !{!"Homebrew clang version 19.1.7"} +!67 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 16, type: !68, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!68 = !DISubroutineType(types: !69) +!69 = !{!28, !28} +!70 = !{} +!71 = !DILocalVariable(name: "unused", arg: 1, scope: !67, file: !3, line: 16, type: !28) +!72 = !DILocation(line: 16, column: 16, scope: !67) +!73 = !DILocation(line: 18, column: 2, scope: !67) +!74 = !DILocation(line: 19, column: 2, scope: !67) +!75 = !DILocation(line: 20, column: 7, scope: !67) +!76 = !DILocation(line: 20, column: 5, scope: !67) +!77 = !DILocation(line: 21, column: 2, scope: !67) +!78 = !DILocation(line: 22, column: 2, scope: !67) +!79 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 25, type: !68, scopeLine: 26, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!80 = !DILocalVariable(name: "unused", arg: 1, scope: !79, file: !3, line: 25, type: !28) +!81 = !DILocation(line: 25, column: 16, scope: !79) +!82 = !DILocation(line: 27, column: 2, scope: !79) +!83 = !DILocation(line: 28, column: 2, scope: !79) +!84 = !DILocation(line: 29, column: 2, scope: !79) +!85 = !DILocation(line: 30, column: 2, scope: !79) +!86 = distinct !DISubprogram(name: "P2", scope: !3, file: !3, line: 33, type: !68, scopeLine: 34, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!87 = !DILocalVariable(name: "unused", arg: 1, scope: !86, file: !3, line: 33, type: !28) +!88 = !DILocation(line: 33, column: 16, scope: !86) +!89 = !DILocalVariable(name: "r", scope: !86, file: !3, line: 35, type: !27) +!90 = !DILocation(line: 35, column: 6, scope: !86) +!91 = !DILocation(line: 35, column: 10, scope: !86) +!92 = !DILocation(line: 36, column: 6, scope: !93) +!93 = distinct !DILexicalBlock(scope: !86, file: !3, line: 36, column: 6) +!94 = !DILocation(line: 36, column: 6, scope: !86) +!95 = !DILocation(line: 37, column: 8, scope: !96) +!96 = distinct !DILexicalBlock(scope: !93, file: !3, line: 36, column: 9) +!97 = !DILocation(line: 37, column: 6, scope: !96) +!98 = !DILocation(line: 38, column: 3, scope: !96) +!99 = !DILocation(line: 39, column: 2, scope: !96) +!100 = !DILocation(line: 40, column: 2, scope: !86) +!101 = distinct !DISubprogram(name: "P3", scope: !3, file: !3, line: 43, type: !68, scopeLine: 44, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!102 = !DILocalVariable(name: "unused", arg: 1, scope: !101, file: !3, line: 43, type: !28) +!103 = !DILocation(line: 43, column: 16, scope: !101) +!104 = !DILocation(line: 45, column: 2, scope: !101) +!105 = !DILocation(line: 46, column: 2, scope: !101) +!106 = !DILocation(line: 47, column: 2, scope: !101) +!107 = !DILocation(line: 48, column: 2, scope: !101) +!108 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 51, type: !109, scopeLine: 52, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !70) +!109 = !DISubroutineType(types: !110) +!110 = !{!27} +!111 = !DILocalVariable(name: "t0", scope: !108, file: !3, line: 56, type: !112) +!112 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !113, line: 31, baseType: !114) +!113 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!114 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !115, line: 118, baseType: !116) +!115 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!116 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !117, size: 64) +!117 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !115, line: 103, size: 65536, elements: !118) +!118 = !{!119, !120, !130} +!119 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !117, file: !115, line: 104, baseType: !26, size: 64) +!120 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !117, file: !115, line: 105, baseType: !121, size: 64, offset: 64) +!121 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !122, size: 64) +!122 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !115, line: 57, size: 192, elements: !123) +!123 = !{!124, !128, !129} +!124 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !122, file: !115, line: 58, baseType: !125, size: 64) +!125 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !126, size: 64) +!126 = !DISubroutineType(types: !127) +!127 = !{null, !28} +!128 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !122, file: !115, line: 59, baseType: !28, size: 64, offset: 64) +!129 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !122, file: !115, line: 60, baseType: !121, size: 64, offset: 128) +!130 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !117, file: !115, line: 106, baseType: !131, size: 65408, offset: 128) +!131 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !132) +!132 = !{!133} +!133 = !DISubrange(count: 8176) +!134 = !DILocation(line: 56, column: 12, scope: !108) +!135 = !DILocalVariable(name: "t1", scope: !108, file: !3, line: 56, type: !112) +!136 = !DILocation(line: 56, column: 16, scope: !108) +!137 = !DILocalVariable(name: "t2", scope: !108, file: !3, line: 56, type: !112) +!138 = !DILocation(line: 56, column: 20, scope: !108) +!139 = !DILocalVariable(name: "t3", scope: !108, file: !3, line: 56, type: !112) +!140 = !DILocation(line: 56, column: 24, scope: !108) +!141 = !DILocation(line: 58, column: 2, scope: !108) +!142 = !DILocation(line: 59, column: 2, scope: !108) +!143 = !DILocation(line: 60, column: 2, scope: !108) +!144 = !DILocation(line: 61, column: 2, scope: !108) +!145 = !DILocation(line: 63, column: 15, scope: !108) +!146 = !DILocation(line: 63, column: 2, scope: !108) +!147 = !DILocation(line: 64, column: 15, scope: !108) +!148 = !DILocation(line: 64, column: 2, scope: !108) +!149 = !DILocation(line: 65, column: 15, scope: !108) +!150 = !DILocation(line: 65, column: 2, scope: !108) +!151 = !DILocation(line: 66, column: 15, scope: !108) +!152 = !DILocation(line: 66, column: 2, scope: !108) +!153 = !DILocation(line: 68, column: 2, scope: !108) +!154 = !DILocation(line: 0, scope: !108) +!155 = !DILocation(line: 70, column: 2, scope: !108) diff --git a/dartagnan/src/test/resources/lkmm/rcu-MP.ll b/dartagnan/src/test/resources/lkmm/rcu-MP.ll index b8fa27e57c..c6c26137c5 100644 --- a/dartagnan/src/test/resources/lkmm/rcu-MP.ll +++ b/dartagnan/src/test/resources/lkmm/rcu-MP.ll @@ -1,158 +1,217 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/rcu-MP.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu-MP.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/rcu-MP.c' +source_filename = "benchmarks/lkmm/rcu-MP.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global i32 0, align 4, !dbg !26 -@.str = private unnamed_addr constant [24 x i8] c"!(r_y == 1 && r_x == 0)\00", align 1 -@.str.1 = private unnamed_addr constant [47 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/rcu-MP.c\00", align 1 -@__PRETTY_FUNCTION__.P1 = private unnamed_addr constant [17 x i8] c"void *P1(void *)\00", align 1 +@y = dso_local global i32 0, align 4, !dbg !47 +@__func__.P1 = private unnamed_addr constant [3 x i8] c"P1\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [9 x i8] c"rcu-MP.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [24 x i8] c"!(r_y == 1 && r_x == 0)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !38 { - call void @llvm.dbg.value(metadata i8* %0, metadata !42, metadata !DIExpression()), !dbg !43 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !44 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !45 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !46 - ret i8* null, !dbg !47 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !57 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !61, !DIExpression(), !62) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !63 + call void @__LKMM_fence(i32 noundef 8), !dbg !64 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !65 + ret ptr null, !dbg !66 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !48 { - call void @llvm.dbg.value(metadata i8* %0, metadata !49, metadata !DIExpression()), !dbg !50 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !51 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !52 - call void @llvm.dbg.value(metadata i32 %2, metadata !53, metadata !DIExpression()), !dbg !50 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !54 - call void @llvm.dbg.value(metadata i32 %3, metadata !55, metadata !DIExpression()), !dbg !50 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !56 - %4 = icmp eq i32 %2, 1, !dbg !57 - %5 = icmp eq i32 %3, 0, !dbg !57 - %or.cond = select i1 %4, i1 %5, i1 false, !dbg !57 - br i1 %or.cond, label %6, label %7, !dbg !57 - -6: ; preds = %1 - call void @__assert_fail(i8* noundef getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 noundef 24, i8* noundef getelementptr inbounds ([17 x i8], [17 x i8]* @__PRETTY_FUNCTION__.P1, i64 0, i64 0)) #6, !dbg !57 - unreachable, !dbg !57 - -7: ; preds = %1 - ret i8* null, !dbg !60 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !67 { + %2 = alloca ptr, align 8 + %3 = alloca i32, align 4 + %4 = alloca i32, align 4 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !68, !DIExpression(), !69) + call void @__LKMM_fence(i32 noundef 6), !dbg !70 + #dbg_declare(ptr %3, !71, !DIExpression(), !72) + %5 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !73 + %6 = trunc i64 %5 to i32, !dbg !73 + store i32 %6, ptr %3, align 4, !dbg !72 + #dbg_declare(ptr %4, !74, !DIExpression(), !75) + %7 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !76 + %8 = trunc i64 %7 to i32, !dbg !76 + store i32 %8, ptr %4, align 4, !dbg !75 + call void @__LKMM_fence(i32 noundef 7), !dbg !77 + %9 = load i32, ptr %3, align 4, !dbg !78 + %10 = icmp eq i32 %9, 1, !dbg !78 + br i1 %10, label %11, label %14, !dbg !78 + +11: ; preds = %1 + %12 = load i32, ptr %4, align 4, !dbg !78 + %13 = icmp eq i32 %12, 0, !dbg !78 + br label %14 + +14: ; preds = %11, %1 + %15 = phi i1 [ false, %1 ], [ %13, %11 ], !dbg !79 + %16 = xor i1 %15, true, !dbg !78 + %17 = xor i1 %16, true, !dbg !78 + %18 = zext i1 %17 to i32, !dbg !78 + %19 = sext i32 %18 to i64, !dbg !78 + %20 = icmp ne i64 %19, 0, !dbg !78 + br i1 %20, label %21, label %23, !dbg !78 + +21: ; preds = %14 + call void @__assert_rtn(ptr noundef @__func__.P1, ptr noundef @.str, i32 noundef 24, ptr noundef @.str.1) #3, !dbg !78 + unreachable, !dbg !78 + +22: ; No predecessors! + br label %24, !dbg !78 + +23: ; preds = %14 + br label %24, !dbg !78 + +24: ; preds = %23, %22 + ret ptr null, !dbg !80 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #3 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !61 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !64, metadata !DIExpression(DW_OP_deref)), !dbg !68 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !69 - call void @llvm.dbg.value(metadata i64* %2, metadata !70, metadata !DIExpression(DW_OP_deref)), !dbg !68 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !71 - ret i32 0, !dbg !72 +define dso_local i32 @main() #0 !dbg !81 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !84, !DIExpression(), !107) + #dbg_declare(ptr %3, !108, !DIExpression(), !109) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !110 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !111 + ret i32 0, !dbg !112 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #4 - -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!30, !31, !32, !33, !34, !35, !36} -!llvm.ident = !{!37} +!llvm.module.flags = !{!49, !50, !51, !52, !53, !54, !55} +!llvm.ident = !{!56} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu-MP.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "ee7d341ab9b618f6b5d9b52d690bd6c4") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 7, type: !28, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/rcu-MP.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "ee7d341ab9b618f6b5d9b52d690bd6c4") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/rcu-MP.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "ee7d341ab9b618f6b5d9b52d690bd6c4") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!30 = !{i32 7, !"Dwarf Version", i32 5} -!31 = !{i32 2, !"Debug Info Version", i32 3} -!32 = !{i32 1, !"wchar_size", i32 4} -!33 = !{i32 7, !"PIC Level", i32 2} -!34 = !{i32 7, !"PIE Level", i32 2} -!35 = !{i32 7, !"uwtable", i32 1} -!36 = !{i32 7, !"frame-pointer", i32 2} -!37 = !{!"Ubuntu clang version 14.0.6"} -!38 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 10, type: !39, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!39 = !DISubroutineType(types: !40) -!40 = !{!24, !24} -!41 = !{} -!42 = !DILocalVariable(name: "arg", arg: 1, scope: !38, file: !28, line: 10, type: !24) -!43 = !DILocation(line: 0, scope: !38) -!44 = !DILocation(line: 12, column: 2, scope: !38) -!45 = !DILocation(line: 13, column: 2, scope: !38) -!46 = !DILocation(line: 14, column: 2, scope: !38) -!47 = !DILocation(line: 15, column: 2, scope: !38) -!48 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 18, type: !39, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!49 = !DILocalVariable(name: "arg", arg: 1, scope: !48, file: !28, line: 18, type: !24) -!50 = !DILocation(line: 0, scope: !48) -!51 = !DILocation(line: 20, column: 2, scope: !48) -!52 = !DILocation(line: 21, column: 12, scope: !48) -!53 = !DILocalVariable(name: "r_y", scope: !48, file: !28, line: 21, type: !29) -!54 = !DILocation(line: 22, column: 12, scope: !48) -!55 = !DILocalVariable(name: "r_x", scope: !48, file: !28, line: 22, type: !29) -!56 = !DILocation(line: 23, column: 2, scope: !48) -!57 = !DILocation(line: 24, column: 5, scope: !58) -!58 = distinct !DILexicalBlock(scope: !59, file: !28, line: 24, column: 5) -!59 = distinct !DILexicalBlock(scope: !48, file: !28, line: 24, column: 5) -!60 = !DILocation(line: 25, column: 2, scope: !48) -!61 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 29, type: !62, scopeLine: 30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !41) -!62 = !DISubroutineType(types: !63) -!63 = !{!29} -!64 = !DILocalVariable(name: "t1", scope: !61, file: !28, line: 34, type: !65) -!65 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !66, line: 27, baseType: !67) -!66 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!67 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!68 = !DILocation(line: 0, scope: !61) -!69 = !DILocation(line: 36, column: 2, scope: !61) -!70 = !DILocalVariable(name: "t2", scope: !61, file: !28, line: 34, type: !65) -!71 = !DILocation(line: 37, column: 2, scope: !61) -!72 = !DILocation(line: 39, column: 2, scope: !61) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !0, !47} +!30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 24, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 24, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 3) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 24, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 72, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 9) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 24, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 192, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 24) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 8, type: !28, isLocal: false, isDefinition: true) +!49 = !{i32 7, !"Dwarf Version", i32 5} +!50 = !{i32 2, !"Debug Info Version", i32 3} +!51 = !{i32 1, !"wchar_size", i32 4} +!52 = !{i32 8, !"PIC Level", i32 2} +!53 = !{i32 7, !"PIE Level", i32 2} +!54 = !{i32 7, !"uwtable", i32 2} +!55 = !{i32 7, !"frame-pointer", i32 2} +!56 = !{!"Homebrew clang version 19.1.7"} +!57 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 10, type: !58, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!58 = !DISubroutineType(types: !59) +!59 = !{!27, !27} +!60 = !{} +!61 = !DILocalVariable(name: "arg", arg: 1, scope: !57, file: !3, line: 10, type: !27) +!62 = !DILocation(line: 10, column: 16, scope: !57) +!63 = !DILocation(line: 12, column: 2, scope: !57) +!64 = !DILocation(line: 13, column: 2, scope: !57) +!65 = !DILocation(line: 14, column: 2, scope: !57) +!66 = !DILocation(line: 15, column: 2, scope: !57) +!67 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 18, type: !58, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!68 = !DILocalVariable(name: "arg", arg: 1, scope: !67, file: !3, line: 18, type: !27) +!69 = !DILocation(line: 18, column: 16, scope: !67) +!70 = !DILocation(line: 20, column: 2, scope: !67) +!71 = !DILocalVariable(name: "r_y", scope: !67, file: !3, line: 21, type: !28) +!72 = !DILocation(line: 21, column: 6, scope: !67) +!73 = !DILocation(line: 21, column: 12, scope: !67) +!74 = !DILocalVariable(name: "r_x", scope: !67, file: !3, line: 22, type: !28) +!75 = !DILocation(line: 22, column: 6, scope: !67) +!76 = !DILocation(line: 22, column: 12, scope: !67) +!77 = !DILocation(line: 23, column: 2, scope: !67) +!78 = !DILocation(line: 24, column: 5, scope: !67) +!79 = !DILocation(line: 0, scope: !67) +!80 = !DILocation(line: 25, column: 2, scope: !67) +!81 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 29, type: !82, scopeLine: 30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +!82 = !DISubroutineType(types: !83) +!83 = !{!28} +!84 = !DILocalVariable(name: "t1", scope: !81, file: !3, line: 34, type: !85) +!85 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !86, line: 31, baseType: !87) +!86 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!87 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !88, line: 118, baseType: !89) +!88 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!89 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !90, size: 64) +!90 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !88, line: 103, size: 65536, elements: !91) +!91 = !{!92, !93, !103} +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !90, file: !88, line: 104, baseType: !26, size: 64) +!93 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !90, file: !88, line: 105, baseType: !94, size: 64, offset: 64) +!94 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !95, size: 64) +!95 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !88, line: 57, size: 192, elements: !96) +!96 = !{!97, !101, !102} +!97 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !95, file: !88, line: 58, baseType: !98, size: 64) +!98 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !99, size: 64) +!99 = !DISubroutineType(types: !100) +!100 = !{null, !27} +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !95, file: !88, line: 59, baseType: !27, size: 64, offset: 64) +!102 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !95, file: !88, line: 60, baseType: !94, size: 64, offset: 128) +!103 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !90, file: !88, line: 106, baseType: !104, size: 65408, offset: 128) +!104 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !105) +!105 = !{!106} +!106 = !DISubrange(count: 8176) +!107 = !DILocation(line: 34, column: 12, scope: !81) +!108 = !DILocalVariable(name: "t2", scope: !81, file: !3, line: 34, type: !85) +!109 = !DILocation(line: 34, column: 16, scope: !81) +!110 = !DILocation(line: 36, column: 2, scope: !81) +!111 = !DILocation(line: 37, column: 2, scope: !81) +!112 = !DILocation(line: 39, column: 2, scope: !81) diff --git a/dartagnan/src/test/resources/lkmm/rcu-gp20.ll b/dartagnan/src/test/resources/lkmm/rcu-gp20.ll index fe2cfae20c..7fabcc16d0 100644 --- a/dartagnan/src/test/resources/lkmm/rcu-gp20.ll +++ b/dartagnan/src/test/resources/lkmm/rcu-gp20.ll @@ -1,178 +1,227 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/rcu-gp20.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu-gp20.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/rcu-gp20.c' +source_filename = "benchmarks/lkmm/rcu-gp20.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@r_x = dso_local global i32 0, align 4, !dbg !30 -@y = dso_local global i32 0, align 4, !dbg !26 -@r_y = dso_local global i32 0, align 4, !dbg !32 -@.str = private unnamed_addr constant [24 x i8] c"!(r_x == 0 && r_y == 1)\00", align 1 -@.str.1 = private unnamed_addr constant [49 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/rcu-gp20.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@r_x = dso_local global i32 0, align 4, !dbg !49 +@y = dso_local global i32 0, align 4, !dbg !47 +@r_y = dso_local global i32 0, align 4, !dbg !51 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [11 x i8] c"rcu-gp20.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [24 x i8] c"!(r_x == 0 && r_y == 1)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !42 { - call void @llvm.dbg.value(metadata i8* %0, metadata !46, metadata !DIExpression()), !dbg !47 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !48 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !49 - store i32 %2, i32* @r_x, align 4, !dbg !50 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !51 - store i32 %3, i32* @r_y, align 4, !dbg !52 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !53 - ret i8* null, !dbg !54 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !61 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !65, !DIExpression(), !66) + call void @__LKMM_fence(i32 noundef 6), !dbg !67 + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !68 + %4 = trunc i64 %3 to i32, !dbg !68 + store i32 %4, ptr @r_x, align 4, !dbg !69 + %5 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !70 + %6 = trunc i64 %5 to i32, !dbg !70 + store i32 %6, ptr @r_y, align 4, !dbg !71 + call void @__LKMM_fence(i32 noundef 7), !dbg !72 + ret ptr null, !dbg !73 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !55 { - call void @llvm.dbg.value(metadata i8* %0, metadata !56, metadata !DIExpression()), !dbg !57 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !58 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !59 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !60 - ret i8* null, !dbg !61 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !74 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !75, !DIExpression(), !76) + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !77 + call void @__LKMM_fence(i32 noundef 8), !dbg !78 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !79 + ret ptr null, !dbg !80 } -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !62 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !65, metadata !DIExpression(DW_OP_deref)), !dbg !69 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !70 - call void @llvm.dbg.value(metadata i64* %2, metadata !71, metadata !DIExpression(DW_OP_deref)), !dbg !69 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !72 - %5 = load i64, i64* %1, align 8, !dbg !73 - call void @llvm.dbg.value(metadata i64 %5, metadata !65, metadata !DIExpression()), !dbg !69 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !74 - %7 = load i64, i64* %2, align 8, !dbg !75 - call void @llvm.dbg.value(metadata i64 %7, metadata !71, metadata !DIExpression()), !dbg !69 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !76 - %9 = load i32, i32* @r_x, align 4, !dbg !77 - %10 = icmp eq i32 %9, 0, !dbg !77 - %11 = load i32, i32* @r_y, align 4, !dbg !77 - %12 = icmp eq i32 %11, 1, !dbg !77 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !77 - br i1 %or.cond, label %13, label %14, !dbg !77 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 noundef 43, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !77 - unreachable, !dbg !77 - -14: ; preds = %0 - ret i32 0, !dbg !80 +define dso_local i32 @main() #0 !dbg !81 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !84, !DIExpression(), !107) + #dbg_declare(ptr %3, !108, !DIExpression(), !109) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !110 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !111 + %6 = load ptr, ptr %2, align 8, !dbg !112 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !113 + %8 = load ptr, ptr %3, align 8, !dbg !114 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !115 + %10 = load i32, ptr @r_x, align 4, !dbg !116 + %11 = icmp eq i32 %10, 0, !dbg !116 + br i1 %11, label %12, label %15, !dbg !116 + +12: ; preds = %0 + %13 = load i32, ptr @r_y, align 4, !dbg !116 + %14 = icmp eq i32 %13, 1, !dbg !116 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !117 + %17 = xor i1 %16, true, !dbg !116 + %18 = xor i1 %17, true, !dbg !116 + %19 = zext i1 %18 to i32, !dbg !116 + %20 = sext i32 %19 to i64, !dbg !116 + %21 = icmp ne i64 %20, 0, !dbg !116 + br i1 %21, label %22, label %24, !dbg !116 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 43, ptr noundef @.str.1) #3, !dbg !116 + unreachable, !dbg !116 + +23: ; No predecessors! + br label %25, !dbg !116 + +24: ; preds = %15 + br label %25, !dbg !116 + +25: ; preds = %24, %23 + ret i32 0, !dbg !118 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40} -!llvm.ident = !{!41} +!llvm.module.flags = !{!53, !54, !55, !56, !57, !58, !59} +!llvm.ident = !{!60} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu-gp20.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "b0caa70c4bd139823f22290f84c5437c") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 7, type: !23, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/rcu-gp20.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "b0caa70c4bd139823f22290f84c5437c") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !24, !25} +!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/rcu-gp20.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "b0caa70c4bd139823f22290f84c5437c") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !26) +!26 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !27, line: 32, baseType: !28) +!27 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!28 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !0, !47, !49, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !28, line: 10, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !28, line: 11, type: !29, isLocal: false, isDefinition: true) -!34 = !{i32 7, !"Dwarf Version", i32 5} -!35 = !{i32 2, !"Debug Info Version", i32 3} -!36 = !{i32 1, !"wchar_size", i32 4} -!37 = !{i32 7, !"PIC Level", i32 2} -!38 = !{i32 7, !"PIE Level", i32 2} -!39 = !{i32 7, !"uwtable", i32 1} -!40 = !{i32 7, !"frame-pointer", i32 2} -!41 = !{!"Ubuntu clang version 14.0.6"} -!42 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 13, type: !43, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!43 = !DISubroutineType(types: !44) -!44 = !{!24, !24} -!45 = !{} -!46 = !DILocalVariable(name: "unused", arg: 1, scope: !42, file: !28, line: 13, type: !24) -!47 = !DILocation(line: 0, scope: !42) -!48 = !DILocation(line: 15, column: 2, scope: !42) -!49 = !DILocation(line: 16, column: 8, scope: !42) -!50 = !DILocation(line: 16, column: 6, scope: !42) -!51 = !DILocation(line: 17, column: 8, scope: !42) -!52 = !DILocation(line: 17, column: 6, scope: !42) -!53 = !DILocation(line: 18, column: 2, scope: !42) -!54 = !DILocation(line: 19, column: 2, scope: !42) -!55 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 22, type: !43, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!56 = !DILocalVariable(name: "unused", arg: 1, scope: !55, file: !28, line: 22, type: !24) -!57 = !DILocation(line: 0, scope: !55) -!58 = !DILocation(line: 24, column: 2, scope: !55) -!59 = !DILocation(line: 25, column: 2, scope: !55) -!60 = !DILocation(line: 26, column: 2, scope: !55) -!61 = !DILocation(line: 27, column: 2, scope: !55) -!62 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 30, type: !63, scopeLine: 31, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!63 = !DISubroutineType(types: !64) -!64 = !{!29} -!65 = !DILocalVariable(name: "t1", scope: !62, file: !28, line: 35, type: !66) -!66 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !67, line: 27, baseType: !68) -!67 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!68 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!69 = !DILocation(line: 0, scope: !62) -!70 = !DILocation(line: 37, column: 2, scope: !62) -!71 = !DILocalVariable(name: "t2", scope: !62, file: !28, line: 35, type: !66) -!72 = !DILocation(line: 38, column: 2, scope: !62) -!73 = !DILocation(line: 40, column: 15, scope: !62) -!74 = !DILocation(line: 40, column: 2, scope: !62) -!75 = !DILocation(line: 41, column: 15, scope: !62) -!76 = !DILocation(line: 41, column: 2, scope: !62) -!77 = !DILocation(line: 43, column: 2, scope: !78) -!78 = distinct !DILexicalBlock(scope: !79, file: !28, line: 43, column: 2) -!79 = distinct !DILexicalBlock(scope: !62, file: !28, line: 43, column: 2) -!80 = !DILocation(line: 45, column: 2, scope: !62) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 43, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 43, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 88, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 11) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 43, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 192, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 24) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 8, type: !23, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !3, line: 10, type: !23, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !3, line: 11, type: !23, isLocal: false, isDefinition: true) +!53 = !{i32 7, !"Dwarf Version", i32 5} +!54 = !{i32 2, !"Debug Info Version", i32 3} +!55 = !{i32 1, !"wchar_size", i32 4} +!56 = !{i32 8, !"PIC Level", i32 2} +!57 = !{i32 7, !"PIE Level", i32 2} +!58 = !{i32 7, !"uwtable", i32 2} +!59 = !{i32 7, !"frame-pointer", i32 2} +!60 = !{!"Homebrew clang version 19.1.7"} +!61 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 13, type: !62, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!62 = !DISubroutineType(types: !63) +!63 = !{!24, !24} +!64 = !{} +!65 = !DILocalVariable(name: "unused", arg: 1, scope: !61, file: !3, line: 13, type: !24) +!66 = !DILocation(line: 13, column: 16, scope: !61) +!67 = !DILocation(line: 15, column: 2, scope: !61) +!68 = !DILocation(line: 16, column: 8, scope: !61) +!69 = !DILocation(line: 16, column: 6, scope: !61) +!70 = !DILocation(line: 17, column: 8, scope: !61) +!71 = !DILocation(line: 17, column: 6, scope: !61) +!72 = !DILocation(line: 18, column: 2, scope: !61) +!73 = !DILocation(line: 19, column: 2, scope: !61) +!74 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 22, type: !62, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!75 = !DILocalVariable(name: "unused", arg: 1, scope: !74, file: !3, line: 22, type: !24) +!76 = !DILocation(line: 22, column: 16, scope: !74) +!77 = !DILocation(line: 24, column: 2, scope: !74) +!78 = !DILocation(line: 25, column: 2, scope: !74) +!79 = !DILocation(line: 26, column: 2, scope: !74) +!80 = !DILocation(line: 27, column: 2, scope: !74) +!81 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 30, type: !82, scopeLine: 31, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!82 = !DISubroutineType(types: !83) +!83 = !{!23} +!84 = !DILocalVariable(name: "t1", scope: !81, file: !3, line: 35, type: !85) +!85 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !86, line: 31, baseType: !87) +!86 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!87 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !88, line: 118, baseType: !89) +!88 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!89 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !90, size: 64) +!90 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !88, line: 103, size: 65536, elements: !91) +!91 = !{!92, !93, !103} +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !90, file: !88, line: 104, baseType: !28, size: 64) +!93 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !90, file: !88, line: 105, baseType: !94, size: 64, offset: 64) +!94 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !95, size: 64) +!95 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !88, line: 57, size: 192, elements: !96) +!96 = !{!97, !101, !102} +!97 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !95, file: !88, line: 58, baseType: !98, size: 64) +!98 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !99, size: 64) +!99 = !DISubroutineType(types: !100) +!100 = !{null, !24} +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !95, file: !88, line: 59, baseType: !24, size: 64, offset: 64) +!102 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !95, file: !88, line: 60, baseType: !94, size: 64, offset: 128) +!103 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !90, file: !88, line: 106, baseType: !104, size: 65408, offset: 128) +!104 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !105) +!105 = !{!106} +!106 = !DISubrange(count: 8176) +!107 = !DILocation(line: 35, column: 12, scope: !81) +!108 = !DILocalVariable(name: "t2", scope: !81, file: !3, line: 35, type: !85) +!109 = !DILocation(line: 35, column: 16, scope: !81) +!110 = !DILocation(line: 37, column: 2, scope: !81) +!111 = !DILocation(line: 38, column: 2, scope: !81) +!112 = !DILocation(line: 40, column: 15, scope: !81) +!113 = !DILocation(line: 40, column: 2, scope: !81) +!114 = !DILocation(line: 41, column: 15, scope: !81) +!115 = !DILocation(line: 41, column: 2, scope: !81) +!116 = !DILocation(line: 43, column: 2, scope: !81) +!117 = !DILocation(line: 0, scope: !81) +!118 = !DILocation(line: 45, column: 2, scope: !81) diff --git a/dartagnan/src/test/resources/lkmm/rcu.ll b/dartagnan/src/test/resources/lkmm/rcu.ll index 0eaa7a5b71..b7d5c6b847 100644 --- a/dartagnan/src/test/resources/lkmm/rcu.ll +++ b/dartagnan/src/test/resources/lkmm/rcu.ll @@ -1,178 +1,227 @@ -; ModuleID = '/home/ponce/git/Dat3M/output/rcu.ll' -source_filename = "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu.c" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +; ModuleID = 'benchmarks/lkmm/rcu.c' +source_filename = "benchmarks/lkmm/rcu.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" -%union.pthread_attr_t = type { i64, [48 x i8] } - @x = dso_local global i32 0, align 4, !dbg !0 -@y = dso_local global i32 0, align 4, !dbg !26 -@r_x = dso_local global i32 0, align 4, !dbg !30 -@r_y = dso_local global i32 0, align 4, !dbg !32 -@.str = private unnamed_addr constant [24 x i8] c"!(r_x == 1 && r_y == 0)\00", align 1 -@.str.1 = private unnamed_addr constant [44 x i8] c"/home/ponce/git/Dat3M/benchmarks/lkmm/rcu.c\00", align 1 -@__PRETTY_FUNCTION__.main = private unnamed_addr constant [11 x i8] c"int main()\00", align 1 +@y = dso_local global i32 0, align 4, !dbg !47 +@r_x = dso_local global i32 0, align 4, !dbg !49 +@r_y = dso_local global i32 0, align 4, !dbg !51 +@__func__.main = private unnamed_addr constant [5 x i8] c"main\00", align 1, !dbg !30 +@.str = private unnamed_addr constant [6 x i8] c"rcu.c\00", align 1, !dbg !37 +@.str.1 = private unnamed_addr constant [24 x i8] c"!(r_x == 1 && r_y == 0)\00", align 1, !dbg !42 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P0(i8* noundef %0) #0 !dbg !42 { - call void @llvm.dbg.value(metadata i8* %0, metadata !46, metadata !DIExpression()), !dbg !47 - call void @__LKMM_FENCE(i32 noundef 7) #5, !dbg !48 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !49 - call void @__LKMM_STORE(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1, i32 noundef 1) #5, !dbg !50 - call void @__LKMM_FENCE(i32 noundef 8) #5, !dbg !51 - ret i8* null, !dbg !52 +define dso_local ptr @P0(ptr noundef %0) #0 !dbg !61 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !65, !DIExpression(), !66) + call void @__LKMM_fence(i32 noundef 6), !dbg !67 + call void @__LKMM_store(ptr noundef @x, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !68 + call void @__LKMM_store(ptr noundef @y, i64 noundef 4, i64 noundef 1, i32 noundef 0), !dbg !69 + call void @__LKMM_fence(i32 noundef 7), !dbg !70 + ret ptr null, !dbg !71 } -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare void @__LKMM_FENCE(i32 noundef) #2 +declare void @__LKMM_fence(i32 noundef) #1 -declare void @__LKMM_STORE(i8* noundef, i32 noundef, i32 noundef) #2 +declare void @__LKMM_store(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @P1(i8* noundef %0) #0 !dbg !53 { - call void @llvm.dbg.value(metadata i8* %0, metadata !54, metadata !DIExpression()), !dbg !55 - %2 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @x to i8*), i32 noundef 1) #5, !dbg !56 - store i32 %2, i32* @r_x, align 4, !dbg !57 - call void @__LKMM_FENCE(i32 noundef 9) #5, !dbg !58 - %3 = call i32 @__LKMM_LOAD(i8* noundef bitcast (i32* @y to i8*), i32 noundef 1) #5, !dbg !59 - store i32 %3, i32* @r_y, align 4, !dbg !60 - ret i8* null, !dbg !61 +define dso_local ptr @P1(ptr noundef %0) #0 !dbg !72 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + #dbg_declare(ptr %2, !73, !DIExpression(), !74) + %3 = call i64 @__LKMM_load(ptr noundef @x, i64 noundef 4, i32 noundef 0), !dbg !75 + %4 = trunc i64 %3 to i32, !dbg !75 + store i32 %4, ptr @r_x, align 4, !dbg !76 + call void @__LKMM_fence(i32 noundef 8), !dbg !77 + %5 = call i64 @__LKMM_load(ptr noundef @y, i64 noundef 4, i32 noundef 0), !dbg !78 + %6 = trunc i64 %5 to i32, !dbg !78 + store i32 %6, ptr @r_y, align 4, !dbg !79 + ret ptr null, !dbg !80 } -declare i32 @__LKMM_LOAD(i8* noundef, i32 noundef) #2 +declare i64 @__LKMM_load(ptr noundef, i64 noundef, i32 noundef) #1 ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !62 { - %1 = alloca i64, align 8 - %2 = alloca i64, align 8 - call void @llvm.dbg.value(metadata i64* %1, metadata !65, metadata !DIExpression(DW_OP_deref)), !dbg !69 - %3 = call i32 @pthread_create(i64* noundef nonnull %1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P0, i8* noundef null) #5, !dbg !70 - call void @llvm.dbg.value(metadata i64* %2, metadata !71, metadata !DIExpression(DW_OP_deref)), !dbg !69 - %4 = call i32 @pthread_create(i64* noundef nonnull %2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef nonnull @P1, i8* noundef null) #5, !dbg !72 - %5 = load i64, i64* %1, align 8, !dbg !73 - call void @llvm.dbg.value(metadata i64 %5, metadata !65, metadata !DIExpression()), !dbg !69 - %6 = call i32 @pthread_join(i64 noundef %5, i8** noundef null) #5, !dbg !74 - %7 = load i64, i64* %2, align 8, !dbg !75 - call void @llvm.dbg.value(metadata i64 %7, metadata !71, metadata !DIExpression()), !dbg !69 - %8 = call i32 @pthread_join(i64 noundef %7, i8** noundef null) #5, !dbg !76 - %9 = load i32, i32* @r_x, align 4, !dbg !77 - %10 = icmp eq i32 %9, 1, !dbg !77 - %11 = load i32, i32* @r_y, align 4, !dbg !77 - %12 = icmp eq i32 %11, 0, !dbg !77 - %or.cond = select i1 %10, i1 %12, i1 false, !dbg !77 - br i1 %or.cond, label %13, label %14, !dbg !77 - -13: ; preds = %0 - call void @__assert_fail(i8* noundef getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 noundef 43, i8* noundef getelementptr inbounds ([11 x i8], [11 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #6, !dbg !77 - unreachable, !dbg !77 - -14: ; preds = %0 - ret i32 0, !dbg !80 +define dso_local i32 @main() #0 !dbg !81 { + %1 = alloca i32, align 4 + %2 = alloca ptr, align 8 + %3 = alloca ptr, align 8 + store i32 0, ptr %1, align 4 + #dbg_declare(ptr %2, !84, !DIExpression(), !107) + #dbg_declare(ptr %3, !108, !DIExpression(), !109) + %4 = call i32 @pthread_create(ptr noundef %2, ptr noundef null, ptr noundef @P0, ptr noundef null), !dbg !110 + %5 = call i32 @pthread_create(ptr noundef %3, ptr noundef null, ptr noundef @P1, ptr noundef null), !dbg !111 + %6 = load ptr, ptr %2, align 8, !dbg !112 + %7 = call i32 @_pthread_join(ptr noundef %6, ptr noundef null), !dbg !113 + %8 = load ptr, ptr %3, align 8, !dbg !114 + %9 = call i32 @_pthread_join(ptr noundef %8, ptr noundef null), !dbg !115 + %10 = load i32, ptr @r_x, align 4, !dbg !116 + %11 = icmp eq i32 %10, 1, !dbg !116 + br i1 %11, label %12, label %15, !dbg !116 + +12: ; preds = %0 + %13 = load i32, ptr @r_y, align 4, !dbg !116 + %14 = icmp eq i32 %13, 0, !dbg !116 + br label %15 + +15: ; preds = %12, %0 + %16 = phi i1 [ false, %0 ], [ %14, %12 ], !dbg !117 + %17 = xor i1 %16, true, !dbg !116 + %18 = xor i1 %17, true, !dbg !116 + %19 = zext i1 %18 to i32, !dbg !116 + %20 = sext i32 %19 to i64, !dbg !116 + %21 = icmp ne i64 %20, 0, !dbg !116 + br i1 %21, label %22, label %24, !dbg !116 + +22: ; preds = %15 + call void @__assert_rtn(ptr noundef @__func__.main, ptr noundef @.str, i32 noundef 43, ptr noundef @.str.1) #3, !dbg !116 + unreachable, !dbg !116 + +23: ; No predecessors! + br label %25, !dbg !116 + +24: ; preds = %15 + br label %25, !dbg !116 + +25: ; preds = %24, %23 + ret i32 0, !dbg !118 } -; Function Attrs: nounwind -declare i32 @pthread_create(i64* noundef, %union.pthread_attr_t* noundef, i8* (i8*)* noundef, i8* noundef) #3 - -declare i32 @pthread_join(i64 noundef, i8** noundef) #2 +declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 -; Function Attrs: noreturn nounwind -declare void @__assert_fail(i8* noundef, i8* noundef, i32 noundef, i8* noundef) #4 +declare i32 @_pthread_join(ptr noundef, ptr noundef) #1 -; Function Attrs: nofree nosync nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +; Function Attrs: cold noreturn +declare void @__assert_rtn(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2 -attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } -attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #3 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #4 = { noreturn nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #5 = { nounwind } -attributes #6 = { noreturn nounwind } +attributes #0 = { noinline nounwind uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { cold noreturn "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { cold noreturn } !llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!34, !35, !36, !37, !38, !39, !40} -!llvm.ident = !{!41} +!llvm.module.flags = !{!53, !54, !55, !56, !57, !58, !59} +!llvm.ident = !{!60} !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !28, line: 7, type: !29, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "Ubuntu clang version 14.0.6", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !23, globals: !25, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "/home/ponce/git/Dat3M/benchmarks/lkmm/rcu.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "dad53a6fc905d03af1a936e703cc6339") +!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 7, type: !28, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "Homebrew clang version 19.1.7", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !29, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "benchmarks/lkmm/rcu.c", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "dad53a6fc905d03af1a936e703cc6339") !4 = !{!5} -!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) -!6 = !DIFile(filename: "include/lkmm.h", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "f219e5a4f2482585588927d06bb5e5c6") +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "__LKMM_memory_order", file: !6, line: 3, baseType: !7, size: 32, elements: !8) +!6 = !DIFile(filename: "include/lkmm.h", directory: "/Users/r/git/dat3m", checksumkind: CSK_MD5, checksum: "26457005f8f39b3952d279119fb45118") !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) -!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22} -!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) -!10 = !DIEnumerator(name: "memory_order_once", value: 1) -!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) -!12 = !DIEnumerator(name: "memory_order_release", value: 3) -!13 = !DIEnumerator(name: "mb", value: 4) -!14 = !DIEnumerator(name: "wmb", value: 5) -!15 = !DIEnumerator(name: "rmb", value: 6) -!16 = !DIEnumerator(name: "rcu_lock", value: 7) -!17 = !DIEnumerator(name: "rcu_unlock", value: 8) -!18 = !DIEnumerator(name: "rcu_sync", value: 9) -!19 = !DIEnumerator(name: "before_atomic", value: 10) -!20 = !DIEnumerator(name: "after_atomic", value: 11) -!21 = !DIEnumerator(name: "after_spinlock", value: 12) -!22 = !DIEnumerator(name: "barrier", value: 13) -!23 = !{!24} -!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) -!25 = !{!0, !26, !30, !32} -!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) -!27 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !28, line: 8, type: !29, isLocal: false, isDefinition: true) -!28 = !DIFile(filename: "benchmarks/lkmm/rcu.c", directory: "/home/ponce/git/Dat3M", checksumkind: CSK_MD5, checksum: "dad53a6fc905d03af1a936e703cc6339") -!29 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21} +!9 = !DIEnumerator(name: "__LKMM_once", value: 0) +!10 = !DIEnumerator(name: "__LKMM_acquire", value: 1) +!11 = !DIEnumerator(name: "__LKMM_release", value: 2) +!12 = !DIEnumerator(name: "__LKMM_mb", value: 3) +!13 = !DIEnumerator(name: "__LKMM_wmb", value: 4) +!14 = !DIEnumerator(name: "__LKMM_rmb", value: 5) +!15 = !DIEnumerator(name: "__LKMM_rcu_lock", value: 6) +!16 = !DIEnumerator(name: "__LKMM_rcu_unlock", value: 7) +!17 = !DIEnumerator(name: "__LKMM_rcu_sync", value: 8) +!18 = !DIEnumerator(name: "__LKMM_before_atomic", value: 9) +!19 = !DIEnumerator(name: "__LKMM_after_atomic", value: 10) +!20 = !DIEnumerator(name: "__LKMM_after_spinlock", value: 11) +!21 = !DIEnumerator(name: "__LKMM_barrier", value: 12) +!22 = !{!23, !27, !28} +!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__LKMM_int_t", file: !6, line: 27, baseType: !24) +!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !25, line: 32, baseType: !26) +!25 = !DIFile(filename: "/usr/local/include/_types/_intmax_t.h", directory: "", checksumkind: CSK_MD5, checksum: "e37b9240f30f486478152ef3989b1545") +!26 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!29 = !{!30, !37, !42, !0, !47, !49, !51} !30 = !DIGlobalVariableExpression(var: !31, expr: !DIExpression()) -!31 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !28, line: 10, type: !29, isLocal: false, isDefinition: true) -!32 = !DIGlobalVariableExpression(var: !33, expr: !DIExpression()) -!33 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !28, line: 11, type: !29, isLocal: false, isDefinition: true) -!34 = !{i32 7, !"Dwarf Version", i32 5} -!35 = !{i32 2, !"Debug Info Version", i32 3} -!36 = !{i32 1, !"wchar_size", i32 4} -!37 = !{i32 7, !"PIC Level", i32 2} -!38 = !{i32 7, !"PIE Level", i32 2} -!39 = !{i32 7, !"uwtable", i32 1} -!40 = !{i32 7, !"frame-pointer", i32 2} -!41 = !{!"Ubuntu clang version 14.0.6"} -!42 = distinct !DISubprogram(name: "P0", scope: !28, file: !28, line: 13, type: !43, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!43 = !DISubroutineType(types: !44) -!44 = !{!24, !24} -!45 = !{} -!46 = !DILocalVariable(name: "unused", arg: 1, scope: !42, file: !28, line: 13, type: !24) -!47 = !DILocation(line: 0, scope: !42) -!48 = !DILocation(line: 15, column: 2, scope: !42) -!49 = !DILocation(line: 16, column: 2, scope: !42) -!50 = !DILocation(line: 17, column: 2, scope: !42) -!51 = !DILocation(line: 18, column: 2, scope: !42) -!52 = !DILocation(line: 19, column: 2, scope: !42) -!53 = distinct !DISubprogram(name: "P1", scope: !28, file: !28, line: 22, type: !43, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!54 = !DILocalVariable(name: "unused", arg: 1, scope: !53, file: !28, line: 22, type: !24) -!55 = !DILocation(line: 0, scope: !53) -!56 = !DILocation(line: 24, column: 8, scope: !53) -!57 = !DILocation(line: 24, column: 6, scope: !53) -!58 = !DILocation(line: 25, column: 2, scope: !53) -!59 = !DILocation(line: 26, column: 8, scope: !53) -!60 = !DILocation(line: 26, column: 6, scope: !53) -!61 = !DILocation(line: 27, column: 2, scope: !53) -!62 = distinct !DISubprogram(name: "main", scope: !28, file: !28, line: 30, type: !63, scopeLine: 31, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !45) -!63 = !DISubroutineType(types: !64) -!64 = !{!29} -!65 = !DILocalVariable(name: "t1", scope: !62, file: !28, line: 35, type: !66) -!66 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !67, line: 27, baseType: !68) -!67 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h", directory: "", checksumkind: CSK_MD5, checksum: "2d764266ce95ab26d4a4767c2ec78176") -!68 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) -!69 = !DILocation(line: 0, scope: !62) -!70 = !DILocation(line: 37, column: 2, scope: !62) -!71 = !DILocalVariable(name: "t2", scope: !62, file: !28, line: 35, type: !66) -!72 = !DILocation(line: 38, column: 2, scope: !62) -!73 = !DILocation(line: 40, column: 15, scope: !62) -!74 = !DILocation(line: 40, column: 2, scope: !62) -!75 = !DILocation(line: 41, column: 15, scope: !62) -!76 = !DILocation(line: 41, column: 2, scope: !62) -!77 = !DILocation(line: 43, column: 2, scope: !78) -!78 = distinct !DILexicalBlock(scope: !79, file: !28, line: 43, column: 2) -!79 = distinct !DILexicalBlock(scope: !62, file: !28, line: 43, column: 2) -!80 = !DILocation(line: 45, column: 2, scope: !62) +!31 = distinct !DIGlobalVariable(scope: null, file: !3, line: 43, type: !32, isLocal: true, isDefinition: true) +!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 40, elements: !35) +!33 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !34) +!34 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!35 = !{!36} +!36 = !DISubrange(count: 5) +!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) +!38 = distinct !DIGlobalVariable(scope: null, file: !3, line: 43, type: !39, isLocal: true, isDefinition: true) +!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 48, elements: !40) +!40 = !{!41} +!41 = !DISubrange(count: 6) +!42 = !DIGlobalVariableExpression(var: !43, expr: !DIExpression()) +!43 = distinct !DIGlobalVariable(scope: null, file: !3, line: 43, type: !44, isLocal: true, isDefinition: true) +!44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 192, elements: !45) +!45 = !{!46} +!46 = !DISubrange(count: 24) +!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression()) +!48 = distinct !DIGlobalVariable(name: "y", scope: !2, file: !3, line: 8, type: !28, isLocal: false, isDefinition: true) +!49 = !DIGlobalVariableExpression(var: !50, expr: !DIExpression()) +!50 = distinct !DIGlobalVariable(name: "r_x", scope: !2, file: !3, line: 10, type: !28, isLocal: false, isDefinition: true) +!51 = !DIGlobalVariableExpression(var: !52, expr: !DIExpression()) +!52 = distinct !DIGlobalVariable(name: "r_y", scope: !2, file: !3, line: 11, type: !28, isLocal: false, isDefinition: true) +!53 = !{i32 7, !"Dwarf Version", i32 5} +!54 = !{i32 2, !"Debug Info Version", i32 3} +!55 = !{i32 1, !"wchar_size", i32 4} +!56 = !{i32 8, !"PIC Level", i32 2} +!57 = !{i32 7, !"PIE Level", i32 2} +!58 = !{i32 7, !"uwtable", i32 2} +!59 = !{i32 7, !"frame-pointer", i32 2} +!60 = !{!"Homebrew clang version 19.1.7"} +!61 = distinct !DISubprogram(name: "P0", scope: !3, file: !3, line: 13, type: !62, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!62 = !DISubroutineType(types: !63) +!63 = !{!27, !27} +!64 = !{} +!65 = !DILocalVariable(name: "unused", arg: 1, scope: !61, file: !3, line: 13, type: !27) +!66 = !DILocation(line: 13, column: 16, scope: !61) +!67 = !DILocation(line: 15, column: 2, scope: !61) +!68 = !DILocation(line: 16, column: 2, scope: !61) +!69 = !DILocation(line: 17, column: 2, scope: !61) +!70 = !DILocation(line: 18, column: 2, scope: !61) +!71 = !DILocation(line: 19, column: 2, scope: !61) +!72 = distinct !DISubprogram(name: "P1", scope: !3, file: !3, line: 22, type: !62, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!73 = !DILocalVariable(name: "unused", arg: 1, scope: !72, file: !3, line: 22, type: !27) +!74 = !DILocation(line: 22, column: 16, scope: !72) +!75 = !DILocation(line: 24, column: 8, scope: !72) +!76 = !DILocation(line: 24, column: 6, scope: !72) +!77 = !DILocation(line: 25, column: 2, scope: !72) +!78 = !DILocation(line: 26, column: 8, scope: !72) +!79 = !DILocation(line: 26, column: 6, scope: !72) +!80 = !DILocation(line: 27, column: 2, scope: !72) +!81 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 30, type: !82, scopeLine: 31, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !64) +!82 = !DISubroutineType(types: !83) +!83 = !{!28} +!84 = !DILocalVariable(name: "t1", scope: !81, file: !3, line: 35, type: !85) +!85 = !DIDerivedType(tag: DW_TAG_typedef, name: "pthread_t", file: !86, line: 31, baseType: !87) +!86 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_t.h", directory: "", checksumkind: CSK_MD5, checksum: "086fc6d7dc3c67fdb87e7376555dcfd7") +!87 = !DIDerivedType(tag: DW_TAG_typedef, name: "__darwin_pthread_t", file: !88, line: 118, baseType: !89) +!88 = !DIFile(filename: "/usr/local/include/sys/_pthread/_pthread_types.h", directory: "", checksumkind: CSK_MD5, checksum: "4e2ea0e1af95894da0a6030a21a8ebee") +!89 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !90, size: 64) +!90 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_opaque_pthread_t", file: !88, line: 103, size: 65536, elements: !91) +!91 = !{!92, !93, !103} +!92 = !DIDerivedType(tag: DW_TAG_member, name: "__sig", scope: !90, file: !88, line: 104, baseType: !26, size: 64) +!93 = !DIDerivedType(tag: DW_TAG_member, name: "__cleanup_stack", scope: !90, file: !88, line: 105, baseType: !94, size: 64, offset: 64) +!94 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !95, size: 64) +!95 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__darwin_pthread_handler_rec", file: !88, line: 57, size: 192, elements: !96) +!96 = !{!97, !101, !102} +!97 = !DIDerivedType(tag: DW_TAG_member, name: "__routine", scope: !95, file: !88, line: 58, baseType: !98, size: 64) +!98 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !99, size: 64) +!99 = !DISubroutineType(types: !100) +!100 = !{null, !27} +!101 = !DIDerivedType(tag: DW_TAG_member, name: "__arg", scope: !95, file: !88, line: 59, baseType: !27, size: 64, offset: 64) +!102 = !DIDerivedType(tag: DW_TAG_member, name: "__next", scope: !95, file: !88, line: 60, baseType: !94, size: 64, offset: 128) +!103 = !DIDerivedType(tag: DW_TAG_member, name: "__opaque", scope: !90, file: !88, line: 106, baseType: !104, size: 65408, offset: 128) +!104 = !DICompositeType(tag: DW_TAG_array_type, baseType: !34, size: 65408, elements: !105) +!105 = !{!106} +!106 = !DISubrange(count: 8176) +!107 = !DILocation(line: 35, column: 15, scope: !81) +!108 = !DILocalVariable(name: "t2", scope: !81, file: !3, line: 35, type: !85) +!109 = !DILocation(line: 35, column: 19, scope: !81) +!110 = !DILocation(line: 37, column: 2, scope: !81) +!111 = !DILocation(line: 38, column: 2, scope: !81) +!112 = !DILocation(line: 40, column: 15, scope: !81) +!113 = !DILocation(line: 40, column: 2, scope: !81) +!114 = !DILocation(line: 41, column: 15, scope: !81) +!115 = !DILocation(line: 41, column: 2, scope: !81) +!116 = !DILocation(line: 43, column: 2, scope: !81) +!117 = !DILocation(line: 0, scope: !81) +!118 = !DILocation(line: 45, column: 2, scope: !81) diff --git a/include/lkmm.h b/include/lkmm.h index c9b07cf99f..4cab8a9d32 100644 --- a/include/lkmm.h +++ b/include/lkmm.h @@ -1,45 +1,58 @@ #include -typedef enum memory_order { - memory_order_relaxed, - memory_order_once, - memory_order_acquire, - memory_order_release, - mb, - wmb, - rmb, - rcu_lock, - rcu_unlock, - rcu_sync, - before_atomic, - after_atomic, - after_spinlock, - barrier, -} memory_order; - -typedef enum operation { - op_add, - op_sub, - op_and, - op_or, -} operation; - -extern int __LKMM_LOAD(void*, memory_order); -extern void __LKMM_STORE(void*, int, memory_order); -extern void __LKMM_FENCE(int); -extern int __LKMM_XCHG(int*, int, memory_order); -extern int __LKMM_CMPXCHG(int*, int, int, memory_order, memory_order); -extern void __LKMM_ATOMIC_OP(int*, int, operation); -extern int __LKMM_ATOMIC_FETCH_OP(int*, int, memory_order, operation); -extern int __LKMM_ATOMIC_OP_RETURN(int*, int, memory_order, operation); +typedef enum __LKMM_memory_order { + __LKMM_once, + __LKMM_acquire, + __LKMM_release, + __LKMM_mb, + __LKMM_wmb, + __LKMM_rmb, + __LKMM_rcu_lock, + __LKMM_rcu_unlock, + __LKMM_rcu_sync, + __LKMM_before_atomic, + __LKMM_after_atomic, + __LKMM_after_spinlock, + __LKMM_barrier, +} __LKMM_memory_order; + +typedef enum __LKMM_operation { + __LKMM_op_add, + __LKMM_op_sub, + __LKMM_op_and, + __LKMM_op_or, +} __LKMM_operation; + +typedef typeof(sizeof(int)) __LKMM_size_t; +typedef intmax_t __LKMM_int_t; + +/* Intrinsics defined by the verifier */ +extern __LKMM_int_t __LKMM_load(const volatile void*, __LKMM_size_t, __LKMM_memory_order); +extern void __LKMM_store(volatile void*, __LKMM_size_t, __LKMM_int_t, __LKMM_memory_order); +extern __LKMM_int_t __LKMM_xchg(volatile void*, __LKMM_size_t, __LKMM_int_t, __LKMM_memory_order); +extern __LKMM_int_t __LKMM_cmpxchg(volatile void*, __LKMM_size_t, __LKMM_int_t, __LKMM_int_t, __LKMM_memory_order, __LKMM_memory_order); +extern void __LKMM_atomic_op(volatile void*, __LKMM_size_t, __LKMM_int_t, __LKMM_operation); +extern __LKMM_int_t __LKMM_atomic_op_return(volatile void*, __LKMM_size_t, __LKMM_int_t, __LKMM_memory_order, __LKMM_operation); +extern __LKMM_int_t __LKMM_atomic_fetch_op(volatile void*, __LKMM_size_t, __LKMM_int_t, __LKMM_memory_order, __LKMM_operation); +extern void __LKMM_fence(__LKMM_memory_order); + +/* Converting macros being used below */ +#define __LKMM_LOAD(p, mo) (typeof(*p))__LKMM_load(p, sizeof(*(p)), __LKMM_##mo) +#define __LKMM_STORE(p, v, mo) __LKMM_store(p, sizeof(*(p)), (__LKMM_int_t)(v), __LKMM_##mo) +#define __LKMM_XCHG(p, v, mo) (typeof(*p)) __LKMM_xchg(p, sizeof(*(p)), (__LKMM_int_t)(v), __LKMM_##mo) +#define __LKMM_CMPXCHG(p, c, v, mo0, mo1) (typeof(*p)) __LKMM_cmpxchg(p, sizeof(*(p)), (__LKMM_int_t)(c), (__LKMM_int_t)(v), __LKMM_##mo0, __LKMM_##mo1) +#define __LKMM_ATOMIC_OP(p, v, op) __LKMM_atomic_op(p, sizeof(*(p)), (__LKMM_int_t)(v), __LKMM_##op) +#define __LKMM_ATOMIC_OP_RETURN(p, v, mo, op) (typeof(*p)) __LKMM_atomic_op_return(p, sizeof(*(p)), (__LKMM_int_t)(v), __LKMM_##mo, __LKMM_##op) +#define __LKMM_ATOMIC_FETCH_OP(p, v, mo, op) (typeof(*p)) __LKMM_atomic_fetch_op(p, sizeof(*(p)), (__LKMM_int_t)(v), __LKMM_##mo, __LKMM_##op) +#define __LKMM_FENCE(mo) __LKMM_fence(__LKMM_##mo) /******************************************************************************* ** ONCE, FENCES AND FRIENDS ******************************************************************************/ /* ONCE */ -#define READ_ONCE(x) __LKMM_LOAD(&x, memory_order_once) -#define WRITE_ONCE(x, v) __LKMM_STORE(&x, v, memory_order_once) +#define READ_ONCE(x) __LKMM_LOAD(&x, once) +#define WRITE_ONCE(x, v) __LKMM_STORE(&x, v, once) /* Fences */ @@ -54,8 +67,8 @@ extern int __LKMM_ATOMIC_OP_RETURN(int*, int, memory_order, operation); #define smp_mb__after_unlock_lock() __LKMM_FENCE(after_unlock_lock) /* Acquire/Release and friends */ -#define smp_load_acquire(p) __LKMM_LOAD(p, memory_order_acquire) -#define smp_store_release(p, v) __LKMM_STORE(p, v, memory_order_release) +#define smp_load_acquire(p) __LKMM_LOAD(p, acquire) +#define smp_store_release(p, v) __LKMM_STORE(p, v, release) #define rcu_dereference(p) READ_ONCE(p) #define rcu_assign_pointer(p, v) smp_store_release(&(p), v) #define smp_store_mb(x, v) \ @@ -66,24 +79,24 @@ do { \ /* Exchange */ #define xchg(p, v) __LKMM_XCHG(p, v, mb); -#define xchg_relaxed(p, v) __LKMM_XCHG(p, v, memory_order_relaxed) -#define xchg_release(p, v) __LKMM_XCHG(p, v, memory_order_release) -#define xchg_acquire(p, v) __LKMM_XCHG(p, v, memory_order_acquire) +#define xchg_relaxed(p, v) __LKMM_XCHG(p, v, once) +#define xchg_release(p, v) __LKMM_XCHG(p, v, release) +#define xchg_acquire(p, v) __LKMM_XCHG(p, v, acquire) #define xchg_long(p, v) __LKMM_XCHG(p, v, mb); -#define xchg_long_relaxed(p, v) __LKMM_XCHG(p, v, memory_order_relaxed) -#define xchg_long_release(p, v) __LKMM_XCHG(p, v, memory_order_release) -#define xchg_long_acquire(p, v) __LKMM_XCHG(p, v, memory_order_acquire) +#define xchg_long_relaxed(p, v) __LKMM_XCHG(p, v, once) +#define xchg_long_release(p, v) __LKMM_XCHG(p, v, release) +#define xchg_long_acquire(p, v) __LKMM_XCHG(p, v, acquire) #define cmpxchg(p, o, n) __LKMM_CMPXCHG(p, o, n, mb, mb) -#define cmpxchg_relaxed(p, o, n) __LKMM_CMPXCHG(p, o, n, memory_order_relaxed, memory_order_relaxed) -#define cmpxchg_acquire(p, o, n) __LKMM_CMPXCHG(p, o, n, memory_order_acquire, memory_order_acquire) -#define cmpxchg_release(p, o, n) __LKMM_CMPXCHG(p, o, n, memory_order_release, memory_order_release) +#define cmpxchg_relaxed(p, o, n) __LKMM_CMPXCHG(p, o, n, once, once) +#define cmpxchg_acquire(p, o, n) __LKMM_CMPXCHG(p, o, n, acquire, acquire) +#define cmpxchg_release(p, o, n) __LKMM_CMPXCHG(p, o, n, release, release) #define cmpxchg_long(p, o, n) __LKMM_CMPXCHG(p, o, n, mb, mb) -#define cmpxchg_long_relaxed(p, o, n) __LKMM_CMPXCHG(p, o, n, memory_order_relaxed, memory_order_relaxed) -#define cmpxchg_long_acquire(p, o, n) __LKMM_CMPXCHG(p, o, n, memory_order_acquire, memory_order_acquire) -#define cmpxchg_long_release(p, o, n) __LKMM_CMPXCHG(p, o, n, memory_order_release, memory_order_release) +#define cmpxchg_long_relaxed(p, o, n) __LKMM_CMPXCHG(p, o, n, once, once) +#define cmpxchg_long_acquire(p, o, n) __LKMM_CMPXCHG(p, o, n, acquire, acquire) +#define cmpxchg_long_release(p, o, n) __LKMM_CMPXCHG(p, o, n, release, release) /******************************************************************************* ** ATOMIC OPERATIONS @@ -133,14 +146,14 @@ typedef atomic64_t atomic_long_t; /* Value-returning atomics */ #define atomic_fetch_add(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_add) -#define atomic_fetch_add_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_add) -#define atomic_fetch_add_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_add) -#define atomic_fetch_add_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_add) +#define atomic_fetch_add_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_add) +#define atomic_fetch_add_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_add) +#define atomic_fetch_add_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_add) #define atomic_long_fetch_add(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_add) -#define atomic_long_fetch_add_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_add) -#define atomic_long_fetch_add_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_add) -#define atomic_long_fetch_add_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_add) +#define atomic_long_fetch_add_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_add) +#define atomic_long_fetch_add_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_add) +#define atomic_long_fetch_add_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_add) #define atomic_fetch_inc(v) atomic_fetch_add(1, v) #define atomic_fetch_inc_relaxed(v) atomic_fetch_add_relaxed(1, v) @@ -153,14 +166,14 @@ typedef atomic64_t atomic_long_t; #define atomic_long_fetch_inc_release(v) atomic_long_fetch_add_release(1, v) #define atomic_fetch_sub(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_sub) -#define atomic_fetch_sub_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_sub) -#define atomic_fetch_sub_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_sub) -#define atomic_fetch_sub_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_sub) +#define atomic_fetch_sub_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_sub) +#define atomic_fetch_sub_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_sub) +#define atomic_fetch_sub_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_sub) #define atomic_long_fetch_sub(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_sub) -#define atomic_long_fetch_sub_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_sub) -#define atomic_long_fetch_sub_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_sub) -#define atomic_long_fetch_sub_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_sub) +#define atomic_long_fetch_sub_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_sub) +#define atomic_long_fetch_sub_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_sub) +#define atomic_long_fetch_sub_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_sub) #define atomic_fetch_dec(v) atomic_fetch_sub(1, v) #define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, v) @@ -173,14 +186,14 @@ typedef atomic64_t atomic_long_t; #define atomic_long_fetch_dec_release(v) atomic_long_fetch_sub_release(1, v) #define atomic_fetch_and(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_and) -#define atomic_fetch_and_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_and) -#define atomic_fetch_and_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_and) -#define atomic_fetch_and_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_and) +#define atomic_fetch_and_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_and) +#define atomic_fetch_and_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_and) +#define atomic_fetch_and_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_and) #define atomic_long_fetch_and(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_and) -#define atomic_long_fetch_and_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_and) -#define atomic_long_fetch_and_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_and) -#define atomic_long_fetch_and_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_and) +#define atomic_long_fetch_and_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_and) +#define atomic_long_fetch_and_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_and) +#define atomic_long_fetch_and_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_and) #define atomic_fetch_andnot(i, v) atomic_fetch_and(~(i), v) #define atomic_fetch_andnot_relaxed(i, v) atomic_fetch_and_relaxed(~(i), v) @@ -193,19 +206,19 @@ typedef atomic64_t atomic_long_t; #define atomic_long_fetch_andnot_release(i, v) atomic_long_fetch_and_release(~(i), v) #define atomic_fetch_or(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_or) -#define atomic_fetch_or_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_or) -#define atomic_fetch_or_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_or) -#define atomic_fetch_or_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_or) +#define atomic_fetch_or_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_or) +#define atomic_fetch_or_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_or) +#define atomic_fetch_or_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_or) #define atomic_long_fetch_or(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, mb, op_or) -#define atomic_long_fetch_or_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_relaxed, op_or) -#define atomic_long_fetch_or_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_acquire, op_or) -#define atomic_long_fetch_or_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, memory_order_release, op_or) +#define atomic_long_fetch_or_relaxed(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, once, op_or) +#define atomic_long_fetch_or_acquire(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, acquire, op_or) +#define atomic_long_fetch_or_release(i, v) __LKMM_ATOMIC_FETCH_OP(&(v)->counter, i, release, op_or) #define atomic_add_return(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, mb, op_add) -#define atomic_add_return_relaxed(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_relaxed, op_add) -#define atomic_add_return_acquire(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_acquire, op_add) -#define atomic_add_return_release(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_release, op_add) +#define atomic_add_return_relaxed(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, once, op_add) +#define atomic_add_return_acquire(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, acquire, op_add) +#define atomic_add_return_release(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, release, op_add) #define atomic_inc_return(v) atomic_add_return(1, v) #define atomic_inc_return_relaxed(v) atomic_add_return_relaxed(1, v) @@ -218,14 +231,14 @@ typedef atomic64_t atomic_long_t; #define atomic_long_inc_return_release(v) atomic_long_add_return_release(1, v) #define atomic_sub_return(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, mb, op_sub) -#define atomic_sub_return_relaxed(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_relaxed, op_sub) -#define atomic_sub_return_acquire(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_acquire, op_sub) -#define atomic_sub_return_release(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_release, op_sub) +#define atomic_sub_return_relaxed(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, once, op_sub) +#define atomic_sub_return_acquire(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, acquire, op_sub) +#define atomic_sub_return_release(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, release, op_sub) #define atomic_long_sub_return(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, mb, op_sub) -#define atomic_long_sub_return_relaxed(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_relaxed, op_sub) -#define atomic_long_sub_return_acquire(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_acquire, op_sub) -#define atomic_long_sub_return_release(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, memory_order_release, op_sub) +#define atomic_long_sub_return_relaxed(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, once, op_sub) +#define atomic_long_sub_return_acquire(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, acquire, op_sub) +#define atomic_long_sub_return_release(i, v) __LKMM_ATOMIC_OP_RETURN(&(v)->counter, i, release, op_sub) #define atomic_dec_return(v) atomic_sub_return(1, v) #define atomic_dec_return_relaxed(v) atomic_sub_return_relaxed(1, v) From e6cb1c7d10657f3a776c4e2cd6b5bc2f38dbcb96 Mon Sep 17 00:00:00 2001 From: Hernan Ponce de Leon Date: Mon, 26 May 2025 16:21:06 +0200 Subject: [PATCH 07/10] Remove unnecessary includes in cat models (#895) Signed-off-by: Hernan Ponce de Leon Co-authored-by: Hernan Ponce de Leon --- cat/aarch64.cat | 13 ------------- cat/arm.cat | 3 --- cat/c11-orig.cat | 3 --- cat/c11-partialsc.cat | 3 --- cat/c11.cat | 3 --- cat/lock.cat | 16 +++++++--------- cat/opencl-herd.cat | 2 -- cat/power.cat | 1 - cat/rc11.cat | 3 --- cat/riscv-orig.cat | 3 --- cat/riscv.cat | 6 ------ cat/sc.cat | 3 --- cat/svcomp.cat | 3 --- cat/tso.cat | 2 -- 14 files changed, 7 insertions(+), 57 deletions(-) diff --git a/cat/aarch64.cat b/cat/aarch64.cat index 4b76cc212a..1fd065bcd5 100644 --- a/cat/aarch64.cat +++ b/cat/aarch64.cat @@ -38,19 +38,6 @@ "ARMv8 AArch64" -(* - * Include the cos.cat file shipped with herd. - * This builds the co relation as a total order over writes to the same - * location and then consequently defines the fr relation using co and - * rf. - *) -include "cos.cat" - -(* - * Include aarch64fences.cat so that barriers show up in generated diagrams. - *) -include "aarch64fences.cat" - (* * As a restriction of the model, all observers are limited to the same * inner-shareable domain. Consequently, the ISH, OSH and SY barrier diff --git a/cat/arm.cat b/cat/arm.cat index 83b5c57c8a..c86e993ced 100644 --- a/cat/arm.cat +++ b/cat/arm.cat @@ -1,8 +1,5 @@ ARM -(* Model for ARM, ie with po-loc omitted from ppo *) -include "cos.cat" - (* Uniproc *) acyclic po-loc | rf | fr | co as uniproc diff --git a/cat/c11-orig.cat b/cat/c11-orig.cat index fcfd0af4dd..5c4e293486 100644 --- a/cat/c11-orig.cat +++ b/cat/c11-orig.cat @@ -9,9 +9,6 @@ Rewritten by Luc Maranget for herd7 *) -include "c11_cos.cat" -include "c11_los.cat" - let asw = IW * (M \ IW) let sb = po let mo = co diff --git a/cat/c11-partialsc.cat b/cat/c11-partialsc.cat index f80b5544fc..dbc893a527 100644 --- a/cat/c11-partialsc.cat +++ b/cat/c11-partialsc.cat @@ -12,9 +12,6 @@ C "C++11" * https://multicore.doc.ic.ac.uk/overhauling/c11_partialSC.cat *) -include "c11_cos.cat" -include "c11_los.cat" - // dynamic_tag relates events to itself that access an address whose init event is marked X let dynamic_tag(X) = [range([IW & X]; loc)] diff --git a/cat/c11.cat b/cat/c11.cat index 1abd41f349..168a8e1d1f 100644 --- a/cat/c11.cat +++ b/cat/c11.cat @@ -12,9 +12,6 @@ C "C++11" * https://multicore.doc.ic.ac.uk/overhauling/c11_simp.cat *) -include "c11_cos.cat" -include "c11_los.cat" - // dynamic_tag relates events to itself that access an address whose init event is marked X let dynamic_tag(X) = [range([IW & X]; loc)] diff --git a/cat/lock.cat b/cat/lock.cat index c8a83e5457..861580f1d4 100644 --- a/cat/lock.cat +++ b/cat/lock.cat @@ -1,9 +1,9 @@ -// // SPDX-License-Identifier: GPL-2.0+ -// (* -// * Copyright (C) 2016 Luc Maranget for Inria -// * Copyright (C) 2017 Alan Stern -// *) -// +// SPDX-License-Identifier: GPL-2.0+ +(* + * Copyright (C) 2016 Luc Maranget for Inria + * Copyright (C) 2017 Alan Stern + *) + // (* // * Generate coherence orders and handle lock operations // * @@ -143,6 +143,4 @@ // let fre = fr & ext // let fri = fr & int // -// show co,rf,fr - -include "basic.cat" \ No newline at end of file +show co,rf,fr \ No newline at end of file diff --git a/cat/opencl-herd.cat b/cat/opencl-herd.cat index 7e3e549a58..9981d20255 100644 --- a/cat/opencl-herd.cat +++ b/cat/opencl-herd.cat @@ -25,8 +25,6 @@ OpenCL // dynamic_tag relates events to itself that access an address whose init event is marked X or Fence tagged with X let dynamic_tag(X) = [range([IW & X]; loc)] | [X & F] -include "basic.cat" - let symm(r) = r | r^-1 let wi = int diff --git a/cat/power.cat b/cat/power.cat index 7711ce90a3..7120c17cc4 100644 --- a/cat/power.cat +++ b/cat/power.cat @@ -1,6 +1,5 @@ Power -include "cos.cat" include "ppcfences.cat" (* Uniproc *) diff --git a/cat/rc11.cat b/cat/rc11.cat index d144fd7d35..c12efd50c1 100644 --- a/cat/rc11.cat +++ b/cat/rc11.cat @@ -7,9 +7,6 @@ RC11 * Cat coding by Sicon Colin. *) -(* Define co (and fr) *) -include "cos.cat" - // This is needed for herd which can create a single event for rmw instructions let myrmw = [RMW] | rmw diff --git a/cat/riscv-orig.cat b/cat/riscv-orig.cat index 266afaad2f..71ec6462e8 100644 --- a/cat/riscv-orig.cat +++ b/cat/riscv-orig.cat @@ -56,9 +56,6 @@ let ppo = | r12 | r13 -(* Compute coherence relation *) -include "cos-opt.cat" - (**********) (* Axioms *) (**********) diff --git a/cat/riscv.cat b/cat/riscv.cat index 8ae1aabb54..d32f4cad71 100644 --- a/cat/riscv.cat +++ b/cat/riscv.cat @@ -6,9 +6,6 @@ Partial (* Definitions *) (***************) -(* Define co (and fr) *) -include "cos.cat" - (*************) (* Utilities *) (*************) @@ -59,9 +56,6 @@ let ppo = | r12 | r13 -(* Compute coherence relation *) -include "cos-opt.cat" - (**********) (* Axioms *) (**********) diff --git a/cat/sc.cat b/cat/sc.cat index 8a58733297..c24e157c04 100644 --- a/cat/sc.cat +++ b/cat/sc.cat @@ -1,8 +1,5 @@ SC -(* Define co (and fr) *) -include "cos.cat" - (* All communication relations *) let com = (rf | fr | co) diff --git a/cat/svcomp.cat b/cat/svcomp.cat index 292bb30bc0..9eb9f1107c 100644 --- a/cat/svcomp.cat +++ b/cat/svcomp.cat @@ -1,8 +1,5 @@ SVCOMP -(* Define co (and fr) *) -include "cos.cat" - (* All communication relations *) let com = (rf | fr | co) diff --git a/cat/tso.cat b/cat/tso.cat index 9f81377cd0..10d1eca97b 100644 --- a/cat/tso.cat +++ b/cat/tso.cat @@ -1,8 +1,6 @@ "X86 TSO" -include "cos.cat" include "x86fences.cat" -include "filters.cat" (* All communication relations *) let com = (co | fr | rf) From 9e1464faa39b89c01b8d6940ee9df1bbe87561fd Mon Sep 17 00:00:00 2001 From: Hernan Ponce de Leon Date: Fri, 30 May 2025 10:41:34 +0200 Subject: [PATCH 08/10] Add batch execution mode (#894) Signed-off-by: Hernan Ponce de Leon Co-authored-by: Hernan Ponce de Leon --- .../java/com/dat3m/dartagnan/Dartagnan.java | 466 ++++++++---------- .../parsers/program/ProgramParser.java | 4 +- .../event/lang/catomic/AtomicLoad.java | 2 +- .../event/lang/catomic/AtomicStore.java | 2 +- .../processing/CoreCodeVerification.java | 6 +- .../com/dat3m/dartagnan/utils/Result.java | 4 +- .../dartagnan/utils/options/BaseOptions.java | 1 + .../dartagnan/utils/printer/OutputLogger.java | 71 +++ .../verification/solving/ModelChecker.java | 2 +- .../dat3m/ui/result/ReachabilityResult.java | 4 +- 10 files changed, 304 insertions(+), 258 deletions(-) create mode 100644 dartagnan/src/main/java/com/dat3m/dartagnan/utils/printer/OutputLogger.java diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java b/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java index 0345cc35b3..b34f903cea 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java @@ -61,13 +61,16 @@ import org.sosy_lab.java_smt.api.SolverContext; import org.sosy_lab.java_smt.api.SolverContext.ProverOptions; import org.sosy_lab.java_smt.api.SolverException; - +import java.nio.file.*; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Path; import java.util.*; +import java.util.stream.Stream; +import com.dat3m.dartagnan.utils.printer.OutputLogger; +import com.dat3m.dartagnan.utils.printer.OutputLogger.ResultSummary; import static com.dat3m.dartagnan.GlobalSettings.getOrCreateOutputDirectory; import static com.dat3m.dartagnan.configuration.OptionInfo.collectOptions; @@ -150,18 +153,31 @@ public static void main(String[] args) throws Exception { Configuration config = loadConfiguration(args); Dartagnan o = new Dartagnan(config); - File fileProgram = new File(Arrays.stream(args).filter(a -> supportedFormats.stream().anyMatch(a::endsWith)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("Input program not given or format not recognized"))); - logger.info("Program path: {}", fileProgram); - File fileModel = new File(Arrays.stream(args).filter(a -> a.endsWith(".cat")).findFirst() .orElseThrow(() -> new IllegalArgumentException("CAT model not given or format not recognized"))); logger.info("CAT file path: {}", fileModel); + Wmm mcm = new ParserCat(Path.of(o.getCatIncludePath())).parse(fileModel); + final OutputLogger output = new OutputLogger(fileModel, config); + + final List files = new ArrayList(); + Stream.of(args) + .map(File::new) + .forEach(file -> { + if (file.exists()) { + final String path = file.getAbsolutePath(); + logger.info("Program(s) path: {}", path); + if (file.isDirectory()) { + files.addAll(getProgramsFiles(path)); + } else if (file.isFile() && supportedFormats.stream().anyMatch(file.getName()::endsWith)) { + files.add(file); + } + } + }); + if (files.isEmpty()) { + throw new IllegalArgumentException("Path to input program(s) not given or format not recognized"); + } - Wmm mcm = new ParserCat(Path.of(o.getCatIncludePath())).parse(fileModel); - Program p = new ProgramParser().parse(fileProgram); EnumSet properties = o.getProperty(); WitnessGraph witness = new WitnessGraph(); @@ -170,87 +186,110 @@ public static void main(String[] args) throws Exception { witness = new ParserWitness().parse(new File(o.getWitnessPath())); } - VerificationTaskBuilder builder = VerificationTask.builder() - .withConfig(config) - .withProgressModel(o.getProgressModel()) - .withWitness(witness); - // If the arch has been set during parsing (this only happens for litmus tests) - // and the user did not explicitly add the target option, we use the one - // obtained during parsing. - if (p.getArch() != null && !config.hasProperty(TARGET)) { - builder = builder.withTarget(p.getArch()); + if (properties.contains(DATARACEFREEDOM) && properties.size() > 1) { + System.out.println("Data race detection cannot be combined with other properties"); + if(!(files.size() > 1)) { + System.exit(1); + } } - VerificationTask task = builder.build(p, mcm, properties); - ShutdownManager sdm = ShutdownManager.create(); - Thread t = new Thread(() -> { - try { - if (o.hasTimeout()) { - // Converts timeout from secs to millisecs - Thread.sleep(1000L * o.getTimeout()); - sdm.requestShutdown("Shutdown Request"); - logger.warn("Shutdown Request"); - } - } catch (InterruptedException e) { - // Verification ended, nothing to be done. - } - }); + ResultSummary summary = null; + for (File f : files) { - try { - long startTime = System.currentTimeMillis(); - t.start(); - Configuration solverConfig = Configuration.builder() - .setOption(PHANTOM_REFERENCES, valueOf(o.usePhantomReferences())) - .build(); - try (SolverContext ctx = createSolverContext( - solverConfig, - sdm.getNotifier(), - o.getSolver()); - ProverWithTracker prover = new ProverWithTracker(ctx, - o.getDumpSmtLib() ? GlobalSettings.getOutputDirectory() + String.format("/%s.smt2", p.getName()) : "", - ProverOptions.GENERATE_MODELS)) { - ModelChecker modelChecker; - if (properties.contains(DATARACEFREEDOM)) { - if (properties.size() > 1) { - System.out.println("Data race detection cannot be combined with other properties"); - System.exit(1); + ShutdownManager sdm = ShutdownManager.create(); + Thread t = new Thread(() -> { + try { + if (o.hasTimeout()) { + // Converts timeout from secs to millisecs + Thread.sleep(1000L * o.getTimeout()); + sdm.requestShutdown("Shutdown Request"); } - modelChecker = DataRaceSolver.run(ctx, prover, task); - } else { - // Property is either PROGRAM_SPEC, TERMINATION, or CAT_SPEC - modelChecker = switch (o.getMethod()) { - case EAGER -> AssumeSolver.run(ctx, prover, task); - case LAZY -> RefinementSolver.run(ctx, prover, task); - }; + } catch (InterruptedException e) { + // Verification ended, nothing to be done. } + }); - // Verification ended, we can interrupt the timeout Thread - t.interrupt(); - - if (modelChecker.hasModel() && o.getWitnessType().generateGraphviz()) { - generateExecutionGraphFile(task, prover, modelChecker, o.getWitnessType()); + try { + VerificationTaskBuilder builder = VerificationTask.builder() + .withConfig(config) + .withProgressModel(o.getProgressModel()) + .withWitness(witness); + Program p = new ProgramParser().parse(f); + // If the arch has been set during parsing (this only happens for litmus tests) + // and the user did not explicitly add the target option, we use the one + // obtained during parsing. + if (p.getArch() != null && !config.hasProperty(TARGET)) { + builder = builder.withTarget(p.getArch()); } + VerificationTask task = builder.build(p, mcm, properties); + + long startTime = System.currentTimeMillis(); + t.start(); + Configuration solverConfig = Configuration.builder() + .setOption(PHANTOM_REFERENCES, valueOf(o.usePhantomReferences())) + .build(); + try (SolverContext ctx = createSolverContext( + solverConfig, + sdm.getNotifier(), + o.getSolver()); + ProverWithTracker prover = new ProverWithTracker(ctx, + o.getDumpSmtLib() ? GlobalSettings.getOutputDirectory() + String.format("/%s.smt2", p.getName()) : "", + ProverOptions.GENERATE_MODELS)) { + ModelChecker modelChecker; + if (properties.contains(DATARACEFREEDOM)) { + modelChecker = DataRaceSolver.run(ctx, prover, task); + } else { + // Property is either PROGRAM_SPEC, TERMINATION, or CAT_SPEC + modelChecker = switch (o.getMethod()) { + case EAGER -> AssumeSolver.run(ctx, prover, task); + case LAZY -> RefinementSolver.run(ctx, prover, task); + }; + } + + // Verification ended, we can interrupt the timeout Thread + t.interrupt(); + long endTime = System.currentTimeMillis(); - long endTime = System.currentTimeMillis(); - ResultSummary summary = generateResultSummary(task, prover, modelChecker); - System.out.print(summary.text()); - System.out.println("Total verification time: " + Utils.toTimeString(endTime - startTime)); + summary = summaryFromResult(task, prover, modelChecker, f.toString(), (endTime - startTime)); - // We only generate witnesses if we are not validating one. - if (o.getWitnessType().equals(GRAPHML) && !o.runValidator()) { - generateWitnessIfAble(task, prover, modelChecker, summary.toString()); + if (modelChecker.hasModel() && o.getWitnessType().generateGraphviz()) { + generateExecutionGraphFile(task, prover, modelChecker, o.getWitnessType()); + } + // We only generate SVCOMP witnesses if we are not validating one. + if (o.getWitnessType().equals(GRAPHML) && !o.runValidator()) { + generateWitnessIfAble(task, prover, modelChecker, summary.details()); + } } - System.exit(summary.code().asInt()); + } catch (InterruptedException e) { + final long time = 1000L * o.getTimeout(); + summary = new ResultSummary(f.toString(), "", TIMEDOUT, "", "", "", time, TIMEOUT_ELAPSED); + } catch (Exception e) { + final String reason = e.getClass().getSimpleName(); + final String details = "\t" + Optional.ofNullable(e.getMessage()).orElse("Unknown error occurred"); + summary = new ResultSummary(f.toString(), "", ERROR, "", reason, details, 0, UNKNOWN_ERROR); } - } catch (InterruptedException e) { - logger.warn("Timeout elapsed. The SMT solver was stopped"); - System.out.println("TIMEOUT"); - System.exit(TIMEOUT_ELAPSED.asInt()); - } catch (Exception e) { - logger.error(e.getMessage(), e); - System.out.println("ERROR"); + output.addResult(summary); + } + output.toStdOut(files.size() > 1); + if (summary != null) { + // Running batch mode results in normal termination independent of the individual results + System.exit((files.size() > 1 ? NORMAL_TERMINATION : summary.code()).asInt()); + } + } + + public static List getProgramsFiles(String path) { + List files = new ArrayList(); + try (Stream stream = Files.walk(Paths.get(path))) { + files = stream.filter(Files::isRegularFile) + .filter(p -> supportedFormats.stream().anyMatch(p.toString()::endsWith)) + .map(Path::toFile) + .sorted(Comparator.comparing(File::toString)) + .toList(); + } catch (IOException e) { + logger.error("There was an I/O error when accessing path " + path); System.exit(UNKNOWN_ERROR.asInt()); } + return files; } public static File generateExecutionGraphFile(VerificationTask task, ProverEnvironment prover, ModelChecker modelChecker, @@ -278,7 +317,7 @@ encodingContext, new ModelExt(prover.getModel()) } private static void generateWitnessIfAble(VerificationTask task, ProverEnvironment prover, - ModelChecker modelChecker, String summary) { + ModelChecker modelChecker, String details) { // ------------------ Generate Witness, if possible ------------------ final EnumSet properties = task.getProperty(); if (task.getProgram().getFormat().equals(SourceLanguage.LLVM) && modelChecker.hasModel() @@ -286,7 +325,7 @@ private static void generateWitnessIfAble(VerificationTask task, ProverEnvironme && modelChecker.getResult() != UNKNOWN) { try { WitnessBuilder w = WitnessBuilder.of(modelChecker.getEncodingContext(), prover, - modelChecker.getResult(), summary); + modelChecker.getResult(), details); if (w.canBeBuilt()) { w.build().write(); } @@ -296,8 +335,8 @@ private static void generateWitnessIfAble(VerificationTask task, ProverEnvironme } } - public static ResultSummary generateResultSummary(VerificationTask task, ProverEnvironment prover, - ModelChecker modelChecker) throws SolverException { + public static ResultSummary summaryFromResult(VerificationTask task, ProverEnvironment prover, + ModelChecker modelChecker, String path, long time) throws SolverException { // ----------------- Generate output of verification result ----------------- final Program p = task.getProgram(); final EnumSet props = task.getProperty(); @@ -307,168 +346,107 @@ public static ResultSummary generateResultSummary(VerificationTask task, ProverE ? new IREvaluator(encCtx, new ModelExt(prover.getModel())) : null; final boolean hasViolations = result == FAIL && (model != null); - final boolean hasPositiveWitnesses = result == PASS && (model != null); - - StringBuilder summary = new StringBuilder(); - - if (p.getFormat() != SourceLanguage.LITMUS) { - final SyntacticContextAnalysis synContext = newInstance(p); - if (hasViolations) { - printWarningIfThreadStartFailed(p, model); - if (props.contains(PROGRAM_SPEC) && model.propertyViolated(PROGRAM_SPEC)) { - summary.append("===== Program specification violation found =====\n"); - for (Assert ass : p.getThreadEvents(Assert.class)) { - final boolean isViolated = model.assertionViolated(ass); - if (isViolated) { - final String callStack = makeContextString( - synContext.getContextInfo(ass).getContextOfType(CallContext.class), " -> "); - summary - .append("\tE").append(ass.getGlobalId()) - .append(":\t") - .append(callStack.isEmpty() ? callStack : callStack + " -> ") - .append(getSourceLocationString(ass)) - .append(": ").append(ass.getErrorMessage()) - .append("\n"); - } - } - summary.append("=================================================\n"); - summary.append(result).append("\n"); - // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION - ExitCode code = task.getWitness().isEmpty() ? PROGRAM_SPEC_VIOLATION : NORMAL_TERMINATION; - return new ResultSummary(summary.toString(), code); - } - if (props.contains(TERMINATION) && model.propertyViolated(TERMINATION)) { - summary.append("============ Termination violation found ============\n"); - for (Event e : p.getThreadEvents()) { - final boolean isStuckLoop = e instanceof CondJump jump - && e.hasTag(Tag.NONTERMINATION) && !e.hasTag(Tag.BOUND) - && model.jumpTaken(jump); - final boolean isStuckBarrier = e instanceof BlockingEvent barrier - && model.isBlocked(barrier); - - if (isStuckLoop || isStuckBarrier) { - final String callStack = makeContextString( - synContext.getContextInfo(e).getContextOfType(CallContext.class), " -> "); - summary - .append("\tE").append(e.getGlobalId()) - .append(":\t") - .append(callStack.isEmpty() ? callStack : callStack + " -> ") - .append(getSourceLocationString(e)) - .append("\n"); - } - } - summary.append("=================================================\n"); - summary.append(result).append("\n"); - // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION - ExitCode code = task.getWitness().isEmpty() ? TERMINATION_VIOLATION : NORMAL_TERMINATION; - return new ResultSummary(summary.toString(), code); - } - if (props.contains(DATARACEFREEDOM) && model.propertyViolated(DATARACEFREEDOM)) { - summary.append("============= SVCOMP data race found ============\n"); - summary.append("=================================================\n"); - summary.append(result).append("\n"); - // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION - ExitCode code = task.getWitness().isEmpty() ? DATA_RACE_FREEDOM_VIOLATION : NORMAL_TERMINATION; - return new ResultSummary(summary.toString(), code); - } - final List violatedCATSpecs = !props.contains(CAT_SPEC) ? List.of() - : task.getMemoryModel().getAxioms().stream() - .filter(Axiom::isFlagged) - .filter(model::isFlaggedAxiomViolated) - .toList(); - if (!violatedCATSpecs.isEmpty()) { - summary.append("======= CAT specification violation found =======\n"); - // Computed by the model checker since it needs access to the WmmEncoder - summary.append(modelChecker.getFlaggedPairsOutput()); - summary.append("=================================================\n"); - summary.append(result).append("\n"); - // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION - ExitCode code = task.getWitness().isEmpty() ? CAT_SPEC_VIOLATION : NORMAL_TERMINATION; - return new ResultSummary(summary.toString(), code); - } - } else if (hasPositiveWitnesses) { - if (props.contains(PROGRAM_SPEC) && model.propertySatisfied(PROGRAM_SPEC)) { - // The check above is just a sanity check: the program spec has to be true - // because it is the only property that got encoded. - summary.append("Program specification witness found.").append("\n"); - } - } else if (result == UNKNOWN && modelChecker.hasModel()) { - // We reached unrolling bounds. - final List reachedBounds = p.getThreadEventsWithAllTags(Tag.BOUND) - .stream().filter(model::isExecuted) - .toList(); - summary.append("=========== Not fully unrolled loops ============\n"); - for (Event bound : reachedBounds) { - summary - .append("\t") - .append(synContext.getSourceLocationWithContext(bound, true)) + final boolean hasViolationsWithoutWitness = result == FAIL && (model == null); + + String reason = ""; + StringBuilder details = new StringBuilder(); + // We only show the condition if this is the reason of the failure + String condition = ""; + final boolean ignoreFilter = task.getConfig().hasProperty(IGNORE_FILTER_SPECIFICATION) && task.getConfig().getProperty(IGNORE_FILTER_SPECIFICATION).equals("true"); + final boolean nonEmptyFilter = !(p.getFilterSpecification() instanceof BoolLiteral bLit) || !bLit.getValue(); + final String filter = !ignoreFilter && nonEmptyFilter ? p.getFilterSpecification().toString() : ""; + + final SyntacticContextAnalysis synContext = newInstance(p); + if (hasViolations) { + printWarningIfThreadStartFailed(p, model); + if (props.contains(PROGRAM_SPEC) && model.propertyViolated(PROGRAM_SPEC)) { + reason = ResultSummary.PROGRAM_SPEC_REASON; + condition = getSpecificationString(p); + List violations = p.getThreadEvents(Assert.class) + .stream().filter(ass -> model.assertionViolated(ass)) + .toList(); + for (Assert ass : violations) { + final String callStack = makeContextString(synContext.getContextInfo(ass).getContextOfType(CallContext.class), " -> "); + details + .append("\tE").append(ass.getGlobalId()) + .append(":\t") + .append(callStack.isEmpty() ? callStack : callStack + " -> ") + .append(getSourceLocationString(ass)) + .append(": ").append(ass.getErrorMessage()) .append("\n"); } - summary.append("=================================================\n"); - try { - increaseBoundAndDump(reachedBounds, task.getConfig()); - } catch (IOException e) { - logger.warn("Failed to save bounds file: {}", e.getLocalizedMessage()); - } - summary.append(result).append("\n"); - return new ResultSummary(summary.toString(), BOUNDED_RESULT); - } - summary.append(result).append("\n"); - } else { - // Litmus-specific output format that matches with Herd7 (as good as it can) - Expression filterSpec = p.getFilterSpecification(); - if (!(filterSpec instanceof BoolLiteral bLit) || !bLit.getValue()) { - summary.append("Filter ").append(filterSpec).append("\n"); + // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION + ExitCode code = task.getWitness().isEmpty() ? PROGRAM_SPEC_VIOLATION : NORMAL_TERMINATION; + return new ResultSummary(path, filter, FAIL, condition, reason, details.toString(), time, code); } - - // NOTE: We cannot produce an output that matches herd7 when checking for both program spec and cat properties. - // This requires two SMT-queries because a single model is unlikely to witness/falsify both properties - // simultaneously. - // Instead, if we check for multiple safety properties, we find the first one and - // generate output based on its type (Program spec OR CAT property) - // TODO: Perform two separate checks - - if (hasPositiveWitnesses) { - // We have a positive witness or no violations, then the program must be ok. - // NOTE: We also treat the UNKNOWN case as positive, assuming that - // looping litmus tests are unusual. - printSpecification(summary, p); - summary.append("Ok").append("\n"); - } else if (hasViolations) { - if (props.contains(PROGRAM_SPEC) && model.propertyViolated(PROGRAM_SPEC)) { - // Program spec violated - printSpecification(summary, p); - summary.append("No").append("\n"); - } else { - final List violatedCATSpecs = !props.contains(CAT_SPEC) ? List.of() - : task.getMemoryModel().getAxioms().stream() - .filter(Axiom::isFlagged) - .filter(model::isFlaggedAxiomViolated) - .toList(); - for (Axiom violatedAx : violatedCATSpecs) { - summary.append("Flag ") - .append(Optional.ofNullable(violatedAx.getName()).orElse(violatedAx.getNameOrTerm())) + if (props.contains(TERMINATION) && model.propertyViolated(TERMINATION)) { + reason = ResultSummary.TERMINATION_REASON; + for (Event e : p.getThreadEvents()) { + final boolean isStuckLoop = e instanceof CondJump jump + && e.hasTag(Tag.NONTERMINATION) && !e.hasTag(Tag.BOUND) + && model.jumpTaken(jump); + final boolean isStuckBarrier = e instanceof BlockingEvent barrier + && model.isBlocked(barrier); + + if (isStuckLoop || isStuckBarrier) { + final String callStack = makeContextString( + synContext.getContextInfo(e).getContextOfType(CallContext.class), " -> "); + details + .append("\tE").append(e.getGlobalId()) + .append(":\t") + .append(callStack.isEmpty() ? callStack : callStack + " -> ") + .append(getSourceLocationString(e)) .append("\n"); } } - } else { - // We have neither a witness nor a violation ... - if (result == UNKNOWN) { - // Sanity check: UNKNOWN is not an expected result for litmus tests - logger.warn("Unexpected result for litmus test: {}", result); - summary.append(result).append("\n"); - } else if (task.getProperty().contains(PROGRAM_SPEC)) { - // ... which can be good or bad (no witness = bad, not violation = good) - printSpecification(summary, p); - summary.append(result == PASS ? "Ok" : "No").append("\n"); - } + // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION + ExitCode code = task.getWitness().isEmpty() ? TERMINATION_VIOLATION : NORMAL_TERMINATION; + return new ResultSummary(path, filter, FAIL, condition, reason, details.toString(), time, code); + } + if (props.contains(DATARACEFREEDOM) && model.propertyViolated(DATARACEFREEDOM)) { + reason = ResultSummary.SVCOMP_RACE_REASON; + // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION + ExitCode code = task.getWitness().isEmpty() ? DATA_RACE_FREEDOM_VIOLATION : NORMAL_TERMINATION; + return new ResultSummary(path, filter, FAIL, condition, reason, details.toString(), time, code); + } + final List violatedCATSpecs = !props.contains(CAT_SPEC) ? List.of() + : task.getMemoryModel().getAxioms().stream() + .filter(Axiom::isFlagged) + .filter(model::isFlaggedAxiomViolated) + .toList(); + if (!violatedCATSpecs.isEmpty()) { + reason = ResultSummary.CAT_SPEC_REASON; + // In validation mode, we expect to find the violation, thus NORMAL_TERMINATION + ExitCode code = task.getWitness().isEmpty() ? CAT_SPEC_VIOLATION : NORMAL_TERMINATION; + return new ResultSummary(path, filter, FAIL, condition, reason, modelChecker.getFlaggedPairsOutput(), time, code); + } + } else if (hasViolationsWithoutWitness) { + // Only for programs with exists/forall specifications + reason = ResultSummary.PROGRAM_SPEC_REASON; + condition = getSpecificationString(p); + } else if (result == UNKNOWN && modelChecker.hasModel()) { + // We reached unrolling bounds. + final List reachedBounds = p.getThreadEventsWithAllTags(Tag.BOUND) + .stream().filter(model::isExecuted) + .toList(); + reason = ResultSummary.BOUND_REASON; + for (Event bound : reachedBounds) { + details + .append("\t") + .append(synContext.getSourceLocationWithContext(bound, true)) + .append("\n"); + } + try { + increaseBoundAndDump(reachedBounds, task.getConfig()); + } catch (IOException e) { + logger.warn("Failed to save bounds file: {}", e.getLocalizedMessage()); } } // We consider those cases without an explicit return to yield normal termination. // This includes verification of litmus code, independent of the verification result. // In validation mode, we expect to find the violation, thus the WITNESS_NOT_VALIDATED error ExitCode code = task.getWitness().isEmpty() ? NORMAL_TERMINATION : WITNESS_NOT_VALIDATED; - return new ResultSummary(summary.toString(), code); + return new ResultSummary(path, filter, result, condition, reason, details.toString(), time, code); } private static void increaseBoundAndDump(List boundEvents, Configuration config) throws IOException { @@ -520,25 +498,17 @@ private static void printWarningIfThreadStartFailed(Program p, IREvaluator model )); } - private static void printSpecification(StringBuilder sb, Program program) { - sb.append("Condition ").append(program.getSpecificationType().toString().toLowerCase()).append(" "); - boolean init = false; - if (program.getSpecification() != null) { - sb.append(new ExpressionPrinter(true).visit(program.getSpecification())); - init = true; - } - for (Assert assertion : program.getThreadEvents(Assert.class)) { - sb.append(init ? " && " : "").append(assertion.getExpression()).append("%").append(assertion.getGlobalId()); - init = true; - } - sb.append("\n"); - } - - public static record ResultSummary (String text, ExitCode code) { - @Override - public String toString() { - return String.format("%s%s(exit-code: %s)", text, text.endsWith("\n") ? "" : " ", code.asInt()); + private static String getSpecificationString(Program program) { + final StringBuilder sb = new StringBuilder(); + final SourceLanguage format = program.getFormat(); + if (format == SourceLanguage.LITMUS || format == SourceLanguage.SPV) { + sb.append(program.getSpecificationType().toString().toLowerCase()).append(" "); + if (program.getSpecification() != null) { + sb.append(new ExpressionPrinter(true).visit(program.getSpecification())); + } + sb.append("\n"); } + return sb.toString(); } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java index 9eb9d0b447..4f006204bf 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java @@ -123,7 +123,9 @@ private ParserInterface getConcreteLitmusParser(String programText) { } else if(programText.indexOf(TYPE_LITMUS_VULKAN) == 0) { return new ParserLitmusVulkan(); } - throw new ParsingException("Unknown input file type"); + final int spaceIndex = programText.indexOf(" "); + final String litmusFormat = (spaceIndex != -1) ? " " + programText.substring(0, spaceIndex) : ""; + throw new ParsingException("Unknown litmus format" + litmusFormat); } private String readFirstLine(File file) throws IOException { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicLoad.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicLoad.java index da62486f14..4c92f1941b 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicLoad.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicLoad.java @@ -16,7 +16,7 @@ public AtomicLoad(Register register, Expression address, String mo) { super(register, address, mo); Preconditions.checkArgument(!mo.isEmpty(), "Atomic events cannot have empty memory order"); Preconditions.checkArgument(!mo.equals(MO_RELEASE) && !mo.equals(MO_ACQUIRE_RELEASE), - getClass().getName() + " can not have memory order: " + mo); + getClass().getSimpleName() + " cannot have memory order: " + mo); } private AtomicLoad(AtomicLoad other) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicStore.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicStore.java index 3830771397..f6ebda6059 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicStore.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/event/lang/catomic/AtomicStore.java @@ -14,7 +14,7 @@ public AtomicStore(Expression address, Expression value, String mo){ super(address, value, mo); Preconditions.checkArgument(!mo.isEmpty(), "Atomic events cannot have empty memory order"); Preconditions.checkArgument(!mo.equals(MO_ACQUIRE) && !mo.equals(MO_ACQUIRE_RELEASE), - getClass().getName() + " can not have memory order: " + mo); + getClass().getSimpleName() + " cannot have memory order: " + mo); } private AtomicStore(AtomicStore other) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/CoreCodeVerification.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/CoreCodeVerification.java index ebb7f6348f..9cc2c3fbe6 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/CoreCodeVerification.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/CoreCodeVerification.java @@ -48,11 +48,11 @@ public void run(Function function) { final List nonCoreEvents = function.getEvents().stream(). filter(e -> !(e instanceof CodeAnnotation) && !CORE_CLASSES.contains(e.getClass())).toList(); if (!nonCoreEvents.isEmpty()) { - System.out.println("ERROR: Found non-core events."); + StringBuilder msg = new StringBuilder(); for (Event e : nonCoreEvents) { - System.out.printf("%2s: %-30s %s %n", e.getGlobalId(), e, e.getClass().getSimpleName()); + msg.append(String.format("\t%2s: %-30s %s %n", e.getGlobalId(), e, e.getClass().getSimpleName())); } - throw new MalformedProgramException("ERROR: Found non-core events."); + throw new MalformedProgramException("Found non-core events.\n" + msg); } } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/utils/Result.java b/dartagnan/src/main/java/com/dat3m/dartagnan/utils/Result.java index 5828be0b9a..bcd51e0054 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/utils/Result.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/utils/Result.java @@ -3,13 +3,13 @@ //TODO (HP): Can we add some result for "Bounded Safety" and use UNKNOWN for cases where we really have // no result (e.g. inconclusive Saturation-Refinement) public enum Result { - PASS, FAIL, UNKNOWN; + PASS, FAIL, UNKNOWN, ERROR, TIMEDOUT; public Result invert() { return switch (this) { case PASS -> FAIL; case FAIL -> PASS; - case UNKNOWN -> UNKNOWN; + default -> this; }; } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/utils/options/BaseOptions.java b/dartagnan/src/main/java/com/dat3m/dartagnan/utils/options/BaseOptions.java index 56f093fd5f..9a9b496594 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/utils/options/BaseOptions.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/utils/options/BaseOptions.java @@ -122,4 +122,5 @@ public boolean getDumpSmtLib() { public String getCatIncludePath() { return catIncludePath; } + } \ No newline at end of file diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/utils/printer/OutputLogger.java b/dartagnan/src/main/java/com/dat3m/dartagnan/utils/printer/OutputLogger.java new file mode 100644 index 0000000000..dab12cc471 --- /dev/null +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/utils/printer/OutputLogger.java @@ -0,0 +1,71 @@ +package com.dat3m.dartagnan.utils.printer; + +import com.dat3m.dartagnan.expression.Expression; +import com.dat3m.dartagnan.utils.Result; +import com.dat3m.dartagnan.utils.ExitCode; +import com.dat3m.dartagnan.utils.Utils; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import org.sosy_lab.common.configuration.Configuration; + +import static com.dat3m.dartagnan.utils.Result.*; + +public class OutputLogger { + + private final List results = new ArrayList(); + private final File modelFile; + private final Configuration config; + + public OutputLogger(File file, Configuration config) { + this.modelFile = file; + this.config = config; + } + + public void addResult(ResultSummary result) { + results.add(result); + } + + public void toStdOut(boolean batchMode) { + if (batchMode) { + System.out.println("================ Configuration =================="); + System.out.println("cat = " + modelFile); + System.out.print(config.asPropertiesString()); // it already contains its own \n + System.out.println("================================================="); + } + for (ResultSummary r : results) { + if (batchMode) { + System.out.println(); + } + System.out.println(r); + } + } + + public record ResultSummary ( + String test, String filter, Result result, String condition, + String reason, String details, long time, ExitCode code) { + + public static final String PROGRAM_SPEC_REASON = "Program specification violation found"; + public static final String TERMINATION_REASON = "Termination violation found"; + public static final String CAT_SPEC_REASON = "CAT specification violation found"; + public static final String SVCOMP_RACE_REASON = "SVCOMP data race found"; + public static final String BOUND_REASON = "Not fully unrolled loops"; + + @Override + public String toString() { + final String shownFilter = !filter.isEmpty() ? String.format("Filter: %s%n", filter) : ""; + final String shownCondition = !condition.isEmpty() ? String.format("Condition: %s", condition) : ""; + final String shownReason = result != PASS && !reason.isEmpty() ? String.format("Reason: %s%n", reason) : ""; + final String shownDetails = !details.isEmpty() ? String.format("Details:%n%s", details) : ""; + final String shownTime = time > 0 ? String.format("Time: %s", Utils.toTimeString(time)) : ""; + return String.format("Test: %s%n%sResult: %s%n%s%s%s%s", + test, shownFilter, result, shownReason, shownCondition, shownDetails, shownTime); + } + + public String toUIString() { + return String.format("Result: %s%n%sTime: %s", result, !details.isEmpty() ? "Details:%n" + details : "", Utils.toTimeString(time)); + } + } + +} + diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/verification/solving/ModelChecker.java b/dartagnan/src/main/java/com/dat3m/dartagnan/verification/solving/ModelChecker.java index b13f217e4a..1af7b69410 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/verification/solving/ModelChecker.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/verification/solving/ModelChecker.java @@ -118,7 +118,7 @@ protected void saveFlaggedPairsOutput(Wmm wmm, WmmEncoder encoder, ProverEnviron final SyntacticContextAnalysis synContext = newInstance(program); for (Axiom ax : wmm.getAxioms()) { if (ax.isFlagged() && irModel.isFlaggedAxiomViolated(ax)) { - StringBuilder violatingPairs = new StringBuilder("Flag " + Optional.ofNullable(ax.getName()).orElse(ax.getRelation().getNameOrTerm())).append("\n"); + StringBuilder violatingPairs = new StringBuilder("\tFlag " + Optional.ofNullable(ax.getName()).orElse(ax.getRelation().getNameOrTerm())).append("\n"); encoder.getEventGraph(ax.getRelation(), model).apply((e1, e2) -> { final String callSeparator = " -> "; final String callStackFirst = makeContextString( diff --git a/ui/src/main/java/com/dat3m/ui/result/ReachabilityResult.java b/ui/src/main/java/com/dat3m/ui/result/ReachabilityResult.java index 18aee32dfc..c6620c30e7 100644 --- a/ui/src/main/java/com/dat3m/ui/result/ReachabilityResult.java +++ b/ui/src/main/java/com/dat3m/ui/result/ReachabilityResult.java @@ -83,6 +83,7 @@ private void run() { .withProgressModel(ProgressModel.uniform(options.progress())) .build(program, wmm, options.properties()); + long startTime = System.currentTimeMillis(); t.start(); final Configuration solverConfig = Configuration.builder() .setOption(PHANTOM_REFERENCES, "true") @@ -100,7 +101,8 @@ private void run() { }; // Verification ended, we can interrupt the timeout Thread t.interrupt(); - verdict = Dartagnan.generateResultSummary(task, prover, modelChecker).text(); + long endTime = System.currentTimeMillis(); + verdict = Dartagnan.summaryFromResult(task, prover, modelChecker, "", (endTime - startTime)).toUIString(); if (modelChecker.hasModel() && modelChecker.getResult() != Result.UNKNOWN) { witnessFile = Dartagnan.generateExecutionGraphFile(task, prover, modelChecker, WitnessType.PNG); From 788a8629c1a3c446f86bf1be839f3c7902d3a2ba Mon Sep 17 00:00:00 2001 From: Haining Date: Mon, 3 Mar 2025 10:14:09 +0100 Subject: [PATCH 09/10] Add Supports for OpenCL Alignment Decoration Signed-off-by: Haining Tong --- benchmarks/opencl/alignment/alignment1.cl | 21 + benchmarks/opencl/alignment/alignment10.cl | 26 ++ benchmarks/opencl/alignment/alignment2.cl | 24 ++ benchmarks/opencl/alignment/alignment3.cl | 42 ++ benchmarks/opencl/alignment/alignment4.cl | 116 ++++++ benchmarks/opencl/alignment/alignment5.cl | 32 ++ benchmarks/opencl/alignment/alignment6.cl | 43 ++ benchmarks/opencl/alignment/alignment7.cl | 31 ++ benchmarks/opencl/alignment/alignment8.cl | 25 ++ benchmarks/opencl/alignment/alignment9.cl | 25 ++ .../dartagnan/expression/type/ArrayType.java | 10 + .../expression/type/TypeFactory.java | 15 +- .../visitors/spirv/VisitorOpsAnnotation.java | 10 +- .../visitors/spirv/VisitorOpsConversion.java | 21 +- .../visitors/spirv/VisitorOpsFunction.java | 16 +- .../visitors/spirv/VisitorOpsLogical.java | 2 +- .../visitors/spirv/VisitorOpsMemory.java | 31 +- .../spirv/builders/DecorationsBuilder.java | 9 +- .../spirv/builders/ProgramBuilder.java | 49 ++- .../visitors/spirv/decorations/Alignment.java | 25 ++ .../visitors/spirv/helpers/HelperTypes.java | 47 ++- .../dartagnan/program/memory/Memory.java | 18 +- .../transformers/MemoryTransformer.java | 4 +- .../spirv/VisitorOpsAnnotationTest.java | 63 +++ .../spirv/VisitorOpsConversionTest.java | 17 + .../visitors/spirv/VisitorOpsMemoryTest.java | 31 ++ .../spirv/mocks/MockProgramBuilder.java | 5 + .../opencl/basic/SpirvAssertionsTest.java | 11 + .../spirv/opencl/basic/alignment1.spvasm | 91 ++++ .../spirv/opencl/basic/alignment10.spvasm | 74 ++++ .../spirv/opencl/basic/alignment2.spvasm | 77 ++++ .../spirv/opencl/basic/alignment3.spvasm | 134 ++++++ .../spirv/opencl/basic/alignment4.spvasm | 387 ++++++++++++++++++ .../spirv/opencl/basic/alignment5.spvasm | 94 +++++ .../spirv/opencl/basic/alignment6.spvasm | 169 ++++++++ .../spirv/opencl/basic/alignment7.spvasm | 119 ++++++ .../spirv/opencl/basic/alignment8.spvasm | 88 ++++ .../spirv/opencl/basic/alignment9.spvasm | 119 ++++++ .../spirv/opencl/basic/vector-aligned.spvasm | 70 ++++ 39 files changed, 2139 insertions(+), 52 deletions(-) create mode 100644 benchmarks/opencl/alignment/alignment1.cl create mode 100644 benchmarks/opencl/alignment/alignment10.cl create mode 100644 benchmarks/opencl/alignment/alignment2.cl create mode 100644 benchmarks/opencl/alignment/alignment3.cl create mode 100644 benchmarks/opencl/alignment/alignment4.cl create mode 100644 benchmarks/opencl/alignment/alignment5.cl create mode 100644 benchmarks/opencl/alignment/alignment6.cl create mode 100644 benchmarks/opencl/alignment/alignment7.cl create mode 100644 benchmarks/opencl/alignment/alignment8.cl create mode 100644 benchmarks/opencl/alignment/alignment9.cl create mode 100644 dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java create mode 100644 dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm diff --git a/benchmarks/opencl/alignment/alignment1.cl b/benchmarks/opencl/alignment/alignment1.cl new file mode 100644 index 0000000000..4718737f92 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1.cl @@ -0,0 +1,21 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment1.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1.spvasm + +__kernel void test(global uint *x) +{ + local uint3 data[2]; + + data[0].x = 0; + data[0].y = 1; + data[0].z = 2; + + data[1].x = 3; + data[1].y = 4; + data[1].z = 5; + + for (int i = 0; i < 8; i++) + { + x[i] = *(((uint*)data) + i); + } +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment10.cl b/benchmarks/opencl/alignment/alignment10.cl new file mode 100644 index 0000000000..d2dc9ee940 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment10.cl @@ -0,0 +1,26 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment10.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment10.spvasm + +struct struct1 { + unsigned int a[3]__attribute__ ((aligned (16))); + unsigned int b[3]__attribute__ ((aligned (16))); +}; + +struct struct2 { + unsigned int a[3]; + unsigned int b[3]; +}; + +__kernel void test(global uint *x) +{ + local struct struct1 s1; + local struct struct2 s2; + + *(((uint*)s1.a[0]) + 4) = 1; + *(((uint*)s2.a[0]) + 3) = 2; + + x[0] = s1.b[0]; + x[1] = s2.b[0]; + +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment2.cl b/benchmarks/opencl/alignment/alignment2.cl new file mode 100644 index 0000000000..12d76ab86c --- /dev/null +++ b/benchmarks/opencl/alignment/alignment2.cl @@ -0,0 +1,24 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment2.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment2.spvasm + +struct aligned_struct { + unsigned int e0 __attribute__ ((aligned (16))); + unsigned int e1 __attribute__ ((aligned (16))); +}; + +kernel void test(global int *x) { + + local struct aligned_struct aligned; + local unsigned int unaligned[2]; + + *(&aligned.e0) = 1; + *(&aligned.e0 + 4) = 2; + *(unaligned) = 3; + *(unaligned + 1) = 4; + + x[0] = aligned.e0; + x[1] = aligned.e1; + x[2] = unaligned[0]; + x[3] = unaligned[1]; +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment3.cl b/benchmarks/opencl/alignment/alignment3.cl new file mode 100644 index 0000000000..553c35a507 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment3.cl @@ -0,0 +1,42 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment3.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment3.spvasm + +struct aligned_struct { + unsigned int e0[3] __attribute__ ((aligned (16))); + unsigned int e1[3] __attribute__ ((aligned (16))); +}; + +kernel void test(global int *x) { + + local struct aligned_struct aligned; + local unsigned int unaligned[2][3]; + + aligned.e0[0] = 0; + aligned.e0[1] = 1; + aligned.e0[2] = 2; + aligned.e1[0] = 4; + aligned.e1[1] = 5; + aligned.e1[2] = 6; + + unaligned[0][0] = 10; + unaligned[0][1] = 11; + unaligned[0][2] = 12; + unaligned[1][0] = 13; + unaligned[1][1] = 14; + unaligned[1][2] = 15; + + x[0] = aligned.e0[0]; + x[1] = aligned.e0[1]; + x[2] = aligned.e0[2]; + x[3] = aligned.e1[0]; + x[4] = aligned.e1[1]; + x[5] = aligned.e1[2]; + + x[6] = unaligned[0][0]; + x[7] = unaligned[0][1]; + x[8] = unaligned[0][2]; + x[9] = unaligned[1][0]; + x[10] = unaligned[1][1]; + x[11] = unaligned[1][2]; +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment4.cl b/benchmarks/opencl/alignment/alignment4.cl new file mode 100644 index 0000000000..0e369d0f8d --- /dev/null +++ b/benchmarks/opencl/alignment/alignment4.cl @@ -0,0 +1,116 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment4.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment4.spvasm + +struct aligned_struct { + unsigned int e0[3] __attribute__ ((aligned (16))); + unsigned int e1[3] __attribute__ ((aligned (16))); +}; + +struct nested_aligned_struct { + struct aligned_struct as0[3] __attribute__ ((aligned (64))); + struct aligned_struct as1[3] __attribute__ ((aligned (64))); +}; + +kernel void test(global int *x) { + local struct nested_aligned_struct nested_aligned; + local unsigned int unaligned[2][2][3]; + + nested_aligned.as0[0].e0[0] = 0; + nested_aligned.as0[0].e0[1] = 1; + nested_aligned.as0[0].e0[2] = 2; + nested_aligned.as0[0].e1[0] = 3; + nested_aligned.as0[0].e1[1] = 4; + nested_aligned.as0[0].e1[2] = 5; + nested_aligned.as0[1].e0[0] = 6; + nested_aligned.as0[1].e0[1] = 7; + nested_aligned.as0[1].e0[2] = 8; + nested_aligned.as0[1].e1[0] = 9; + nested_aligned.as0[1].e1[1] = 10; + nested_aligned.as0[1].e1[2] = 11; + nested_aligned.as0[2].e0[0] = 12; + nested_aligned.as0[2].e0[1] = 13; + nested_aligned.as0[2].e0[2] = 14; + nested_aligned.as0[2].e1[0] = 15; + nested_aligned.as0[2].e1[1] = 16; + nested_aligned.as0[2].e1[2] = 17; + nested_aligned.as1[0].e0[0] = 18; + nested_aligned.as1[0].e0[1] = 19; + nested_aligned.as1[0].e0[2] = 20; + nested_aligned.as1[0].e1[0] = 21; + nested_aligned.as1[0].e1[1] = 22; + nested_aligned.as1[0].e1[2] = 23; + nested_aligned.as1[1].e0[0] = 24; + nested_aligned.as1[1].e0[1] = 25; + nested_aligned.as1[1].e0[2] = 26; + nested_aligned.as1[1].e1[0] = 27; + nested_aligned.as1[1].e1[1] = 28; + nested_aligned.as1[1].e1[2] = 29; + nested_aligned.as1[2].e0[0] = 30; + nested_aligned.as1[2].e0[1] = 31; + nested_aligned.as1[2].e0[2] = 32; + nested_aligned.as1[2].e1[0] = 33; + nested_aligned.as1[2].e1[1] = 34; + nested_aligned.as1[2].e1[2] = 35; + unaligned[0][0][0] = 36; + unaligned[0][0][1] = 37; + unaligned[0][0][2] = 38; + unaligned[0][1][0] = 39; + unaligned[0][1][1] = 40; + unaligned[0][1][2] = 41; + unaligned[1][0][0] = 42; + unaligned[1][0][1] = 43; + unaligned[1][0][2] = 44; + unaligned[1][1][0] = 45; + unaligned[1][1][1] = 46; + unaligned[1][1][2] = 47; + + x[0] = nested_aligned.as0[0].e0[0]; + x[1] = nested_aligned.as0[0].e0[1]; + x[2] = nested_aligned.as0[0].e0[2]; + x[3] = nested_aligned.as0[0].e1[0]; + x[4] = nested_aligned.as0[0].e1[1]; + x[5] = nested_aligned.as0[0].e1[2]; + x[6] = nested_aligned.as0[1].e0[0]; + x[7] = nested_aligned.as0[1].e0[1]; + x[8] = nested_aligned.as0[1].e0[2]; + x[9] = nested_aligned.as0[1].e1[0]; + x[10] = nested_aligned.as0[1].e1[1]; + x[11] = nested_aligned.as0[1].e1[2]; + x[12] = nested_aligned.as0[2].e0[0]; + x[13] = nested_aligned.as0[2].e0[1]; + x[14] = nested_aligned.as0[2].e0[2]; + x[15] = nested_aligned.as0[2].e1[0]; + x[16] = nested_aligned.as0[2].e1[1]; + x[17] = nested_aligned.as0[2].e1[2]; + x[18] = nested_aligned.as1[0].e0[0]; + x[19] = nested_aligned.as1[0].e0[1]; + x[20] = nested_aligned.as1[0].e0[2]; + x[21] = nested_aligned.as1[0].e1[0]; + x[22] = nested_aligned.as1[0].e1[1]; + x[23] = nested_aligned.as1[0].e1[2]; + x[24] = nested_aligned.as1[1].e0[0]; + x[25] = nested_aligned.as1[1].e0[1]; + x[26] = nested_aligned.as1[1].e0[2]; + x[27] = nested_aligned.as1[1].e1[0]; + x[28] = nested_aligned.as1[1].e1[1]; + x[29] = nested_aligned.as1[1].e1[2]; + x[30] = nested_aligned.as1[2].e0[0]; + x[31] = nested_aligned.as1[2].e0[1]; + x[32] = nested_aligned.as1[2].e0[2]; + x[33] = nested_aligned.as1[2].e1[0]; + x[34] = nested_aligned.as1[2].e1[1]; + x[35] = nested_aligned.as1[2].e1[2]; + x[36] = unaligned[0][0][0]; + x[37] = unaligned[0][0][1]; + x[38] = unaligned[0][0][2]; + x[39] = unaligned[0][1][0]; + x[40] = unaligned[0][1][1]; + x[41] = unaligned[0][1][2]; + x[42] = unaligned[1][0][0]; + x[43] = unaligned[1][0][1]; + x[44] = unaligned[1][0][2]; + x[45] = unaligned[1][1][0]; + x[46] = unaligned[1][1][1]; + x[47] = unaligned[1][1][2]; +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment5.cl b/benchmarks/opencl/alignment/alignment5.cl new file mode 100644 index 0000000000..4c67443ba9 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment5.cl @@ -0,0 +1,32 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment5.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment5.spvasm + +struct struct1 { + int a; // 4 bytes, aligned to 4 + char b; // 1 byte +}__attribute__ ((aligned (16))); + +struct struct2 { + char b; // 1 byte + int a; // 4 bytes, aligned to 4 +}; + + +__kernel void manual_vs_struct(__global uchar *out) +{ + local struct struct1 s1; + local struct struct2 s2; + + s1.a = 0; + s1.b = 1; + s2.a = 2; + s2.b = 3; + *((int *)(&s1.a + 1)) = 22; + *((int *)(&s2.a + 1)) = 33; + + out[0] = s1.a; + out[1] = s1.b; + out[2] = s2.a; + out[3] = s2.b; +} diff --git a/benchmarks/opencl/alignment/alignment6.cl b/benchmarks/opencl/alignment/alignment6.cl new file mode 100644 index 0000000000..34e351715b --- /dev/null +++ b/benchmarks/opencl/alignment/alignment6.cl @@ -0,0 +1,43 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment6.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment6.spvasm + +struct aligned_struct { + unsigned int e0[3] __attribute__ ((aligned (16))); + unsigned int e1[3] __attribute__ ((aligned (16))); +}; + +global struct aligned_struct aligned; + +kernel void test(global int *x, global struct aligned_struct *aligned) { + + local unsigned int unaligned[2][3]; + + aligned->e0[0] = 0; + aligned->e0[1] = 1; + aligned->e0[2] = 2; + aligned->e1[0] = 4; + aligned->e1[1] = 5; + aligned->e1[2] = 6; + + unaligned[0][0] = 10; + unaligned[0][1] = 11; + unaligned[0][2] = 12; + unaligned[1][0] = 13; + unaligned[1][1] = 14; + unaligned[1][2] = 15; + + x[0] = aligned->e0[0]; + x[1] = aligned->e0[1]; + x[2] = aligned->e0[2]; + x[3] = aligned->e1[0]; + x[4] = aligned->e1[1]; + x[5] = aligned->e1[2]; + + x[6] = unaligned[0][0]; + x[7] = unaligned[0][1]; + x[8] = unaligned[0][2]; + x[9] = unaligned[1][0]; + x[10] = unaligned[1][1]; + x[11] = unaligned[1][2]; +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment7.cl b/benchmarks/opencl/alignment/alignment7.cl new file mode 100644 index 0000000000..5f1c87dfb4 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment7.cl @@ -0,0 +1,31 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment7.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment7.spvasm + +struct struct1 { + int a; // 4 bytes, aligned to 4 + char b; // 1 byte +}__attribute__ ((aligned (16))); + +struct struct2 { + char b; // 1 byte + int a; // 4 bytes, aligned to 4 +}; + +global struct struct1 s1; +global struct struct2 s2; + +__kernel void manual_vs_struct(__global uchar *out, __global struct struct1 *s1, __global struct struct2 *s2) +{ + s1->a = 0; + s1->b = 1; + s2->a = 2; + s2->b = 3; + *((int *)(&s1->a + 1)) = 22; + *((int *)(&s2->a + 1)) = 33; + + out[0] = s1->a; + out[1] = s1->b; + out[2] = s2->a; + out[3] = s2->b; +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment8.cl b/benchmarks/opencl/alignment/alignment8.cl new file mode 100644 index 0000000000..506dc6344d --- /dev/null +++ b/benchmarks/opencl/alignment/alignment8.cl @@ -0,0 +1,25 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment8.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment8.spvasm + +struct aligned_struct { + unsigned int e0 __attribute__ ((aligned (16))); + unsigned int e1 __attribute__ ((aligned (16))); +}; + +global struct aligned_struct aligned; + +kernel void test(global int *x, global struct aligned_struct *aligned) { + + local unsigned int unaligned[2]; + + *(&aligned->e0) = 1; + *(&aligned->e0 + 4) = 2; + *(unaligned) = 3; + *(unaligned + 1) = 4; + + x[0] = aligned->e0; + x[1] = aligned->e1; + x[2] = unaligned[0]; + x[3] = unaligned[1]; +} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment9.cl b/benchmarks/opencl/alignment/alignment9.cl new file mode 100644 index 0000000000..4380335aff --- /dev/null +++ b/benchmarks/opencl/alignment/alignment9.cl @@ -0,0 +1,25 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment9.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment9.spvasm + +struct aligned_struct { + uint3 data[2]; +}; + +global struct aligned_struct aligned; + +__kernel void test(global uint *x, global struct aligned_struct *aligned) +{ + aligned->data[0].x = 0; + aligned->data[0].y = 1; + aligned->data[0].z = 2; + + aligned->data[1].x = 3; + aligned->data[1].y = 4; + aligned->data[1].z = 5; + + for (int i = 0; i < 8; i++) + { + x[i] = *(((uint*)aligned) + i); + } +} \ No newline at end of file diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java index ff7cea3248..a32552142e 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java @@ -6,10 +6,20 @@ public class ArrayType implements Type { private final Type elementType; private final int numElements; + private final int paddingStart; ArrayType(Type elementType, int numElements) { + this(elementType, numElements, numElements); + } + + ArrayType(Type elementType, int numElements, int paddingStart) { this.elementType = elementType; this.numElements = numElements; + this.paddingStart = paddingStart; + } + + public int getPaddingStart() { + return paddingStart; } // NOTE: We use empty arrays to represent unknown size. diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java index fc60feeb67..4004b8ef83 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java @@ -1,5 +1,7 @@ package com.dat3m.dartagnan.expression.type; +import com.dat3m.dartagnan.expression.Expression; +import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.utils.Normalizer; import com.google.common.math.IntMath; @@ -34,6 +36,10 @@ public static TypeFactory getInstance() { return instance; } + public Expression getDefaultAlignment() { + return ExpressionFactory.getInstance().makeValue(getMemorySizeInBytes(getArchType()), getArchType()); + } + public BooleanType getBooleanType() { return booleanType; } @@ -117,6 +123,13 @@ public ArrayType getArrayType(Type element, int size) { return typeNormalizer.normalize(new ArrayType(element, size)); } + public ArrayType getArrayType(Type element, int size, int paddingStart) { + checkArgument(0 <= size, "Negative element count in array."); + checkArgument(0 <= paddingStart, "Negative padding start index in array."); + checkArgument(paddingStart <= size, "Padding start index %s is greater than array size %s", paddingStart, size); + return typeNormalizer.normalize(new ArrayType(element, size, paddingStart)); + } + public IntegerType getArchType() { return pointerDifferenceType; } @@ -262,7 +275,7 @@ public static boolean isStaticTypeOf(Type staticType, Type runtimeType) { } if (staticType instanceof ArrayType aStaticType && runtimeType instanceof ArrayType aRuntimeType) { int countStatic = aStaticType.getNumElements(); - int countRuntime = aRuntimeType.getNumElements(); + int countRuntime = Math.min(aRuntimeType.getPaddingStart(), aRuntimeType.getNumElements()); if (countStatic != countRuntime && (countRuntime != -1 || countStatic <= 0)) { return false; } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java index 2e3b54b678..409403ace8 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java @@ -3,9 +3,9 @@ import com.dat3m.dartagnan.exception.ParsingException; import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; import com.dat3m.dartagnan.parsers.SpirvParser; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Decoration; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; import java.util.Set; @@ -15,10 +15,12 @@ public class VisitorOpsAnnotation extends SpirvBaseVisitor { private final Decoration builtIn; private final Decoration offset; + private final Decoration alignment; public VisitorOpsAnnotation(ProgramBuilder builder) { this.builtIn = builder.getDecorationsBuilder().getDecoration(BUILT_IN); this.offset = builder.getDecorationsBuilder().getDecoration(OFFSET); + this.alignment = builder.getDecorationsBuilder().getDecoration(ALIGNMENT); } @Override @@ -30,6 +32,10 @@ public Void visitOpDecorate(SpirvParser.OpDecorateContext ctx) { String value = ctx.decoration().builtIn().getText(); builtIn.addDecoration(id, value); } + case ALIGNMENT -> { + String value = ctx.decoration().alignmentLiteralInteger().getText(); + alignment.addDecoration(id, value); + } case BINDING, DESCRIPTOR_SET, SPEC_ID, NON_WRITABLE -> { // Skip // BINDING - The order of arguments to the entry point @@ -37,7 +43,7 @@ public Void visitOpDecorate(SpirvParser.OpDecorateContext ctx) { // SPEC_ID - The order of spec constants // NON_WRITABLE - Read-only pointer } - case ALIGNMENT, ARRAY_STRIDE, BLOCK, BUFFER_BLOCK, COHERENT, CONSTANT, FUNC_PARAM_ATTR, LINKAGE_ATTRIBUTES, + case ARRAY_STRIDE, BLOCK, BUFFER_BLOCK, COHERENT, CONSTANT, FUNC_PARAM_ATTR, LINKAGE_ATTRIBUTES, NO_CONTRACTION, NO_PERSPECTIVE -> { // TODO: Implementation } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java index b845e63343..9ae0ebbd0e 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java @@ -48,7 +48,7 @@ public Void visitOpBitcast(SpirvParser.OpBitcastContext ctx) { Expression convertedExpr = expressions.makeCast(operandExpr, resultType); Register reg = builder.addRegister(id, typeId); - builder.addEvent(new Local(reg, convertedExpr)); + builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); return null; } @@ -62,7 +62,21 @@ public Void visitOpConvertPtrToU(SpirvParser.OpConvertPtrToUContext ctx) { Expression pointerExpr = builder.getExpression(ctx.pointer().getText()); Expression convertedPointer = expressions.makeCast(pointerExpr, builder.getType(typeId), false); Register reg = builder.addRegister(id, typeId); - builder.addEvent(new Local(reg, convertedPointer)); + builder.addEvent(EventFactory.newLocal(reg, convertedPointer)); + return null; + } + + @Override + public Void visitOpConvertUToPtr(SpirvParser.OpConvertUToPtrContext ctx) { + String id = ctx.idResult().getText(); + String typeId = ctx.idResultType().getText(); + if (!(builder.getType(typeId) instanceof ScopedPointerType)) { + throw new ParsingException("Type '%s' is not a pointer type for id '%s'", typeId, id); + } + Expression integerExpr = builder.getExpression(ctx.integerValue().getText()); + Expression convertedInteger = expressions.makeCast(integerExpr, builder.getType(typeId), false); + Register reg = builder.addRegister(id, typeId); + builder.addEvent(EventFactory.newLocal(reg, convertedInteger)); return null; } @@ -122,13 +136,14 @@ private void convertAndAddLocal(String typeId, String id, Expression operandExpr } Expression convertedExpr = expressions.makeCast(operandExpr, targetType, isSigned); Register reg = builder.addRegister(id, typeId); - builder.addEvent(new Local(reg, convertedExpr)); + builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); } public Set getSupportedOps() { return Set.of( "OpBitcast", "OpConvertPtrToU", + "OpConvertUToPtr", "OpPtrCastToGeneric", "OpUConvert", "OpSConvert" diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java index cab3b2d0ad..0831e54827 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java @@ -2,11 +2,16 @@ import com.dat3m.dartagnan.exception.ParsingException; import com.dat3m.dartagnan.expression.Expression; +import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; -import com.dat3m.dartagnan.expression.type.*; +import com.dat3m.dartagnan.expression.type.FunctionType; +import com.dat3m.dartagnan.expression.type.ScopedPointerType; +import com.dat3m.dartagnan.expression.type.TypeFactory; +import com.dat3m.dartagnan.expression.type.VoidType; import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; import com.dat3m.dartagnan.parsers.SpirvParser; import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Alignment; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperInputs; import com.dat3m.dartagnan.program.Function; import com.dat3m.dartagnan.program.Register; @@ -20,6 +25,7 @@ import java.util.*; import java.util.stream.IntStream; +import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.ALIGNMENT; import static com.dat3m.dartagnan.program.event.EventFactory.newValueFunctionCall; import static com.dat3m.dartagnan.program.event.EventFactory.newVoidFunctionCall; @@ -27,10 +33,12 @@ public class VisitorOpsFunction extends SpirvBaseVisitor { private static final int DEFAULT_INPUT_SIZE = 10; private static final TypeFactory types = TypeFactory.getInstance(); + private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); private final Map forwardFunctions = new HashMap<>(); private final Map> forwardCalls = new HashMap<>(); private final Map parameters = new HashMap<>(); private final ProgramBuilder builder; + private final Alignment alignment; private String currentId; private FunctionType currentType; private List currentArgs; @@ -38,6 +46,7 @@ public class VisitorOpsFunction extends SpirvBaseVisitor { public VisitorOpsFunction(ProgramBuilder builder) { this.builder = builder; + this.alignment = (Alignment) builder.getDecorationsBuilder().getDecoration(ALIGNMENT); } @Override @@ -181,12 +190,15 @@ private void checkFunctionType(String id, Function function, Type type) { } private Expression createEntryPointParameter(String id, Type type) { + Integer alignmentNum = alignment.getValue(id); + Expression alignmentExpr = alignmentNum == null ? + types.getDefaultAlignment() : expressions.makeValue(alignmentNum, types.getArchType()); Expression value = createEntryPointParameterValue(id, type); if (type instanceof ScopedPointerType pType) { String ptrId = HelperInputs.castPointerId(id); pType = types.getScopedPointerType(pType.getScopeId(), value.getType()); ScopedPointerVariable pointer = builder.allocateScopedPointerVariable( - ptrId, value, pType.getScopeId(), value.getType()); + ptrId, value, alignmentExpr, pType.getScopeId(), value.getType()); builder.addExpression(ptrId, pointer); value = pointer.getAddress(); } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsLogical.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsLogical.java index b2e29ebb5d..9763c22439 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsLogical.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsLogical.java @@ -60,7 +60,7 @@ public Event visitOpSelect(SpirvParser.OpSelectContext ctx) { id, type, op1.getType(), op2.getType()); } if (op1.getType() instanceof IntegerType || op1.getType() instanceof BooleanType) { - return builder.addEvent(new Local(register, expressions.makeITE(cond, op1, op2))); + return builder.addEvent(EventFactory.newLocal(register, expressions.makeITE(cond, op1, op2))); } throw new ParsingException("Illegal definition for '%s', " + "operands must be integers or arrays of booleans", id); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java index b022d8fc15..1e802a13b9 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java @@ -8,18 +8,19 @@ import com.dat3m.dartagnan.expression.type.*; import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; import com.dat3m.dartagnan.parsers.SpirvParser; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Alignment; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.BuiltIn; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperTypes; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperInputs; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperTags; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; -import com.dat3m.dartagnan.program.memory.ScopedPointer; -import com.dat3m.dartagnan.program.memory.ScopedPointerVariable; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperTypes; import com.dat3m.dartagnan.program.Register; import com.dat3m.dartagnan.program.event.Event; import com.dat3m.dartagnan.program.event.EventFactory; import com.dat3m.dartagnan.program.event.Tag; import com.dat3m.dartagnan.program.event.core.Load; +import com.dat3m.dartagnan.program.memory.ScopedPointer; +import com.dat3m.dartagnan.program.memory.ScopedPointerVariable; import org.antlr.v4.runtime.RuleContext; import java.util.ArrayList; @@ -29,6 +30,7 @@ import java.util.function.BiFunction; import java.util.stream.Collectors; +import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.ALIGNMENT; import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.BUILT_IN; import static com.dat3m.dartagnan.expression.utils.ExpressionHelper.isScalar; @@ -38,10 +40,12 @@ public class VisitorOpsMemory extends SpirvBaseVisitor { private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); private final ProgramBuilder builder; private final BuiltIn builtIn; + private final Alignment alignment; public VisitorOpsMemory(ProgramBuilder builder) { this.builder = builder; this.builtIn = (BuiltIn) builder.getDecorationsBuilder().getDecoration(BUILT_IN); + this.alignment = (Alignment) builder.getDecorationsBuilder().getDecoration(ALIGNMENT); } @Override @@ -151,6 +155,12 @@ public Event visitOpVariable(SpirvParser.OpVariableContext ctx) { String typeId = ctx.idResultType().getText(); if (builder.getType(typeId) instanceof ScopedPointerType pointerType) { Type type = pointerType.getPointedType(); + Integer alignmentNum = alignment.getValue(id); + Expression alignmentExpr = alignmentNum == null ? + types.getDefaultAlignment() : expressions.makeValue(alignmentNum, types.getArchType()); + if (alignmentNum != null) { + type = HelperTypes.getAlignedType(type, alignmentNum); + } Expression value = getOpVariableInitialValue(ctx, type); if (value != null) { if (!TypeFactory.isStaticTypeOf(value.getType(), type)) { @@ -163,7 +173,8 @@ public Event visitOpVariable(SpirvParser.OpVariableContext ctx) { } else { value = builder.makeUndefinedValue(type); } - ScopedPointerVariable pointer = builder.allocateScopedPointerVariable(id, value, pointerType.getScopeId(), type); + ScopedPointerVariable pointer = builder.allocateScopedPointerVariable(id, value, alignmentExpr, + pointerType.getScopeId(), type); validateVariableStorageClass(pointer, ctx.storageClass().getText()); builder.addExpression(id, pointer); return null; @@ -187,10 +198,14 @@ private Expression getOpVariableInitialValue(SpirvParser.OpVariableContext ctx, } return builtIn.getDecoration(id, type); } - if (ctx.initializer() != null) { - return builder.getExpression(ctx.initializer().getText()); + if (ctx.initializer() == null) { + return null; } - return null; + Expression initExpr = builder.getExpression(ctx.initializer().getText()); + if (alignment.getValue(id) != null) { + initExpr = builder.getAlignedValue(id, initExpr, type); + } + return initExpr; } private void validateVariableStorageClass(ScopedPointerVariable pointer, String classToken) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java index 3a542be92d..b2422dfba4 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java @@ -1,16 +1,12 @@ package com.dat3m.dartagnan.parsers.program.visitors.spirv.builders; import com.dat3m.dartagnan.exception.ParsingException; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.BuiltIn; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Decoration; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Offset; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.*; import com.dat3m.dartagnan.program.ThreadGrid; import java.util.EnumMap; -import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.BUILT_IN; -import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.OFFSET; +import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.*; public class DecorationsBuilder { @@ -19,6 +15,7 @@ public class DecorationsBuilder { public DecorationsBuilder(ThreadGrid grid) { mapping.put(BUILT_IN, new BuiltIn(grid)); mapping.put(OFFSET, new Offset()); + mapping.put(ALIGNMENT, new Alignment()); } public Decoration getDecoration(DecorationType type) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java index d7f818fe05..f57a7d8ff9 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java @@ -5,9 +5,8 @@ import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; -import com.dat3m.dartagnan.expression.type.FunctionType; -import com.dat3m.dartagnan.expression.type.ScopedPointerType; -import com.dat3m.dartagnan.expression.type.TypeFactory; +import com.dat3m.dartagnan.expression.aggregates.ConstructExpr; +import com.dat3m.dartagnan.expression.type.*; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.BuiltIn; import com.dat3m.dartagnan.program.*; import com.dat3m.dartagnan.program.event.Event; @@ -20,9 +19,11 @@ import com.dat3m.dartagnan.program.processing.transformers.MemoryTransformer; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.IntStream; import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.BUILT_IN; @@ -49,6 +50,34 @@ public ProgramBuilder(ThreadGrid grid) { this.decorationsBuilder = new DecorationsBuilder(grid); } + public Expression getAlignedValue(String id, Expression base, Type type) { + if (type instanceof AggregateType aggregateType && base instanceof ConstructExpr constructExpr) { + List elements = aggregateType.getFields().stream() + .map(field -> { + int index = aggregateType.getFields().indexOf(field); + return getAlignedValue(id, constructExpr.getOperands().get(index), field.type()); + }) + .collect(Collectors.toList()); + return ExpressionFactory.getInstance().makeConstruct(type, elements); + } + if (type instanceof ArrayType arrayType && base instanceof ConstructExpr constructExpr) { + int numOperands = constructExpr.getOperands().size(); + if (arrayType.getNumElements() < numOperands) { + throw new ParsingException("Array initializer has too many elements for variable '%s'", id); + } + List elements = IntStream.range(0, arrayType.getNumElements()) + .mapToObj(i -> i < numOperands + ? getAlignedValue(id, constructExpr.getOperands().get(i), arrayType.getElementType()) + : makeUndefinedValue(arrayType.getElementType())) + .collect(Collectors.toList()); + return ExpressionFactory.getInstance().makeArray(arrayType.getElementType(), elements, true); + } + if (base.getType().equals(type)) { + return base; + } + throw new ParsingException("Cannot align initializer for variable '" + id + "' of type " + type); + } + public Program build() { validateBeforeBuild(); controlFlowBuilder.build(); @@ -180,22 +209,18 @@ public Set getVariables() { .collect(Collectors.toSet()); } - public MemoryObject allocateVariable(String id, int bytes) { - MemoryObject memObj = program.getMemory().allocateVirtual(bytes, true, null); + public ScopedPointerVariable allocateScopedPointerVariable(String id, Expression initValue, + Expression alignment, String storageClass, Type pointedType) { + int bytes = TypeFactory.getInstance().getMemorySizeInBytes(pointedType); + MemoryObject memObj = program.getMemory().allocateVirtual(bytes, true, alignment, null); memObj.setName(id); - return memObj; - } - - public ScopedPointerVariable allocateScopedPointerVariable(String id, Expression initValue, String storageClass, Type pointedType) { - MemoryObject memObj = allocateVariable(id, TypeFactory.getInstance().getMemorySizeInBytes(pointedType)); memObj.setIsThreadLocal(false); memObj.setInitialValue(0, initValue); if (arch == Arch.OPENCL) { String openCLSpace = Tag.Spirv.toOpenCLTag(Tag.Spirv.getStorageClassTag(Set.of(storageClass))); memObj.addFeatureTag(openCLSpace); } - return ExpressionFactory.getInstance().makeScopedPointerVariable( - id, storageClass, pointedType, memObj); + return ExpressionFactory.getInstance().makeScopedPointerVariable(id, storageClass, pointedType, memObj); } public String getPointerStorageClass(String id) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java new file mode 100644 index 0000000000..d9bec81264 --- /dev/null +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java @@ -0,0 +1,25 @@ +package com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations; + +import com.dat3m.dartagnan.exception.ParsingException; + +import java.util.HashMap; +import java.util.Map; + +public class Alignment implements Decoration { + + private final Map mapping = new HashMap<>(); + + @Override + public void addDecoration(String id, String... params) { + if (params.length != 1) { + throw new ParsingException("Illegal decoration '%s' for '%s'", + getClass().getSimpleName(), id); + } + int alignment = Integer.parseInt(params[0]); + mapping.put(id, alignment); + } + + public Integer getValue(String id) { + return mapping.get(id); + } +} diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java index f37d3dcd33..edab3fd985 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java @@ -4,13 +4,14 @@ import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; -import com.dat3m.dartagnan.expression.integers.IntLiteral; +import com.dat3m.dartagnan.expression.aggregates.ConstructExpr; import com.dat3m.dartagnan.expression.integers.IntBinaryOp; +import com.dat3m.dartagnan.expression.integers.IntLiteral; import com.dat3m.dartagnan.expression.type.*; -import com.dat3m.dartagnan.expression.aggregates.ConstructExpr; import java.util.ArrayList; import java.util.List; +import java.util.stream.IntStream; import static com.dat3m.dartagnan.expression.integers.IntBinaryOp.ADD; import static com.dat3m.dartagnan.expression.integers.IntBinaryOp.MUL; @@ -67,15 +68,6 @@ public static Expression getMemberAddress(String id, Expression base, Type type, return base; } - public static Expression getPointerOffset(Expression base, Type type, Expression offset) { - int size = types.getMemorySizeInBytes(type); - IntLiteral sizeExpr = expressions.makeValue(size, archType); - Expression formattedOffset = expressions.makeIntegerCast(offset, archType, false); - Expression offsetExpr = expressions.makeBinary(sizeExpr, MUL, formattedOffset); - Expression formattedBase = expressions.makeIntegerCast(base, archType, false); - return expressions.makeBinary(formattedBase, ADD, offsetExpr); - } - public static Expression createResultExpression(String id, Type type, Expression op1, Expression op2, IntBinaryOp op) { if (isScalar(type)) { return expressions.makeBinary(op1, op, op2); @@ -178,4 +170,37 @@ private static String indexNonConstantError(String id) { private static String indexNonConstantForStructError(String id) { return String.format("Index of a struct member is non-constant for variable '%s'", id); } + + public static Type getAlignedType(Type type, int alignmentNum) { + if (type instanceof IntegerType) { + return types.getIntegerType(alignmentNum * 8); + } + if (type instanceof AggregateType aggregateType) { + List fieldTypes = new ArrayList<>(); + for (int i = 0; i < aggregateType.getFields().size(); i++) { + Type fieldType = aggregateType.getFields().get(i).type(); + if (types.getMemorySizeInBytes(fieldType) > alignmentNum) { + fieldType = getAlignedType(fieldType, alignmentNum); + } + fieldTypes.add(fieldType); + } + List alignmentList = new ArrayList<>(List.of(0)); + IntStream.range(0, fieldTypes.size() - 1).forEach(i -> { + int fieldAlignment = types.getMemorySizeInBytes(fieldTypes.get(i)); + alignmentList.add(fieldAlignment + alignmentList.get(i)); + }); + return types.getAggregateType(fieldTypes, alignmentList); + } + if (type instanceof ArrayType arrayType) { + Type elementType = arrayType.getElementType(); + int arraySizeInBytes = types.getMemorySizeInBytes(arrayType); + if (arraySizeInBytes > alignmentNum) { + return types.getArrayType(getAlignedType(elementType, alignmentNum), arrayType.getNumElements()); + } + int paddedSize = alignmentNum / types.getMemorySizeInBytes(elementType); + int paddingStart = arrayType.getNumElements(); + return types.getArrayType(elementType, paddedSize, paddingStart); + } + throw new ParsingException("Invalid type '%s' for alignment '%d'", type, alignmentNum); + } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java index f891b25eed..ce0283e756 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java @@ -16,12 +16,17 @@ public class Memory { private final ArrayList objects = new ArrayList<>(); private final Type ptrType = TypeFactory.getInstance().getPointerType(); private final IntegerType archType = TypeFactory.getInstance().getArchType(); - private final Expression defaultAlignment = ExpressionFactory.getInstance().makeValue(8, archType); + private final TypeFactory types = TypeFactory.getInstance(); private int nextIndex = 1; // Generates a new, statically allocated memory object. public MemoryObject allocate(int size) { + final Expression defaultAlignment = types.getDefaultAlignment(); + return allocate(size, defaultAlignment); + } + + public MemoryObject allocate(int size, Expression defaultAlignment) { Preconditions.checkArgument(size > 0, "Illegal allocation. Size must be positive"); final Expression sizeExpr = ExpressionFactory.getInstance().makeValue(size, archType); final MemoryObject memoryObject = new MemoryObject(nextIndex++, sizeExpr, defaultAlignment, null, ptrType); @@ -39,9 +44,14 @@ public MemoryObject allocate(Alloc allocationSite) { } public VirtualMemoryObject allocateVirtual(int size, boolean generic, VirtualMemoryObject alias) { + return allocateVirtual(size, generic, types.getDefaultAlignment(), alias); + } + + public VirtualMemoryObject allocateVirtual(int size, boolean generic, Expression alignment, + VirtualMemoryObject alias) { Preconditions.checkArgument(size > 0, "Illegal allocation. Size must be positive"); final Expression sizeExpr = ExpressionFactory.getInstance().makeValue(size, archType); - final VirtualMemoryObject address = new VirtualMemoryObject(nextIndex++, sizeExpr, defaultAlignment, + final VirtualMemoryObject address = new VirtualMemoryObject(nextIndex++, sizeExpr, alignment, generic, alias, ptrType); objects.add(address); return address; @@ -53,8 +63,8 @@ public boolean deleteMemoryObject(MemoryObject obj) { /** * Accesses all shared variables. - * @return - * Copy of the complete collection of allocated objects. + * + * @return Copy of the complete collection of allocated objects. */ public ImmutableSet getObjects() { return ImmutableSet.copyOf(objects); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java index 439ead5eb4..4d21f5e641 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java @@ -114,8 +114,8 @@ private Expression applyMapping(MemoryObject memObj, int scopeDepth) { Map mapping = scopeMapping.get(scopeDepth); if (!mapping.containsKey(memObj)) { MemoryObject copy = memObj instanceof VirtualMemoryObject - ? program.getMemory().allocateVirtual(memObj.getKnownSize(), true, null) - : program.getMemory().allocate(memObj.getKnownSize()); + ? program.getMemory().allocateVirtual(memObj.getKnownSize(), true, memObj.alignment(), null) + : program.getMemory().allocate(memObj.getKnownSize(), memObj.alignment()); copy.setName(makeVariableName(scopeDepth, memObj.getName())); for (int offset : memObj.getInitializedFields()) { Expression value = memObj.getInitialValue(offset); diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java new file mode 100644 index 0000000000..77c95ac9ff --- /dev/null +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java @@ -0,0 +1,63 @@ +package com.dat3m.dartagnan.parsers.program.visitors.spirv; + +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Alignment; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Offset; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockProgramBuilder; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockSpirvParser; +import com.dat3m.dartagnan.program.memory.ScopedPointerVariable; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class VisitorOpsAnnotationTest { + + private final MockProgramBuilder builder = new MockProgramBuilder(); + + @Test + public void testAlignment() { + // given + String input = "OpDecorate %v_uint_aligned Alignment 16"; + + // when + visit(input); + + // then + Alignment alignment = (Alignment) builder.getDecorationsBuilder().getDecoration(DecorationType.ALIGNMENT); + assertEquals(16, (long) alignment.getValue("%v_uint_aligned")); + } + + @Test + public void testOffset() { + // given + String input = """ + OpMemberDecorate %struct 0 Offset 0 + OpMemberDecorate %struct 1 Offset 1 + OpMemberDecorate %struct 2 Offset 3 + OpMemberDecorate %struct 3 Offset 6 + OpMemberDecorate %struct 4 Offset 10 + OpMemberDecorate %struct 5 Offset 15 + OpMemberDecorate %struct 6 Offset 21 + OpMemberDecorate %struct 7 Offset 28 + """; + + // when + visit(input); + + // then + Offset offset = (Offset) builder.getDecorationsBuilder().getDecoration(DecorationType.OFFSET); + assertEquals(0, (long) offset.getValue("%struct").get(0)); + assertEquals(1, (long) offset.getValue("%struct").get(1)); + assertEquals(3, (long) offset.getValue("%struct").get(2)); + assertEquals(6, (long) offset.getValue("%struct").get(3)); + assertEquals(10, (long) offset.getValue("%struct").get(4)); + assertEquals(15, (long) offset.getValue("%struct").get(5)); + assertEquals(21, (long) offset.getValue("%struct").get(6)); + assertEquals(28, (long) offset.getValue("%struct").get(7)); + } + + private void visit(String text) { + builder.mockFunctionStart(true); + new MockSpirvParser(text).spv().spvInstructions().accept(new VisitorOpsAnnotation(builder)); + } +} diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java index cee591691d..4e5d693d75 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java @@ -104,6 +104,23 @@ public void opConvertPtrToUValid() { assertEquals(builder.getType("%uint"), reg.getType()); } + @Test + public void opConvertUToPtrValid() { + // given + String input = "%value2 = OpConvertUToPtr %_ptr_Function_uint %value1"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%_ptr_Function_uint", "%uint", "Function"); + builder.mockConstant("%value1", "%uint", 1); + builder.mockFunctionStart(true); + + // when + visit(input); + + // then + Expression reg = builder.getExpression("%value2"); + assertEquals(builder.getType("%_ptr_Function_uint"), reg.getType()); + } + @Test public void opUConvertValidConstant() { // given diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java index c8b8300382..f4ef188255 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java @@ -221,6 +221,37 @@ public void testVariable() { } } + @Test + public void testAlignedVariable() { + // given + String input = """ + %v1 = OpVariable %int_ptr Uniform + %v2 = OpVariable %arr_ptr Uniform + """; + + builder.mockIntType("%int", 128); + builder.mockVectorType("%arr", "%int", 3); + builder.mockPtrType("%int_ptr", "%int", "Uniform"); + builder.mockPtrType("%arr_ptr", "%arr", "Uniform"); + builder.mockPointerAlignment("%v1", 32); + builder.mockPointerAlignment("%v2", 64); + + + // when + parse(input); + + // then + ScopedPointerVariable v1 = (ScopedPointerVariable) builder.getExpression("%v1"); + assertNotNull(v1); + assertEquals(32, v1.getAddress().getKnownAlignment()); + assertEquals(256, ((IntegerType) v1.getInnerType()).getBitWidth()); + ScopedPointerVariable v2 = (ScopedPointerVariable) builder.getExpression("%v2"); + assertNotNull(v2); + assertEquals(64, TypeFactory.getInstance().getMemorySizeInBytes(v2.getInnerType())); + assertEquals(4, ((ArrayType) v2.getInnerType()).getNumElements()); + assertEquals(3, ((ArrayType) v2.getInnerType()).getPaddingStart()); + } + @Test public void testInitializedVariableConstant() { String input = """ diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java index bb6bad10bb..6bcb6d77b6 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java @@ -154,6 +154,11 @@ public void mockStructMemberOffsets(String id, Integer... offsets) { } } + public void mockPointerAlignment(String id, int alignment) { + Decoration decoration = getDecorationsBuilder().getDecoration(DecorationType.ALIGNMENT); + decoration.addDecoration(id, Integer.toString(alignment)); + } + public void mockFunctionStart(boolean addStartLabel) { FunctionType type = typeFactory.getFunctionType(typeFactory.getVoidType(), List.of()); startCurrentFunction(new Function("mock_function", type, List.of(), 0, null)); diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java index 30b996e418..f18b29488c 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java @@ -47,7 +47,18 @@ public SpirvAssertionsTest(String file, int bound, Result expected) { @Parameterized.Parameters(name = "{index}: {0}, {1}, {2}") public static Iterable data() throws IOException { return Arrays.asList(new Object[][]{ + {"vector-aligned.spvasm", 1, PASS}, {"idx-overflow.spvasm", 1, PASS}, + {"alignment1.spvasm", 9, PASS}, + {"alignment2.spvasm", 1, PASS}, + {"alignment3.spvasm", 1, PASS}, + {"alignment4.spvasm", 1, PASS}, + {"alignment5.spvasm", 1, PASS}, + {"alignment6.spvasm", 1, PASS}, + {"alignment7.spvasm", 1, PASS}, + {"alignment8.spvasm", 1, PASS}, + {"alignment9.spvasm", 9, PASS}, + {"alignment10.spvasm", 9, PASS} }); } diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm new file mode 100644 index 0000000000..79edae0dd8 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm @@ -0,0 +1,91 @@ +; @Input: %12={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%12[0] == 0 and %12[1] == 1 and %12[2] == 2 and %12[4] == 3 and %12[5] == 4 and %12[6] == 5) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 58 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %11 "test" + OpSource OpenCL_C 200000 + OpName %test_data "test.data" + OpDecorate %19 Alignment 4 + OpDecorate %21 Alignment 4 + OpDecorate %test_data Alignment 16 + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_8 = OpConstant %uint 8 + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2 +%_ptr_Workgroup__arr_v3uint_uint_2 = OpTypePointer Workgroup %_arr_v3uint_uint_2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %10 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_v3uint = OpTypePointer Workgroup %v3uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool + %test_data = OpVariable %_ptr_Workgroup__arr_v3uint_uint_2 Workgroup + %11 = OpFunction %void DontInline %10 + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %19 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %21 = OpVariable %_ptr_Function_uint Function + OpStore %19 %12 Aligned 4 + %24 = OpInBoundsPtrAccessChain %_ptr_Workgroup_v3uint %test_data %uint_0 %uint_0 + %25 = OpLoad %v3uint %24 Aligned 16 + %26 = OpCompositeInsert %v3uint %uint_0 %25 0 + OpStore %24 %26 Aligned 16 + %27 = OpLoad %v3uint %24 Aligned 16 + %29 = OpCompositeInsert %v3uint %uint_1 %27 1 + OpStore %24 %29 Aligned 16 + %30 = OpLoad %v3uint %24 Aligned 16 + %31 = OpCompositeInsert %v3uint %uint_2 %30 2 + OpStore %24 %31 Aligned 16 + %32 = OpInBoundsPtrAccessChain %_ptr_Workgroup_v3uint %test_data %uint_0 %uint_1 + %33 = OpLoad %v3uint %32 Aligned 16 + %35 = OpCompositeInsert %v3uint %uint_3 %33 0 + OpStore %32 %35 Aligned 16 + %36 = OpLoad %v3uint %32 Aligned 16 + %38 = OpCompositeInsert %v3uint %uint_4 %36 1 + OpStore %32 %38 Aligned 16 + %39 = OpLoad %v3uint %32 Aligned 16 + %41 = OpCompositeInsert %v3uint %uint_5 %39 2 + OpStore %32 %41 Aligned 16 + OpStore %21 %uint_0 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_data %uint_0 %uint_0 %uint_0 + %45 = OpPtrCastToGeneric %_ptr_Generic_uint %43 + OpBranch %14 + %14 = OpLabel + %46 = OpLoad %uint %21 Aligned 4 + %49 = OpSLessThan %bool %46 %uint_8 + OpBranchConditional %49 %15 %17 + %15 = OpLabel + %50 = OpLoad %uint %21 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %45 %50 + %52 = OpLoad %uint %51 Aligned 4 + %53 = OpLoad %_ptr_CrossWorkgroup_uint %19 Aligned 4 + %54 = OpLoad %uint %21 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %53 %54 + OpStore %55 %52 Aligned 4 + OpBranch %16 + %16 = OpLabel + %56 = OpLoad %uint %21 Aligned 4 + %57 = OpIAdd %uint %56 %uint_1 + OpStore %21 %57 Aligned 4 + OpBranch %14 + %17 = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm new file mode 100644 index 0000000000..73a7784315 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm @@ -0,0 +1,74 @@ +; @Input: %22 = {0, 0} +; @Output: forall (%22[0] == 1 and %22[1] == 2) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 45 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %21 "test" + OpSource OpenCL_C 200000 + OpName %struct_struct1 "struct.struct1" + OpName %test_s1 "test.s1" + OpName %struct_struct2 "struct.struct2" + OpName %test_s2 "test.s2" + OpDecorate %test_s2 Alignment 4 + OpDecorate %25 Alignment 4 + OpDecorate %test_s1 Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_struct1 = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 +%_ptr_Workgroup_struct_struct1 = OpTypePointer Workgroup %struct_struct1 +%struct_struct2 = OpTypeStruct %_arr_uint_uint_3 %_arr_uint_uint_3 +%_ptr_Workgroup_struct_struct2 = OpTypePointer Workgroup %struct_struct2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %20 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %5 = OpUndef %_arr_uint_uint_3 + %9 = OpUndef %_arr_uchar_uint_4 + %11 = OpConstantComposite %struct_struct1 %5 %9 %5 %9 + %test_s1 = OpVariable %_ptr_Workgroup_struct_struct1 Workgroup %11 + %15 = OpConstantComposite %struct_struct2 %5 %5 + %test_s2 = OpVariable %_ptr_Workgroup_struct_struct2 Workgroup %15 + %21 = OpFunction %void DontInline %20 + %22 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %23 = OpLabel + %25 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + OpStore %25 %22 Aligned 4 + %28 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s1 %uint_0 %uint_0 %uint_0 + %30 = OpPtrCastToGeneric %_ptr_Generic_uint %28 + %31 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %30 %uint_4 + OpStore %31 %uint_1 Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s2 %uint_0 %uint_0 %uint_0 + %34 = OpPtrCastToGeneric %_ptr_Generic_uint %33 + %35 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %34 %uint_3 + OpStore %35 %uint_2 Aligned 4 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s1 %uint_0 %uint_2 %uint_0 + %38 = OpLoad %uint %37 Aligned 16 + %39 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %39 %uint_0 + OpStore %40 %38 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s2 %uint_0 %uint_1 %uint_0 + %42 = OpLoad %uint %41 Aligned 4 + %43 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %43 %uint_1 + OpStore %44 %42 Aligned 4 + OpReturn + OpFunctionEnd + diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm new file mode 100644 index 0000000000..ed1e9c3488 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm @@ -0,0 +1,77 @@ +; @Input: %20={0, 0, 0, 0} +; @Output: forall (%20[0] == 1 and %20[1] == 2 and %20[2] == 3 and %20[3] == 4) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 47 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %19 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_struct "struct.aligned_struct" + OpName %test_aligned "test.aligned" + OpName %test_unaligned "test.unaligned" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %23 Alignment 4 + OpDecorate %test_aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %3 = OpUndef %uint + %uint_12 = OpConstant %uint 12 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_4 = OpConstant %uint 4 + %uint_3 = OpConstant %uint 3 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_struct = OpTypeStruct %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 +%_ptr_Workgroup_struct_aligned_struct = OpTypePointer Workgroup %struct_aligned_struct +%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 +%_ptr_Workgroup__arr_uint_uint_2 = OpTypePointer Workgroup %_arr_uint_uint_2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %18 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %7 = OpUndef %_arr_uchar_uint_12 + %9 = OpConstantComposite %struct_aligned_struct %3 %7 %3 %7 +%test_aligned = OpVariable %_ptr_Workgroup_struct_aligned_struct Workgroup %9 +%test_unaligned = OpVariable %_ptr_Workgroup__arr_uint_uint_2 Workgroup + %19 = OpFunction %void DontInline %18 + %20 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %21 = OpLabel + %23 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + OpStore %23 %20 Aligned 4 + %26 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 + OpStore %26 %uint_1 Aligned 16 + %28 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 + %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %28 %uint_4 + OpStore %30 %uint_2 Aligned 4 + %31 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 + OpStore %31 %uint_3 Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 + OpStore %33 %uint_4 Aligned 4 + %34 = OpLoad %uint %26 Aligned 16 + %35 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %35 %uint_0 + OpStore %36 %34 Aligned 4 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 + %38 = OpLoad %uint %37 Aligned 16 + %39 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %39 %uint_1 + OpStore %40 %38 Aligned 4 + %41 = OpLoad %uint %31 Aligned 4 + %42 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %42 %uint_2 + OpStore %43 %41 Aligned 4 + %44 = OpLoad %uint %33 Aligned 4 + %45 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 + %46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %45 %uint_3 + OpStore %46 %44 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm new file mode 100644 index 0000000000..5e23e48799 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm @@ -0,0 +1,134 @@ +; @Input: %22={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%22[0] == 0 and %22[1] == 1 and %22[2] == 2 and %22[3] == 4 and %22[4] == 5 and %22[5] == 6 and %22[6] == 10 and %22[7] == 11 and %22[8] == 12 and %22[9] == 13 and %22[10] == 14 and %22[11] == 15) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 88 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %21 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_struct "struct.aligned_struct" + OpName %test_aligned "test.aligned" + OpName %test_unaligned "test.unaligned" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %25 Alignment 4 + OpDecorate %test_aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_12 = OpConstant %uint 12 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_struct = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 +%_ptr_Workgroup_struct_aligned_struct = OpTypePointer Workgroup %struct_aligned_struct +%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2 +%_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 = OpTypePointer Workgroup %_arr__arr_uint_uint_3_uint_2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %20 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %5 = OpUndef %_arr_uint_uint_3 + %9 = OpUndef %_arr_uchar_uint_4 + %11 = OpConstantComposite %struct_aligned_struct %5 %9 %5 %9 +%test_aligned = OpVariable %_ptr_Workgroup_struct_aligned_struct Workgroup %11 +%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 Workgroup + %21 = OpFunction %void DontInline %20 + %22 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %23 = OpLabel + %25 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + OpStore %25 %22 Aligned 4 + %28 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + OpStore %28 %uint_0 Aligned 16 + %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_1 + OpStore %30 %uint_1 Aligned 4 + %31 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_2 + OpStore %31 %uint_2 Aligned 8 + %32 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 %uint_0 + OpStore %32 %uint_4 Aligned 16 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 %uint_1 + OpStore %33 %uint_5 Aligned 4 + %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 %uint_2 + OpStore %35 %uint_6 Aligned 8 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %37 %uint_10 Aligned 4 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %39 %uint_11 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 + OpStore %41 %uint_12 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %43 %uint_13 Aligned 4 + %45 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %45 %uint_14 Aligned 4 + %47 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 + OpStore %47 %uint_15 Aligned 4 + %49 = OpLoad %uint %28 Aligned 16 + %50 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %50 %uint_0 + OpStore %51 %49 Aligned 4 + %52 = OpLoad %uint %30 Aligned 4 + %53 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %53 %uint_1 + OpStore %54 %52 Aligned 4 + %55 = OpLoad %uint %31 Aligned 8 + %56 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %56 %uint_2 + OpStore %57 %55 Aligned 4 + %58 = OpLoad %uint %32 Aligned 16 + %59 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %59 %uint_3 + OpStore %60 %58 Aligned 4 + %61 = OpLoad %uint %33 Aligned 4 + %62 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %63 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %62 %uint_4 + OpStore %63 %61 Aligned 4 + %64 = OpLoad %uint %35 Aligned 8 + %65 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %66 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %65 %uint_5 + OpStore %66 %64 Aligned 4 + %67 = OpLoad %uint %37 Aligned 4 + %68 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %69 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %68 %uint_6 + OpStore %69 %67 Aligned 4 + %70 = OpLoad %uint %39 Aligned 4 + %71 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %73 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %71 %uint_7 + OpStore %73 %70 Aligned 4 + %74 = OpLoad %uint %41 Aligned 4 + %75 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %75 %uint_8 + OpStore %77 %74 Aligned 4 + %78 = OpLoad %uint %43 Aligned 4 + %79 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %81 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %79 %uint_9 + OpStore %81 %78 Aligned 4 + %82 = OpLoad %uint %45 Aligned 4 + %83 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %84 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %83 %uint_10 + OpStore %84 %82 Aligned 4 + %85 = OpLoad %uint %47 Aligned 4 + %86 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 + %87 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %86 %uint_11 + OpStore %87 %85 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm new file mode 100644 index 0000000000..082e5013d2 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm @@ -0,0 +1,387 @@ +; @Input: %27={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%27[0] == 0 and %27[1] == 1 and %27[2] == 2 and %27[3] == 3 and %27[4] == 4 and %27[5] == 5 and %27[6] == 6 and %27[7] == 7 and %27[8] == 8 and %27[9] == 9 and %27[10] == 10 and %27[11] == 11 and %27[12] == 12 and %27[13] == 13 and %27[14] == 14 and %27[15] == 15 and %27[16] == 16 and %27[17] == 17 and %27[18] == 18 and %27[19] == 19 and %27[20] == 20 and %27[21] == 21 and %27[22] == 22 and %27[23] == 23 and %27[24] == 24 and %27[25] == 25 and %27[26] == 26 and %27[27] == 27 and %27[28] == 28 and %27[29] == 29 and %27[30] == 30 and %27[31] == 31 and %27[32] == 32 and %27[33] == 33 and %27[34] == 34 and %27[35] == 35 and %27[36] == 36 and %27[37] == 37 and %27[38] == 38 and %27[39] == 39 and %27[40] == 40 and %27[41] == 41 and %27[42] == 42 and %27[43] == 43 and %27[44] == 44 and %27[45] == 45 and %27[46] == 46 and %27[47] == 47) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 268 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %26 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_struct "struct.aligned_struct" + OpName %struct_nested_aligned_struct "struct.nested_aligned_struct" + OpName %test_nested_aligned "test.nested_aligned" + OpName %test_unaligned "test.unaligned" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %30 Alignment 4 + OpDecorate %test_nested_aligned Alignment 64 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_32 = OpConstant %uint 32 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_12 = OpConstant %uint 12 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_16 = OpConstant %uint 16 + %uint_17 = OpConstant %uint 17 + %uint_18 = OpConstant %uint 18 + %uint_19 = OpConstant %uint 19 + %uint_20 = OpConstant %uint 20 + %uint_21 = OpConstant %uint 21 + %uint_22 = OpConstant %uint 22 + %uint_23 = OpConstant %uint 23 + %uint_24 = OpConstant %uint 24 + %uint_25 = OpConstant %uint 25 + %uint_26 = OpConstant %uint 26 + %uint_27 = OpConstant %uint 27 + %uint_28 = OpConstant %uint 28 + %uint_29 = OpConstant %uint 29 + %uint_30 = OpConstant %uint 30 + %uint_31 = OpConstant %uint 31 + %uint_33 = OpConstant %uint 33 + %uint_34 = OpConstant %uint 34 + %uint_35 = OpConstant %uint 35 + %uint_36 = OpConstant %uint 36 + %uint_37 = OpConstant %uint 37 + %uint_38 = OpConstant %uint 38 + %uint_39 = OpConstant %uint 39 + %uint_40 = OpConstant %uint 40 + %uint_41 = OpConstant %uint 41 + %uint_42 = OpConstant %uint 42 + %uint_43 = OpConstant %uint 43 + %uint_44 = OpConstant %uint 44 + %uint_45 = OpConstant %uint 45 + %uint_46 = OpConstant %uint 46 + %uint_47 = OpConstant %uint 47 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_struct = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 +%_arr_struct_aligned_struct_uint_3 = OpTypeArray %struct_aligned_struct %uint_3 +%_arr_uchar_uint_32 = OpTypeArray %uchar %uint_32 +%struct_nested_aligned_struct = OpTypeStruct %_arr_struct_aligned_struct_uint_3 %_arr_uchar_uint_32 %_arr_struct_aligned_struct_uint_3 %_arr_uchar_uint_32 +%_ptr_Workgroup_struct_nested_aligned_struct = OpTypePointer Workgroup %struct_nested_aligned_struct +%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2 +%_arr__arr__arr_uint_uint_3_uint_2_uint_2 = OpTypeArray %_arr__arr_uint_uint_3_uint_2 %uint_2 +%_ptr_Workgroup__arr__arr__arr_uint_uint_3_uint_2_uint_2 = OpTypePointer Workgroup %_arr__arr__arr_uint_uint_3_uint_2_uint_2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %25 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %10 = OpUndef %_arr_struct_aligned_struct_uint_3 + %13 = OpUndef %_arr_uchar_uint_32 + %15 = OpConstantComposite %struct_nested_aligned_struct %10 %13 %10 %13 +%test_nested_aligned = OpVariable %_ptr_Workgroup_struct_nested_aligned_struct Workgroup %15 +%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr__arr_uint_uint_3_uint_2_uint_2 Workgroup + %26 = OpFunction %void DontInline %25 + %27 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %28 = OpLabel + %30 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + OpStore %30 %27 Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_0 %uint_0 + OpStore %33 %uint_0 Aligned 64 + %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_0 %uint_1 + OpStore %35 %uint_1 Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_0 %uint_2 + OpStore %36 %uint_2 Aligned 8 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_2 %uint_0 + OpStore %37 %uint_3 Aligned 16 + %38 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_2 %uint_1 + OpStore %38 %uint_4 Aligned 4 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_2 %uint_2 + OpStore %39 %uint_5 Aligned 8 + %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_0 %uint_0 + OpStore %41 %uint_6 Aligned 32 + %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_0 %uint_1 + OpStore %43 %uint_7 Aligned 4 + %45 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_0 %uint_2 + OpStore %45 %uint_8 Aligned 8 + %47 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_2 %uint_0 + OpStore %47 %uint_9 Aligned 16 + %49 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_2 %uint_1 + OpStore %49 %uint_10 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_2 %uint_2 + OpStore %51 %uint_11 Aligned 8 + %53 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_0 %uint_0 + OpStore %53 %uint_12 Aligned 64 + %55 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_0 %uint_1 + OpStore %55 %uint_13 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_0 %uint_2 + OpStore %57 %uint_14 Aligned 8 + %59 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_2 %uint_0 + OpStore %59 %uint_15 Aligned 16 + %61 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_2 %uint_1 + OpStore %61 %uint_16 Aligned 4 + %63 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_2 %uint_2 + OpStore %63 %uint_17 Aligned 8 + %65 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_0 %uint_0 + OpStore %65 %uint_18 Aligned 64 + %67 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_0 %uint_1 + OpStore %67 %uint_19 Aligned 4 + %69 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_0 %uint_2 + OpStore %69 %uint_20 Aligned 8 + %71 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_2 %uint_0 + OpStore %71 %uint_21 Aligned 16 + %73 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_2 %uint_1 + OpStore %73 %uint_22 Aligned 4 + %75 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_2 %uint_2 + OpStore %75 %uint_23 Aligned 8 + %77 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_0 %uint_0 + OpStore %77 %uint_24 Aligned 32 + %79 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_0 %uint_1 + OpStore %79 %uint_25 Aligned 4 + %81 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_0 %uint_2 + OpStore %81 %uint_26 Aligned 8 + %83 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_2 %uint_0 + OpStore %83 %uint_27 Aligned 16 + %85 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_2 %uint_1 + OpStore %85 %uint_28 Aligned 4 + %87 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_2 %uint_2 + OpStore %87 %uint_29 Aligned 8 + %89 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_0 %uint_0 + OpStore %89 %uint_30 Aligned 64 + %91 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_0 %uint_1 + OpStore %91 %uint_31 Aligned 4 + %93 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_0 %uint_2 + OpStore %93 %uint_32 Aligned 8 + %94 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_2 %uint_0 + OpStore %94 %uint_33 Aligned 16 + %96 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_2 %uint_1 + OpStore %96 %uint_34 Aligned 4 + %98 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_2 %uint_2 + OpStore %98 %uint_35 Aligned 8 + %100 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 %uint_0 + OpStore %100 %uint_36 Aligned 4 + %102 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 %uint_1 + OpStore %102 %uint_37 Aligned 4 + %104 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 %uint_2 + OpStore %104 %uint_38 Aligned 4 + %106 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 %uint_0 + OpStore %106 %uint_39 Aligned 4 + %108 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 %uint_1 + OpStore %108 %uint_40 Aligned 4 + %110 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 %uint_2 + OpStore %110 %uint_41 Aligned 4 + %112 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 %uint_0 + OpStore %112 %uint_42 Aligned 4 + %114 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 %uint_1 + OpStore %114 %uint_43 Aligned 4 + %116 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 %uint_2 + OpStore %116 %uint_44 Aligned 4 + %118 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 %uint_0 + OpStore %118 %uint_45 Aligned 4 + %120 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 %uint_1 + OpStore %120 %uint_46 Aligned 4 + %122 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 %uint_2 + OpStore %122 %uint_47 Aligned 4 + %124 = OpLoad %uint %33 Aligned 64 + %125 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %126 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %125 %uint_0 + OpStore %126 %124 Aligned 4 + %127 = OpLoad %uint %35 Aligned 4 + %128 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %129 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %128 %uint_1 + OpStore %129 %127 Aligned 4 + %130 = OpLoad %uint %36 Aligned 8 + %131 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %132 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %131 %uint_2 + OpStore %132 %130 Aligned 4 + %133 = OpLoad %uint %37 Aligned 16 + %134 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %135 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %134 %uint_3 + OpStore %135 %133 Aligned 4 + %136 = OpLoad %uint %38 Aligned 4 + %137 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %138 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %137 %uint_4 + OpStore %138 %136 Aligned 4 + %139 = OpLoad %uint %39 Aligned 8 + %140 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %141 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %140 %uint_5 + OpStore %141 %139 Aligned 4 + %142 = OpLoad %uint %41 Aligned 32 + %143 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %144 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %143 %uint_6 + OpStore %144 %142 Aligned 4 + %145 = OpLoad %uint %43 Aligned 4 + %146 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %147 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %146 %uint_7 + OpStore %147 %145 Aligned 4 + %148 = OpLoad %uint %45 Aligned 8 + %149 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %150 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %149 %uint_8 + OpStore %150 %148 Aligned 4 + %151 = OpLoad %uint %47 Aligned 16 + %152 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %153 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %152 %uint_9 + OpStore %153 %151 Aligned 4 + %154 = OpLoad %uint %49 Aligned 4 + %155 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %156 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %155 %uint_10 + OpStore %156 %154 Aligned 4 + %157 = OpLoad %uint %51 Aligned 8 + %158 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %159 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %158 %uint_11 + OpStore %159 %157 Aligned 4 + %160 = OpLoad %uint %53 Aligned 64 + %161 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %162 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %161 %uint_12 + OpStore %162 %160 Aligned 4 + %163 = OpLoad %uint %55 Aligned 4 + %164 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %165 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %164 %uint_13 + OpStore %165 %163 Aligned 4 + %166 = OpLoad %uint %57 Aligned 8 + %167 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %168 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %167 %uint_14 + OpStore %168 %166 Aligned 4 + %169 = OpLoad %uint %59 Aligned 16 + %170 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %171 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %170 %uint_15 + OpStore %171 %169 Aligned 4 + %172 = OpLoad %uint %61 Aligned 4 + %173 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %174 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %173 %uint_16 + OpStore %174 %172 Aligned 4 + %175 = OpLoad %uint %63 Aligned 8 + %176 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %177 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %176 %uint_17 + OpStore %177 %175 Aligned 4 + %178 = OpLoad %uint %65 Aligned 64 + %179 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %180 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %179 %uint_18 + OpStore %180 %178 Aligned 4 + %181 = OpLoad %uint %67 Aligned 4 + %182 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %183 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %182 %uint_19 + OpStore %183 %181 Aligned 4 + %184 = OpLoad %uint %69 Aligned 8 + %185 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %186 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %185 %uint_20 + OpStore %186 %184 Aligned 4 + %187 = OpLoad %uint %71 Aligned 16 + %188 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %189 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %188 %uint_21 + OpStore %189 %187 Aligned 4 + %190 = OpLoad %uint %73 Aligned 4 + %191 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %192 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %191 %uint_22 + OpStore %192 %190 Aligned 4 + %193 = OpLoad %uint %75 Aligned 8 + %194 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %195 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %194 %uint_23 + OpStore %195 %193 Aligned 4 + %196 = OpLoad %uint %77 Aligned 32 + %197 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %198 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %197 %uint_24 + OpStore %198 %196 Aligned 4 + %199 = OpLoad %uint %79 Aligned 4 + %200 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %201 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %200 %uint_25 + OpStore %201 %199 Aligned 4 + %202 = OpLoad %uint %81 Aligned 8 + %203 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %204 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %203 %uint_26 + OpStore %204 %202 Aligned 4 + %205 = OpLoad %uint %83 Aligned 16 + %206 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %207 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %206 %uint_27 + OpStore %207 %205 Aligned 4 + %208 = OpLoad %uint %85 Aligned 4 + %209 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %210 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %209 %uint_28 + OpStore %210 %208 Aligned 4 + %211 = OpLoad %uint %87 Aligned 8 + %212 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %213 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %212 %uint_29 + OpStore %213 %211 Aligned 4 + %214 = OpLoad %uint %89 Aligned 64 + %215 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %216 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %215 %uint_30 + OpStore %216 %214 Aligned 4 + %217 = OpLoad %uint %91 Aligned 4 + %218 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %219 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %218 %uint_31 + OpStore %219 %217 Aligned 4 + %220 = OpLoad %uint %93 Aligned 8 + %221 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %222 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %221 %uint_32 + OpStore %222 %220 Aligned 4 + %223 = OpLoad %uint %94 Aligned 16 + %224 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %225 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %224 %uint_33 + OpStore %225 %223 Aligned 4 + %226 = OpLoad %uint %96 Aligned 4 + %227 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %228 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %227 %uint_34 + OpStore %228 %226 Aligned 4 + %229 = OpLoad %uint %98 Aligned 8 + %230 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %231 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %230 %uint_35 + OpStore %231 %229 Aligned 4 + %232 = OpLoad %uint %100 Aligned 4 + %233 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %234 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %233 %uint_36 + OpStore %234 %232 Aligned 4 + %235 = OpLoad %uint %102 Aligned 4 + %236 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %237 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %236 %uint_37 + OpStore %237 %235 Aligned 4 + %238 = OpLoad %uint %104 Aligned 4 + %239 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %240 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %239 %uint_38 + OpStore %240 %238 Aligned 4 + %241 = OpLoad %uint %106 Aligned 4 + %242 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %243 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %242 %uint_39 + OpStore %243 %241 Aligned 4 + %244 = OpLoad %uint %108 Aligned 4 + %245 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %246 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %245 %uint_40 + OpStore %246 %244 Aligned 4 + %247 = OpLoad %uint %110 Aligned 4 + %248 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %249 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %248 %uint_41 + OpStore %249 %247 Aligned 4 + %250 = OpLoad %uint %112 Aligned 4 + %251 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %252 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %251 %uint_42 + OpStore %252 %250 Aligned 4 + %253 = OpLoad %uint %114 Aligned 4 + %254 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %255 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %254 %uint_43 + OpStore %255 %253 Aligned 4 + %256 = OpLoad %uint %116 Aligned 4 + %257 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %258 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %257 %uint_44 + OpStore %258 %256 Aligned 4 + %259 = OpLoad %uint %118 Aligned 4 + %260 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %261 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %260 %uint_45 + OpStore %261 %259 Aligned 4 + %262 = OpLoad %uint %120 Aligned 4 + %263 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %264 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %263 %uint_46 + OpStore %264 %262 Aligned 4 + %265 = OpLoad %uint %122 Aligned 4 + %266 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 + %267 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %266 %uint_47 + OpStore %267 %265 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm new file mode 100644 index 0000000000..16552936c0 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm @@ -0,0 +1,94 @@ +; @Input: %21={0, 0, 0, 0} +; @Output: forall (%21[0] == 0 and %21[1] == 22 and %21[2] == 2 and %21[3] == 3) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 60 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %20 "manual_vs_struct" + OpSource OpenCL_C 200000 + OpName %struct_struct1 "struct.struct1" + OpName %manual_vs_struct_s1 "manual_vs_struct.s1" + OpName %struct_struct2 "struct.struct2" + OpName %manual_vs_struct_s2 "manual_vs_struct.s2" + OpDecorate %manual_vs_struct_s2 Alignment 4 + OpDecorate %24 Alignment 4 + OpDecorate %manual_vs_struct_s1 Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %3 = OpUndef %uint + %5 = OpUndef %uchar + %uint_11 = OpConstant %uint 11 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uint_2 = OpConstant %uint 2 + %uchar_3 = OpConstant %uchar 3 + %uint_22 = OpConstant %uint 22 + %uint_33 = OpConstant %uint 33 + %uint_3 = OpConstant %uint 3 +%_arr_uchar_uint_11 = OpTypeArray %uchar %uint_11 +%struct_struct1 = OpTypeStruct %uint %uchar %_arr_uchar_uint_11 +%_ptr_Workgroup_struct_struct1 = OpTypePointer Workgroup %struct_struct1 +%struct_struct2 = OpTypeStruct %uchar %uint +%_ptr_Workgroup_struct_struct2 = OpTypePointer Workgroup %struct_struct2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %19 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar +%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Workgroup_uchar = OpTypePointer Workgroup %uchar +%_ptr_Generic_uint = OpTypePointer Generic %uint + %8 = OpUndef %_arr_uchar_uint_11 + %10 = OpConstantComposite %struct_struct1 %3 %5 %8 +%manual_vs_struct_s1 = OpVariable %_ptr_Workgroup_struct_struct1 Workgroup %10 + %14 = OpConstantComposite %struct_struct2 %5 %3 +%manual_vs_struct_s2 = OpVariable %_ptr_Workgroup_struct_struct2 Workgroup %14 + %20 = OpFunction %void DontInline %19 + %21 = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %22 = OpLabel + %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function + OpStore %24 %21 Aligned 4 + %27 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s1 %uint_0 %uint_0 + OpStore %27 %uint_0 Aligned 16 + %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %manual_vs_struct_s1 %uint_0 %uint_1 + OpStore %30 %uchar_1 Aligned 4 + %32 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s2 %uint_0 %uint_1 + OpStore %32 %uint_2 Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %manual_vs_struct_s2 %uint_0 %uint_0 + OpStore %34 %uchar_3 Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s1 %uint_0 %uint_0 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %36 %uint_1 + %39 = OpPtrCastToGeneric %_ptr_Generic_uint %37 + OpStore %39 %uint_22 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s2 %uint_0 %uint_1 + %42 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %41 %uint_1 + %43 = OpPtrCastToGeneric %_ptr_Generic_uint %42 + OpStore %43 %uint_33 Aligned 4 + %45 = OpLoad %uint %27 Aligned 16 + %46 = OpUConvert %uchar %45 + %47 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 + %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %47 %uint_0 + OpStore %48 %46 Aligned 1 + %49 = OpLoad %uchar %30 Aligned 4 + %50 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %50 %uint_1 + OpStore %51 %49 Aligned 1 + %52 = OpLoad %uint %32 Aligned 4 + %53 = OpUConvert %uchar %52 + %54 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %54 %uint_2 + OpStore %55 %53 Aligned 1 + %56 = OpLoad %uchar %34 Aligned 4 + %57 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 + %59 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %57 %uint_3 + OpStore %59 %56 Aligned 1 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm new file mode 100644 index 0000000000..71a7ae5d7f --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm @@ -0,0 +1,169 @@ +; @Input: %20={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%20[0] == 0 and %20[1] == 1 and %20[2] == 2 and %20[3] == 4 and %20[4] == 5 and %20[5] == 6 and %20[6] == 10 and %20[7] == 11 and %20[8] == 12 and %20[9] == 13 and %20[10] == 14 and %20[11] == 15) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 120 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %19 "test" + OpSource OpenCL_C 200000 + OpName %test_unaligned "test.unaligned" + OpName %struct_aligned_struct "struct.aligned_struct" + OpName %aligned "aligned" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %test_unaligned Alignment 4 + OpDecorate %24 Alignment 4 + OpDecorate %26 Alignment 4 + OpDecorate %aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_12 = OpConstant %uint 12 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2 +%_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 = OpTypePointer Workgroup %_arr__arr_uint_uint_3_uint_2 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_struct = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 +%_ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer CrossWorkgroup %struct_aligned_struct + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %18 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_struct +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_struct +%_ptr_CrossWorkgroup__arr_uint_uint_3 = OpTypePointer CrossWorkgroup %_arr_uint_uint_3 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 Workgroup + %13 = OpConstantNull %struct_aligned_struct + %aligned = OpVariable %_ptr_CrossWorkgroup_struct_aligned_struct CrossWorkgroup %13 + %19 = OpFunction %void DontInline %18 + %20 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %21 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_struct + %22 = OpLabel + %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %26 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct Function + OpStore %24 %20 Aligned 4 + OpStore %26 %21 Aligned 4 + %27 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %27 %uint_0 %uint_0 + %31 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %30 %uint_0 %uint_0 + OpStore %31 %uint_0 Aligned 16 + %32 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %32 %uint_0 %uint_0 + %35 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %33 %uint_0 %uint_1 + OpStore %35 %uint_1 Aligned 4 + %36 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %36 %uint_0 %uint_0 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %37 %uint_0 %uint_2 + OpStore %38 %uint_2 Aligned 8 + %39 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %39 %uint_0 %uint_2 + %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %40 %uint_0 %uint_0 + OpStore %41 %uint_4 Aligned 16 + %42 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %42 %uint_0 %uint_2 + %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %43 %uint_0 %uint_1 + OpStore %44 %uint_5 Aligned 4 + %46 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %46 %uint_0 %uint_2 + %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %47 %uint_0 %uint_2 + OpStore %48 %uint_6 Aligned 8 + %51 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %51 %uint_10 Aligned 4 + %53 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %53 %uint_11 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 + OpStore %55 %uint_12 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %57 %uint_13 Aligned 4 + %59 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %59 %uint_14 Aligned 4 + %61 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 + OpStore %61 %uint_15 Aligned 4 + %63 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %64 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %63 %uint_0 %uint_0 + %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %64 %uint_0 %uint_0 + %66 = OpLoad %uint %65 Aligned 16 + %67 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %68 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %67 %uint_0 + OpStore %68 %66 Aligned 4 + %69 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %70 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %69 %uint_0 %uint_0 + %71 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %70 %uint_0 %uint_1 + %72 = OpLoad %uint %71 Aligned 4 + %73 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %74 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %73 %uint_1 + OpStore %74 %72 Aligned 4 + %75 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %76 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %75 %uint_0 %uint_0 + %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %76 %uint_0 %uint_2 + %78 = OpLoad %uint %77 Aligned 8 + %79 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %80 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %79 %uint_2 + OpStore %80 %78 Aligned 4 + %81 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %82 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %81 %uint_0 %uint_2 + %83 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %82 %uint_0 %uint_0 + %84 = OpLoad %uint %83 Aligned 16 + %85 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %86 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %85 %uint_3 + OpStore %86 %84 Aligned 4 + %87 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %88 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %87 %uint_0 %uint_2 + %89 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %88 %uint_0 %uint_1 + %90 = OpLoad %uint %89 Aligned 4 + %91 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %92 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %91 %uint_4 + OpStore %92 %90 Aligned 4 + %93 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 + %94 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %93 %uint_0 %uint_2 + %95 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %94 %uint_0 %uint_2 + %96 = OpLoad %uint %95 Aligned 8 + %97 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %98 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %97 %uint_5 + OpStore %98 %96 Aligned 4 + %99 = OpLoad %uint %51 Aligned 4 + %100 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %101 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %100 %uint_6 + OpStore %101 %99 Aligned 4 + %102 = OpLoad %uint %53 Aligned 4 + %103 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %105 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %103 %uint_7 + OpStore %105 %102 Aligned 4 + %106 = OpLoad %uint %55 Aligned 4 + %107 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %109 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %107 %uint_8 + OpStore %109 %106 Aligned 4 + %110 = OpLoad %uint %57 Aligned 4 + %111 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %113 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %111 %uint_9 + OpStore %113 %110 Aligned 4 + %114 = OpLoad %uint %59 Aligned 4 + %115 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %116 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %115 %uint_10 + OpStore %116 %114 Aligned 4 + %117 = OpLoad %uint %61 Aligned 4 + %118 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 + %119 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %118 %uint_11 + OpStore %119 %117 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm new file mode 100644 index 0000000000..56d99a59ce --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm @@ -0,0 +1,119 @@ +; @Input: %18={0, 0, 0, 0} +; @Input: %19={{0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}} +; @Input: %20={{0, 0}} +; @Output: forall (%18[0] == 0 and %18[1] == 22 and %18[2] == 2 and %18[3] == 3) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 76 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %17 "manual_vs_struct" + OpSource OpenCL_C 200000 + OpName %struct_struct1 "struct.struct1" + OpName %s1 "s1" + OpName %struct_struct2 "struct.struct2" + OpName %s2 "s2" + OpDecorate %s1 LinkageAttributes "s1" Export + OpDecorate %s2 LinkageAttributes "s2" Export + OpDecorate %s2 Alignment 4 + OpDecorate %23 Alignment 4 + OpDecorate %25 Alignment 4 + OpDecorate %27 Alignment 4 + OpDecorate %s1 Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_11 = OpConstant %uint 11 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uint_2 = OpConstant %uint 2 + %uchar_3 = OpConstant %uchar 3 + %uint_22 = OpConstant %uint 22 + %uint_33 = OpConstant %uint 33 + %uint_3 = OpConstant %uint 3 +%_arr_uchar_uint_11 = OpTypeArray %uchar %uint_11 +%struct_struct1 = OpTypeStruct %uint %uchar %_arr_uchar_uint_11 +%_ptr_CrossWorkgroup_struct_struct1 = OpTypePointer CrossWorkgroup %struct_struct1 +%struct_struct2 = OpTypeStruct %uchar %uint +%_ptr_CrossWorkgroup_struct_struct2 = OpTypePointer CrossWorkgroup %struct_struct2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_struct_struct1 %_ptr_CrossWorkgroup_struct_struct2 +%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar +%_ptr_Function__ptr_CrossWorkgroup_struct_struct1 = OpTypePointer Function %_ptr_CrossWorkgroup_struct_struct1 +%_ptr_Function__ptr_CrossWorkgroup_struct_struct2 = OpTypePointer Function %_ptr_CrossWorkgroup_struct_struct2 +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %7 = OpConstantNull %struct_struct1 + %s1 = OpVariable %_ptr_CrossWorkgroup_struct_struct1 CrossWorkgroup %7 + %11 = OpConstantNull %struct_struct2 + %s2 = OpVariable %_ptr_CrossWorkgroup_struct_struct2 CrossWorkgroup %11 + %17 = OpFunction %void DontInline %16 + %18 = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %19 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_struct1 + %20 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_struct2 + %21 = OpLabel + %23 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function + %25 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_struct1 Function + %27 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_struct2 Function + OpStore %23 %18 Aligned 4 + OpStore %25 %19 Aligned 4 + OpStore %27 %20 Aligned 4 + %28 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 + %31 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %28 %uint_0 %uint_0 + OpStore %31 %uint_0 Aligned 16 + %32 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %32 %uint_0 %uint_1 + OpStore %34 %uchar_1 Aligned 4 + %36 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 + %37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %36 %uint_0 %uint_1 + OpStore %37 %uint_2 Aligned 4 + %39 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %39 %uint_0 %uint_0 + OpStore %40 %uchar_3 Aligned 4 + %42 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %42 %uint_0 %uint_0 + %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %43 %uint_1 + %46 = OpPtrCastToGeneric %_ptr_Generic_uint %44 + OpStore %46 %uint_22 Aligned 4 + %48 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 + %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %48 %uint_0 %uint_1 + %50 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %49 %uint_1 + %51 = OpPtrCastToGeneric %_ptr_Generic_uint %50 + OpStore %51 %uint_33 Aligned 4 + %53 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 + %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %53 %uint_0 %uint_0 + %55 = OpLoad %uint %54 Aligned 16 + %56 = OpUConvert %uchar %55 + %57 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 + %58 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %57 %uint_0 + OpStore %58 %56 Aligned 1 + %59 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 + %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %59 %uint_0 %uint_1 + %61 = OpLoad %uchar %60 Aligned 4 + %62 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 + %63 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %62 %uint_1 + OpStore %63 %61 Aligned 1 + %64 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 + %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %64 %uint_0 %uint_1 + %66 = OpLoad %uint %65 Aligned 4 + %67 = OpUConvert %uchar %66 + %68 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 + %69 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %68 %uint_2 + OpStore %69 %67 Aligned 1 + %70 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 + %71 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %70 %uint_0 %uint_0 + %72 = OpLoad %uchar %71 Aligned 4 + %73 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 + %75 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %73 %uint_3 + OpStore %75 %72 Aligned 1 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm new file mode 100644 index 0000000000..aa34b49e44 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm @@ -0,0 +1,88 @@ +; @Input: %18={0, 0, 0, 0} +; @Input: %19={{0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}} +; @Output: forall (%18[0] == 1 and %18[1] == 2 and %18[2] == 3 and %18[3] == 4) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 53 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %17 "test" + OpSource OpenCL_C 200000 + OpName %test_unaligned "test.unaligned" + OpName %struct_aligned_struct "struct.aligned_struct" + OpName %aligned "aligned" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %test_unaligned Alignment 4 + OpDecorate %22 Alignment 4 + OpDecorate %24 Alignment 4 + OpDecorate %aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_2 = OpConstant %uint 2 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_4 = OpConstant %uint 4 + %uint_3 = OpConstant %uint 3 +%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 +%_ptr_Workgroup__arr_uint_uint_2 = OpTypePointer Workgroup %_arr_uint_uint_2 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_struct = OpTypeStruct %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 +%_ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer CrossWorkgroup %struct_aligned_struct + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_struct +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_struct +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%test_unaligned = OpVariable %_ptr_Workgroup__arr_uint_uint_2 Workgroup + %11 = OpConstantNull %struct_aligned_struct + %aligned = OpVariable %_ptr_CrossWorkgroup_struct_aligned_struct CrossWorkgroup %11 + %17 = OpFunction %void DontInline %16 + %18 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %19 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_struct + %20 = OpLabel + %22 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct Function + OpStore %22 %18 Aligned 4 + OpStore %24 %19 Aligned 4 + %25 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %25 %uint_0 %uint_0 + OpStore %27 %uint_1 Aligned 16 + %29 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %29 %uint_0 %uint_0 + %32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %30 %uint_4 + OpStore %32 %uint_2 Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 + OpStore %34 %uint_3 Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 + OpStore %36 %uint_4 Aligned 4 + %37 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %37 %uint_0 %uint_0 + %39 = OpLoad %uint %38 Aligned 16 + %40 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %40 %uint_0 + OpStore %41 %39 Aligned 4 + %42 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %42 %uint_0 %uint_2 + %44 = OpLoad %uint %43 Aligned 16 + %45 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 + %46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %45 %uint_1 + OpStore %46 %44 Aligned 4 + %47 = OpLoad %uint %34 Aligned 4 + %48 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 + %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %48 %uint_2 + OpStore %49 %47 Aligned 4 + %50 = OpLoad %uint %36 Aligned 4 + %51 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 + %52 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %51 %uint_3 + OpStore %52 %50 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm new file mode 100644 index 0000000000..a36802f06f --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm @@ -0,0 +1,119 @@ +; @Input: %14={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %15={{{{0, 0, 0}, {0, 0, 0}}}} +; @Output: forall (%14[0] == 0 and %14[1] == 1 and %14[2] == 2 and %14[3] == 3 and %14[4] == 4 and %14[5] == 5 and %14[6] == 0 and %14[7] == 0) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 80 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %13 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_struct "struct.aligned_struct" + OpName %aligned "aligned" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %22 Alignment 4 + OpDecorate %24 Alignment 4 + OpDecorate %26 Alignment 4 + OpDecorate %aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_8 = OpConstant %uint 8 + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2 +%struct_aligned_struct = OpTypeStruct %_arr_v3uint_uint_2 +%_ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer CrossWorkgroup %struct_aligned_struct + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %12 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_struct +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_struct +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_CrossWorkgroup__arr_v3uint_uint_2 = OpTypePointer CrossWorkgroup %_arr_v3uint_uint_2 +%_ptr_CrossWorkgroup_v3uint = OpTypePointer CrossWorkgroup %v3uint + %bool = OpTypeBool +%_ptr_Generic_uint = OpTypePointer Generic %uint + %7 = OpConstantNull %struct_aligned_struct + %aligned = OpVariable %_ptr_CrossWorkgroup_struct_aligned_struct CrossWorkgroup %7 + %13 = OpFunction %void DontInline %12 + %14 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_struct + %16 = OpLabel + %22 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct Function + %26 = OpVariable %_ptr_Function_uint Function + OpStore %22 %14 Aligned 4 + OpStore %24 %15 Aligned 4 + %27 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %27 %uint_0 %uint_0 + %32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %30 %uint_0 %uint_0 + %33 = OpLoad %v3uint %32 Aligned 16 + %34 = OpCompositeInsert %v3uint %uint_0 %33 0 + OpStore %32 %34 Aligned 16 + %35 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %35 %uint_0 %uint_0 + %37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %36 %uint_0 %uint_0 + %38 = OpLoad %v3uint %37 Aligned 16 + %40 = OpCompositeInsert %v3uint %uint_1 %38 1 + OpStore %37 %40 Aligned 16 + %41 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %42 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %41 %uint_0 %uint_0 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %42 %uint_0 %uint_0 + %44 = OpLoad %v3uint %43 Aligned 16 + %45 = OpCompositeInsert %v3uint %uint_2 %44 2 + OpStore %43 %45 Aligned 16 + %46 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %46 %uint_0 %uint_0 + %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %47 %uint_0 %uint_1 + %49 = OpLoad %v3uint %48 Aligned 16 + %51 = OpCompositeInsert %v3uint %uint_3 %49 0 + OpStore %48 %51 Aligned 16 + %52 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %53 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %52 %uint_0 %uint_0 + %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %53 %uint_0 %uint_1 + %55 = OpLoad %v3uint %54 Aligned 16 + %57 = OpCompositeInsert %v3uint %uint_4 %55 1 + OpStore %54 %57 Aligned 16 + %58 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %59 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %58 %uint_0 %uint_0 + %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %59 %uint_0 %uint_1 + %61 = OpLoad %v3uint %60 Aligned 16 + %63 = OpCompositeInsert %v3uint %uint_5 %61 2 + OpStore %60 %63 Aligned 16 + OpStore %26 %uint_0 Aligned 4 + OpBranch %17 + %17 = OpLabel + %64 = OpLoad %uint %26 Aligned 4 + %67 = OpSLessThan %bool %64 %uint_8 + OpBranchConditional %67 %18 %20 + %18 = OpLabel + %68 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 + %69 = OpBitcast %_ptr_CrossWorkgroup_uint %68 + %71 = OpPtrCastToGeneric %_ptr_Generic_uint %69 + %72 = OpLoad %uint %26 Aligned 4 + %73 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %71 %72 + %74 = OpLoad %uint %73 Aligned 4 + %75 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 + %76 = OpLoad %uint %26 Aligned 4 + %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %75 %76 + OpStore %77 %74 Aligned 4 + OpBranch %19 + %19 = OpLabel + %78 = OpLoad %uint %26 Aligned 4 + %79 = OpIAdd %uint %78 %uint_1 + OpStore %26 %79 Aligned 4 + OpBranch %17 + %20 = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm new file mode 100644 index 0000000000..9d4ee6109c --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm @@ -0,0 +1,70 @@ +; @Input: %output = {0, 0} +; @Output: forall (%output[0] == 5 and %output[1] == 11) +; @Config: 1, 1, 1 +; SPIR-V +; Version: 1.0 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %main "main" + OpSource OpenCL_C 200000 + + OpDecorate %aligned_data Alignment 16 + + %void = OpTypeVoid + %func = OpTypeFunction %void + %uint = OpTypeInt 32 0 + + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + + %v3uint = OpTypeVector %uint 3 +%_arr2_v3uint = OpTypeArray %v3uint %uint_2 +%output_type = OpTypeRuntimeArray %uint + + %ptr_uint = OpTypePointer CrossWorkgroup %uint +%_ptr_CrossWorkgroup__arr2_v3uint = OpTypePointer CrossWorkgroup %_arr2_v3uint +%_ptr_CrossWorkgroup_v3uint = OpTypePointer CrossWorkgroup %v3uint + %ptr_output = OpTypePointer CrossWorkgroup %output_type + + %arr1 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2 + %arr2 = OpConstantComposite %v3uint %uint_3 %uint_4 %uint_5 + %arr3 = OpConstantComposite %v3uint %uint_6 %uint_7 %uint_8 + %arr4 = OpConstantComposite %v3uint %uint_9 %uint_10 %uint_11 + %value1 = OpConstantComposite %_arr2_v3uint %arr1 %arr2 + %value2 = OpConstantComposite %_arr2_v3uint %arr3 %arr4 + +%aligned_data = OpVariable %_ptr_CrossWorkgroup__arr2_v3uint CrossWorkgroup %value1 +%normal_data = OpVariable %_ptr_CrossWorkgroup__arr2_v3uint CrossWorkgroup %value2 + %output = OpVariable %ptr_output CrossWorkgroup + + %main = OpFunction %void None %func + %label = OpLabel + + %output_0 = OpAccessChain %ptr_uint %output %uint_0 + %output_1 = OpAccessChain %ptr_uint %output %uint_1 + + %aligned_12 = OpInBoundsAccessChain %ptr_uint %aligned_data %uint_1 %uint_2 + %normal_12 = OpInBoundsAccessChain %ptr_uint %normal_data %uint_1 %uint_2 + + %v0 = OpLoad %uint %aligned_12 + %v1 = OpLoad %uint %normal_12 + + OpStore %output_0 %v0 + OpStore %output_1 %v1 + + OpReturn + OpFunctionEnd From add4cc0e7f2df78157eb079df15b57ae7312acbb Mon Sep 17 00:00:00 2001 From: Natalia Gavrilenko Date: Thu, 22 May 2025 17:46:32 +0200 Subject: [PATCH 10/10] SPIR-V Alignment and ArrayStride Signed-off-by: Natalia Gavrilenko --- .../alignment/alignment1-array-global.cl | 32 ++ .../alignment/alignment1-array-local.cl | 36 ++ .../alignment/alignment1-array-pointer.cl | 33 ++ .../alignment/alignment1-struct-global.cl | 41 ++ .../alignment/alignment1-struct-local.cl | 45 ++ .../alignment/alignment1-struct-pointer.cl | 42 ++ benchmarks/opencl/alignment/alignment1.cl | 21 - benchmarks/opencl/alignment/alignment10.cl | 26 -- .../alignment/alignment2-struct-global.cl | 53 +++ .../alignment/alignment2-struct-local.cl | 57 +++ .../alignment/alignment2-struct-pointer.cl | 54 +++ benchmarks/opencl/alignment/alignment2.cl | 24 -- .../alignment/alignment3-struct-global.cl | 33 ++ .../alignment/alignment3-struct-local.cl | 37 ++ .../alignment/alignment3-struct-pointer.cl | 34 ++ benchmarks/opencl/alignment/alignment3.cl | 42 -- .../alignment/alignment4-struct-global.cl | 47 +++ .../alignment/alignment4-struct-local.cl | 51 +++ .../alignment/alignment4-struct-pointer.cl | 48 +++ benchmarks/opencl/alignment/alignment4.cl | 116 ------ .../alignment/alignment5-struct-global.cl | 47 +++ .../alignment/alignment5-struct-local.cl | 51 +++ .../alignment/alignment5-struct-pointer.cl | 48 +++ benchmarks/opencl/alignment/alignment5.cl | 32 -- benchmarks/opencl/alignment/alignment6.cl | 43 -- benchmarks/opencl/alignment/alignment7.cl | 31 -- benchmarks/opencl/alignment/alignment8.cl | 25 -- benchmarks/opencl/alignment/alignment9.cl | 25 -- .../expression/ExpressionFactory.java | 46 ++- .../dartagnan/expression/misc/GEPExpr.java | 10 +- .../dartagnan/expression/type/ArrayType.java | 45 +- .../expression/type/ScopedPointerType.java | 20 +- .../expression/type/TypeFactory.java | 71 ++-- .../dartagnan/expression/type/TypeOffset.java | 4 + .../parsers/program/visitors/VisitorLlvm.java | 4 +- .../visitors/spirv/VisitorOpsAnnotation.java | 17 +- .../visitors/spirv/VisitorOpsComposite.java | 16 +- .../visitors/spirv/VisitorOpsConstant.java | 4 +- .../visitors/spirv/VisitorOpsConversion.java | 107 +++-- .../visitors/spirv/VisitorOpsFunction.java | 23 +- .../visitors/spirv/VisitorOpsMemory.java | 44 +- .../visitors/spirv/VisitorOpsType.java | 38 +- .../spirv/builders/DecorationsBuilder.java | 2 +- .../spirv/builders/ProgramBuilder.java | 52 +-- .../{Alignment.java => ArrayStride.java} | 6 +- .../visitors/spirv/decorations/BuiltIn.java | 16 +- .../VisitorExtensionOpenClStd.java | 4 +- .../visitors/spirv/helpers/HelperInputs.java | 38 +- .../visitors/spirv/helpers/HelperTypes.java | 86 +--- .../com/dat3m/dartagnan/program/Program.java | 2 +- .../dartagnan/program/memory/Memory.java | 15 +- .../program/processing/GEPToAddition.java | 22 +- .../transformers/MemoryTransformer.java | 13 +- .../spirv/VisitorOpsAnnotationTest.java | 15 - .../spirv/VisitorOpsCompositeTest.java | 5 +- .../spirv/VisitorOpsConstantTest.java | 23 +- .../spirv/VisitorOpsConversionTest.java | 299 ++++++++++++-- .../spirv/VisitorOpsFunctionTest.java | 9 +- .../visitors/spirv/VisitorOpsMemoryTest.java | 81 ++-- .../visitors/spirv/VisitorOpsTypeTest.java | 264 ++++++++++-- .../spirv/helpers/HelperInputsTest.java | 112 ++++- .../spirv/mocks/MockProgramBuilder.java | 17 +- .../dartagnan/spirv/header/AbstractTest.java | 2 +- .../opencl/alignment/SpirvAssertionsTest.java | 100 +++++ .../opencl/basic/SpirvAssertionsTest.java | 11 - .../vulkan/alignment/SpirvAssertionsTest.java | 110 +++++ .../spirv/vulkan/basic/SpirvChecksTest.java | 5 +- .../alignment/alignment1-array-global.spvasm | 156 +++++++ .../alignment/alignment1-array-local.spvasm | 152 +++++++ .../alignment/alignment1-array-pointer.spvasm | 198 +++++++++ .../alignment/alignment1-struct-global.spvasm | 146 +++++++ .../alignment/alignment1-struct-local.spvasm | 142 +++++++ .../alignment1-struct-pointer.spvasm | 197 +++++++++ .../alignment/alignment2-struct-global.spvasm | 170 ++++++++ .../alignment/alignment2-struct-local.spvasm | 166 ++++++++ .../alignment2-struct-pointer.spvasm | 253 ++++++++++++ .../alignment/alignment3-struct-global.spvasm | 135 ++++++ .../alignment/alignment3-struct-local.spvasm | 131 ++++++ .../alignment3-struct-pointer.spvasm | 170 ++++++++ .../alignment/alignment4-struct-global.spvasm | 160 ++++++++ .../alignment/alignment4-struct-local.spvasm | 156 +++++++ .../alignment4-struct-pointer.spvasm | 227 ++++++++++ .../alignment/alignment5-struct-global.spvasm | 174 ++++++++ .../alignment/alignment5-struct-local.spvasm | 173 ++++++++ .../alignment5-struct-pointer.spvasm | 293 +++++++++++++ .../spirv/opencl/basic/alignment1.spvasm | 91 ---- .../spirv/opencl/basic/alignment10.spvasm | 74 ---- .../spirv/opencl/basic/alignment2.spvasm | 77 ---- .../spirv/opencl/basic/alignment3.spvasm | 134 ------ .../spirv/opencl/basic/alignment4.spvasm | 387 ------------------ .../spirv/opencl/basic/alignment5.spvasm | 94 ----- .../spirv/opencl/basic/alignment6.spvasm | 169 -------- .../spirv/opencl/basic/alignment7.spvasm | 119 ------ .../spirv/opencl/basic/alignment8.spvasm | 88 ---- .../spirv/opencl/basic/alignment9.spvasm | 119 ------ .../spirv/opencl/basic/vector-aligned.spvasm | 70 ---- .../alignment/alignment1-array-local.spvasm | 141 +++++++ .../alignment/alignment1-array-pointer.spvasm | 163 ++++++++ .../alignment/alignment1-struct-local.spvasm | 140 +++++++ .../alignment1-struct-pointer.spvasm | 137 +++++++ .../alignment/alignment2-struct-local.spvasm | 164 ++++++++ .../alignment2-struct-pointer.spvasm | 161 ++++++++ .../alignment/alignment3-struct-local.spvasm | 129 ++++++ .../alignment3-struct-pointer.spvasm | 126 ++++++ .../alignment/alignment4-struct-local.spvasm | 154 +++++++ .../alignment4-struct-pointer.spvasm | 152 +++++++ .../alignment/alignment5-struct-local.spvasm | 195 +++++++++ .../alignment5-struct-pointer.spvasm | 177 ++++++++ .../array-stride-array-initializer.spvasm | 145 +++++++ .../alignment/array-stride-array-input.spvasm | 138 +++++++ ...array-stride-array-overwrite-scalar.spvasm | 162 ++++++++ ...array-stride-array-overwrite-vector.spvasm | 148 +++++++ .../array-stride-runtime-array-input.spvasm | 138 +++++++ ...ride-runtime-array-overwrite-scalar.spvasm | 162 ++++++++ ...ride-runtime-array-overwrite-vector.spvasm | 148 +++++++ ...inter-stride-array-overwrite-scalar.spvasm | 166 ++++++++ ...inter-stride-array-overwrite-vector.spvasm | 152 +++++++ ...e-scalar-overwrite-result-no-stride.spvasm | 141 +++++++ ...ride-scalar-overwrite-result-stride.spvasm | 141 +++++++ ...e-vector-overwrite-result-no-stride.spvasm | 136 ++++++ ...ride-vector-overwrite-result-stride.spvasm | 136 ++++++ .../vulkan/basic/composite-extract.spvasm | 4 +- .../vulkan/basic/composite-initial.spvasm | 16 +- .../vulkan/basic/composite-insert.spvasm | 16 +- 124 files changed, 8943 insertions(+), 2398 deletions(-) create mode 100644 benchmarks/opencl/alignment/alignment1-array-global.cl create mode 100644 benchmarks/opencl/alignment/alignment1-array-local.cl create mode 100644 benchmarks/opencl/alignment/alignment1-array-pointer.cl create mode 100644 benchmarks/opencl/alignment/alignment1-struct-global.cl create mode 100644 benchmarks/opencl/alignment/alignment1-struct-local.cl create mode 100644 benchmarks/opencl/alignment/alignment1-struct-pointer.cl delete mode 100644 benchmarks/opencl/alignment/alignment1.cl delete mode 100644 benchmarks/opencl/alignment/alignment10.cl create mode 100644 benchmarks/opencl/alignment/alignment2-struct-global.cl create mode 100644 benchmarks/opencl/alignment/alignment2-struct-local.cl create mode 100644 benchmarks/opencl/alignment/alignment2-struct-pointer.cl delete mode 100644 benchmarks/opencl/alignment/alignment2.cl create mode 100644 benchmarks/opencl/alignment/alignment3-struct-global.cl create mode 100644 benchmarks/opencl/alignment/alignment3-struct-local.cl create mode 100644 benchmarks/opencl/alignment/alignment3-struct-pointer.cl delete mode 100644 benchmarks/opencl/alignment/alignment3.cl create mode 100644 benchmarks/opencl/alignment/alignment4-struct-global.cl create mode 100644 benchmarks/opencl/alignment/alignment4-struct-local.cl create mode 100644 benchmarks/opencl/alignment/alignment4-struct-pointer.cl delete mode 100644 benchmarks/opencl/alignment/alignment4.cl create mode 100644 benchmarks/opencl/alignment/alignment5-struct-global.cl create mode 100644 benchmarks/opencl/alignment/alignment5-struct-local.cl create mode 100644 benchmarks/opencl/alignment/alignment5-struct-pointer.cl delete mode 100644 benchmarks/opencl/alignment/alignment5.cl delete mode 100644 benchmarks/opencl/alignment/alignment6.cl delete mode 100644 benchmarks/opencl/alignment/alignment7.cl delete mode 100644 benchmarks/opencl/alignment/alignment8.cl delete mode 100644 benchmarks/opencl/alignment/alignment9.cl rename dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/{Alignment.java => ArrayStride.java} (80%) create mode 100644 dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/alignment/SpirvAssertionsTest.java create mode 100644 dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/alignment/SpirvAssertionsTest.java create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-global.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-global.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-global.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-global.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-global.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-global.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-pointer.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm delete mode 100644 dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-local.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-pointer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-initializer.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-input.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-scalar.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-vector.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-input.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-scalar.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-vector.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-scalar.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-vector.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-no-stride.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-stride.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-no-stride.spvasm create mode 100644 dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-stride.spvasm diff --git a/benchmarks/opencl/alignment/alignment1-array-global.cl b/benchmarks/opencl/alignment/alignment1-array-global.cl new file mode 100644 index 0000000000..9fd9072559 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1-array-global.cl @@ -0,0 +1,32 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment1-array-global.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1-array-global.spvasm + +typedef int aligned_t __attribute__((vector_size(3 * sizeof(int)))); +typedef int unaligned_t[3]; + +global static aligned_t aligned[3]; +global static unaligned_t unaligned[3]; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + aligned[0][0] = 0; + aligned[0][1] = 1; + aligned[0][2] = 2; + + aligned[1][0] = 3; + aligned[1][1] = 4; + aligned[1][2] = 5; + + unaligned[0][0] = 6; + unaligned[0][1] = 7; + unaligned[0][2] = 8; + + unaligned[1][0] = 9; + unaligned[1][1] = 10; + unaligned[1][2] = 11; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment1-array-local.cl b/benchmarks/opencl/alignment/alignment1-array-local.cl new file mode 100644 index 0000000000..2db2acb2be --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1-array-local.cl @@ -0,0 +1,36 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment1-array-local.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1-array-local.spvasm + +// clspv -O0 alignment1-array-local.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment1-array-local.spvasm + +typedef int aligned_t __attribute__((vector_size(3 * sizeof(int)))); +typedef int unaligned_t[3]; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + local aligned_t aligned[3]; + local unaligned_t unaligned[3]; + + aligned[0][0] = 0; + aligned[0][1] = 1; + aligned[0][2] = 2; + + aligned[1][0] = 3; + aligned[1][1] = 4; + aligned[1][2] = 5; + + unaligned[0][0] = 6; + unaligned[0][1] = 7; + unaligned[0][2] = 8; + + unaligned[1][0] = 9; + unaligned[1][1] = 10; + unaligned[1][2] = 11; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment1-array-pointer.cl b/benchmarks/opencl/alignment/alignment1-array-pointer.cl new file mode 100644 index 0000000000..b78213f356 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1-array-pointer.cl @@ -0,0 +1,33 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment1-array-pointer.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1-array-pointer.spvasm + +// clspv -O0 alignment1-array-pointer.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment1-array-pointer.spvasm + +typedef int aligned_t __attribute__((vector_size(3 * sizeof(int)))); +typedef int unaligned_t[3] __attribute__((aligned (4))); + +__kernel void test(global aligned_t* aligned, global unaligned_t* unaligned, global int *r_aligned, global int* r_unaligned) { + aligned[0][0] = 0; + aligned[0][1] = 1; + aligned[0][2] = 2; + + aligned[1][0] = 3; + aligned[1][1] = 4; + aligned[1][2] = 5; + + unaligned[0][0] = 6; + unaligned[0][1] = 7; + unaligned[0][2] = 8; + + unaligned[1][0] = 9; + unaligned[1][1] = 10; + unaligned[1][2] = 11; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment1-struct-global.cl b/benchmarks/opencl/alignment/alignment1-struct-global.cl new file mode 100644 index 0000000000..6497aab599 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1-struct-global.cl @@ -0,0 +1,41 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment1-struct-global.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1-struct-global.spvasm + +typedef struct __attribute__ ((aligned (16))) { + int x; + int y; + int z; +} aligned_t; + +typedef struct { + int x; + int y; + int z; +} unaligned_t; + +global static aligned_t aligned[3]; +global static unaligned_t unaligned[3]; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + aligned[0].x = 0; + aligned[0].y = 1; + aligned[0].z = 2; + + aligned[1].x = 3; + aligned[1].y = 4; + aligned[1].z = 5; + + unaligned[0].x = 6; + unaligned[0].y = 7; + unaligned[0].z = 8; + + unaligned[1].x = 9; + unaligned[1].y = 10; + unaligned[1].z = 11; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment1-struct-local.cl b/benchmarks/opencl/alignment/alignment1-struct-local.cl new file mode 100644 index 0000000000..98435ce93a --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1-struct-local.cl @@ -0,0 +1,45 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment1-struct-local.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1-struct-local.spvasm + +// clspv -O0 alignment1-struct-local.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment1-struct-local.spvasm + +typedef struct __attribute__ ((aligned (16))) { + int x; + int y; + int z; +} aligned_t; + +typedef struct { + int x; + int y; + int z; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + local aligned_t aligned[3]; + local unaligned_t unaligned[3]; + + aligned[0].x = 0; + aligned[0].y = 1; + aligned[0].z = 2; + + aligned[1].x = 3; + aligned[1].y = 4; + aligned[1].z = 5; + + unaligned[0].x = 6; + unaligned[0].y = 7; + unaligned[0].z = 8; + + unaligned[1].x = 9; + unaligned[1].y = 10; + unaligned[1].z = 11; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment1-struct-pointer.cl b/benchmarks/opencl/alignment/alignment1-struct-pointer.cl new file mode 100644 index 0000000000..f49ef8afd6 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment1-struct-pointer.cl @@ -0,0 +1,42 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment1-struct-pointer.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment1-struct-pointer.spvasm + +// clspv -O0 alignment1-struct-pointer.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment1-struct-pointer.spvasm + +typedef struct __attribute__ ((aligned (16))) { + int x; + int y; + int z; +} aligned_t; + +typedef struct { + int x; + int y; + int z; +} unaligned_t; + +__kernel void test(global aligned_t* aligned, global unaligned_t* unaligned, global int *r_aligned, global int* r_unaligned) { + aligned[0].x = 0; + aligned[0].y = 1; + aligned[0].z = 2; + + aligned[1].x = 3; + aligned[1].y = 4; + aligned[1].z = 5; + + unaligned[0].x = 6; + unaligned[0].y = 7; + unaligned[0].z = 8; + + unaligned[1].x = 9; + unaligned[1].y = 10; + unaligned[1].z = 11; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment1.cl b/benchmarks/opencl/alignment/alignment1.cl deleted file mode 100644 index 4718737f92..0000000000 --- a/benchmarks/opencl/alignment/alignment1.cl +++ /dev/null @@ -1,21 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment1.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment1.spvasm - -__kernel void test(global uint *x) -{ - local uint3 data[2]; - - data[0].x = 0; - data[0].y = 1; - data[0].z = 2; - - data[1].x = 3; - data[1].y = 4; - data[1].z = 5; - - for (int i = 0; i < 8; i++) - { - x[i] = *(((uint*)data) + i); - } -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment10.cl b/benchmarks/opencl/alignment/alignment10.cl deleted file mode 100644 index d2dc9ee940..0000000000 --- a/benchmarks/opencl/alignment/alignment10.cl +++ /dev/null @@ -1,26 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment10.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment10.spvasm - -struct struct1 { - unsigned int a[3]__attribute__ ((aligned (16))); - unsigned int b[3]__attribute__ ((aligned (16))); -}; - -struct struct2 { - unsigned int a[3]; - unsigned int b[3]; -}; - -__kernel void test(global uint *x) -{ - local struct struct1 s1; - local struct struct2 s2; - - *(((uint*)s1.a[0]) + 4) = 1; - *(((uint*)s2.a[0]) + 3) = 2; - - x[0] = s1.b[0]; - x[1] = s2.b[0]; - -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment2-struct-global.cl b/benchmarks/opencl/alignment/alignment2-struct-global.cl new file mode 100644 index 0000000000..731049104e --- /dev/null +++ b/benchmarks/opencl/alignment/alignment2-struct-global.cl @@ -0,0 +1,53 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment2-struct-global.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment2-struct-global.spvasm + +typedef struct __attribute__ ((aligned (32))) { + int a; + int b; + int c; + int d; + int e; +} aligned_t; + +typedef struct { + int a; + int b; + int c; + int d; + int e; +} unaligned_t; + +global static aligned_t aligned[3]; +global static unaligned_t unaligned[3]; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + aligned[0].a = 0; + aligned[0].b = 1; + aligned[0].c = 2; + aligned[0].d = 3; + aligned[0].e = 4; + + aligned[1].a = 5; + aligned[1].b = 6; + aligned[1].c = 7; + aligned[1].d = 8; + aligned[1].e = 9; + + unaligned[0].a = 10; + unaligned[0].b = 11; + unaligned[0].c = 12; + unaligned[0].d = 13; + unaligned[0].e = 14; + + unaligned[1].a = 15; + unaligned[1].b = 16; + unaligned[1].c = 17; + unaligned[1].d = 18; + unaligned[1].e = 19; + + for (int i = 0; i < 16; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment2-struct-local.cl b/benchmarks/opencl/alignment/alignment2-struct-local.cl new file mode 100644 index 0000000000..cfa7dd20d3 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment2-struct-local.cl @@ -0,0 +1,57 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment2-struct-local.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment2-struct-local.spvasm + +// clspv -O0 alignment2-struct-local.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment2-struct-local.spvasm + +typedef struct __attribute__ ((aligned (32))) { + int a; + int b; + int c; + int d; + int e; +} aligned_t; + +typedef struct { + int a; + int b; + int c; + int d; + int e; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + local aligned_t aligned[3]; + local unaligned_t unaligned[3]; + + aligned[0].a = 0; + aligned[0].b = 1; + aligned[0].c = 2; + aligned[0].d = 3; + aligned[0].e = 4; + + aligned[1].a = 5; + aligned[1].b = 6; + aligned[1].c = 7; + aligned[1].d = 8; + aligned[1].e = 9; + + unaligned[0].a = 10; + unaligned[0].b = 11; + unaligned[0].c = 12; + unaligned[0].d = 13; + unaligned[0].e = 14; + + unaligned[1].a = 15; + unaligned[1].b = 16; + unaligned[1].c = 17; + unaligned[1].d = 18; + unaligned[1].e = 19; + + for (int i = 0; i < 16; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment2-struct-pointer.cl b/benchmarks/opencl/alignment/alignment2-struct-pointer.cl new file mode 100644 index 0000000000..1bec37e063 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment2-struct-pointer.cl @@ -0,0 +1,54 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment2-struct-pointer.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment2-struct-pointer.spvasm + +// clspv -O0 alignment2-struct-pointer.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment2-struct-pointer.spvasm + +typedef struct __attribute__ ((aligned (32))) { + int a; + int b; + int c; + int d; + int e; +} aligned_t; + +typedef struct { + int a; + int b; + int c; + int d; + int e; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned, global aligned_t* aligned, global unaligned_t* unaligned) { + aligned[0].a = 0; + aligned[0].b = 1; + aligned[0].c = 2; + aligned[0].d = 3; + aligned[0].e = 4; + + aligned[1].a = 5; + aligned[1].b = 6; + aligned[1].c = 7; + aligned[1].d = 8; + aligned[1].e = 9; + + unaligned[0].a = 10; + unaligned[0].b = 11; + unaligned[0].c = 12; + unaligned[0].d = 13; + unaligned[0].e = 14; + + unaligned[1].a = 15; + unaligned[1].b = 16; + unaligned[1].c = 17; + unaligned[1].d = 18; + unaligned[1].e = 19; + + for (int i = 0; i < 16; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment2.cl b/benchmarks/opencl/alignment/alignment2.cl deleted file mode 100644 index 12d76ab86c..0000000000 --- a/benchmarks/opencl/alignment/alignment2.cl +++ /dev/null @@ -1,24 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment2.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment2.spvasm - -struct aligned_struct { - unsigned int e0 __attribute__ ((aligned (16))); - unsigned int e1 __attribute__ ((aligned (16))); -}; - -kernel void test(global int *x) { - - local struct aligned_struct aligned; - local unsigned int unaligned[2]; - - *(&aligned.e0) = 1; - *(&aligned.e0 + 4) = 2; - *(unaligned) = 3; - *(unaligned + 1) = 4; - - x[0] = aligned.e0; - x[1] = aligned.e1; - x[2] = unaligned[0]; - x[3] = unaligned[1]; -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment3-struct-global.cl b/benchmarks/opencl/alignment/alignment3-struct-global.cl new file mode 100644 index 0000000000..74083341fe --- /dev/null +++ b/benchmarks/opencl/alignment/alignment3-struct-global.cl @@ -0,0 +1,33 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment3-struct-global.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment3-struct-global.spvasm + +typedef struct { + int a __attribute__ ((aligned (8))); + int b __attribute__ ((aligned (8))); +} aligned_t; + +typedef struct { + int a; + int b; +} unaligned_t; + +global static aligned_t aligned[3]; +global static unaligned_t unaligned[3]; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + aligned[0].a = 0; + aligned[0].b = 1; + aligned[1].a = 2; + aligned[1].b = 3; + + unaligned[0].a = 4; + unaligned[0].b = 5; + unaligned[1].a = 6; + unaligned[1].b = 7; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment3-struct-local.cl b/benchmarks/opencl/alignment/alignment3-struct-local.cl new file mode 100644 index 0000000000..e5c5ce6986 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment3-struct-local.cl @@ -0,0 +1,37 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment3-struct-local.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment3-struct-local.spvasm + +// clspv -O0 alignment3-struct-local.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment3-struct-local.spvasm + +typedef struct { + int a __attribute__ ((aligned (8))); + int b __attribute__ ((aligned (8))); +} aligned_t; + +typedef struct { + int a; + int b; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + local aligned_t aligned[3]; + local unaligned_t unaligned[3]; + + aligned[0].a = 0; + aligned[0].b = 1; + aligned[1].a = 2; + aligned[1].b = 3; + + unaligned[0].a = 4; + unaligned[0].b = 5; + unaligned[1].a = 6; + unaligned[1].b = 7; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment3-struct-pointer.cl b/benchmarks/opencl/alignment/alignment3-struct-pointer.cl new file mode 100644 index 0000000000..2e1e1947fd --- /dev/null +++ b/benchmarks/opencl/alignment/alignment3-struct-pointer.cl @@ -0,0 +1,34 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment3-struct-pointer.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment3-struct-pointer.spvasm + +// clspv -O0 alignment3-struct-pointer.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment3-struct-pointer.spvasm + +typedef struct { + int a __attribute__ ((aligned (8))); + int b __attribute__ ((aligned (8))); +} aligned_t; + +typedef struct { + int a; + int b; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned, global aligned_t* aligned, global unaligned_t* unaligned) { + aligned[0].a = 0; + aligned[0].b = 1; + aligned[1].a = 2; + aligned[1].b = 3; + + unaligned[0].a = 4; + unaligned[0].b = 5; + unaligned[1].a = 6; + unaligned[1].b = 7; + + for (int i = 0; i < 8; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment3.cl b/benchmarks/opencl/alignment/alignment3.cl deleted file mode 100644 index 553c35a507..0000000000 --- a/benchmarks/opencl/alignment/alignment3.cl +++ /dev/null @@ -1,42 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment3.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment3.spvasm - -struct aligned_struct { - unsigned int e0[3] __attribute__ ((aligned (16))); - unsigned int e1[3] __attribute__ ((aligned (16))); -}; - -kernel void test(global int *x) { - - local struct aligned_struct aligned; - local unsigned int unaligned[2][3]; - - aligned.e0[0] = 0; - aligned.e0[1] = 1; - aligned.e0[2] = 2; - aligned.e1[0] = 4; - aligned.e1[1] = 5; - aligned.e1[2] = 6; - - unaligned[0][0] = 10; - unaligned[0][1] = 11; - unaligned[0][2] = 12; - unaligned[1][0] = 13; - unaligned[1][1] = 14; - unaligned[1][2] = 15; - - x[0] = aligned.e0[0]; - x[1] = aligned.e0[1]; - x[2] = aligned.e0[2]; - x[3] = aligned.e1[0]; - x[4] = aligned.e1[1]; - x[5] = aligned.e1[2]; - - x[6] = unaligned[0][0]; - x[7] = unaligned[0][1]; - x[8] = unaligned[0][2]; - x[9] = unaligned[1][0]; - x[10] = unaligned[1][1]; - x[11] = unaligned[1][2]; -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment4-struct-global.cl b/benchmarks/opencl/alignment/alignment4-struct-global.cl new file mode 100644 index 0000000000..86d185854e --- /dev/null +++ b/benchmarks/opencl/alignment/alignment4-struct-global.cl @@ -0,0 +1,47 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment4-struct-global.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment4-struct-global.spvasm + +typedef struct { + int a __attribute__ ((aligned (8))); + int b __attribute__ ((aligned (8))); + int c __attribute__ ((aligned (16))); + int d __attribute__ ((aligned (16))); +} aligned_t; + +typedef struct { + int a; + int b; + int c; + int d; +} unaligned_t; + +global static aligned_t aligned[3]; +global static unaligned_t unaligned[3]; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + aligned[0].a = 0; + aligned[0].b = 1; + aligned[0].c = 2; + aligned[0].d = 3; + + aligned[1].a = 4; + aligned[1].b = 5; + aligned[1].c = 6; + aligned[1].d = 7; + + unaligned[0].a = 8; + unaligned[0].b = 9; + unaligned[0].c = 10; + unaligned[0].d = 11; + + unaligned[1].a = 12; + unaligned[1].b = 13; + unaligned[1].c = 14; + unaligned[1].d = 15; + + for (int i = 0; i < 24; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment4-struct-local.cl b/benchmarks/opencl/alignment/alignment4-struct-local.cl new file mode 100644 index 0000000000..05df1aa587 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment4-struct-local.cl @@ -0,0 +1,51 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment4-struct-local.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment4-struct-local.spvasm + +// clspv -O0 alignment4-struct-local.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment4-struct-local.spvasm + +typedef struct { + int a __attribute__ ((aligned (8))); + int b __attribute__ ((aligned (8))); + int c __attribute__ ((aligned (16))); + int d __attribute__ ((aligned (16))); +} aligned_t; + +typedef struct { + int a; + int b; + int c; + int d; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned) { + local aligned_t aligned[3]; + local unaligned_t unaligned[3]; + + aligned[0].a = 0; + aligned[0].b = 1; + aligned[0].c = 2; + aligned[0].d = 3; + + aligned[1].a = 4; + aligned[1].b = 5; + aligned[1].c = 6; + aligned[1].d = 7; + + unaligned[0].a = 8; + unaligned[0].b = 9; + unaligned[0].c = 10; + unaligned[0].d = 11; + + unaligned[1].a = 12; + unaligned[1].b = 13; + unaligned[1].c = 14; + unaligned[1].d = 15; + + for (int i = 0; i < 24; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment4-struct-pointer.cl b/benchmarks/opencl/alignment/alignment4-struct-pointer.cl new file mode 100644 index 0000000000..7a5f71c6ab --- /dev/null +++ b/benchmarks/opencl/alignment/alignment4-struct-pointer.cl @@ -0,0 +1,48 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment4-struct-pointer.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment4-struct-pointer.spvasm + +// clspv -O0 alignment4-struct-pointer.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment4-struct-pointer.spvasm + +typedef struct { + int a __attribute__ ((aligned (8))); + int b __attribute__ ((aligned (8))); + int c __attribute__ ((aligned (16))); + int d __attribute__ ((aligned (16))); +} aligned_t; + +typedef struct { + int a; + int b; + int c; + int d; +} unaligned_t; + +__kernel void test(global int *r_aligned, global int* r_unaligned, global aligned_t* aligned, global unaligned_t* unaligned) { + aligned[0].a = 0; + aligned[0].b = 1; + aligned[0].c = 2; + aligned[0].d = 3; + + aligned[1].a = 4; + aligned[1].b = 5; + aligned[1].c = 6; + aligned[1].d = 7; + + unaligned[0].a = 8; + unaligned[0].b = 9; + unaligned[0].c = 10; + unaligned[0].d = 11; + + unaligned[1].a = 12; + unaligned[1].b = 13; + unaligned[1].c = 14; + unaligned[1].d = 15; + + for (int i = 0; i < 24; i++) { + r_aligned[i] = *(((int*) aligned) + i); + r_unaligned[i] = *(((int*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment4.cl b/benchmarks/opencl/alignment/alignment4.cl deleted file mode 100644 index 0e369d0f8d..0000000000 --- a/benchmarks/opencl/alignment/alignment4.cl +++ /dev/null @@ -1,116 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment4.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment4.spvasm - -struct aligned_struct { - unsigned int e0[3] __attribute__ ((aligned (16))); - unsigned int e1[3] __attribute__ ((aligned (16))); -}; - -struct nested_aligned_struct { - struct aligned_struct as0[3] __attribute__ ((aligned (64))); - struct aligned_struct as1[3] __attribute__ ((aligned (64))); -}; - -kernel void test(global int *x) { - local struct nested_aligned_struct nested_aligned; - local unsigned int unaligned[2][2][3]; - - nested_aligned.as0[0].e0[0] = 0; - nested_aligned.as0[0].e0[1] = 1; - nested_aligned.as0[0].e0[2] = 2; - nested_aligned.as0[0].e1[0] = 3; - nested_aligned.as0[0].e1[1] = 4; - nested_aligned.as0[0].e1[2] = 5; - nested_aligned.as0[1].e0[0] = 6; - nested_aligned.as0[1].e0[1] = 7; - nested_aligned.as0[1].e0[2] = 8; - nested_aligned.as0[1].e1[0] = 9; - nested_aligned.as0[1].e1[1] = 10; - nested_aligned.as0[1].e1[2] = 11; - nested_aligned.as0[2].e0[0] = 12; - nested_aligned.as0[2].e0[1] = 13; - nested_aligned.as0[2].e0[2] = 14; - nested_aligned.as0[2].e1[0] = 15; - nested_aligned.as0[2].e1[1] = 16; - nested_aligned.as0[2].e1[2] = 17; - nested_aligned.as1[0].e0[0] = 18; - nested_aligned.as1[0].e0[1] = 19; - nested_aligned.as1[0].e0[2] = 20; - nested_aligned.as1[0].e1[0] = 21; - nested_aligned.as1[0].e1[1] = 22; - nested_aligned.as1[0].e1[2] = 23; - nested_aligned.as1[1].e0[0] = 24; - nested_aligned.as1[1].e0[1] = 25; - nested_aligned.as1[1].e0[2] = 26; - nested_aligned.as1[1].e1[0] = 27; - nested_aligned.as1[1].e1[1] = 28; - nested_aligned.as1[1].e1[2] = 29; - nested_aligned.as1[2].e0[0] = 30; - nested_aligned.as1[2].e0[1] = 31; - nested_aligned.as1[2].e0[2] = 32; - nested_aligned.as1[2].e1[0] = 33; - nested_aligned.as1[2].e1[1] = 34; - nested_aligned.as1[2].e1[2] = 35; - unaligned[0][0][0] = 36; - unaligned[0][0][1] = 37; - unaligned[0][0][2] = 38; - unaligned[0][1][0] = 39; - unaligned[0][1][1] = 40; - unaligned[0][1][2] = 41; - unaligned[1][0][0] = 42; - unaligned[1][0][1] = 43; - unaligned[1][0][2] = 44; - unaligned[1][1][0] = 45; - unaligned[1][1][1] = 46; - unaligned[1][1][2] = 47; - - x[0] = nested_aligned.as0[0].e0[0]; - x[1] = nested_aligned.as0[0].e0[1]; - x[2] = nested_aligned.as0[0].e0[2]; - x[3] = nested_aligned.as0[0].e1[0]; - x[4] = nested_aligned.as0[0].e1[1]; - x[5] = nested_aligned.as0[0].e1[2]; - x[6] = nested_aligned.as0[1].e0[0]; - x[7] = nested_aligned.as0[1].e0[1]; - x[8] = nested_aligned.as0[1].e0[2]; - x[9] = nested_aligned.as0[1].e1[0]; - x[10] = nested_aligned.as0[1].e1[1]; - x[11] = nested_aligned.as0[1].e1[2]; - x[12] = nested_aligned.as0[2].e0[0]; - x[13] = nested_aligned.as0[2].e0[1]; - x[14] = nested_aligned.as0[2].e0[2]; - x[15] = nested_aligned.as0[2].e1[0]; - x[16] = nested_aligned.as0[2].e1[1]; - x[17] = nested_aligned.as0[2].e1[2]; - x[18] = nested_aligned.as1[0].e0[0]; - x[19] = nested_aligned.as1[0].e0[1]; - x[20] = nested_aligned.as1[0].e0[2]; - x[21] = nested_aligned.as1[0].e1[0]; - x[22] = nested_aligned.as1[0].e1[1]; - x[23] = nested_aligned.as1[0].e1[2]; - x[24] = nested_aligned.as1[1].e0[0]; - x[25] = nested_aligned.as1[1].e0[1]; - x[26] = nested_aligned.as1[1].e0[2]; - x[27] = nested_aligned.as1[1].e1[0]; - x[28] = nested_aligned.as1[1].e1[1]; - x[29] = nested_aligned.as1[1].e1[2]; - x[30] = nested_aligned.as1[2].e0[0]; - x[31] = nested_aligned.as1[2].e0[1]; - x[32] = nested_aligned.as1[2].e0[2]; - x[33] = nested_aligned.as1[2].e1[0]; - x[34] = nested_aligned.as1[2].e1[1]; - x[35] = nested_aligned.as1[2].e1[2]; - x[36] = unaligned[0][0][0]; - x[37] = unaligned[0][0][1]; - x[38] = unaligned[0][0][2]; - x[39] = unaligned[0][1][0]; - x[40] = unaligned[0][1][1]; - x[41] = unaligned[0][1][2]; - x[42] = unaligned[1][0][0]; - x[43] = unaligned[1][0][1]; - x[44] = unaligned[1][0][2]; - x[45] = unaligned[1][1][0]; - x[46] = unaligned[1][1][1]; - x[47] = unaligned[1][1][2]; -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment5-struct-global.cl b/benchmarks/opencl/alignment/alignment5-struct-global.cl new file mode 100644 index 0000000000..ccf459daca --- /dev/null +++ b/benchmarks/opencl/alignment/alignment5-struct-global.cl @@ -0,0 +1,47 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment5-struct-global.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment5-struct-global.spvasm + +typedef struct { + char a __attribute__ ((aligned (4))); + char b[4]; +} aligned_t; + +typedef struct { + char a; + char b[4]; +} unaligned_t; + +global static aligned_t aligned[3]; +global static unaligned_t unaligned[3]; + +__kernel void test(global char *r_aligned, global char* r_unaligned) { + aligned[0].a = 0; + aligned[0].b[0] = 1; + aligned[0].b[1] = 2; + aligned[0].b[2] = 3; + aligned[0].b[3] = 4; + + aligned[1].a = 5; + aligned[1].b[0] = 6; + aligned[1].b[1] = 7; + aligned[1].b[2] = 8; + aligned[1].b[3] = 9; + + unaligned[0].a = 10; + unaligned[0].b[0] = 11; + unaligned[0].b[1] = 12; + unaligned[0].b[2] = 13; + unaligned[0].b[3] = 14; + + unaligned[1].a = 15; + unaligned[1].b[0] = 16; + unaligned[1].b[1] = 17; + unaligned[1].b[2] = 18; + unaligned[1].b[3] = 19; + + for (int i = 0; i < 16; i++) { + r_aligned[i] = *(((char*) aligned) + i); + r_unaligned[i] = *(((char*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment5-struct-local.cl b/benchmarks/opencl/alignment/alignment5-struct-local.cl new file mode 100644 index 0000000000..cd02c4087a --- /dev/null +++ b/benchmarks/opencl/alignment/alignment5-struct-local.cl @@ -0,0 +1,51 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment5-struct-local.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment5-struct-local.spvasm + +// clspv -O0 alignment5-struct-local.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment5-struct-local.spvasm + +typedef struct { + char a __attribute__ ((aligned (4))); + char b[4]; +} aligned_t; + +typedef struct { + char a; + char b[4]; +} unaligned_t; + +__kernel void test(global char *r_aligned, global char* r_unaligned) { + local aligned_t aligned[3]; + local unaligned_t unaligned[3]; + + aligned[0].a = 0; + aligned[0].b[0] = 1; + aligned[0].b[1] = 2; + aligned[0].b[2] = 3; + aligned[0].b[3] = 4; + + aligned[1].a = 5; + aligned[1].b[0] = 6; + aligned[1].b[1] = 7; + aligned[1].b[2] = 8; + aligned[1].b[3] = 9; + + unaligned[0].a = 10; + unaligned[0].b[0] = 11; + unaligned[0].b[1] = 12; + unaligned[0].b[2] = 13; + unaligned[0].b[3] = 14; + + unaligned[1].a = 15; + unaligned[1].b[0] = 16; + unaligned[1].b[1] = 17; + unaligned[1].b[2] = 18; + unaligned[1].b[3] = 19; + + for (int i = 0; i < 16; i++) { + r_aligned[i] = *(((char*) aligned) + i); + r_unaligned[i] = *(((char*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment5-struct-pointer.cl b/benchmarks/opencl/alignment/alignment5-struct-pointer.cl new file mode 100644 index 0000000000..b6b143fd19 --- /dev/null +++ b/benchmarks/opencl/alignment/alignment5-struct-pointer.cl @@ -0,0 +1,48 @@ +// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -fno-discard-value-names -cl-opt-disable -emit-llvm -c alignment5-struct-pointer.cl -o a.bc +// llvm-spirv a.bc -o a.spv +// spirv-dis a.spv > alignment5-struct-pointer.spvasm + +// clspv -O0 alignment5-struct-pointer.cl --cl-std=CL2.0 --inline-entry-points --spv-version=1.6 +// spirv-opt --upgrade-memory-model -o a.opt.spv a.spv +// spirv-dis a.opt.spv > alignment5-struct-pointer.spvasm + +typedef struct { + char a __attribute__ ((aligned (4))); + char b[4]; +} aligned_t; + +typedef struct { + char a; + char b[4]; +} unaligned_t; + +__kernel void test(global char *r_aligned, global char* r_unaligned, global aligned_t* aligned, global unaligned_t* unaligned) { + aligned[0].a = 0; + aligned[0].b[0] = 1; + aligned[0].b[1] = 2; + aligned[0].b[2] = 3; + aligned[0].b[3] = 4; + + aligned[1].a = 5; + aligned[1].b[0] = 6; + aligned[1].b[1] = 7; + aligned[1].b[2] = 8; + aligned[1].b[3] = 9; + + unaligned[0].a = 10; + unaligned[0].b[0] = 11; + unaligned[0].b[1] = 12; + unaligned[0].b[2] = 13; + unaligned[0].b[3] = 14; + + unaligned[1].a = 15; + unaligned[1].b[0] = 16; + unaligned[1].b[1] = 17; + unaligned[1].b[2] = 18; + unaligned[1].b[3] = 19; + + for (int i = 0; i < 16; i++) { + r_aligned[i] = *(((char*) aligned) + i); + r_unaligned[i] = *(((char*) unaligned) + i); + } +} diff --git a/benchmarks/opencl/alignment/alignment5.cl b/benchmarks/opencl/alignment/alignment5.cl deleted file mode 100644 index 4c67443ba9..0000000000 --- a/benchmarks/opencl/alignment/alignment5.cl +++ /dev/null @@ -1,32 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment5.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment5.spvasm - -struct struct1 { - int a; // 4 bytes, aligned to 4 - char b; // 1 byte -}__attribute__ ((aligned (16))); - -struct struct2 { - char b; // 1 byte - int a; // 4 bytes, aligned to 4 -}; - - -__kernel void manual_vs_struct(__global uchar *out) -{ - local struct struct1 s1; - local struct struct2 s2; - - s1.a = 0; - s1.b = 1; - s2.a = 2; - s2.b = 3; - *((int *)(&s1.a + 1)) = 22; - *((int *)(&s2.a + 1)) = 33; - - out[0] = s1.a; - out[1] = s1.b; - out[2] = s2.a; - out[3] = s2.b; -} diff --git a/benchmarks/opencl/alignment/alignment6.cl b/benchmarks/opencl/alignment/alignment6.cl deleted file mode 100644 index 34e351715b..0000000000 --- a/benchmarks/opencl/alignment/alignment6.cl +++ /dev/null @@ -1,43 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment6.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment6.spvasm - -struct aligned_struct { - unsigned int e0[3] __attribute__ ((aligned (16))); - unsigned int e1[3] __attribute__ ((aligned (16))); -}; - -global struct aligned_struct aligned; - -kernel void test(global int *x, global struct aligned_struct *aligned) { - - local unsigned int unaligned[2][3]; - - aligned->e0[0] = 0; - aligned->e0[1] = 1; - aligned->e0[2] = 2; - aligned->e1[0] = 4; - aligned->e1[1] = 5; - aligned->e1[2] = 6; - - unaligned[0][0] = 10; - unaligned[0][1] = 11; - unaligned[0][2] = 12; - unaligned[1][0] = 13; - unaligned[1][1] = 14; - unaligned[1][2] = 15; - - x[0] = aligned->e0[0]; - x[1] = aligned->e0[1]; - x[2] = aligned->e0[2]; - x[3] = aligned->e1[0]; - x[4] = aligned->e1[1]; - x[5] = aligned->e1[2]; - - x[6] = unaligned[0][0]; - x[7] = unaligned[0][1]; - x[8] = unaligned[0][2]; - x[9] = unaligned[1][0]; - x[10] = unaligned[1][1]; - x[11] = unaligned[1][2]; -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment7.cl b/benchmarks/opencl/alignment/alignment7.cl deleted file mode 100644 index 5f1c87dfb4..0000000000 --- a/benchmarks/opencl/alignment/alignment7.cl +++ /dev/null @@ -1,31 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment7.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment7.spvasm - -struct struct1 { - int a; // 4 bytes, aligned to 4 - char b; // 1 byte -}__attribute__ ((aligned (16))); - -struct struct2 { - char b; // 1 byte - int a; // 4 bytes, aligned to 4 -}; - -global struct struct1 s1; -global struct struct2 s2; - -__kernel void manual_vs_struct(__global uchar *out, __global struct struct1 *s1, __global struct struct2 *s2) -{ - s1->a = 0; - s1->b = 1; - s2->a = 2; - s2->b = 3; - *((int *)(&s1->a + 1)) = 22; - *((int *)(&s2->a + 1)) = 33; - - out[0] = s1->a; - out[1] = s1->b; - out[2] = s2->a; - out[3] = s2->b; -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment8.cl b/benchmarks/opencl/alignment/alignment8.cl deleted file mode 100644 index 506dc6344d..0000000000 --- a/benchmarks/opencl/alignment/alignment8.cl +++ /dev/null @@ -1,25 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment8.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment8.spvasm - -struct aligned_struct { - unsigned int e0 __attribute__ ((aligned (16))); - unsigned int e1 __attribute__ ((aligned (16))); -}; - -global struct aligned_struct aligned; - -kernel void test(global int *x, global struct aligned_struct *aligned) { - - local unsigned int unaligned[2]; - - *(&aligned->e0) = 1; - *(&aligned->e0 + 4) = 2; - *(unaligned) = 3; - *(unaligned + 1) = 4; - - x[0] = aligned->e0; - x[1] = aligned->e1; - x[2] = unaligned[0]; - x[3] = unaligned[1]; -} \ No newline at end of file diff --git a/benchmarks/opencl/alignment/alignment9.cl b/benchmarks/opencl/alignment/alignment9.cl deleted file mode 100644 index 4380335aff..0000000000 --- a/benchmarks/opencl/alignment/alignment9.cl +++ /dev/null @@ -1,25 +0,0 @@ -// clang -x cl -cl-std=CL2.0 -target spir-unknown-unknown -cl-opt-disable -emit-llvm -c alignment9.cl -o a.bc -// llvm-spirv a.bc -o a.spv -// spirv-dis a.spv > alignment9.spvasm - -struct aligned_struct { - uint3 data[2]; -}; - -global struct aligned_struct aligned; - -__kernel void test(global uint *x, global struct aligned_struct *aligned) -{ - aligned->data[0].x = 0; - aligned->data[0].y = 1; - aligned->data[0].z = 2; - - aligned->data[1].x = 3; - aligned->data[1].y = 4; - aligned->data[1].z = 5; - - for (int i = 0; i < 8; i++) - { - x[i] = *(((uint*)aligned) + i); - } -} \ No newline at end of file diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/ExpressionFactory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/ExpressionFactory.java index 02fb0741d7..06dbf5fd54 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/ExpressionFactory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/ExpressionFactory.java @@ -12,7 +12,6 @@ import com.dat3m.dartagnan.program.memory.ScopedPointer; import com.dat3m.dartagnan.program.memory.ScopedPointerVariable; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import java.math.BigDecimal; @@ -20,6 +19,8 @@ import java.util.ArrayList; import java.util.List; +import static com.dat3m.dartagnan.expression.type.TypeFactory.isStaticTypeOf; + public final class ExpressionFactory { private static final ExpressionFactory instance = new ExpressionFactory(); @@ -263,18 +264,21 @@ public Expression makeConstruct(Type type, List arguments) return new ConstructExpr(type, arguments); } - public Expression makeArray(Type elementType, List items, boolean fixedSize) { - final ArrayType type = fixedSize ? types.getArrayType(elementType, items.size()) : - types.getArrayType(elementType); - if (items.size() > 0) { - Preconditions.checkArgument(items.stream().allMatch(e -> TypeFactory.isStaticTypeOf(e.getType(), items.get(0).getType())), - "All elements in an array must have the same type."); + public Expression makeArray(ArrayType type, List items) { + Preconditions.checkArgument(!type.hasKnownNumElements() || type.getNumElements() == items.size(), + "The number of elements must match"); + if (!items.isEmpty()) { + long distinctSubtypesCount = items.stream().map(Expression::getType).distinct().count(); + Preconditions.checkArgument(distinctSubtypesCount == 1, + "All elements in an array must have the same type."); + Preconditions.checkArgument(isStaticTypeOf(items.get(0).getType(), type.getElementType()), + "Array elements must match expected type"); } return new ConstructExpr(type, items); } public Expression makeExtract(Expression object, int index) { - return makeExtract(object, ImmutableList.of(index)); + return makeExtract(object, List.of(index)); } public Expression makeExtract(Expression object, Iterable indices) { @@ -285,7 +289,7 @@ public Expression makeExtract(Expression object, Iterable indices) { } public Expression makeInsert(Expression aggregate, Expression value, int index) { - return makeInsert(aggregate, value, ImmutableList.of(index)); + return makeInsert(aggregate, value, List.of(index)); } public Expression makeInsert(Expression aggregate, Expression value, Iterable indices) { @@ -303,20 +307,26 @@ public Expression makeAggregateCmp(Expression x, AggregateCmpOp op, Expression y // Pointers public Expression makeGetElementPointer(Type indexingType, Expression base, List offsets) { - //TODO getPointerType() + return makeGetElementPointer(indexingType, base, offsets, null); + } + + public Expression makeGetElementPointer(Type indexingType, Expression base, List offsets, Integer stride) { + // TODO: Stride should be a property of the pointer, not of a GEPExpr. + // Refactor GEPExpr to only accept a (new) PointerType and a list of offsets. + // A PointerType should have the referred type and the stride in its attributes. Preconditions.checkArgument(base.getType().equals(types.getArchType()), "Applying offsets to non-pointer expression."); - return new GEPExpr(indexingType, base, offsets); + Preconditions.checkArgument(stride == null || stride >= types.getMemorySizeInBytes(indexingType), + "Stride cannot be smaller than indexing type"); + return new GEPExpr(indexingType, base, offsets, stride); } - public ScopedPointer makeScopedPointer(String id, String scopeId, Type type, Expression address) { - ScopedPointerType pointerType = types.getScopedPointerType(scopeId, type); - return new ScopedPointer(id, pointerType, address); + public ScopedPointer makeScopedPointer(String id, ScopedPointerType type, Expression value) { + return new ScopedPointer(id, type, value); } - public ScopedPointerVariable makeScopedPointerVariable(String id, String scopeId, Type type, MemoryObject address) { - ScopedPointerType pointerType = types.getScopedPointerType(scopeId, type); - return new ScopedPointerVariable(id, pointerType, address); + public ScopedPointerVariable makeScopedPointerVariable(String id, ScopedPointerType type, MemoryObject memObj) { + return new ScopedPointerVariable(id, type, memObj); } // ----------------------------------------------------------------------------------------------------------------- @@ -329,7 +339,7 @@ public Expression makeGeneralZero(Type type) { for (int i = 0; i < arrayType.getNumElements(); i++) { zeroes.add(zero); } - return makeArray(arrayType.getElementType(), zeroes, true); + return makeArray(arrayType, zeroes); } else if (type instanceof AggregateType structType) { List zeroes = new ArrayList<>(structType.getFields().size()); for (TypeOffset typeOffset : structType.getFields()) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/misc/GEPExpr.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/misc/GEPExpr.java index 670c1f4c2c..81891dfa1c 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/misc/GEPExpr.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/misc/GEPExpr.java @@ -5,8 +5,6 @@ import com.dat3m.dartagnan.expression.ExpressionVisitor; import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.expression.base.NaryExpressionBase; -import com.dat3m.dartagnan.expression.type.AggregateType; -import com.dat3m.dartagnan.expression.type.ArrayType; import com.dat3m.dartagnan.expression.type.IntegerType; import com.dat3m.dartagnan.expression.utils.ExpressionHelper; import com.google.common.base.Preconditions; @@ -19,14 +17,16 @@ public final class GEPExpr extends NaryExpressionBase { private final Type indexingType; + private final Integer stride; - public GEPExpr(Type indexType, Expression base, List offsets) { + public GEPExpr(Type indexType, Expression base, List offsets, Integer stride) { super(base.getType(), ExpressionKind.Other.GEP, concat(base, offsets)); ExpressionHelper.checkExpectedType(base, IntegerType.class); if (offsets.size() > 1) { Preconditions.checkArgument(isAggregateLike(indexType), "Indexing with multiple indices into non-aggregate type."); } this.indexingType = indexType; + this.stride = stride; } private static ImmutableList concat(Expression base, List offsets) { @@ -48,6 +48,10 @@ public ImmutableList getOffsets() { return operands.subList(1, operands.size()); } + public Integer getStride() { + return stride; + } + @Override public T accept(ExpressionVisitor visitor) { return visitor.visitGEPExpression(this); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java index a32552142e..eb61aa102b 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ArrayType.java @@ -2,24 +2,20 @@ import com.dat3m.dartagnan.expression.Type; +import java.util.Objects; + public class ArrayType implements Type { private final Type elementType; private final int numElements; - private final int paddingStart; - - ArrayType(Type elementType, int numElements) { - this(elementType, numElements, numElements); - } + private final Integer stride; + private final Integer alignment; - ArrayType(Type elementType, int numElements, int paddingStart) { + ArrayType(Type elementType, int numElements, Integer stride, Integer alignment) { this.elementType = elementType; this.numElements = numElements; - this.paddingStart = paddingStart; - } - - public int getPaddingStart() { - return paddingStart; + this.stride = stride; + this.alignment = alignment; } // NOTE: We use empty arrays to represent unknown size. @@ -31,19 +27,36 @@ public int getPaddingStart() { public Type getElementType() { return elementType; } + public Integer getStride() { + return stride; + } + public Integer getAlignment() { + return alignment; + } + @Override - public boolean equals(Object obj) { - return this == obj || - obj instanceof ArrayType o && elementType.equals(o.elementType) && numElements == o.numElements; + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ArrayType arrayType)) return false; + return numElements == arrayType.numElements + && Objects.equals(stride, arrayType.stride) + && Objects.equals(alignment, arrayType.alignment) + && Objects.equals(elementType, arrayType.elementType); } @Override public int hashCode() { - return 31 * elementType.hashCode() + numElements; + return Objects.hash(elementType, numElements, stride, alignment); } @Override public String toString() { - return String.format("[%s x %s]", hasKnownNumElements() ? numElements : "?", elementType); + String numString = hasKnownNumElements() ? Integer.toString(numElements) : "?"; + if (stride != null) { + return String.format("[%s x %s]:%s", numString, elementType, stride); + } else if (alignment != null) { + return String.format("[%s x %s]:%s", numString, elementType, alignment); + } + return String.format("[%s x %s]", numString, elementType); } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ScopedPointerType.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ScopedPointerType.java index 8c651e373a..87125ff27a 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ScopedPointerType.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/ScopedPointerType.java @@ -10,11 +10,13 @@ public class ScopedPointerType extends IntegerType { private final String scopeId; private final Type pointedType; + private final Integer stride; - ScopedPointerType(String scopeId, Type pointedType) { + ScopedPointerType(String scopeId, Type pointedType, Integer stride) { super(ARCH_SIZE); this.scopeId = scopeId; this.pointedType = pointedType; + this.stride = stride; } public String getScopeId() { @@ -25,22 +27,32 @@ public Type getPointedType() { return pointedType; } + public Integer getStride() { + return stride; + } + @Override public String toString() { - return String.format("%s(%s)*", pointedType.toString(), scopeId); + if (stride != null) { + return String.format("%s(%s:%s)*", pointedType, scopeId, stride); + } + return String.format("%s(%s)*", pointedType, scopeId); } @Override public boolean equals(Object o) { if (this == o) return true; + if (!super.equals(o)) return false; if (o instanceof ScopedPointerType that) { - return Objects.equals(scopeId, that.scopeId) && Objects.equals(pointedType, that.pointedType); + return Objects.equals(scopeId, that.scopeId) + && Objects.equals(pointedType, that.pointedType) + && Objects.equals(stride, that.stride); } return super.equals(o); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), scopeId, pointedType); + return Objects.hash(super.hashCode(), scopeId, pointedType, stride); } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java index 4004b8ef83..09404a60c8 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeFactory.java @@ -1,7 +1,5 @@ package com.dat3m.dartagnan.expression.type; -import com.dat3m.dartagnan.expression.Expression; -import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.utils.Normalizer; import com.google.common.math.IntMath; @@ -36,10 +34,6 @@ public static TypeFactory getInstance() { return instance; } - public Expression getDefaultAlignment() { - return ExpressionFactory.getInstance().makeValue(getMemorySizeInBytes(getArchType()), getArchType()); - } - public BooleanType getBooleanType() { return booleanType; } @@ -55,10 +49,15 @@ public IntegerType getIntegerType(int bitWidth) { return typeNormalizer.normalize(new IntegerType(bitWidth)); } - public ScopedPointerType getScopedPointerType(String scopeId, Type pointedType) { + public ScopedPointerType getScopedPointerType(String scopeId, Type pointedType, Integer stride) { checkNotNull(scopeId); checkNotNull(pointedType); - return typeNormalizer.normalize(new ScopedPointerType(scopeId, pointedType)); + if (stride != null) { + checkArgument(stride > 0, "Stride must be positive"); + checkArgument(stride >= getMemorySizeInBytes(pointedType), + "Stride cannot be smaller than element size"); + } + return typeNormalizer.normalize(new ScopedPointerType(scopeId, pointedType, stride)); } public FloatType getFloatType(int mantissaBits, int exponentBits) { @@ -115,19 +114,30 @@ private List computeDefaultOffsets(List fields) { } public ArrayType getArrayType(Type element) { - return typeNormalizer.normalize(new ArrayType(element, -1)); + return getArrayType(element, -1, null, null); } public ArrayType getArrayType(Type element, int size) { checkArgument(0 <= size, "Negative element count in array."); - return typeNormalizer.normalize(new ArrayType(element, size)); + return getArrayType(element, size, null, null); } - public ArrayType getArrayType(Type element, int size, int paddingStart) { - checkArgument(0 <= size, "Negative element count in array."); - checkArgument(0 <= paddingStart, "Negative padding start index in array."); - checkArgument(paddingStart <= size, "Padding start index %s is greater than array size %s", paddingStart, size); - return typeNormalizer.normalize(new ArrayType(element, size, paddingStart)); + public ArrayType getArrayType(Type element, int size, Integer stride) { + return getArrayType(element, size, stride, null); + } + + public ArrayType getArrayType(Type element, int size, Integer stride, Integer alignment) { + checkArgument(stride == null || alignment == null, + "Stride and alignment cannot be used simultaneously"); + if (stride != null) { + checkArgument(stride > 0, "Stride must be positive"); + checkArgument(stride >= getMemorySizeInBytes(element), + "Stride cannot be smaller than element size"); + } + if (alignment != null) { + checkArgument(alignment > 0, "Alignment must be positive"); + } + return typeNormalizer.normalize(new ArrayType(element, size, stride, alignment)); } public IntegerType getArchType() { @@ -142,7 +152,7 @@ public int getMemorySizeInBytes(Type type) { return getMemorySizeInBytes(type, true); } - public int getMemorySizeInBytes(Type type, boolean padded) { + private int getMemorySizeInBytes(Type type, boolean padded) { if (type instanceof BooleanType) { return 1; } @@ -154,8 +164,18 @@ public int getMemorySizeInBytes(Type type, boolean padded) { } if (type instanceof ArrayType arrayType) { if (arrayType.hasKnownNumElements()) { - Type elType = arrayType.getElementType(); - return getMemorySizeInBytes(elType) * arrayType.getNumElements(); + Integer stride = arrayType.getStride(); + if (stride != null) { + return stride * arrayType.getNumElements(); + } + int elSize = getMemorySizeInBytes(arrayType.getElementType()); + if (elSize >= 0) { + int size = elSize * arrayType.getNumElements(); + if (arrayType.getAlignment() != null) { + return paddedSize(size, arrayType.getAlignment()); + } + return size; + } } return -1; } @@ -177,11 +197,15 @@ public int getMemorySizeInBytes(Type type, boolean padded) { throw new UnsupportedOperationException("Cannot compute memory layout of type " + type); } - public int getAlignment(Type type) { + private int getAlignment(Type type) { if (type instanceof BooleanType || type instanceof IntegerType || type instanceof FloatType) { return getMemorySizeInBytes(type); } if (type instanceof ArrayType arrayType) { + Integer alignment = arrayType.getAlignment(); + if (alignment != null) { + return alignment; + } return getAlignment(arrayType.getElementType()); } if (type instanceof AggregateType aType) { @@ -215,12 +239,11 @@ public Map decomposeIntoPrimitives(Type type) { if (!arrayType.hasKnownNumElements() || innerDecomposition == null) { return null; } - - final int size = getMemorySizeInBytes(arrayType.getElementType()); + Integer stride = arrayType.getStride(); + final int size = stride != null ? stride : getMemorySizeInBytes(arrayType.getElementType()); for (int i = 0; i < arrayType.getNumElements(); i++) { - final int offset = i * size; for (Map.Entry entry : innerDecomposition.entrySet()) { - decomposition.put(entry.getKey() + offset, entry.getValue()); + decomposition.put(entry.getKey() + i * size, entry.getValue()); } } } else if (type instanceof AggregateType aggregateType) { @@ -275,7 +298,7 @@ public static boolean isStaticTypeOf(Type staticType, Type runtimeType) { } if (staticType instanceof ArrayType aStaticType && runtimeType instanceof ArrayType aRuntimeType) { int countStatic = aStaticType.getNumElements(); - int countRuntime = Math.min(aRuntimeType.getPaddingStart(), aRuntimeType.getNumElements()); + int countRuntime = aRuntimeType.getNumElements(); if (countStatic != countRuntime && (countRuntime != -1 || countStatic <= 0)) { return false; } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeOffset.java b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeOffset.java index b569460c86..cdd2ed2b78 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeOffset.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/expression/type/TypeOffset.java @@ -11,7 +11,11 @@ public static TypeOffset of(Type type, int index) { return new TypeOffset(type, 0); } if (type instanceof ArrayType arrayType) { + Integer stride = arrayType.getStride(); Type elType = arrayType.getElementType(); + if (stride != null) { + return new TypeOffset(elType, stride * index); + } return new TypeOffset(elType, types.getMemorySizeInBytes(elType) * index); } if (type instanceof AggregateType aggregateType) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/VisitorLlvm.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/VisitorLlvm.java index 948a3e130a..6d02eb2b64 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/VisitorLlvm.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/VisitorLlvm.java @@ -880,7 +880,7 @@ public Expression visitTypeValue(TypeValueContext ctx) { @Override public Expression visitArrayConst(ArrayConstContext ctx) { assert expectedType instanceof ArrayType; - final Type elementType = ((ArrayType)expectedType).getElementType(); + final ArrayType arrayType = (ArrayType) expectedType; if (ctx.StringLit() != null) { //TODO handle strings return expressions.makeGeneralZero(expectedType); // We make a 0 for now. @@ -889,7 +889,7 @@ public Expression visitArrayConst(ArrayConstContext ctx) { for (TypeConstContext typeConst : ctx.typeConst()) { arrayValues.add(visitTypeConst(typeConst)); } - return expressions.makeArray(elementType, arrayValues, true); + return expressions.makeArray(arrayType, arrayValues); } @Override diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java index 409403ace8..799be8c2b4 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotation.java @@ -13,14 +13,14 @@ public class VisitorOpsAnnotation extends SpirvBaseVisitor { + private final Decoration arrayStride; private final Decoration builtIn; private final Decoration offset; - private final Decoration alignment; public VisitorOpsAnnotation(ProgramBuilder builder) { + this.arrayStride = builder.getDecorationsBuilder().getDecoration(ARRAY_STRIDE); this.builtIn = builder.getDecorationsBuilder().getDecoration(BUILT_IN); this.offset = builder.getDecorationsBuilder().getDecoration(OFFSET); - this.alignment = builder.getDecorationsBuilder().getDecoration(ALIGNMENT); } @Override @@ -28,22 +28,23 @@ public Void visitOpDecorate(SpirvParser.OpDecorateContext ctx) { String id = ctx.targetIdRef().getText(); DecorationType type = fromString(ctx.decoration().getChild(0).getText()); switch (type) { + case ARRAY_STRIDE -> { + String value = ctx.decoration().arrayStride().literalInteger().getText(); + arrayStride.addDecoration(id, value); + } case BUILT_IN -> { String value = ctx.decoration().builtIn().getText(); builtIn.addDecoration(id, value); } - case ALIGNMENT -> { - String value = ctx.decoration().alignmentLiteralInteger().getText(); - alignment.addDecoration(id, value); - } - case BINDING, DESCRIPTOR_SET, SPEC_ID, NON_WRITABLE -> { + case ALIGNMENT, BINDING, DESCRIPTOR_SET, SPEC_ID, NON_WRITABLE -> { // Skip + // ALIGNMENT - Can have a visible effect only for out-of-bounds accesses // BINDING - The order of arguments to the entry point // DESCRIPTOR_SET - Linkage to arguments of the entry point // SPEC_ID - The order of spec constants // NON_WRITABLE - Read-only pointer } - case ARRAY_STRIDE, BLOCK, BUFFER_BLOCK, COHERENT, CONSTANT, FUNC_PARAM_ATTR, LINKAGE_ATTRIBUTES, + case BLOCK, BUFFER_BLOCK, COHERENT, CONSTANT, FUNC_PARAM_ATTR, LINKAGE_ATTRIBUTES, NO_CONTRACTION, NO_PERSPECTIVE -> { // TODO: Implementation } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsComposite.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsComposite.java index 3e30ddb0ee..2110fe2947 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsComposite.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsComposite.java @@ -31,7 +31,7 @@ public Void visitOpCompositeExtract(SpirvParser.OpCompositeExtractContext ctx) { Type type = builder.getType(ctx.idResultType().getText()); List indexes = ctx.indexesLiteralInteger().stream() .map(SpirvParser.IndexesLiteralIntegerContext::getText) - .map(Integer::parseInt) + .map(Integer::parseUnsignedInt) .toList(); Expression element = getElement(compositeExpression, indexes, id); if (type.equals(element.getType())) { @@ -49,7 +49,7 @@ public Void visitOpCompositeInsert(SpirvParser.OpCompositeInsertContext ctx) { Type type = builder.getType(ctx.idResultType().getText()); List indexes = ctx.indexesLiteralInteger().stream() .map(SpirvParser.IndexesLiteralIntegerContext::getText) - .map(Integer::parseInt) + .map(Integer::parseUnsignedInt) .toList(); Expression insertion = getInsertion(compositeExpression, objectExpr, indexes, id); if (TypeFactory.isStaticTypeOf(compositeExpression.getType(), type)) { @@ -68,7 +68,7 @@ public Void visitOpVectorShuffle(SpirvParser.OpVectorShuffleContext ctx) { Expression v2 = builder.getExpression(v2Id); List components = ctx.components().stream() .map(SpirvParser.ComponentsContext::getText) - .map(Integer::parseInt) + .map(Integer::parseUnsignedInt) .toList(); Type type = builder.getType(ctx.idResultType().getText()); if (!(type instanceof ArrayType aType)) { @@ -92,11 +92,13 @@ public Void visitOpVectorShuffle(SpirvParser.OpVectorShuffleContext ctx) { concat.add(expressions.makeExtract(v1, index)); } else if (index >= s1 && index < s1 + s2) { concat.add(expressions.makeExtract(v2, index - s1)); + } else if (index == 0xffffffff) { + concat.add(builder.makeUndefinedValue(eType)); } else { throw new ParsingException("Index %s out of bounds in OpVectorShuffle '%s'", index, id); } } - builder.addExpression(id, expressions.makeArray(aType1.getElementType(), concat, true)); + builder.addExpression(id, expressions.makeArray(aType1, concat)); return null; } @@ -126,7 +128,7 @@ public Void visitOpCompositeConstruct(SpirvParser.OpCompositeConstructContext ct } elements.add(elem); } - Expression array = getArray(arrayType.getElementType(), elements, id); + Expression array = getArray(arrayType, elements, id); if (!TypeFactory.isStaticTypeOf(array.getType(), type)) { throw new ParsingException(String.format("There must be exactly one constituent for each top-level element of the result " + "(\"flattening\" vectors is not yet supported) and their types should match for '%s'", id)); @@ -169,9 +171,9 @@ private Expression getConstruct(Type type, List elements, String id) } } - private Expression getArray(Type eType, List elements, String id) { + private Expression getArray(ArrayType type, List elements, String id) { try { - return expressions.makeArray(eType, elements, true); + return expressions.makeArray(type, elements); } catch (Exception e) { throw new ParsingException(String.format("%s Offending id: '%s'", e.getMessage(), id)); } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstant.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstant.java index 95e67654a2..465e09b29f 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstant.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstant.java @@ -128,7 +128,7 @@ private Expression getConstantNullExpression(String typeId, Type type) { } Expression exp = getConstantNullExpression(typeId, arrayType.getElementType()); List elements = Collections.nCopies(arrayType.getNumElements(), exp); - return expressions.makeArray(arrayType.getElementType(), elements, true); + return expressions.makeArray(arrayType, elements); } if (type instanceof AggregateType aggregateType) { List elements = new ArrayList<>(); @@ -216,7 +216,7 @@ private Expression makeConstantArray(String id, ArrayType type, List ele } elements.add(expression); } - return expressions.makeArray(elementType, elements, true); + return expressions.makeArray(type, elements); } private Integer getInputValue(String id) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java index 9ae0ebbd0e..730ee74816 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversion.java @@ -11,13 +11,13 @@ import com.dat3m.dartagnan.parsers.SpirvParser; import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; import com.dat3m.dartagnan.program.Register; +import com.dat3m.dartagnan.program.event.Event; import com.dat3m.dartagnan.program.event.EventFactory; import com.dat3m.dartagnan.program.event.Tag; -import com.dat3m.dartagnan.program.event.core.Local; import java.util.Set; -public class VisitorOpsConversion extends SpirvBaseVisitor { +public class VisitorOpsConversion extends SpirvBaseVisitor { private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); private final ProgramBuilder builder; @@ -27,7 +27,7 @@ public VisitorOpsConversion(ProgramBuilder builder) { } @Override - public Void visitOpBitcast(SpirvParser.OpBitcastContext ctx) { + public Event visitOpBitcast(SpirvParser.OpBitcastContext ctx) { String id = ctx.idResult().getText(); String typeId = ctx.idResultType().getText(); String operand = ctx.operand().getText(); @@ -35,8 +35,7 @@ public Void visitOpBitcast(SpirvParser.OpBitcastContext ctx) { Expression operandExpr = builder.getExpression(operand); Type operandType = operandExpr.getType(); - if (resultType instanceof ArrayType || operandType instanceof ArrayType || - (operandType instanceof ScopedPointerType pointerType && pointerType.getPointedType() instanceof ArrayType)) { + if (resultType instanceof ArrayType || operandType instanceof ArrayType) { // TODO: Support bitcast between arrays throw new ParsingException("Bitcast between arrays is not supported for id '%s'", id); } @@ -48,86 +47,86 @@ public Void visitOpBitcast(SpirvParser.OpBitcastContext ctx) { Expression convertedExpr = expressions.makeCast(operandExpr, resultType); Register reg = builder.addRegister(id, typeId); - builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); - return null; + return builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); } @Override - public Void visitOpConvertPtrToU(SpirvParser.OpConvertPtrToUContext ctx) { + public Event visitOpConvertPtrToU(SpirvParser.OpConvertPtrToUContext ctx) { String id = ctx.idResult().getText(); - String typeId = ctx.idResultType().getText(); - if (!(builder.getType(typeId) instanceof IntegerType)) { - throw new ParsingException("Type '%s' is not an integer type for id '%s'", typeId, id); + Type type = builder.getType(ctx.idResultType().getText()); + Expression pointer = builder.getExpression(ctx.pointer().getText()); + if (type instanceof ScopedPointerType || !(type instanceof IntegerType)) { + throw new ParsingException("Illegal OpConvertPtrToU for '%s', " + + "attempt to convent into a non-integer type", id); } - Expression pointerExpr = builder.getExpression(ctx.pointer().getText()); - Expression convertedPointer = expressions.makeCast(pointerExpr, builder.getType(typeId), false); - Register reg = builder.addRegister(id, typeId); - builder.addEvent(EventFactory.newLocal(reg, convertedPointer)); - return null; + if (!(pointer.getType() instanceof ScopedPointerType)) { + throw new ParsingException("Illegal OpConvertPtrToU for '%s', " + + "attempt to apply conversion on a non-pointer type", id); + } + Expression convertedPointer = expressions.makeCast(pointer, type, false); + Register register = builder.addRegister(id, type); + return builder.addEvent(EventFactory.newLocal(register, convertedPointer)); } @Override - public Void visitOpConvertUToPtr(SpirvParser.OpConvertUToPtrContext ctx) { + public Event visitOpConvertUToPtr(SpirvParser.OpConvertUToPtrContext ctx) { String id = ctx.idResult().getText(); - String typeId = ctx.idResultType().getText(); - if (!(builder.getType(typeId) instanceof ScopedPointerType)) { - throw new ParsingException("Type '%s' is not a pointer type for id '%s'", typeId, id); + Type type = builder.getType(ctx.idResultType().getText()); + Expression value = builder.getExpression(ctx.integerValue().getText()); + if (!(type instanceof ScopedPointerType)) { + throw new ParsingException("Illegal OpConvertUToPtr for '%s', " + + "attempt to convent into a non-pointer type", id); } - Expression integerExpr = builder.getExpression(ctx.integerValue().getText()); - Expression convertedInteger = expressions.makeCast(integerExpr, builder.getType(typeId), false); - Register reg = builder.addRegister(id, typeId); - builder.addEvent(EventFactory.newLocal(reg, convertedInteger)); - return null; + if (value.getType() instanceof ScopedPointerType + || !(value.getType() instanceof IntegerType)) { + throw new ParsingException("Illegal OpConvertUToPtr for '%s', " + + "attempt to apply conversion on a non-integer value", id); + } + Expression pointer = expressions.makeCast(value, type, false); + Register register = builder.addRegister(id, type); + return builder.addEvent(EventFactory.newLocal(register, pointer)); } @Override - public Void visitOpPtrCastToGeneric(SpirvParser.OpPtrCastToGenericContext ctx) { + public Event visitOpPtrCastToGeneric(SpirvParser.OpPtrCastToGenericContext ctx) { String id = ctx.idResult().getText(); - String typeId = ctx.idResultType().getText(); - if (!(builder.getType(typeId) instanceof ScopedPointerType genericType)) { - throw new ParsingException("Type '%s' is not a pointer type for id '%s'", typeId, id); - } - if (!genericType.getScopeId().equals(Tag.Spirv.SC_GENERIC)) { - throw new ParsingException("Invalid storage class '%s' for OpPtrCastToGeneric for id '%s'", genericType.getScopeId(), id); + Type type = builder.getType(ctx.idResultType().getText()); + Expression oldPointer = builder.getExpression(ctx.pointer().getText()); + if (!(type instanceof ScopedPointerType newType) + || !(oldPointer.getType() instanceof ScopedPointerType oldType)) { + throw new ParsingException("Illegal OpPointerCastToGeneric for '%s', " + + "attempt to apply cast to a non-pointer", id); } - String pointerId = ctx.pointer().getText(); - Expression pointer = builder.getExpression(pointerId); - if (!(pointer.getType() instanceof ScopedPointerType pointerType)) { - throw new ParsingException("Type '%s' is not a pointer type for id '%s'", pointerId, id); + if (!newType.getPointedType().equals(oldType.getPointedType())) { + throw new ParsingException("Illegal OpPointerCastToGeneric for '%s', " + + "result and original pointers point to different types", id); } - String pointerSC = pointerType.getScopeId(); - Set supportedSC = Set.of( - Tag.Spirv.SC_CROSS_WORKGROUP, - Tag.Spirv.SC_WORKGROUP, - Tag.Spirv.SC_FUNCTION); - if (!supportedSC.contains(pointerSC)) { - throw new ParsingException("Invalid storage class '%s' for OpPtrCastToGeneric for id '%s'", pointerSC, id); + if (!newType.getScopeId().equals(Tag.Spirv.SC_GENERIC)) { + throw new ParsingException("Illegal OpPointerCastToGeneric for '%s', " + + "attempt to cast into a non-generic pointer", id); } - Expression convertedExpr = expressions.makeCast(pointer, genericType); - Register reg = builder.addRegister(id, typeId); - builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); + Expression newPointer = expressions.makeScopedPointer(id, newType, oldPointer); + builder.addExpression(id, newPointer); return null; } @Override - public Void visitOpUConvert(SpirvParser.OpUConvertContext ctx) { + public Event visitOpUConvert(SpirvParser.OpUConvertContext ctx) { String id = ctx.idResult().getText(); String typeId = ctx.idResultType().getText(); Expression operandExpr = builder.getExpression(ctx.unsignedValue().getText()); - convertAndAddLocal(typeId, id, operandExpr, false); - return null; + return convertAndAddLocal(typeId, id, operandExpr, false); } @Override - public Void visitOpSConvert(SpirvParser.OpSConvertContext ctx) { + public Event visitOpSConvert(SpirvParser.OpSConvertContext ctx) { String id = ctx.idResult().getText(); String typeId = ctx.idResultType().getText(); Expression operandExpr = builder.getExpression(ctx.signedValue().getText()); - convertAndAddLocal(typeId, id, operandExpr, true); - return null; + return convertAndAddLocal(typeId, id, operandExpr, true); } - private void convertAndAddLocal(String typeId, String id, Expression operandExpr, boolean isSigned) { + private Event convertAndAddLocal(String typeId, String id, Expression operandExpr, boolean isSigned) { Type targetType = builder.getType(typeId); Type operandType = operandExpr.getType(); if (!(targetType instanceof IntegerType) || !(operandType instanceof IntegerType)) { @@ -136,7 +135,7 @@ private void convertAndAddLocal(String typeId, String id, Expression operandExpr } Expression convertedExpr = expressions.makeCast(operandExpr, targetType, isSigned); Register reg = builder.addRegister(id, typeId); - builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); + return builder.addEvent(EventFactory.newLocal(reg, convertedExpr)); } public Set getSupportedOps() { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java index 0831e54827..f33e216d36 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunction.java @@ -2,7 +2,6 @@ import com.dat3m.dartagnan.exception.ParsingException; import com.dat3m.dartagnan.expression.Expression; -import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.expression.type.FunctionType; import com.dat3m.dartagnan.expression.type.ScopedPointerType; @@ -11,7 +10,6 @@ import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; import com.dat3m.dartagnan.parsers.SpirvParser; import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Alignment; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperInputs; import com.dat3m.dartagnan.program.Function; import com.dat3m.dartagnan.program.Register; @@ -19,13 +17,11 @@ import com.dat3m.dartagnan.program.event.Tag; import com.dat3m.dartagnan.program.event.core.Local; import com.dat3m.dartagnan.program.event.functions.FunctionCall; -import com.dat3m.dartagnan.program.memory.ScopedPointer; import com.dat3m.dartagnan.program.memory.ScopedPointerVariable; import java.util.*; import java.util.stream.IntStream; -import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.ALIGNMENT; import static com.dat3m.dartagnan.program.event.EventFactory.newValueFunctionCall; import static com.dat3m.dartagnan.program.event.EventFactory.newVoidFunctionCall; @@ -33,12 +29,10 @@ public class VisitorOpsFunction extends SpirvBaseVisitor { private static final int DEFAULT_INPUT_SIZE = 10; private static final TypeFactory types = TypeFactory.getInstance(); - private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); private final Map forwardFunctions = new HashMap<>(); private final Map> forwardCalls = new HashMap<>(); private final Map parameters = new HashMap<>(); private final ProgramBuilder builder; - private final Alignment alignment; private String currentId; private FunctionType currentType; private List currentArgs; @@ -46,7 +40,6 @@ public class VisitorOpsFunction extends SpirvBaseVisitor { public VisitorOpsFunction(ProgramBuilder builder) { this.builder = builder; - this.alignment = (Alignment) builder.getDecorationsBuilder().getDecoration(ALIGNMENT); } @Override @@ -85,6 +78,7 @@ public Void visitOpFunctionParameter(SpirvParser.OpFunctionParameterContext ctx) "outside of a function definition", id); } Type type = builder.getType(ctx.idResultType().getText()); + // TODO: Apply FuncParameter decorations (ByVal, Zext, Sext) List argTypes = currentType.getParameterTypes(); int idx = currentArgs.size(); if (idx >= argTypes.size() || !type.equals(argTypes.get(idx))) { @@ -118,10 +112,7 @@ public Void visitOpFunctionCall(SpirvParser.OpFunctionCallContext ctx) { Type returnType = builder.getType(typeId); List args = ctx.argument().stream() .map(a -> builder.getExpression(a.getText())).toList(); - List argTypes = args.stream() - .map(e -> e instanceof ScopedPointer pBase - ? types.getScopedPointerType(pBase.getScopeId(), pBase.getInnerType()) - : e.getType()).toList(); + List argTypes = args.stream().map(Expression::getType).toList(); FunctionType functionType = types.getFunctionType(builder.getType(typeId), argTypes); Function function = getCalledFunction(functionId, functionType); FunctionCall event; @@ -190,15 +181,11 @@ private void checkFunctionType(String id, Function function, Type type) { } private Expression createEntryPointParameter(String id, Type type) { - Integer alignmentNum = alignment.getValue(id); - Expression alignmentExpr = alignmentNum == null ? - types.getDefaultAlignment() : expressions.makeValue(alignmentNum, types.getArchType()); Expression value = createEntryPointParameterValue(id, type); if (type instanceof ScopedPointerType pType) { String ptrId = HelperInputs.castPointerId(id); - pType = types.getScopedPointerType(pType.getScopeId(), value.getType()); - ScopedPointerVariable pointer = builder.allocateScopedPointerVariable( - ptrId, value, alignmentExpr, pType.getScopeId(), value.getType()); + pType = types.getScopedPointerType(pType.getScopeId(), value.getType(), pType.getStride()); + ScopedPointerVariable pointer = builder.allocateMemory(ptrId, pType, value); builder.addExpression(ptrId, pointer); value = pointer.getAddress(); } @@ -208,8 +195,6 @@ private Expression createEntryPointParameter(String id, Type type) { private Expression createEntryPointParameterValue(String id, Type type) { if (builder.hasInput(id)) { if (type instanceof ScopedPointerType pType) { - // TODO: Apply decoration FuncParamAttr: ByVal (no array creation), - // Sext (sign extended) and Zext (zero extended) return HelperInputs.castInput(id, types.getArrayType(pType.getPointedType()), builder.getInput(id)); } return HelperInputs.castInput(id, type, builder.getInput(id)); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java index 1e802a13b9..92ae31b6bd 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemory.java @@ -9,7 +9,6 @@ import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; import com.dat3m.dartagnan.parsers.SpirvParser; import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Alignment; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.BuiltIn; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperInputs; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperTags; @@ -30,7 +29,6 @@ import java.util.function.BiFunction; import java.util.stream.Collectors; -import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.ALIGNMENT; import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.BUILT_IN; import static com.dat3m.dartagnan.expression.utils.ExpressionHelper.isScalar; @@ -40,12 +38,10 @@ public class VisitorOpsMemory extends SpirvBaseVisitor { private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); private final ProgramBuilder builder; private final BuiltIn builtIn; - private final Alignment alignment; public VisitorOpsMemory(ProgramBuilder builder) { this.builder = builder; this.builtIn = (BuiltIn) builder.getDecorationsBuilder().getDecoration(BUILT_IN); - this.alignment = (Alignment) builder.getDecorationsBuilder().getDecoration(ALIGNMENT); } @Override @@ -54,7 +50,7 @@ public Event visitOpStore(SpirvParser.OpStoreContext ctx) { String valueId = ctx.object().getText(); Expression value = builder.getExpression(valueId); Type type = value.getType(); - List events = visitMemoryAccess(valueId, type, pointer, (i, exp) -> + List events = visitMemoryAccess(valueId, type, pointer, (i, exp) -> i == -1 ? EventFactory.newStore(exp, value) : EventFactory.newStore(exp, expressions.makeExtract(value, i))); @@ -88,7 +84,7 @@ public Event visitOpLoad(SpirvParser.OpLoadContext ctx) { builder.addExpression(resultId, expressions.makeConstruct(type, registers)); } if (type instanceof ArrayType arrayType) { - builder.addExpression(resultId, expressions.makeArray(arrayType.getElementType(), registers, true)); + builder.addExpression(resultId, expressions.makeArray(arrayType, registers)); } Set tags = parseMemoryAccessTags(ctx.memoryAccess()); checkAndPropagateTags(events, tags, Tag.Spirv.MEM_AVAILABLE, ctx.pointer().getText(), "OpLoad"); @@ -105,7 +101,7 @@ private List visitMemoryAccess(String id, Type type, Expression pointer, } for (int i = 0; i < arrayType.getNumElements(); i++) { List index = List.of(expressions.makeValue(i, types.getArchType())); - Expression address = expressions.makeGetElementPointer(arrayType.getElementType(), pointer, index); + Expression address = expressions.makeGetElementPointer(arrayType.getElementType(), pointer, index, arrayType.getStride()); events.add(f.apply(i, address)); } } else if (type instanceof AggregateType aggregateType) { @@ -128,10 +124,10 @@ private List visitMemoryAccess(String id, Type type, Expression pointer, private Set parseMemoryAccessTags(SpirvParser.MemoryAccessContext ctx) { if (ctx != null) { List operands = ctx.memoryAccessTag().stream().map(RuleContext::getText).toList(); - Integer alignment = ctx.literalInteger() != null ? Integer.parseInt(ctx.literalInteger().getText()) : null; + Integer alignmentTag = ctx.literalInteger() != null ? Integer.parseInt(ctx.literalInteger().getText()) : null; List paramIds = ctx.idRef().stream().map(RuleContext::getText).toList(); List paramsValues = ctx.idRef().stream().map(c -> builder.getExpression(c.getText())).toList(); - return HelperTags.parseMemoryOperandsTags(operands, alignment, paramIds, paramsValues); + return HelperTags.parseMemoryOperandsTags(operands, alignmentTag, paramIds, paramsValues); } return Set.of(); } @@ -152,34 +148,26 @@ private void checkAndPropagateTags(List events, Set tags, String @Override public Event visitOpVariable(SpirvParser.OpVariableContext ctx) { String id = ctx.idResult().getText(); - String typeId = ctx.idResultType().getText(); - if (builder.getType(typeId) instanceof ScopedPointerType pointerType) { - Type type = pointerType.getPointedType(); - Integer alignmentNum = alignment.getValue(id); - Expression alignmentExpr = alignmentNum == null ? - types.getDefaultAlignment() : expressions.makeValue(alignmentNum, types.getArchType()); - if (alignmentNum != null) { - type = HelperTypes.getAlignedType(type, alignmentNum); - } + Type type = builder.getType(ctx.idResultType().getText()); + if (type instanceof ScopedPointerType pType) { + type = pType.getPointedType(); Expression value = getOpVariableInitialValue(ctx, type); if (value != null) { if (!TypeFactory.isStaticTypeOf(value.getType(), type)) { throw new ParsingException("Mismatching value type for variable '%s', " + "expected '%s' but received '%s'", id, type, value.getType()); } - type = value.getType(); } else if (!TypeFactory.isStaticType(type)) { throw new ParsingException("Missing initial value for runtime variable '%s'", id); } else { value = builder.makeUndefinedValue(type); } - ScopedPointerVariable pointer = builder.allocateScopedPointerVariable(id, value, alignmentExpr, - pointerType.getScopeId(), type); + ScopedPointerVariable pointer = builder.allocateMemory(id, pType, value); validateVariableStorageClass(pointer, ctx.storageClass().getText()); builder.addExpression(id, pointer); return null; } - throw new ParsingException("Type '%s' is not a pointer type", typeId); + throw new ParsingException("Type '%s' is not a pointer type", ctx.idResultType().getText()); } private Expression getOpVariableInitialValue(SpirvParser.OpVariableContext ctx, Type type) { @@ -198,14 +186,10 @@ private Expression getOpVariableInitialValue(SpirvParser.OpVariableContext ctx, } return builtIn.getDecoration(id, type); } - if (ctx.initializer() == null) { - return null; + if (ctx.initializer() != null) { + return builder.getExpression(ctx.initializer().getText()); } - Expression initExpr = builder.getExpression(ctx.initializer().getText()); - if (alignment.getValue(id) != null) { - initExpr = builder.getAlignedValue(id, initExpr, type); - } - return initExpr; + return null; } private void validateVariableStorageClass(ScopedPointerVariable pointer, String classToken) { @@ -273,7 +257,7 @@ private Event visitOpAccessChain(SpirvParser.IdResultContext idCtx, SpirvParser. } else { exprIndexes.addFirst(builder.getExpression(elCtx.getText())); } - Expression expression = expressions.makeGetElementPointer(baseType, base, exprIndexes); + Expression expression = expressions.makeGetElementPointer(baseType, base, exprIndexes, basePointerType.getStride()); expression = new ScopedPointer(idCtx.getText(), resultPointerType, expression); builder.addExpression(idCtx.getText(), expression); return null; diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsType.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsType.java index db51231f70..52bc93318d 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsType.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsType.java @@ -1,5 +1,6 @@ package com.dat3m.dartagnan.parsers.program.visitors.spirv; +import com.dat3m.dartagnan.configuration.Arch; import com.dat3m.dartagnan.exception.ParsingException; import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.expression.Type; @@ -7,6 +8,7 @@ import com.dat3m.dartagnan.expression.type.TypeFactory; import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; import com.dat3m.dartagnan.parsers.SpirvParser; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.ArrayStride; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Offset; import com.dat3m.dartagnan.parsers.program.visitors.spirv.helpers.HelperTags; @@ -15,16 +17,20 @@ import java.util.*; import java.util.stream.IntStream; +import static com.dat3m.dartagnan.expression.utils.ExpressionHelper.isScalar; + public class VisitorOpsType extends SpirvBaseVisitor { private static final TypeFactory types = TypeFactory.getInstance(); private final ProgramBuilder builder; private final Offset offset; + private final ArrayStride arrayStride; public VisitorOpsType(ProgramBuilder builder) { this.builder = builder; this.offset = (Offset) builder.getDecorationsBuilder().getDecoration(DecorationType.OFFSET); + this.arrayStride = (ArrayStride) builder.getDecorationsBuilder().getDecoration(DecorationType.ARRAY_STRIDE); } @Override @@ -60,8 +66,17 @@ public Type visitOpTypeVector(SpirvParser.OpTypeVectorContext ctx) { String id = ctx.idResult().getText(); String elementTypeName = ctx.componentTypeIdRef().getText(); Type elementType = builder.getType(elementTypeName); + if (!isScalar(elementType)) { + throw new ParsingException("Attempt to use a non-scalar element in vector type '%s'", id); + } int size = Integer.parseInt(ctx.componentCountLiteralInteger().getText()); - Type type = types.getArrayType(elementType, size); + Integer alignment = null; + if (builder.getArch() == Arch.OPENCL && size == 3) { + // In OpenCL, vectors with 3 elements should be aligned to 4 elements + // https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/alignmentOfDataTypes.html + alignment = 4 * types.getMemorySizeInBytes(elementType); + } + Type type = types.getArrayType(elementType, size, null, alignment); return builder.addType(id, type); } @@ -74,7 +89,8 @@ public Type visitOpTypeArray(SpirvParser.OpTypeArrayContext ctx) { Expression lengthExpr = builder.getExpression(lengthValueName); if (lengthExpr != null) { if (lengthExpr instanceof IntLiteral iValue) { - Type type = types.getArrayType(elementType, iValue.getValue().intValue()); + validateArrayStride(id, elementType); + Type type = types.getArrayType(elementType, iValue.getValue().intValue(), arrayStride.getValue(id)); return builder.addType(id, type); } throw new ParsingException("Attempt to use a non-integer value as array size '%s'", lengthValueName); @@ -87,7 +103,8 @@ public Type visitOpTypeRuntimeArray(SpirvParser.OpTypeRuntimeArrayContext ctx) { String id = ctx.idResult().getText(); String elementTypeName = ctx.elementType().getText(); Type elementType = builder.getType(elementTypeName); - Type type = types.getArrayType(elementType); + validateArrayStride(id, elementType); + Type type = types.getArrayType(elementType, -1, arrayStride.getValue(id)); return builder.addType(id, type); } @@ -119,7 +136,9 @@ public Type visitOpTypePointer(SpirvParser.OpTypePointerContext ctx) { String id = ctx.idResult().getText(); String inner = ctx.type().getText(); String storageClass = HelperTags.parseStorageClass(ctx.storageClass().getText()); - Type type = types.getScopedPointerType(storageClass, builder.getType(inner)); + Type elementType = builder.getType(inner); + validateArrayStride(id, elementType); + Type type = types.getScopedPointerType(storageClass, elementType, arrayStride.getValue(id)); return builder.addType(id, type); } @@ -134,6 +153,17 @@ public Type visitOpTypeFunction(SpirvParser.OpTypeFunctionContext ctx) { return builder.addType(id, type); } + private void validateArrayStride(String id, Type elType) { + Integer stride = arrayStride.getValue(id); + if (stride != null) { + int elSize = types.getMemorySizeInBytes(elType); + if (elSize > 0 && elSize > stride) { + throw new ParsingException("Illegal array definition of type '%s', " + + "element size %d exceeds the ArrayStride value %d", id, elSize, stride); + } + } + } + public Set getSupportedOps() { return Set.of( "OpTypeVoid", diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java index b2422dfba4..e5a24e65bf 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/DecorationsBuilder.java @@ -13,9 +13,9 @@ public class DecorationsBuilder { private final EnumMap mapping = new EnumMap<>(DecorationType.class); public DecorationsBuilder(ThreadGrid grid) { + mapping.put(ARRAY_STRIDE, new ArrayStride()); mapping.put(BUILT_IN, new BuiltIn(grid)); mapping.put(OFFSET, new Offset()); - mapping.put(ALIGNMENT, new Alignment()); } public Decoration getDecoration(DecorationType type) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java index f57a7d8ff9..10f4db6083 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/builders/ProgramBuilder.java @@ -5,8 +5,9 @@ import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; -import com.dat3m.dartagnan.expression.aggregates.ConstructExpr; -import com.dat3m.dartagnan.expression.type.*; +import com.dat3m.dartagnan.expression.type.FunctionType; +import com.dat3m.dartagnan.expression.type.ScopedPointerType; +import com.dat3m.dartagnan.expression.type.TypeFactory; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.BuiltIn; import com.dat3m.dartagnan.program.*; import com.dat3m.dartagnan.program.event.Event; @@ -19,11 +20,9 @@ import com.dat3m.dartagnan.program.processing.transformers.MemoryTransformer; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.IntStream; import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.BUILT_IN; @@ -50,34 +49,6 @@ public ProgramBuilder(ThreadGrid grid) { this.decorationsBuilder = new DecorationsBuilder(grid); } - public Expression getAlignedValue(String id, Expression base, Type type) { - if (type instanceof AggregateType aggregateType && base instanceof ConstructExpr constructExpr) { - List elements = aggregateType.getFields().stream() - .map(field -> { - int index = aggregateType.getFields().indexOf(field); - return getAlignedValue(id, constructExpr.getOperands().get(index), field.type()); - }) - .collect(Collectors.toList()); - return ExpressionFactory.getInstance().makeConstruct(type, elements); - } - if (type instanceof ArrayType arrayType && base instanceof ConstructExpr constructExpr) { - int numOperands = constructExpr.getOperands().size(); - if (arrayType.getNumElements() < numOperands) { - throw new ParsingException("Array initializer has too many elements for variable '%s'", id); - } - List elements = IntStream.range(0, arrayType.getNumElements()) - .mapToObj(i -> i < numOperands - ? getAlignedValue(id, constructExpr.getOperands().get(i), arrayType.getElementType()) - : makeUndefinedValue(arrayType.getElementType())) - .collect(Collectors.toList()); - return ExpressionFactory.getInstance().makeArray(arrayType.getElementType(), elements, true); - } - if (base.getType().equals(type)) { - return base; - } - throw new ParsingException("Cannot align initializer for variable '" + id + "' of type " + type); - } - public Program build() { validateBeforeBuild(); controlFlowBuilder.build(); @@ -126,6 +97,10 @@ public void setEntryPointId(String id) { entryPointId = id; } + public Arch getArch() { + return arch; + } + public void setArch(Arch arch) { if (this.arch != null) { throw new ParsingException("Illegal attempt to override memory model"); @@ -209,18 +184,17 @@ public Set getVariables() { .collect(Collectors.toSet()); } - public ScopedPointerVariable allocateScopedPointerVariable(String id, Expression initValue, - Expression alignment, String storageClass, Type pointedType) { - int bytes = TypeFactory.getInstance().getMemorySizeInBytes(pointedType); - MemoryObject memObj = program.getMemory().allocateVirtual(bytes, true, alignment, null); + public ScopedPointerVariable allocateMemory(String id, ScopedPointerType type, Expression value) { + int size = TypeFactory.getInstance().getMemorySizeInBytes(value.getType()); + MemoryObject memObj = program.getMemory().allocateVirtual(size, true, null); + memObj.setInitialValue(0, value); memObj.setName(id); memObj.setIsThreadLocal(false); - memObj.setInitialValue(0, initValue); if (arch == Arch.OPENCL) { - String openCLSpace = Tag.Spirv.toOpenCLTag(Tag.Spirv.getStorageClassTag(Set.of(storageClass))); + String openCLSpace = Tag.Spirv.toOpenCLTag(Tag.Spirv.getStorageClassTag(Set.of(type.getScopeId()))); memObj.addFeatureTag(openCLSpace); } - return ExpressionFactory.getInstance().makeScopedPointerVariable(id, storageClass, pointedType, memObj); + return ExpressionFactory.getInstance().makeScopedPointerVariable(id, type, memObj); } public String getPointerStorageClass(String id) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/ArrayStride.java similarity index 80% rename from dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java rename to dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/ArrayStride.java index d9bec81264..3c8a332fcb 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/Alignment.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/ArrayStride.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.Map; -public class Alignment implements Decoration { +public class ArrayStride implements Decoration { private final Map mapping = new HashMap<>(); @@ -15,8 +15,8 @@ public void addDecoration(String id, String... params) { throw new ParsingException("Illegal decoration '%s' for '%s'", getClass().getSimpleName(), id); } - int alignment = Integer.parseInt(params[0]); - mapping.put(id, alignment); + int arrayStride = Integer.parseInt(params[0]); + mapping.put(id, arrayStride); } public Integer getValue(String id) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/BuiltIn.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/BuiltIn.java index 6604aa98b3..33c9120919 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/BuiltIn.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/decorations/BuiltIn.java @@ -4,10 +4,8 @@ import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; -import com.dat3m.dartagnan.expression.aggregates.ConstructExpr; import com.dat3m.dartagnan.expression.type.ArrayType; import com.dat3m.dartagnan.expression.type.IntegerType; -import com.dat3m.dartagnan.expression.type.TypeFactory; import com.dat3m.dartagnan.program.ThreadGrid; import com.dat3m.dartagnan.program.memory.MemoryObject; @@ -18,7 +16,6 @@ public class BuiltIn implements Decoration { - private static final TypeFactory types = TypeFactory.getInstance(); private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); private final ThreadGrid grid; private final Map mapping; @@ -48,16 +45,7 @@ public void addDecoration(String id, String... params) { public void decorate(String id, MemoryObject memObj, Type type) { if (mapping.containsKey(id)) { - Expression expression = getDecoration(id, type); - if (expression instanceof ConstructExpr cExpr) { - Type elementType = getArrayElementType(id, type); - int size = types.getMemorySizeInBytes(elementType); - memObj.setInitialValue(0, cExpr.getOperands().get(0)); - memObj.setInitialValue(size, cExpr.getOperands().get(1)); - memObj.setInitialValue(size * 2, cExpr.getOperands().get(2)); - } else { - memObj.setInitialValue(0, expression); - } + memObj.setInitialValue(0, getDecorationExpressions(id, type)); } } @@ -96,7 +84,7 @@ private Expression makeArray(String id, Type type, int x, int y, int z) { operands.add(expressions.makeValue(x, elementType)); operands.add(expressions.makeValue(y, elementType)); operands.add(expressions.makeValue(z, elementType)); - return expressions.makeArray(elementType, operands, true); + return expressions.makeArray((ArrayType) type, operands); } private Expression makeScalar(String id, Type type, int x) { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/extenstions/VisitorExtensionOpenClStd.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/extenstions/VisitorExtensionOpenClStd.java index 6dbe05f901..929048de20 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/extenstions/VisitorExtensionOpenClStd.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/extenstions/VisitorExtensionOpenClStd.java @@ -47,7 +47,7 @@ public Expression visitOpencl_s_add_sat(SpirvParser.Opencl_s_add_satContext ctx) expressions.makeExtract(y, i) )); } - return expressions.makeArray(xType.getElementType(), sums, true); + return expressions.makeArray(xType, sums); } throw new ParsingException("Unsupported types for s_add_sat: %s and %s", x.getType(), y.getType()); } @@ -69,7 +69,7 @@ public Expression visitOpencl_s_sub_sat(SpirvParser.Opencl_s_sub_satContext ctx) expressions.makeExtract(y, i) )); } - return expressions.makeArray(xType.getElementType(), subs, true); + return expressions.makeArray(xType, subs); } throw new ParsingException("Unsupported types for s_sub_sat: %s and %s", x.getType(), y.getType()); } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputs.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputs.java index 52f1f3d649..223c1f78f4 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputs.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputs.java @@ -24,13 +24,19 @@ public static String castPointerId(String id) { } public static Expression castInput(String id, Type type, Expression value) { - if (type instanceof ArrayType aType) { - return castArray(id, aType, value); - } - if (type instanceof AggregateType aType) { - return castAggregate(id, aType, value); + if (!(type instanceof ScopedPointerType)) { + if (type.equals(value.getType())) { + return value; + } + if (type instanceof ArrayType aType) { + return castArray(id, aType, value); + } + if (type instanceof AggregateType aType) { + return castAggregate(id, aType, value); + } + return castScalar(id, type, value); } - return castScalar(id, type, value); + throw new ParsingException(errorMismatchingType(id, type, value.getType())); } private static Expression castArray(String id, ArrayType type, Expression value) { @@ -38,12 +44,24 @@ private static Expression castArray(String id, ArrayType type, Expression value) int expectedSize = type.getNumElements(); int actualSize = aValue.getOperands().size(); if (expectedSize == -1 || expectedSize == actualSize) { - Type elementType = type.getElementType(); + Type elType = type.getElementType(); List elements = new ArrayList<>(); for (int i = 0; i < actualSize; i++) { - elements.add(castInput(String.format("%s[%d]", id, i), elementType, aValue.getOperands().get(i))); + elements.add(castInput(String.format("%s[%d]", id, i), elType, aValue.getOperands().get(i))); + } + long distinctTypeCount = elements.stream().map(Expression::getType).distinct().count(); + if (distinctTypeCount <= 1) { + if (!elements.isEmpty()) { + elType = elements.get(0).getType(); + if (type.getStride() != null && type.getStride() < types.getMemorySizeInBytes(elType)) { + throw new ParsingException("Mismatching value type for variable '%s', " + + "element size %d is greater than array stride %d", id, + types.getMemorySizeInBytes(elType), type.getStride()); + } + } + ArrayType aType = types.getArrayType(elType, actualSize, type.getStride(), type.getAlignment()); + return expressions.makeArray(aType, elements); } - return expressions.makeArray(elements.get(0).getType(), elements, true); } } throw new ParsingException(errorMismatchingType(id, type, value.getType())); @@ -68,7 +86,7 @@ private static Expression castAggregate(String id, AggregateType type, Expressio } private static Expression castScalar(String id, Type type, Expression value) { - if (!(type instanceof ScopedPointerType) && value instanceof IntLiteral iConst) { + if (value instanceof IntLiteral iConst) { int iValue = iConst.getValueAsInt(); if (type instanceof BooleanType) { return iValue == 0 ? expressions.makeFalse() : expressions.makeTrue(); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java index edab3fd985..ac4c65083a 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperTypes.java @@ -6,22 +6,17 @@ import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.expression.aggregates.ConstructExpr; import com.dat3m.dartagnan.expression.integers.IntBinaryOp; -import com.dat3m.dartagnan.expression.integers.IntLiteral; import com.dat3m.dartagnan.expression.type.*; import java.util.ArrayList; import java.util.List; -import java.util.stream.IntStream; -import static com.dat3m.dartagnan.expression.integers.IntBinaryOp.ADD; -import static com.dat3m.dartagnan.expression.integers.IntBinaryOp.MUL; import static com.dat3m.dartagnan.expression.utils.ExpressionHelper.isScalar; public class HelperTypes { private static final TypeFactory types = TypeFactory.getInstance(); private static final ExpressionFactory expressions = ExpressionFactory.getInstance(); - private static final IntegerType archType = types.getArchType(); private HelperTypes() { } @@ -54,20 +49,6 @@ public static int getMemberOffset(String id, int offset, Type type, List indexes) { - if (!indexes.isEmpty()) { - id += "[" + indexes.get(0) + "]"; - if (type instanceof ArrayType aType) { - return getArrayMemberAddress(id, base, aType, indexes); - } - if (type instanceof AggregateType aType) { - return getStructMemberAddress(id, base, aType, indexes); - } - throw new ParsingException(indexTooDeepError(id)); - } - return base; - } - public static Expression createResultExpression(String id, Type type, Expression op1, Expression op2, IntBinaryOp op) { if (isScalar(type)) { return expressions.makeBinary(op1, op, op2); @@ -79,7 +60,7 @@ public static Expression createResultExpression(String id, Type type, Expression Expression elementOp2 = op2 instanceof ConstructExpr ? op2.getOperands().get(i) : expressions.makeExtract(op2, i); elements.add(expressions.makeBinary(elementOp1, op, elementOp2)); } - return expressions.makeArray(aType.getElementType(), elements, true); + return expressions.makeArray(aType, elements); } throw new ParsingException("Illegal result type in definition of '%s'", id); } @@ -108,7 +89,11 @@ private static int getArrayMemberOffset(String id, int offset, ArrayType type, L if (index >= 0) { if (type.getNumElements() < 0 || index < type.getNumElements()) { Type elType = type.getElementType(); - offset += types.getOffsetInBytes(type, index); + if (type.getStride() != null) { + offset += index * type.getStride(); + } else { + offset += types.getOffsetInBytes(type, index); + } return getMemberOffset(id, offset, elType, indexes.subList(1, indexes.size())); } throw new ParsingException(indexOutOfBoundsError(id)); @@ -129,32 +114,6 @@ private static int getStructMemberOffset(String id, int offset, AggregateType ty throw new ParsingException(indexNonConstantError(id)); } - private static Expression getArrayMemberAddress(String id, Expression base, ArrayType type, List indexes) { - Type elementType = type.getElementType(); - int size = types.getMemorySizeInBytes(elementType); - IntLiteral sizeExpr = expressions.makeValue(size, archType); - Expression indexExpr = expressions.makeIntegerCast(indexes.get(0), archType, false); - Expression offsetExpr = expressions.makeBinary(sizeExpr, MUL, indexExpr); - Expression expression = expressions.makeBinary(base, ADD, offsetExpr); - return getMemberAddress(id, expression, elementType, indexes.subList(1, indexes.size())); - } - - private static Expression getStructMemberAddress(String id, Expression base, AggregateType type, List indexes) { - Expression indexExpr = indexes.get(0); - if (indexExpr instanceof IntLiteral intLiteral) { - int index = intLiteral.getValueAsInt(); - if (index < type.getFields().size()) { - Type subType = type.getFields().get(index).type(); - int offset = type.getFields().get(index).offset(); - IntLiteral offsetExpr = expressions.makeValue(offset, archType); - Expression expression = expressions.makeBinary(base, ADD, offsetExpr); - return getMemberAddress(id, expression, subType, indexes.subList(1, indexes.size())); - } - throw new ParsingException(indexOutOfBoundsError(id)); - } - throw new ParsingException(indexNonConstantForStructError(id)); - } - private static String indexTooDeepError(String id) { return String.format("Index is too deep for variable '%s'", id); } @@ -170,37 +129,4 @@ private static String indexNonConstantError(String id) { private static String indexNonConstantForStructError(String id) { return String.format("Index of a struct member is non-constant for variable '%s'", id); } - - public static Type getAlignedType(Type type, int alignmentNum) { - if (type instanceof IntegerType) { - return types.getIntegerType(alignmentNum * 8); - } - if (type instanceof AggregateType aggregateType) { - List fieldTypes = new ArrayList<>(); - for (int i = 0; i < aggregateType.getFields().size(); i++) { - Type fieldType = aggregateType.getFields().get(i).type(); - if (types.getMemorySizeInBytes(fieldType) > alignmentNum) { - fieldType = getAlignedType(fieldType, alignmentNum); - } - fieldTypes.add(fieldType); - } - List alignmentList = new ArrayList<>(List.of(0)); - IntStream.range(0, fieldTypes.size() - 1).forEach(i -> { - int fieldAlignment = types.getMemorySizeInBytes(fieldTypes.get(i)); - alignmentList.add(fieldAlignment + alignmentList.get(i)); - }); - return types.getAggregateType(fieldTypes, alignmentList); - } - if (type instanceof ArrayType arrayType) { - Type elementType = arrayType.getElementType(); - int arraySizeInBytes = types.getMemorySizeInBytes(arrayType); - if (arraySizeInBytes > alignmentNum) { - return types.getArrayType(getAlignedType(elementType, alignmentNum), arrayType.getNumElements()); - } - int paddedSize = alignmentNum / types.getMemorySizeInBytes(elementType); - int paddingStart = arrayType.getNumElements(); - return types.getArrayType(elementType, paddedSize, paddingStart); - } - throw new ParsingException("Invalid type '%s' for alignment '%d'", type, alignmentNum); - } } diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/Program.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/Program.java index f0de7102db..d66cdb3f52 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/Program.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/Program.java @@ -158,7 +158,7 @@ public Expression newConstant(Type type) { for (int i = 0; i < arrayType.getNumElements(); i++) { entries.add(newConstant(arrayType.getElementType())); } - return expressions.makeArray(arrayType.getElementType(), entries, true); + return expressions.makeArray(arrayType, entries); } if (type instanceof AggregateType aggregateType) { final List elements = new ArrayList<>(aggregateType.getFields().size()); diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java index ce0283e756..748fb994a1 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/memory/Memory.java @@ -16,17 +16,12 @@ public class Memory { private final ArrayList objects = new ArrayList<>(); private final Type ptrType = TypeFactory.getInstance().getPointerType(); private final IntegerType archType = TypeFactory.getInstance().getArchType(); - private final TypeFactory types = TypeFactory.getInstance(); + private final Expression defaultAlignment = ExpressionFactory.getInstance().makeValue(8, archType); private int nextIndex = 1; // Generates a new, statically allocated memory object. public MemoryObject allocate(int size) { - final Expression defaultAlignment = types.getDefaultAlignment(); - return allocate(size, defaultAlignment); - } - - public MemoryObject allocate(int size, Expression defaultAlignment) { Preconditions.checkArgument(size > 0, "Illegal allocation. Size must be positive"); final Expression sizeExpr = ExpressionFactory.getInstance().makeValue(size, archType); final MemoryObject memoryObject = new MemoryObject(nextIndex++, sizeExpr, defaultAlignment, null, ptrType); @@ -44,14 +39,9 @@ public MemoryObject allocate(Alloc allocationSite) { } public VirtualMemoryObject allocateVirtual(int size, boolean generic, VirtualMemoryObject alias) { - return allocateVirtual(size, generic, types.getDefaultAlignment(), alias); - } - - public VirtualMemoryObject allocateVirtual(int size, boolean generic, Expression alignment, - VirtualMemoryObject alias) { Preconditions.checkArgument(size > 0, "Illegal allocation. Size must be positive"); final Expression sizeExpr = ExpressionFactory.getInstance().makeValue(size, archType); - final VirtualMemoryObject address = new VirtualMemoryObject(nextIndex++, sizeExpr, alignment, + final VirtualMemoryObject address = new VirtualMemoryObject(nextIndex++, sizeExpr, defaultAlignment, generic, alias, ptrType); objects.add(address); return address; @@ -63,7 +53,6 @@ public boolean deleteMemoryObject(MemoryObject obj) { /** * Accesses all shared variables. - * * @return Copy of the complete collection of allocated objects. */ public ImmutableSet getObjects() { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/GEPToAddition.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/GEPToAddition.java index 2b5b17f667..d8b621a5fb 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/GEPToAddition.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/GEPToAddition.java @@ -2,7 +2,6 @@ import com.dat3m.dartagnan.exception.MalformedProgramException; import com.dat3m.dartagnan.expression.Expression; -import com.dat3m.dartagnan.expression.ExpressionFactory; import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.expression.integers.IntLiteral; import com.dat3m.dartagnan.expression.misc.GEPExpr; @@ -10,7 +9,6 @@ import com.dat3m.dartagnan.expression.type.AggregateType; import com.dat3m.dartagnan.expression.type.ArrayType; import com.dat3m.dartagnan.expression.type.IntegerType; -import com.dat3m.dartagnan.expression.type.TypeFactory; import com.dat3m.dartagnan.program.Function; import com.dat3m.dartagnan.program.Program; import com.dat3m.dartagnan.program.event.RegReader; @@ -66,32 +64,28 @@ public void run(Program program) { private static final class GEPToAdditionTransformer extends ExprTransformer { - private final TypeFactory types = TypeFactory.getInstance(); - private final ExpressionFactory expressions = ExpressionFactory.getInstance(); - @Override public Expression visitGEPExpression(GEPExpr gep) { final List indices = gep.getOffsets(); final IntegerType offsetType = (IntegerType) indices.get(0).getType(); - + final Integer baseStride = gep.getStride(); Type indexingType = gep.getIndexingType(); - Expression totalOffset = expressions.makeMul( - expressions.makeValue(types.getMemorySizeInBytes(indexingType), offsetType), - indices.get(0) - ); + + final int baseSize = baseStride != null ? baseStride : types.getMemorySizeInBytes(indexingType); + Expression totalOffset = expressions.makeMul(expressions.makeValue(baseSize, offsetType), indices.get(0)); + for (Expression index : indices.subList(1, indices.size())) { Expression offset; if (indexingType instanceof AggregateType aggType && index instanceof IntLiteral lit) { final int intIndex = lit.getValueAsInt(); final int intOffset = types.getOffsetInBytes(aggType, intIndex); - offset = expressions.makeValue(intOffset, offsetType); indexingType = aggType.getFields().get(intIndex).type(); } else if (indexingType instanceof ArrayType arrayType) { - final int elementSize = types.getMemorySizeInBytes(arrayType.getElementType()); - final Expression scaling = expressions.makeValue(elementSize, offsetType); + Integer stride = arrayType.getStride(); + final int elSize = stride != null ? stride : types.getMemorySizeInBytes(arrayType.getElementType()); + final Expression scaling = expressions.makeValue(elSize, offsetType); final Expression castIndex = expressions.makeCast(index, offsetType, true); - offset = expressions.makeMul(scaling, castIndex); indexingType = arrayType.getElementType(); } else { diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java index 4d21f5e641..ce5b116e13 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/transformers/MemoryTransformer.java @@ -1,7 +1,10 @@ package com.dat3m.dartagnan.program.processing.transformers; import com.dat3m.dartagnan.expression.Expression; +import com.dat3m.dartagnan.expression.Type; import com.dat3m.dartagnan.expression.processing.ExprTransformer; +import com.dat3m.dartagnan.expression.type.ScopedPointerType; +import com.dat3m.dartagnan.expression.type.TypeFactory; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.BuiltIn; import com.dat3m.dartagnan.program.Thread; import com.dat3m.dartagnan.program.*; @@ -22,6 +25,7 @@ public class MemoryTransformer extends ExprTransformer { // Thread / Subgroup / Workgroup / QueueFamily / Device private static final List namePrefixes = List.of("T", "S", "W", "Q", "D"); + private static final Type archType = TypeFactory.getInstance().getArchType(); private final Program program; private final Function function; @@ -62,7 +66,10 @@ public void setThread(Thread thread) { tid = newTid; builtIn.setThreadId(tid); registerMapping = function.getRegisters().stream().collect( - toMap(r -> r, r -> thread.getOrNewRegister(r.getName(), r.getType()))); + toMap(r -> r, r -> { + Type type = r.getType() instanceof ScopedPointerType ? archType : r.getType(); + return thread.getOrNewRegister(r.getName(), type); + })); nonDetMapping = new HashMap<>(); } @@ -114,8 +121,8 @@ private Expression applyMapping(MemoryObject memObj, int scopeDepth) { Map mapping = scopeMapping.get(scopeDepth); if (!mapping.containsKey(memObj)) { MemoryObject copy = memObj instanceof VirtualMemoryObject - ? program.getMemory().allocateVirtual(memObj.getKnownSize(), true, memObj.alignment(), null) - : program.getMemory().allocate(memObj.getKnownSize(), memObj.alignment()); + ? program.getMemory().allocateVirtual(memObj.getKnownSize(), true, null) + : program.getMemory().allocate(memObj.getKnownSize()); copy.setName(makeVariableName(scopeDepth, memObj.getName())); for (int offset : memObj.getInitializedFields()) { Expression value = memObj.getInitialValue(offset); diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java index 77c95ac9ff..f1c2c3d865 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsAnnotationTest.java @@ -1,11 +1,9 @@ package com.dat3m.dartagnan.parsers.program.visitors.spirv; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Alignment; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Offset; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockProgramBuilder; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockSpirvParser; -import com.dat3m.dartagnan.program.memory.ScopedPointerVariable; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -14,19 +12,6 @@ public class VisitorOpsAnnotationTest { private final MockProgramBuilder builder = new MockProgramBuilder(); - @Test - public void testAlignment() { - // given - String input = "OpDecorate %v_uint_aligned Alignment 16"; - - // when - visit(input); - - // then - Alignment alignment = (Alignment) builder.getDecorationsBuilder().getDecoration(DecorationType.ALIGNMENT); - assertEquals(16, (long) alignment.getValue("%v_uint_aligned")); - } - @Test public void testOffset() { // given diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsCompositeTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsCompositeTest.java index b9bf9b9f90..ac6e51d33d 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsCompositeTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsCompositeTest.java @@ -341,7 +341,7 @@ public void testCompositeInsertWrongType1() { builder.mockAggregateType("%struct1", "%array", "%array1"); builder.mockConstant("%test", "%array", List.of(1, 2, 3, 4)); - builder.mockConstant("%test1", "%array", List.of(1, 2)); + builder.mockConstant("%test1", "%array1", List.of(1, 2)); builder.mockConstant("%base", "%struct", List.of("%test1", "%test")); builder.mockConstant("%value", "%uint32", 99); @@ -850,8 +850,7 @@ public void testCompositeConstructMissingOperandArray() { visit(input); fail("Should throw exception"); } catch (Exception e) { - assertEquals("There must be exactly one constituent for each top-level element of the result " + - "(\"flattening\" vectors is not yet supported) and their types should match for '%result'", e.getMessage()); + assertEquals("The number of elements must match Offending id: '%result'", e.getMessage()); } } diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstantTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstantTest.java index ae5d037f71..5d73072e90 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstantTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConstantTest.java @@ -3,10 +3,7 @@ import com.dat3m.dartagnan.exception.ParsingException; import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.expression.ExpressionFactory; -import com.dat3m.dartagnan.expression.type.AggregateType; -import com.dat3m.dartagnan.expression.type.BooleanType; -import com.dat3m.dartagnan.expression.type.IntegerType; -import com.dat3m.dartagnan.expression.type.TypeFactory; +import com.dat3m.dartagnan.expression.type.*; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockProgramBuilder; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockSpirvParser; import org.junit.Test; @@ -119,8 +116,8 @@ public void testOpConstantSpecCompositeBoolean() { private void doTestOpConstantBoolean(String input) { // given - BooleanType bType = builder.mockBoolType("%bool"); - builder.mockVectorType("%bool3v", "%bool", 3); + builder.mockBoolType("%bool"); + ArrayType type = builder.mockVectorType("%bool3v", "%bool", 3); // when Map data = parseConstants(input); @@ -130,7 +127,7 @@ private void doTestOpConstantBoolean(String input) { Expression bTrue = expressions.makeTrue(); Expression bFalse = expressions.makeFalse(); - Expression b3v = expressions.makeArray(bType, List.of(bTrue, bFalse, bTrue), true); + Expression b3v = expressions.makeArray(type, List.of(bTrue, bFalse, bTrue)); assertEquals(bTrue, data.get("%b1")); assertEquals(bFalse, data.get("%b2")); @@ -163,7 +160,7 @@ public void testOpConstantSpecCompositeInteger() { private void doTestOpConstantInteger(String input) { // given IntegerType iType = builder.mockIntType("%int", 64); - builder.mockVectorType("%int4v", "%int", 4); + ArrayType type = builder.mockVectorType("%int4v", "%int", 4); // when Map data = parseConstants(input); @@ -175,7 +172,7 @@ private void doTestOpConstantInteger(String input) { Expression i2 = expressions.makeValue(0, iType); Expression i3 = expressions.makeValue(17, iType); Expression i4 = expressions.makeValue(-123, iType); - Expression i4v = expressions.makeArray(iType, List.of(i1, i2, i3, i4), true); + Expression i4v = expressions.makeArray(type, List.of(i1, i2, i3, i4)); assertEquals(i1, data.get("%i1")); assertEquals(i2, data.get("%i2")); @@ -296,7 +293,7 @@ public void testNestedCompositeTypes() { builder.mockBoolType("%bool"); IntegerType iType = builder.mockIntType("%int", 64); AggregateType innerType = builder.mockAggregateType("%inner", "%bool", "%int"); - builder.mockVectorType("%v2inner", "%inner", 2); + ArrayType aType = builder.mockVectorType("%v2inner", "%inner", 2); AggregateType outerType = builder.mockAggregateType("%outer", "%inner", "%v2inner"); // when @@ -317,7 +314,7 @@ public void testNestedCompositeTypes() { Expression s1 = expressions.makeConstruct(innerType, List.of(b1, i1)); Expression s2 = expressions.makeConstruct(innerType, List.of(b2, i2)); - Expression a0 = expressions.makeArray(innerType, List.of(s1, s2), true); + Expression a0 = expressions.makeArray(aType, List.of(s1, s2)); Expression s = expressions.makeConstruct(outerType, List.of(s0, a0)); assertEquals(b0, data.get("%b0")); @@ -554,7 +551,7 @@ public void testSpecConstantInput() { builder.addInput("%i3", three); IntegerType iType = builder.mockIntType("%int", 64); - builder.mockVectorType("%int3v", "%int", 3); + ArrayType type = builder.mockVectorType("%int3v", "%int", 3); // when Map data = parseConstants(input); @@ -568,7 +565,7 @@ public void testSpecConstantInput() { assertEquals(i2, data.get("%i2")); assertEquals(i3, data.get("%i3")); - assertEquals(expressions.makeArray(iType, List.of(i1, i2, i3), true), data.get("%i3v")); + assertEquals(expressions.makeArray(type, List.of(i1, i2, i3)), data.get("%i3v")); } @Test diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java index 4e5d693d75..a9a423107f 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsConversionTest.java @@ -4,6 +4,7 @@ import com.dat3m.dartagnan.expression.Expression; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockProgramBuilder; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockSpirvParser; +import com.dat3m.dartagnan.program.memory.ScopedPointer; import org.junit.Test; import java.util.List; @@ -15,7 +16,7 @@ public class VisitorOpsConversionTest { private final MockProgramBuilder builder = new MockProgramBuilder(); @Test - public void opBitcastValidPointerToPointer() { + public void testOpBitcastValidPointerToPointer() { // given String input = "%value2 = OpBitcast %_ptr_Function_uchar %value1"; builder.mockIntType("%uint", 32); @@ -34,7 +35,7 @@ public void opBitcastValidPointerToPointer() { } @Test - public void opBitcastValidScalarToScalar() { + public void testOpBitcastValidScalarToScalar() { // given String input = "%value2 = OpBitcast %uchar %value1"; builder.mockIntType("%uint", 32); @@ -51,7 +52,7 @@ public void opBitcastValidScalarToScalar() { } @Test - public void opBitcastScalarToPointer() { + public void testOpBitcastScalarToPointer() { // given String input = "%value2 = OpBitcast %_ptr_Function_uint %value1"; builder.mockIntType("%uint", 32); @@ -68,7 +69,7 @@ public void opBitcastScalarToPointer() { } @Test - public void opBitcastStorageClassMismatch() { + public void testOpBitcastStorageClassMismatch() { // given String input = "%value2 = OpBitcast %_ptr_Workgroup_uint %value1"; builder.mockIntType("%uint", 32); @@ -88,12 +89,12 @@ public void opBitcastStorageClassMismatch() { } @Test - public void opConvertPtrToUValid() { + public void testOpUConvertValidConstant() { // given - String input = "%value2 = OpConvertPtrToU %uint %value1"; + String input = "%value2 = OpUConvert %uint64 %value1"; builder.mockIntType("%uint", 32); - builder.mockPtrType("%_ptr_Function_uint", "%uint", "Function"); - builder.mockVariable("%value1", "%_ptr_Function_uint"); + builder.mockIntType("%uint64", 64); + builder.mockConstant("%value1", "%uint", 1); builder.mockFunctionStart(true); // when @@ -101,15 +102,15 @@ public void opConvertPtrToUValid() { // then Expression reg = builder.getExpression("%value2"); - assertEquals(builder.getType("%uint"), reg.getType()); + assertEquals(builder.getType("%uint64"), reg.getType()); } @Test - public void opConvertUToPtrValid() { + public void testOpSConvertValidConstant() { // given - String input = "%value2 = OpConvertUToPtr %_ptr_Function_uint %value1"; + String input = "%value2 = OpSConvert %uint64 %value1"; builder.mockIntType("%uint", 32); - builder.mockPtrType("%_ptr_Function_uint", "%uint", "Function"); + builder.mockIntType("%uint64", 64); builder.mockConstant("%value1", "%uint", 1); builder.mockFunctionStart(true); @@ -118,17 +119,18 @@ public void opConvertUToPtrValid() { // then Expression reg = builder.getExpression("%value2"); - assertEquals(builder.getType("%_ptr_Function_uint"), reg.getType()); + assertEquals(builder.getType("%uint64"), reg.getType()); } @Test - public void opUConvertValidConstant() { + public void testOpUConvertValidRegister() { // given - String input = "%value2 = OpUConvert %uint64 %value1"; + String input = "%value2 = OpUConvert %uint64 %r1"; builder.mockIntType("%uint", 32); builder.mockIntType("%uint64", 64); - builder.mockConstant("%value1", "%uint", 1); builder.mockFunctionStart(true); + builder.addRegister("%r1", "%uint"); + builder.addExpression("%r1", builder.mockConstant("%value1", "%uint", 99)); // when visit(input); @@ -139,66 +141,187 @@ public void opUConvertValidConstant() { } @Test - public void opSConvertValidConstant() { + public void testOpUConvertInvalidType() { // given - String input = "%value2 = OpSConvert %uint64 %value1"; + String input = "%value2 = OpUConvert %uint2 %value1"; builder.mockIntType("%uint", 32); - builder.mockIntType("%uint64", 64); + builder.mockVectorType("%uint2", "%uint", 2); builder.mockConstant("%value1", "%uint", 1); builder.mockFunctionStart(true); + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Unsupported conversion to type '%uint2' for id '%value2'", e.getMessage()); + } + } + + @Test + public void testOpUConvertInvalidOperand() { + // given + String input = "%value2 = OpUConvert %uint %value1"; + builder.mockIntType("%uint", 32); + builder.mockVectorType("%uint2", "%uint", 2); + builder.mockConstant("%value1", "%uint2", List.of(1, 2)); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Unsupported conversion to type '%uint' for id '%value2'", e.getMessage()); + } + } + + @Test + public void testOpConvertPtrToU() { + // given + String input = "%value = OpConvertPtrToU %uint %pointer"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%pointerType", "%uint", "CrossWorkgroup"); + builder.mockConstant("%pointer", "%pointerType", 0); + builder.mockFunctionStart(true); + // when visit(input); // then - Expression reg = builder.getExpression("%value2"); - assertEquals(builder.getType("%uint64"), reg.getType()); + Expression value = builder.getExpression("%value"); + assertEquals(builder.getType("%uint"), value.getType()); } @Test - public void opUConvertValidRegister() { + public void testOpConvertPtrToUDifferentSize() { // given - String input = "%value2 = OpUConvert %uint64 %r1"; - builder.mockIntType("%uint", 32); + String input = """ + %value16 = OpConvertPtrToU %uint16 %pointer + %value64 = OpConvertPtrToU %uint64 %pointer + """; + builder.mockIntType("%uint16", 16); + builder.mockIntType("%uint32", 32); builder.mockIntType("%uint64", 64); + builder.mockPtrType("%pointerType", "%uint32", "CrossWorkgroup"); + builder.mockConstant("%pointer", "%pointerType", 0); builder.mockFunctionStart(true); - builder.addRegister("%r1", "%uint"); - builder.addExpression("%r1", builder.mockConstant("%value1", "%uint", 99)); // when visit(input); // then - Expression reg = builder.getExpression("%value2"); - assertEquals(builder.getType("%uint64"), reg.getType()); + Expression value16 = builder.getExpression("%value16"); + assertEquals(builder.getType("%uint16"), value16.getType()); + Expression value64 = builder.getExpression("%value64"); + assertEquals(builder.getType("%uint64"), value64.getType()); } @Test - public void opUConvertInvalidType() { + public void testOpConvertPtrToUNonPointerArgument() { // given - String input = "%value2 = OpUConvert %uint2 %value1"; + String input = "%value = OpConvertPtrToU %uint %nonPointer"; builder.mockIntType("%uint", 32); - builder.mockVectorType("%uint2", "%uint", 2); - builder.mockConstant("%value1", "%uint", 1); + builder.mockConstant("%nonPointer", "%uint", 0); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Illegal OpConvertPtrToU for '%value', " + + "attempt to apply conversion on a non-pointer type", e.getMessage()); + } + } + + @Test + public void testOpConvertPtrToUNonIntegerResultType() { + // given + String input = "%value = OpConvertPtrToU %bool %pointer"; + builder.mockBoolType("%bool"); + builder.mockPtrType("%pointerType", "%bool", "CrossWorkgroup"); + builder.mockConstant("%pointer", "%pointerType", 0); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Illegal OpConvertPtrToU for '%value', " + + "attempt to convent into a non-integer type", e.getMessage()); + } + } + + @Test + public void testOpConvertUToPtr() { + // given + String input = "%pointer = OpConvertUToPtr %pointerType %value"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%pointerType", "%uint", "CrossWorkgroup"); + builder.mockConstant("%value", "%uint", 0); builder.mockFunctionStart(true); + // when + visit(input); + + // then + Expression pointer = builder.getExpression("%pointer"); + assertEquals(builder.getType("%pointerType"), pointer.getType()); + } + + @Test + public void testOpConvertUToPtrDifferentSize() { + // given + String input = """ + %pointer1 = OpConvertUToPtr %pointerType %value16 + %pointer2 = OpConvertUToPtr %pointerType %value64 + """; + builder.mockIntType("%uint16", 16); + builder.mockIntType("%uint32", 32); + builder.mockIntType("%uint64", 64); + builder.mockConstant("%value16", "%uint16", 0); + builder.mockConstant("%value64", "%uint64", 0); + builder.mockPtrType("%pointerType", "%uint32", "CrossWorkgroup"); + builder.mockFunctionStart(true); + + // when + visit(input); + + // then + Expression pointer1 = builder.getExpression("%pointer1"); + assertEquals(builder.getType("%pointerType"), pointer1.getType()); + Expression pointer2 = builder.getExpression("%pointer2"); + assertEquals(builder.getType("%pointerType"), pointer2.getType()); + } + + @Test + public void testOpConvertUToPtrNonIntegerArgument() { + // given + String input = "%pointer = OpConvertUToPtr %pointerType %value"; + builder.mockBoolType("%bool"); + builder.mockPtrType("%pointerType", "%bool", "CrossWorkgroup"); + builder.mockConstant("%value", "%bool", false); + try { // when visit(input); fail("Should throw exception"); } catch (ParsingException e) { // then - assertEquals("Unsupported conversion to type '%uint2' for id '%value2'", e.getMessage()); + assertEquals("Illegal OpConvertUToPtr for '%pointer', " + + "attempt to apply conversion on a non-integer value", e.getMessage()); } } @Test - public void opUConvertInvalidOperand() { + public void testOpConvertUToPtrNonPointerResultType() { // given - String input = "%value2 = OpUConvert %uint %value1"; + String input = "%pointer = OpConvertUToPtr %uint %value"; builder.mockIntType("%uint", 32); - builder.mockVectorType("%uint2", "%uint", 2); - builder.mockConstant("%value1", "%uint2", List.of(1, 2)); + builder.mockConstant("%value", "%uint", 0); try { // when @@ -206,11 +329,109 @@ public void opUConvertInvalidOperand() { fail("Should throw exception"); } catch (ParsingException e) { // then - assertEquals("Unsupported conversion to type '%uint' for id '%value2'", e.getMessage()); + assertEquals("Illegal OpConvertUToPtr for '%pointer', " + + "attempt to convent into a non-pointer type", e.getMessage()); + } + } + + @Test + public void testOpPtrCastToGeneric() { + // given + String input = "%newPointer = OpPtrCastToGeneric %newType %oldPointer"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%oldType", "%uint", "CrossWorkgroup"); + builder.mockPtrType("%newType", "%uint", "Generic"); + builder.mockConstant("%oldPointer", "%oldType", 0); + + // when + visit(input); + + // then + ScopedPointer newPointer = (ScopedPointer) builder.getExpression("%newPointer"); + assertEquals(builder.getType("%newType"), newPointer.getType()); + assertEquals(builder.getExpression("%oldPointer"), newPointer.getAddress()); + } + + @Test + public void testOpPtrCastToGenericDiffInnerTypes() { + // given + String input = "%newPointer = OpPtrCastToGeneric %newType %oldPointer"; + builder.mockIntType("%uint32", 32); + builder.mockIntType("%uint64", 64); + builder.mockPtrType("%oldType", "%uint32", "CrossWorkgroup"); + builder.mockPtrType("%newType", "%uint64", "Generic"); + builder.mockConstant("%oldPointer", "%oldType", 0); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Illegal OpPointerCastToGeneric for '%newPointer', " + + "result and original pointers point to different types", e.getMessage()); + } + } + + @Test + public void testOpPtrCastToGenericNonPointerArgument() { + // given + String input = "%newPointer = OpPtrCastToGeneric %newType %oldValue"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%newType", "%uint", "Generic"); + builder.mockConstant("%oldValue", "%uint", 0); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Illegal OpPointerCastToGeneric for '%newPointer', " + + "attempt to apply cast to a non-pointer", e.getMessage()); + } + } + + @Test + public void testOpPtrCastToGenericNonPointerResultType() { + // given + String input = "%newPointer = OpPtrCastToGeneric %uint %oldPointer"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%oldType", "%uint", "CrossWorkgroup"); + builder.mockConstant("%oldPointer", "%oldType", 0); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Illegal OpPointerCastToGeneric for '%newPointer', " + + "attempt to apply cast to a non-pointer", e.getMessage()); + } + } + + @Test + public void testOpPtrCastToGenericNonGenericResultType() { + // given + String input = "%newPointer = OpPtrCastToGeneric %newType %oldPointer"; + builder.mockIntType("%uint", 32); + builder.mockPtrType("%oldType", "%uint", "CrossWorkgroup"); + builder.mockPtrType("%newType", "%uint", "Workgroup"); + builder.mockConstant("%oldPointer", "%oldType", 0); + + try { + // when + visit(input); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + assertEquals("Illegal OpPointerCastToGeneric for '%newPointer', " + + "attempt to cast into a non-generic pointer", e.getMessage()); } } private void visit(String input) { - new MockSpirvParser(input).op().accept(new VisitorOpsConversion(builder)); + new MockSpirvParser(input).spv().accept(new VisitorOpsConversion(builder)); } } diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunctionTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunctionTest.java index ae7abca365..83fa1ccb7d 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunctionTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsFunctionTest.java @@ -554,12 +554,13 @@ public void testPointerFunctionParameterWithArrayInput() { %param = OpFunctionParameter %int_ptr """; + ArrayType inputType = builder.mockVectorType("%array", "%int", 2); builder.mockFunctionType("%void_func", "%void", "%int_ptr"); builder.setEntryPointId("%func"); Expression i1 = expressions.makeValue(1, (IntegerType) builder.getType("%int")); Expression i2 = expressions.makeValue(2, (IntegerType) builder.getType("%int")); - Expression parmInput = expressions.makeArray(builder.getType("%int"), List.of(i1, i2), true); - builder.addInput("%param", parmInput); + Expression value = expressions.makeArray(inputType, List.of(i1, i2)); + builder.addInput("%param", value); // when visit(input); @@ -573,8 +574,8 @@ public void testPointerFunctionParameterWithArrayInput() { assertEquals("%param", function.getParameterRegisters().get(0).getName()); assertEquals(builder.getType("%int_ptr"), function.getParameterRegisters().get(0).getType()); assertEquals(HelperInputs.castPointerId("%param"), ((VirtualMemoryObject) local.getExpr()).getName()); - assertEquals(parmInput.getOperands().get(0), ((VirtualMemoryObject) local.getExpr()).getInitialValue(0)); - assertEquals(parmInput.getOperands().get(1), ((VirtualMemoryObject) local.getExpr()).getInitialValue(8)); + assertEquals(value.getOperands().get(0), ((VirtualMemoryObject) local.getExpr()).getInitialValue(0)); + assertEquals(value.getOperands().get(1), ((VirtualMemoryObject) local.getExpr()).getInitialValue(8)); assertEquals(builder.getExpression("%param"), local.getResultRegister()); } diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java index f4ef188255..45e3ab8ad2 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMemoryTest.java @@ -221,37 +221,6 @@ public void testVariable() { } } - @Test - public void testAlignedVariable() { - // given - String input = """ - %v1 = OpVariable %int_ptr Uniform - %v2 = OpVariable %arr_ptr Uniform - """; - - builder.mockIntType("%int", 128); - builder.mockVectorType("%arr", "%int", 3); - builder.mockPtrType("%int_ptr", "%int", "Uniform"); - builder.mockPtrType("%arr_ptr", "%arr", "Uniform"); - builder.mockPointerAlignment("%v1", 32); - builder.mockPointerAlignment("%v2", 64); - - - // when - parse(input); - - // then - ScopedPointerVariable v1 = (ScopedPointerVariable) builder.getExpression("%v1"); - assertNotNull(v1); - assertEquals(32, v1.getAddress().getKnownAlignment()); - assertEquals(256, ((IntegerType) v1.getInnerType()).getBitWidth()); - ScopedPointerVariable v2 = (ScopedPointerVariable) builder.getExpression("%v2"); - assertNotNull(v2); - assertEquals(64, TypeFactory.getInstance().getMemorySizeInBytes(v2.getInnerType())); - assertEquals(4, ((ArrayType) v2.getInnerType()).getNumElements()); - assertEquals(3, ((ArrayType) v2.getInnerType()).getPaddingStart()); - } - @Test public void testInitializedVariableConstant() { String input = """ @@ -287,9 +256,10 @@ public void testInitializedVariableInput() { Expression i1 = expressions.makeValue(1, archType); Expression i2 = expressions.makeValue(7890, archType); List iValues = Stream.of(1, 2, 3).map(i -> (Expression) expressions.makeValue(i, archType)).toList(); - Expression i3 = expressions.makeArray(archType, iValues, true); - AggregateType aType = types.getAggregateType(List.of(i1.getType(), i2.getType(), i3.getType())); - Expression i4 = expressions.makeConstruct(aType, List.of(i1, i2, i3)); + ArrayType arType = types.getArrayType(archType, 3); + Expression i3 = expressions.makeArray(arType, iValues); + AggregateType agType = types.getAggregateType(List.of(i1.getType(), i2.getType(), i3.getType())); + Expression i4 = expressions.makeConstruct(agType, List.of(i1, i2, i3)); builder = new MockProgramBuilder(); builder.addInput("%v1", i1); @@ -320,9 +290,10 @@ private void doTestInitializedVariable(String input) { Expression o1 = expressions.makeTrue(); Expression o2 = expressions.makeValue(7890, iType); List oValues = Stream.of(1, 2, 3).map(i -> (Expression) expressions.makeValue(i, iType)).toList(); - Expression o3 = expressions.makeArray(iType, oValues, true); - AggregateType aType = types.getAggregateType(List.of(o1.getType(), o2.getType(), o3.getType())); - Expression o4 = expressions.makeConstruct(aType, List.of(o1, o2, o3)); + ArrayType arType = types.getArrayType(iType, 3); + Expression o3 = expressions.makeArray(arType, oValues); + AggregateType agType = types.getAggregateType(List.of(o1.getType(), o2.getType(), o3.getType())); + Expression o4 = expressions.makeConstruct(agType, List.of(o1, o2, o3)); ScopedPointerVariable v1 = (ScopedPointerVariable) builder.getExpression("%v1"); assertNotNull(v1); @@ -363,8 +334,9 @@ public void testRuntimeArray() { """; IntegerType archType = types.getArchType(); - Type arrType = types.getArrayType(archType, 2); - AggregateType aggType = types.getAggregateType(List.of(archType, arrType)); + ArrayType arr1Type = types.getArrayType(archType, 2); + ArrayType arr2Type = types.getArrayType(arr1Type, 3); + AggregateType aggType = types.getAggregateType(List.of(archType, arr1Type)); Expression i1 = expressions.makeValue(1, archType); Expression i2 = expressions.makeValue(2, archType); @@ -373,11 +345,11 @@ public void testRuntimeArray() { Expression i5 = expressions.makeValue(5, archType); Expression i6 = expressions.makeValue(6, archType); - Expression a1 = expressions.makeArray(archType, List.of(i1, i2), true); - Expression a2 = expressions.makeArray(archType, List.of(i3, i4), true); - Expression a3 = expressions.makeArray(archType, List.of(i5, i6), true); + Expression a1 = expressions.makeArray(arr1Type, List.of(i1, i2)); + Expression a2 = expressions.makeArray(arr1Type, List.of(i3, i4)); + Expression a3 = expressions.makeArray(arr1Type, List.of(i5, i6)); - Expression a3a = expressions.makeArray(arrType, List.of(a1, a2, a3), true); + Expression a3a = expressions.makeArray(arr2Type, List.of(a1, a2, a3)); Expression s = expressions.makeConstruct(aggType, List.of(i1, a1)); builder = new MockProgramBuilder(); @@ -462,12 +434,14 @@ public void testReusingRuntimeArrayType() { """; IntegerType archType = types.getArchType(); + ArrayType arr1Type = types.getArrayType(archType, 2); + ArrayType arr2Type = types.getArrayType(archType, 3); Expression i1 = expressions.makeValue(1, archType); Expression i2 = expressions.makeValue(2, archType); Expression i3 = expressions.makeValue(3, archType); - Expression a1 = expressions.makeArray(archType, List.of(i1, i2), true); - Expression a2 = expressions.makeArray(archType, List.of(i1, i2, i3), true); + Expression a1 = expressions.makeArray(arr1Type, List.of(i1, i2)); + Expression a2 = expressions.makeArray(arr2Type, List.of(i1, i2, i3)); builder = new MockProgramBuilder(); builder.addInput("%v1", a1); @@ -594,9 +568,10 @@ public void testMismatchingValueTypeInput() { String input = "%v = OpVariable %i_ptr Uniform"; IntegerType archType = types.getArchType(); + ArrayType arrayType = types.getArrayType(archType, 2); Expression i1 = expressions.makeValue(1, archType); Expression i2 = expressions.makeValue(2, archType); - Expression a = expressions.makeArray(archType, List.of(i1, i2), true); + Expression a = expressions.makeArray(arrayType, List.of(i1, i2)); builder = new MockProgramBuilder(); builder.addInput("%v", a); @@ -621,9 +596,9 @@ public void testMismatchingValueTypeInNestedArray() { // given String input = "%v = OpVariable %arr2int_ptr Uniform %const"; - Type bType = builder.mockBoolType("%bool"); - Type a1Type = builder.mockVectorType("%arr1bool", "%bool", 2); - builder.mockVectorType("%arr2bool", "%arr1bool", 2); + builder.mockBoolType("%bool"); + ArrayType a1Type = builder.mockVectorType("%arr1bool", "%bool", 2); + ArrayType a2Type = builder.mockVectorType("%arr2bool", "%arr1bool", 2); builder.mockIntType("%int", 32); builder.mockVectorType("%arr1int", "%int", 2); @@ -632,8 +607,8 @@ public void testMismatchingValueTypeInNestedArray() { builder.mockPtrType("%arr2int_ptr", "%arr2int", "Uniform"); Expression bool = expressions.makeTrue(); - Expression arr1 = expressions.makeArray(bType, List.of(bool, bool), true); - Expression arr2 = expressions.makeArray(a1Type, List.of(arr1, arr1), true); + Expression arr1 = expressions.makeArray(a1Type, List.of(bool, bool)); + Expression arr2 = expressions.makeArray(a2Type, List.of(arr1, arr1)); builder.addExpression("%const", arr2); @@ -724,8 +699,8 @@ public void testAccessChainArray() { builder.mockPtrType("%v3_ptr", "%v3", "Uniform"); builder.mockPtrType("%i_ptr", "%int", "Uniform"); - Expression i0 = builder.mockConstant("%0", "%i_ptr", 0); - Expression i1 = builder.mockConstant("%1", "%i_ptr", 1); + Expression i0 = builder.mockConstant("%0", "%int", 0); + Expression i1 = builder.mockConstant("%1", "%int", 1); builder.mockConstant("%a1", "%v1", List.of("%1", "%0")); builder.mockConstant("%a2", "%v2", List.of("%a1", "%a1")); builder.mockConstant("%a3", "%v3", List.of("%a2", "%a2")); diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsTypeTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsTypeTest.java index fd0be6de23..9f3231a2fd 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsTypeTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsTypeTest.java @@ -1,23 +1,23 @@ package com.dat3m.dartagnan.parsers.program.visitors.spirv; +import com.dat3m.dartagnan.configuration.Arch; import com.dat3m.dartagnan.exception.ParsingException; import com.dat3m.dartagnan.expression.Type; -import com.dat3m.dartagnan.expression.integers.IntLiteral; -import com.dat3m.dartagnan.expression.type.IntegerType; +import com.dat3m.dartagnan.expression.type.ArrayType; import com.dat3m.dartagnan.expression.type.ScopedPointerType; import com.dat3m.dartagnan.expression.type.TypeFactory; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.Decoration; +import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockProgramBuilder; import com.dat3m.dartagnan.parsers.program.visitors.spirv.mocks.MockSpirvParser; -import com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType; import com.dat3m.dartagnan.program.event.Tag; import org.junit.Test; -import java.math.BigInteger; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static com.dat3m.dartagnan.parsers.program.visitors.spirv.decorations.DecorationType.ARRAY_STRIDE; +import static org.junit.Assert.*; public class VisitorOpsTypeTest { @@ -32,13 +32,15 @@ public void testSupportedTypes() { %bool = OpTypeBool %int = OpTypeInt 16 1 %vector = OpTypeVector %int 10 - %array = OpTypeArray %int %val_20 + %array = OpTypeArray %int %uint_20 %ptr = OpTypePointer Input %int %func = OpTypeFunction %void %ptr %int %struct = OpTypeStruct %int %ptr %array """; - addIntConstant("%val_20", 20); + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_20", "%uint", 20); + addMemberOffset("%struct", "0", "0"); addMemberOffset("%struct", "1", "2"); addMemberOffset("%struct", "2", "10"); @@ -47,14 +49,12 @@ public void testSupportedTypes() { Map data = parseTypes(input); // then - assertEquals(8, data.size()); - Type typeVoid = types.getVoidType(); Type typeBoolean = types.getBooleanType(); Type typeInteger = types.getIntegerType(16); Type typeVector = types.getArrayType(typeInteger, 10); Type typeArray = types.getArrayType(typeInteger, 20); - Type typePointer = types.getScopedPointerType(Tag.Spirv.SC_INPUT, typeInteger); + Type typePointer = types.getScopedPointerType(Tag.Spirv.SC_INPUT, typeInteger, null); Type typeFunction = types.getFunctionType(typeVoid, List.of(typePointer, typeInteger)); Type typeStruct = types.getAggregateType(List.of(typeInteger, typePointer, typeArray), List.of(0, 2, 10)); @@ -105,8 +105,6 @@ public void testIntegerType() { Map data = parseTypes(input); // then - assertEquals(6, data.size()); - assertEquals(types.getIntegerType(8), data.get("%uint_8")); assertEquals(types.getIntegerType(16), data.get("%uint_16")); assertEquals(types.getIntegerType(32), data.get("%uint_32")); @@ -131,8 +129,6 @@ public void testVectorType() { Map data = parseTypes(input); // then - assertEquals(6, data.size()); - Type typeBoolean = types.getBooleanType(); Type typeInteger = types.getIntegerType(32); @@ -142,29 +138,58 @@ public void testVectorType() { assertEquals(types.getArrayType(typeInteger, 20), data.get("%vector_int_20")); } + @Test + public void testVectorTypeNonScalarElement() { + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_3", "%uint", 3); + + doTestNestedVectorType(""" + %subtype1 = OpTypeVector %uint 3 + %vector = OpTypeVector %subtype1 3 + """); + doTestNestedVectorType(""" + %subtype2 = OpTypeArray %uint %uint_3 + %vector = OpTypeVector %subtype2 3 + """); + doTestNestedVectorType(""" + %subtype3 = OpTypeRuntimeArray %uint + %vector = OpTypeVector %subtype3 3 + """); + } + + private void doTestNestedVectorType(String input) { + try { + parseTypes(input); + fail("Should throw exception"); + } catch (ParsingException e) { + assertEquals("Attempt to use a non-scalar element in vector type '%vector'", e.getMessage()); + } + } + @Test public void testArrayType() { // given String input = """ %bool = OpTypeBool %int = OpTypeInt 32 1 - %array_bool_5 = OpTypeArray %bool %val_5 - %array_bool_10 = OpTypeArray %bool %val_10 - %array_int_15 = OpTypeArray %int %val_15 - %array_int_20 = OpTypeArray %int %val_20 + %array_bool_5 = OpTypeArray %bool %uint_5 + %array_bool_10 = OpTypeArray %bool %uint_10 + %array_int_15 = OpTypeArray %int %uint_15 + %array_int_20 = OpTypeArray %int %uint_20 + %array_array_bool = OpTypeArray %array_bool_5 %uint_10 + %array_array_int = OpTypeArray %array_int_15 %uint_20 """; - addIntConstant("%val_5", 5); - addIntConstant("%val_10", 10); - addIntConstant("%val_15", 15); - addIntConstant("%val_20", 20); + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_5", "%uint", 5); + builder.mockConstant("%uint_10", "%uint", 10); + builder.mockConstant("%uint_15", "%uint", 15); + builder.mockConstant("%uint_20", "%uint", 20); // when Map data = parseTypes(input); // then - assertEquals(6, data.size()); - Type typeBoolean = types.getBooleanType(); Type typeInteger = types.getIntegerType(32); @@ -172,6 +197,8 @@ public void testArrayType() { assertEquals(types.getArrayType(typeBoolean, 10), data.get("%array_bool_10")); assertEquals(types.getArrayType(typeInteger, 15), data.get("%array_int_15")); assertEquals(types.getArrayType(typeInteger, 20), data.get("%array_int_20")); + assertEquals(types.getArrayType(data.get("%array_bool_5"), 10), data.get("%array_array_bool")); + assertEquals(types.getArrayType(data.get("%array_int_15"), 20), data.get("%array_array_int")); } @Test @@ -189,8 +216,6 @@ public void testPointerType() { Map data = parseTypes(input); // then - assertEquals(5, data.size()); - ScopedPointerType boolPtr = (ScopedPointerType) data.get("%ptr_input_bool"); assertEquals(Tag.Spirv.SC_INPUT, boolPtr.getScopeId()); assertEquals(builder.getType("%bool"), boolPtr.getPointedType()); @@ -220,26 +245,25 @@ public void testFunctionType() { %void = OpTypeVoid %bool = OpTypeBool %int = OpTypeInt 16 1 - %array = OpTypeArray %int %val_5 + %array = OpTypeArray %int %uint_5 %ptr = OpTypePointer Input %int %f1 = OpTypeFunction %void %f2 = OpTypeFunction %bool %int %array %f3 = OpTypeFunction %ptr %ptr """; - addIntConstant("%val_5", 5); + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_5", "%uint", 5); // when Map data = parseTypes(input); // then - assertEquals(8, data.size()); - Type typeVoid = types.getVoidType(); Type typeBoolean = types.getBooleanType(); Type typeInteger = types.getIntegerType(16); Type typeArray = types.getArrayType(typeInteger, 5); - Type typePointer = types.getScopedPointerType(Tag.Spirv.SC_INPUT, typeInteger); + Type typePointer = types.getScopedPointerType(Tag.Spirv.SC_INPUT, typeInteger, null); assertEquals(data.get("%f1"), types.getFunctionType(typeVoid, List.of())); assertEquals(data.get("%f2"), types.getFunctionType(typeBoolean, List.of(typeInteger, typeArray))); @@ -274,14 +298,16 @@ public void testStructType() { String input = """ %bool = OpTypeBool %int = OpTypeInt 32 0 - %array = OpTypeArray %int %val_10 + %array = OpTypeArray %int %uint_10 %s1 = OpTypeStruct %int %array %ptr = OpTypePointer Input %s1 %s2 = OpTypeStruct %bool %ptr %s3 = OpTypeStruct %bool %ptr """; - addIntConstant("%val_10", 10); + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_10", "%uint", 10); + addMemberOffset("%s1", "0", "0"); addMemberOffset("%s1", "1", "4"); addMemberOffset("%s2", "0", "0"); @@ -293,13 +319,11 @@ public void testStructType() { Map data = parseTypes(input); // then - assertEquals(7, data.size()); - Type typeBoolean = types.getBooleanType(); Type typeInteger = types.getIntegerType(32); Type typeArray = types.getArrayType(typeInteger, 10); Type typeStructFirst = types.getAggregateType(List.of(typeInteger, typeArray), List.of(0, 4)); - Type typePointer = types.getScopedPointerType(Tag.Spirv.SC_INPUT, typeStructFirst); + Type typePointer = types.getScopedPointerType(Tag.Spirv.SC_INPUT, typeStructFirst, null); Type typeStructSecond = types.getAggregateType(List.of(typeBoolean, typePointer), List.of(0, 1)); Type typeStructThird = types.getAggregateType(List.of(typeBoolean, typePointer), List.of(0, 2)); @@ -324,18 +348,172 @@ public void testStructTypeUndefinedReference() { parseTypes(input); } + @Test + public void testAlignmentOpenCL() { + // given + String input = """ + %vector_uint_2 = OpTypeVector %uint 2 + %vector_uint_3 = OpTypeVector %uint 3 + %vector_uint_4 = OpTypeVector %uint 4 + %array_uint_2 = OpTypeArray %uint %uint_2 + %array_uint_3 = OpTypeArray %uint %uint_3 + %array_uint_4 = OpTypeArray %uint %uint_4 + """; + + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_2", "%uint", 2); + builder.mockConstant("%uint_3", "%uint", 3); + builder.mockConstant("%uint_4", "%uint", 4); + + // when + builder.setArch(Arch.OPENCL); + parseTypes(input); + + // then + assertNull(getAlignment("%vector_uint_2")); + assertEquals(16, getAlignment("%vector_uint_3").intValue()); + assertNull(getAlignment("%vector_uint_4")); + assertNull(getAlignment("%array_uint_2")); + assertNull(getAlignment("%array_uint_3")); + assertNull(getAlignment("%array_uint_4")); + } + + @Test + public void testAlignmentVulkan() { + // given + String input = """ + %vector_uint_2 = OpTypeVector %uint 2 + %vector_uint_3 = OpTypeVector %uint 3 + %vector_uint_4 = OpTypeVector %uint 4 + %array_uint_2 = OpTypeArray %uint %uint_2 + %array_uint_3 = OpTypeArray %uint %uint_3 + %array_uint_4 = OpTypeArray %uint %uint_4 + """; + + builder.mockIntType("%uint", 32); + builder.mockConstant("%uint_2", "%uint", 2); + builder.mockConstant("%uint_3", "%uint", 3); + builder.mockConstant("%uint_4", "%uint", 4); + + // when + builder.setArch(Arch.VULKAN); + parseTypes(input); + + // then + assertNull(getAlignment("%vector_uint_2")); + assertNull(getAlignment("%vector_uint_3")); + assertNull(getAlignment("%vector_uint_4")); + assertNull(getAlignment("%array_uint_2")); + assertNull(getAlignment("%array_uint_3")); + assertNull(getAlignment("%array_uint_4")); + } + + @Test + public void testArrayStride() { + Map> iData = Map.of( + "OpTypeArray %uint %uint_3", List.of(4, 8, 16), + "OpTypeArray %array1 %uint_3", List.of(12, 16, 32), + "OpTypeArray %array2 %uint_3", List.of(4, 12, 16, 32), + + "OpTypeRuntimeArray %uint", List.of(4, 8, 16), + "OpTypeRuntimeArray %array1", List.of(12, 16, 32), + "OpTypeRuntimeArray %array2", List.of(4, 12, 16, 32), + + "OpTypePointer Uniform %uint", List.of(4, 8, 16), + "OpTypePointer Uniform %array1", List.of(12, 16, 32), + "OpTypePointer Uniform %array2", List.of(4, 12, 16, 32) + ); + + builder.mockIntType("%uint", 32); + builder.mockVectorType("%array1", "%uint", 3); + builder.mockVectorType("%array2", "%uint", -1); + builder.mockConstant("%uint_3", "%uint", 3); + Decoration decoration = builder.getDecorationsBuilder().getDecoration(ARRAY_STRIDE); + + int i = 0; + for (String op : iData.keySet()) { + for (Integer stride : iData.get(op)) { + i++; + // given + String id1 = "%type1_" + i; + String id2 = "%type2_" + i; + + // when + decoration.addDecoration(id1, Integer.toString(stride)); + parseTypes(String.format("%s = %s\n%s = %s", id1, op, id2, op)); + + // then + assertEquals(stride, getArrayStride(id1)); + assertNull(getArrayStride(id2)); + } + } + } + + @Test + public void testIllegalArrayStride() { + Map> iData = Map.of( + "OpTypeArray %uint %uint_3", List.of(1, 3), + "OpTypeArray %uint64 %uint_3", List.of(1, 4), + "OpTypeArray %array %uint_3", List.of(1, 4, 8), + + "OpTypeRuntimeArray %uint", List.of(1, 3), + "OpTypeRuntimeArray %uint64", List.of(1, 4), + "OpTypeRuntimeArray %array", List.of(1, 4, 8), + + "OpTypePointer Uniform %uint", List.of(1, 3), + "OpTypePointer Uniform %uint64", List.of(1, 4), + "OpTypePointer Uniform %array", List.of(1, 4, 8) + ); + + builder.mockIntType("%uint", 32); + builder.mockIntType("%uint64", 64); + builder.mockVectorType("%array", "%uint", 3); + builder.mockConstant("%uint_3", "%uint", 3); + Decoration decoration = builder.getDecorationsBuilder().getDecoration(ARRAY_STRIDE); + + int i = 0; + for (String op : iData.keySet()) { + for (Integer stride : iData.get(op)) { + i++; + // given + String id = "%type_" + i; + decoration.addDecoration(id, Integer.toString(stride)); + try { + // when + parseTypes(String.format("%s = %s", id, op)); + fail("Should throw exception"); + } catch (ParsingException e) { + // then + int size = op.contains("%array") ? 12 : op.contains("%uint64") ? 8 : 4; + assertEquals(String.format("Illegal array definition of type '%s', " + + "element size %d exceeds the ArrayStride value %d", + id, size, stride), e.getMessage()); + } + } + } + } + private Map parseTypes(String input) { new MockSpirvParser(input).spv().accept(new VisitorOpsType(builder)); return builder.getTypes(); } - private void addIntConstant(String id, int value) { - IntegerType type = types.getArchType(); - IntLiteral iValue = new IntLiteral(type, new BigInteger(Integer.toString(value))); - builder.addExpression(id, iValue); - } - private void addMemberOffset(String id, String idx, String offset) { builder.getDecorationsBuilder().getDecoration(DecorationType.OFFSET).addDecoration(id, idx, offset); } + + private Integer getArrayStride(String id) { + Type type = builder.getType(id); + if (type instanceof ArrayType aType) { + return aType.getStride(); + } + if (type instanceof ScopedPointerType pType) { + return pType.getStride(); + } + throw new RuntimeException("Unexpected type"); + } + + private Integer getAlignment(String id) { + return ((ArrayType) builder.getType(id)).getAlignment(); + } } diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputsTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputsTest.java index 1f9df9468e..4d80ca546b 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputsTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/helpers/HelperInputsTest.java @@ -278,15 +278,15 @@ public void testNestedAggregate2() { @Test public void testPointer1() { Type[] iSubTypes = { - types.getScopedPointerType("test", int32), - types.getScopedPointerType("test", int64) + types.getScopedPointerType("test", int32, null), + types.getScopedPointerType("test", int64, null) }; Type[] iTypes = { iSubTypes[0], iSubTypes[1], - types.getScopedPointerType("test", iSubTypes[0]), - types.getScopedPointerType("test", iSubTypes[1]), + types.getScopedPointerType("test", iSubTypes[0], null), + types.getScopedPointerType("test", iSubTypes[1], null), }; Expression[] iValues = { @@ -308,8 +308,8 @@ public void testPointer1() { @Test public void testPointer2() { Type[] iSubTypes = { - types.getScopedPointerType("test", int32), - types.getScopedPointerType("test", int64) + types.getScopedPointerType("test", int32, null), + types.getScopedPointerType("test", int64, null) }; ArrayType[] iTypes = { @@ -428,6 +428,97 @@ public void testInvalidTypeToArray3() { } } + @Test + public void testInvalidTypeToArray4() { + ArrayType[] iTypes = { + types.getArrayType(types.getArrayType(int32)), + types.getArrayType(types.getArrayType(int32), 2), + }; + + Expression[] iValues = { + makeConstruct(makeConstruct(i32[0]), makeConstruct(i32[1], i32[2])), + makeConstruct(makeConstruct(i64[0]), makeConstruct(i64[1], i64[2])), + makeConstruct(makeConstruct(), makeConstruct(i32[1], i32[2])), + makeConstruct(makeConstruct(), makeConstruct(i64[1], i64[2])) + }; + + for (Expression input : iValues) { + for (ArrayType type : iTypes) { + doTestInvalidType(type, input, "test", type, input.getType()); + } + } + } + + @Test + public void testArrayWithStride() { + Type[] iTypes = { + types.getArrayType(int32, -1, 12), + types.getArrayType(int32, 3, 12), + types.getArrayType(int32, -1, 16), + types.getArrayType(int32, 3, 16), + types.getArrayType(int64, -1, 24), + types.getArrayType(int64, 3, 24), + types.getArrayType(int64, -1, 32), + types.getArrayType(int64, 3, 32) + }; + + Expression[] iValues = { + makeConstruct(i64[0], i64[1], i64[2]), + makeArray(i64[0], i64[1], i64[2]) + }; + + Expression[] expected = { + makeArrayWithStride(12, i32[0], i32[1], i32[2]), + makeArrayWithStride(16, i32[0], i32[1], i32[2]), + makeArrayWithStride(24, i64[0], i64[1], i64[2]), + makeArrayWithStride(32, i64[0], i64[1], i64[2]) + }; + + for (Expression input : iValues) { + for (int i = 0; i < iTypes.length; i++) { + assertEquals(expected[i / 2], castInput("test", iTypes[i], input)); + } + } + } + + @Test + public void testInvalidTypeToArrayWithStride() { + ArrayType[] iTypes = { + types.getArrayType(types.getArrayType(int32), -1, 8), + types.getArrayType(types.getArrayType(int32), 2, 8), + types.getArrayType(types.getArrayType(int32), -1, 12), + types.getArrayType(types.getArrayType(int32), 2, 12), + types.getArrayType(types.getArrayType(int64), -1, 16), + types.getArrayType(types.getArrayType(int64), 2, 16), + types.getArrayType(types.getArrayType(int64), -1, 24), + types.getArrayType(types.getArrayType(int64), 2, 24) + }; + + Expression[] iValues = { + makeConstruct( + makeConstruct(i32[0], i32[1], i32[2], i32[3]), + makeConstruct(i32[0], i32[1], i32[2], i32[3])), + makeConstruct( + makeConstruct(i64[0], i64[1], i64[2], i64[3]), + makeConstruct(i64[0], i64[1], i64[2], i64[3])), + }; + + for (Expression input : iValues) { + for (ArrayType type : iTypes) { + try { + castInput("test", type, input); + fail("Should throw exception"); + } catch (ParsingException e) { + Expression elValue = castInput("element", type.getElementType(), input.getOperands().get(0)); + assertEquals(String.format("Mismatching value type for variable 'test', " + + "element size %d is greater than array stride %d", + types.getMemorySizeInBytes(elValue.getType()), type.getStride()), + e.getMessage()); + } + } + } + } + @Test public void testInvalidTypeToAggregate() { AggregateType[] iTypes = { @@ -521,6 +612,13 @@ private ConstructExpr makeConstruct(Expression... elements) { private ConstructExpr makeArray(Expression... elements) { assertEquals(1, Stream.of(elements).map(Expression::getType).collect(Collectors.toSet()).size()); - return (ConstructExpr) expressions.makeArray(elements[0].getType(), Arrays.asList(elements), true); + ArrayType type = types.getArrayType(elements[0].getType(), elements.length); + return (ConstructExpr) expressions.makeArray(type, Arrays.asList(elements)); + } + + private ConstructExpr makeArrayWithStride(Integer stride, Expression... elements) { + assertEquals(1, Stream.of(elements).map(Expression::getType).collect(Collectors.toSet()).size()); + ArrayType type = types.getArrayType(elements[0].getType(), elements.length, stride); + return (ConstructExpr) expressions.makeArray(type, Arrays.asList(elements)); } } diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java index 6bcb6d77b6..5261757872 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/mocks/MockProgramBuilder.java @@ -52,8 +52,8 @@ public IntegerType mockIntType(String id, int bitWidth) { } public ScopedPointerType mockPtrType(String id, String typeId, String storageClass) { - String storageClassTag = HelperTags.parseStorageClass(storageClass); - return (ScopedPointerType) addType(id, typeFactory.getScopedPointerType(storageClassTag, getType(typeId))); + String tag = HelperTags.parseStorageClass(storageClass); + return (ScopedPointerType) addType(id, typeFactory.getScopedPointerType(tag, getType(typeId), null)); } public ArrayType mockVectorType(String id, String innerTypeId, int size) { @@ -90,9 +90,8 @@ public Expression mockConstant(String id, String typeId, Object value) { IntLiteral iValue = exprFactory.makeValue((int) value, iType); return addExpression(id, iValue); } else if (type instanceof ArrayType aType) { - Type elementType = aType.getElementType(); - List elements = mockConstantArrayElements(elementType, value); - Expression construction = exprFactory.makeArray(elementType, elements, aType.hasKnownNumElements()); + List elements = mockConstantArrayElements(aType.getElementType(), value); + Expression construction = exprFactory.makeArray(aType, elements); return addExpression(id, construction); } else if (type instanceof AggregateType) { List members = ((List) value).stream().map(s -> getExpression((String) s)).toList(); @@ -139,11 +138,10 @@ public Expression mockUndefinedValue(String id, String typeId) { public ScopedPointerVariable mockVariable(String id, String typeId) { ScopedPointerType pointerType = (ScopedPointerType) getType(typeId); Type pointedType = pointerType.getPointedType(); - String scopeId = pointerType.getScopeId(); int bytes = typeFactory.getMemorySizeInBytes(pointedType); MemoryObject memoryObject = program.getMemory().allocate(bytes); memoryObject.setName(id); - ScopedPointerVariable pointer = exprFactory.makeScopedPointerVariable(id, scopeId, pointedType, memoryObject); + ScopedPointerVariable pointer = exprFactory.makeScopedPointerVariable(id, pointerType, memoryObject); return (ScopedPointerVariable) addExpression(id, pointer); } @@ -154,11 +152,6 @@ public void mockStructMemberOffsets(String id, Integer... offsets) { } } - public void mockPointerAlignment(String id, int alignment) { - Decoration decoration = getDecorationsBuilder().getDecoration(DecorationType.ALIGNMENT); - decoration.addDecoration(id, Integer.toString(alignment)); - } - public void mockFunctionStart(boolean addStartLabel) { FunctionType type = typeFactory.getFunctionType(typeFactory.getVoidType(), List.of()); startCurrentFunction(new Function("mock_function", type, List.of(), 0, null)); diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/header/AbstractTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/header/AbstractTest.java index 90dddf69c2..4bb2adb167 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/header/AbstractTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/header/AbstractTest.java @@ -34,7 +34,7 @@ public abstract class AbstractTest { %a3uint = OpTypeArray %uint64 %c3 %struct = OpTypeStruct %a2uint %v1uint %struct_2 = OpTypeStruct %uint16 %uint32 %uint64 - %v1v1uint = OpTypeVector %v1uint 1 + %v1v1uint = OpTypeArray %v1uint %c1 %ptr_uint16 = OpTypePointer Uniform %uint16 %ptr_uint32 = OpTypePointer Uniform %uint32 %ptr_uint64 = OpTypePointer Uniform %uint64 diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/alignment/SpirvAssertionsTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/alignment/SpirvAssertionsTest.java new file mode 100644 index 0000000000..b13fea611f --- /dev/null +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/alignment/SpirvAssertionsTest.java @@ -0,0 +1,100 @@ +package com.dat3m.dartagnan.spirv.opencl.alignment; + +import com.dat3m.dartagnan.configuration.Arch; +import com.dat3m.dartagnan.encoding.ProverWithTracker; +import com.dat3m.dartagnan.parsers.cat.ParserCat; +import com.dat3m.dartagnan.parsers.program.ProgramParser; +import com.dat3m.dartagnan.program.Program; +import com.dat3m.dartagnan.utils.Result; +import com.dat3m.dartagnan.verification.VerificationTask; +import com.dat3m.dartagnan.verification.solving.AssumeSolver; +import com.dat3m.dartagnan.wmm.Wmm; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.sosy_lab.common.ShutdownManager; +import org.sosy_lab.common.configuration.Configuration; +import org.sosy_lab.common.configuration.InvalidConfigurationException; +import org.sosy_lab.common.log.BasicLogManager; +import org.sosy_lab.java_smt.SolverContextFactory; +import org.sosy_lab.java_smt.api.SolverContext; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.EnumSet; + +import static com.dat3m.dartagnan.configuration.Property.PROGRAM_SPEC; +import static com.dat3m.dartagnan.utils.ResourceHelper.getRootPath; +import static com.dat3m.dartagnan.utils.ResourceHelper.getTestResourcePath; +import static com.dat3m.dartagnan.utils.Result.PASS; +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class SpirvAssertionsTest { + + private final String modelPath = getRootPath("cat/opencl.cat"); + private final String programPath; + private final int bound; + private final Result expected; + + public SpirvAssertionsTest(String file, int bound, Result expected) { + this.programPath = getTestResourcePath("spirv/opencl/alignment/" + file); + this.bound = bound; + this.expected = expected; + } + + @Parameterized.Parameters(name = "{index}: {0}, {1}, {2}") + public static Iterable data() throws IOException { + return Arrays.asList(new Object[][]{ + {"alignment1-array-global.spvasm", 9, PASS}, + {"alignment1-array-local.spvasm", 9, PASS}, + {"alignment1-array-pointer.spvasm", 9, PASS}, + {"alignment1-struct-global.spvasm", 9, PASS}, + {"alignment1-struct-local.spvasm", 9, PASS}, + {"alignment1-struct-pointer.spvasm", 9, PASS}, + {"alignment2-struct-global.spvasm", 17, PASS}, + {"alignment2-struct-local.spvasm", 17, PASS}, + {"alignment2-struct-pointer.spvasm", 17, PASS}, + {"alignment3-struct-global.spvasm", 9, PASS}, + {"alignment3-struct-local.spvasm", 9, PASS}, + {"alignment3-struct-pointer.spvasm", 9, PASS}, + {"alignment4-struct-global.spvasm", 25, PASS}, + {"alignment4-struct-local.spvasm", 25, PASS}, + {"alignment4-struct-pointer.spvasm", 25, PASS}, + {"alignment5-struct-global.spvasm", 17, PASS}, + {"alignment5-struct-local.spvasm", 17, PASS}, + {"alignment5-struct-pointer.spvasm", 17, PASS}, + }); + } + + @Test + public void test() throws Exception { + try (SolverContext ctx = mkCtx(); ProverWithTracker prover = mkProver(ctx)) { + assertEquals(expected, AssumeSolver.run(ctx, prover, mkTask()).getResult()); + } + } + + private SolverContext mkCtx() throws InvalidConfigurationException { + Configuration cfg = Configuration.builder().build(); + return SolverContextFactory.createSolverContext( + cfg, + BasicLogManager.create(cfg), + ShutdownManager.create().getNotifier(), + SolverContextFactory.Solvers.Z3); + } + + private ProverWithTracker mkProver(SolverContext ctx) { + return new ProverWithTracker(ctx, "", SolverContext.ProverOptions.GENERATE_MODELS); + } + + private VerificationTask mkTask() throws Exception { + VerificationTask.VerificationTaskBuilder builder = VerificationTask.builder() + .withConfig(Configuration.builder().build()) + .withBound(bound) + .withTarget(Arch.OPENCL); + Program program = new ProgramParser().parse(new File(programPath)); + Wmm mcm = new ParserCat().parse(new File(modelPath)); + return builder.build(program, mcm, EnumSet.of(PROGRAM_SPEC)); + } +} diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java index f18b29488c..30b996e418 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/opencl/basic/SpirvAssertionsTest.java @@ -47,18 +47,7 @@ public SpirvAssertionsTest(String file, int bound, Result expected) { @Parameterized.Parameters(name = "{index}: {0}, {1}, {2}") public static Iterable data() throws IOException { return Arrays.asList(new Object[][]{ - {"vector-aligned.spvasm", 1, PASS}, {"idx-overflow.spvasm", 1, PASS}, - {"alignment1.spvasm", 9, PASS}, - {"alignment2.spvasm", 1, PASS}, - {"alignment3.spvasm", 1, PASS}, - {"alignment4.spvasm", 1, PASS}, - {"alignment5.spvasm", 1, PASS}, - {"alignment6.spvasm", 1, PASS}, - {"alignment7.spvasm", 1, PASS}, - {"alignment8.spvasm", 1, PASS}, - {"alignment9.spvasm", 9, PASS}, - {"alignment10.spvasm", 9, PASS} }); } diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/alignment/SpirvAssertionsTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/alignment/SpirvAssertionsTest.java new file mode 100644 index 0000000000..a697a2ba1b --- /dev/null +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/alignment/SpirvAssertionsTest.java @@ -0,0 +1,110 @@ +package com.dat3m.dartagnan.spirv.vulkan.alignment; + +import com.dat3m.dartagnan.configuration.Arch; +import com.dat3m.dartagnan.encoding.ProverWithTracker; +import com.dat3m.dartagnan.parsers.cat.ParserCat; +import com.dat3m.dartagnan.parsers.program.ProgramParser; +import com.dat3m.dartagnan.program.Program; +import com.dat3m.dartagnan.utils.Result; +import com.dat3m.dartagnan.verification.VerificationTask; +import com.dat3m.dartagnan.verification.solving.AssumeSolver; +import com.dat3m.dartagnan.wmm.Wmm; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.sosy_lab.common.ShutdownManager; +import org.sosy_lab.common.configuration.Configuration; +import org.sosy_lab.common.configuration.InvalidConfigurationException; +import org.sosy_lab.common.log.BasicLogManager; +import org.sosy_lab.java_smt.SolverContextFactory; +import org.sosy_lab.java_smt.api.SolverContext; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.EnumSet; + +import static com.dat3m.dartagnan.configuration.Property.PROGRAM_SPEC; +import static com.dat3m.dartagnan.utils.ResourceHelper.getRootPath; +import static com.dat3m.dartagnan.utils.ResourceHelper.getTestResourcePath; +import static com.dat3m.dartagnan.utils.Result.*; +import static org.junit.Assert.assertEquals; + +@RunWith(Parameterized.class) +public class SpirvAssertionsTest { + + private final String modelPath = getRootPath("cat/spirv.cat"); + private final String programPath; + private final int bound; + private final Result expected; + + public SpirvAssertionsTest(String file, int bound, Result expected) { + this.programPath = getTestResourcePath("spirv/vulkan/alignment/" + file); + this.bound = bound; + this.expected = expected; + } + + @Parameterized.Parameters(name = "{index}: {0}, {1}, {2}") + public static Iterable data() throws IOException { + return Arrays.asList(new Object[][]{ + // Compiler changes type to match alignment + {"alignment1-array-local.spvasm", 9, PASS}, + {"alignment1-array-pointer.spvasm", 9, PASS}, + {"alignment1-struct-local.spvasm", 9, PASS}, + {"alignment1-struct-pointer.spvasm", 9, PASS}, + {"alignment2-struct-local.spvasm", 17, PASS}, + {"alignment2-struct-pointer.spvasm", 17, PASS}, + {"alignment3-struct-local.spvasm", 9, PASS}, + {"alignment3-struct-pointer.spvasm", 9, PASS}, + {"alignment4-struct-local.spvasm", 25, PASS}, + {"alignment4-struct-pointer.spvasm", 25, PASS}, + {"alignment5-struct-local.spvasm", 17, PASS}, + {"alignment5-struct-pointer.spvasm", 17, PASS}, + + // Manual tests with stride greater than element size + {"array-stride-array-initializer.spvasm", 9, PASS}, + {"array-stride-array-input.spvasm", 9, PASS}, + {"array-stride-array-overwrite-scalar.spvasm", 9, PASS}, + {"array-stride-array-overwrite-vector.spvasm", 9, PASS}, + {"array-stride-runtime-array-input.spvasm", 9, PASS}, + {"array-stride-runtime-array-overwrite-scalar.spvasm", 9, PASS}, + {"array-stride-runtime-array-overwrite-vector.spvasm", 9, PASS}, + {"pointer-stride-array-overwrite-scalar.spvasm", 9, PASS}, + {"pointer-stride-array-overwrite-vector.spvasm", 9, PASS}, + {"stride-scalar-overwrite-result-no-stride.spvasm", 17, PASS}, + {"stride-scalar-overwrite-result-stride.spvasm", 17, PASS}, + {"stride-vector-overwrite-result-no-stride.spvasm", 17, PASS}, + {"stride-vector-overwrite-result-stride.spvasm", 17, PASS}, + }); + } + + @Test + public void test() throws Exception { + try (SolverContext ctx = mkCtx(); ProverWithTracker prover = mkProver(ctx)) { + assertEquals(expected, AssumeSolver.run(ctx, prover, mkTask()).getResult()); + } + } + + private SolverContext mkCtx() throws InvalidConfigurationException { + Configuration cfg = Configuration.builder().build(); + return SolverContextFactory.createSolverContext( + cfg, + BasicLogManager.create(cfg), + ShutdownManager.create().getNotifier(), + SolverContextFactory.Solvers.Z3); + } + + private ProverWithTracker mkProver(SolverContext ctx) { + return new ProverWithTracker(ctx, "", SolverContext.ProverOptions.GENERATE_MODELS); + } + + private VerificationTask mkTask() throws Exception { + VerificationTask.VerificationTaskBuilder builder = VerificationTask.builder() + .withConfig(Configuration.builder().build()) + .withBound(bound) + .withTarget(Arch.VULKAN); + Program program = new ProgramParser().parse(new File(programPath)); + Wmm mcm = new ParserCat().parse(new File(modelPath)); + return builder.build(program, mcm, EnumSet.of(PROGRAM_SPEC)); + } +} diff --git a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/basic/SpirvChecksTest.java b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/basic/SpirvChecksTest.java index de78815bd9..66c46f2c5d 100644 --- a/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/basic/SpirvChecksTest.java +++ b/dartagnan/src/test/java/com/dat3m/dartagnan/spirv/vulkan/basic/SpirvChecksTest.java @@ -74,6 +74,8 @@ public static Iterable data() throws IOException { {"vector-read-write.spvasm", 1, PASS}, {"composite-construct.spvasm", 1, PASS}, {"composite-extract.spvasm", 1, PASS}, + {"composite-initial.spvasm", 1, PASS}, + {"composite-insert.spvasm", 1, PASS}, {"spec-id-integer.spvasm", 1, PASS}, {"spec-id-boolean.spvasm", 1, PASS}, {"mixed-size.spvasm", 1, PASS}, @@ -118,7 +120,8 @@ public static Iterable data() throws IOException { {"push-constants-pod.spvasm", 1, PASS}, {"push-constant-mixed.spvasm", 1, PASS}, {"bitwise-scalar.spvasm", 1, PASS}, - {"bitwise-vector.spvasm", 1, PASS} + {"bitwise-vector.spvasm", 1, PASS}, + {"idx-overflow.spvasm", 1, PASS} }); } diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-global.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-global.spvasm new file mode 100644 index 0000000000..6df9bd0df4 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-global.spvasm @@ -0,0 +1,156 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2) +; @Output: forall (%r_aligned[4] == 3 and %r_aligned[5] == 4 and %r_aligned[6] == 5) +; @Output: forall (%r_unaligned[0] == 6 and %r_unaligned[1] == 7 and %r_unaligned[2] == 8) +; @Output: forall (%r_unaligned[3] == 9 and %r_unaligned[4] == 10 and %r_unaligned[5] == 11) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 84 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %17 "test" + OpSource OpenCL_C 200000 + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %vecins "vecins" + OpName %vecins1 "vecins1" + OpName %vecins2 "vecins2" + OpName %vecins3 "vecins3" + OpName %vecins4 "vecins4" + OpName %vecins5 "vecins5" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr6 "add.ptr6" + OpName %arrayidx7 "arrayidx7" + OpName %inc "inc" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %unaligned LinkageAttributes "unaligned" Export + OpDecorate %unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_3 = OpTypeArray %v3uint %uint_3 +%_ptr_CrossWorkgroup__arr_v3uint_uint_3 = OpTypePointer CrossWorkgroup %_arr_v3uint_uint_3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_3 = OpTypeArray %_arr_uint_uint_3 %uint_3 +%_ptr_CrossWorkgroup__arr__arr_uint_uint_3_uint_3 = OpTypePointer CrossWorkgroup %_arr__arr_uint_uint_3_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_CrossWorkgroup_v3uint = OpTypePointer CrossWorkgroup %v3uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool + %6 = OpConstantNull %_arr_v3uint_uint_3 + %aligned = OpVariable %_ptr_CrossWorkgroup__arr_v3uint_uint_3 CrossWorkgroup %6 + %11 = OpConstantNull %_arr__arr_uint_uint_3_uint_3 + %unaligned = OpVariable %_ptr_CrossWorkgroup__arr__arr_uint_uint_3_uint_3 CrossWorkgroup %11 + %17 = OpFunction %void DontInline %16 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %aligned %uint_0 %uint_0 + %33 = OpLoad %v3uint %32 Aligned 16 + %vecins = OpCompositeInsert %v3uint %uint_0 %33 0 + OpStore %32 %vecins Aligned 16 + %35 = OpLoad %v3uint %32 Aligned 16 + %vecins1 = OpCompositeInsert %v3uint %uint_1 %35 1 + OpStore %32 %vecins1 Aligned 16 + %38 = OpLoad %v3uint %32 Aligned 16 + %vecins2 = OpCompositeInsert %v3uint %uint_2 %38 2 + OpStore %32 %vecins2 Aligned 16 + %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %aligned %uint_0 %uint_1 + %42 = OpLoad %v3uint %41 Aligned 16 + %vecins3 = OpCompositeInsert %v3uint %uint_3 %42 0 + OpStore %41 %vecins3 Aligned 16 + %44 = OpLoad %v3uint %41 Aligned 16 + %vecins4 = OpCompositeInsert %v3uint %uint_4 %44 1 + OpStore %41 %vecins4 Aligned 16 + %47 = OpLoad %v3uint %41 Aligned 16 + %vecins5 = OpCompositeInsert %v3uint %uint_5 %47 2 + OpStore %41 %vecins5 Aligned 16 + %50 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + OpStore %50 %uint_6 Aligned 4 + %52 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_1 + OpStore %52 %uint_7 Aligned 4 + %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_2 + OpStore %54 %uint_8 Aligned 4 + %56 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_0 + OpStore %56 %uint_9 Aligned 4 + %58 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_1 + OpStore %58 %uint_10 Aligned 4 + %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_2 + OpStore %60 %uint_11 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %62 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + %64 = OpPtrCastToGeneric %_ptr_Generic_uint %62 + %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + %66 = OpPtrCastToGeneric %_ptr_Generic_uint %65 + OpBranch %for_cond + %for_cond = OpLabel + %67 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %67 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %70 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %64 %70 + %72 = OpLoad %uint %add_ptr Aligned 4 + %73 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %74 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %73 %74 + OpStore %arrayidx %72 Aligned 4 + %76 = OpLoad %uint %i Aligned 4 + %add_ptr6 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %66 %76 + %78 = OpLoad %uint %add_ptr6 Aligned 4 + %79 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %80 = OpLoad %uint %i Aligned 4 + %arrayidx7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %79 %80 + OpStore %arrayidx7 %78 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %82 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %82 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-local.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-local.spvasm new file mode 100644 index 0000000000..762e09a349 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-local.spvasm @@ -0,0 +1,152 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2) +; @Output: forall (%r_aligned[4] == 3 and %r_aligned[5] == 4 and %r_aligned[6] == 5) +; @Output: forall (%r_unaligned[0] == 6 and %r_unaligned[1] == 7 and %r_unaligned[2] == 8) +; @Output: forall (%r_unaligned[3] == 9 and %r_unaligned[4] == 10 and %r_unaligned[5] == 11) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 83 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %15 "test" + OpSource OpenCL_C 200000 + OpName %test_aligned "test.aligned" + OpName %test_unaligned "test.unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %vecins "vecins" + OpName %vecins1 "vecins1" + OpName %vecins2 "vecins2" + OpName %vecins3 "vecins3" + OpName %vecins4 "vecins4" + OpName %vecins5 "vecins5" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr6 "add.ptr6" + OpName %arrayidx7 "arrayidx7" + OpName %inc "inc" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %test_aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_3 = OpTypeArray %v3uint %uint_3 +%_ptr_Workgroup__arr_v3uint_uint_3 = OpTypePointer Workgroup %_arr_v3uint_uint_3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_3 = OpTypeArray %_arr_uint_uint_3 %uint_3 +%_ptr_Workgroup__arr__arr_uint_uint_3_uint_3 = OpTypePointer Workgroup %_arr__arr_uint_uint_3_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_v3uint = OpTypePointer Workgroup %v3uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool +%test_aligned = OpVariable %_ptr_Workgroup__arr_v3uint_uint_3 Workgroup +%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr_uint_uint_3_uint_3 Workgroup + %15 = OpFunction %void DontInline %14 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_v3uint %test_aligned %uint_0 %uint_0 + %31 = OpLoad %v3uint %30 Aligned 16 + %vecins = OpCompositeInsert %v3uint %uint_0 %31 0 + OpStore %30 %vecins Aligned 16 + %33 = OpLoad %v3uint %30 Aligned 16 + %vecins1 = OpCompositeInsert %v3uint %uint_1 %33 1 + OpStore %30 %vecins1 Aligned 16 + %36 = OpLoad %v3uint %30 Aligned 16 + %vecins2 = OpCompositeInsert %v3uint %uint_2 %36 2 + OpStore %30 %vecins2 Aligned 16 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_v3uint %test_aligned %uint_0 %uint_1 + %40 = OpLoad %v3uint %39 Aligned 16 + %vecins3 = OpCompositeInsert %v3uint %uint_3 %40 0 + OpStore %39 %vecins3 Aligned 16 + %42 = OpLoad %v3uint %39 Aligned 16 + %vecins4 = OpCompositeInsert %v3uint %uint_4 %42 1 + OpStore %39 %vecins4 Aligned 16 + %45 = OpLoad %v3uint %39 Aligned 16 + %vecins5 = OpCompositeInsert %v3uint %uint_5 %45 2 + OpStore %39 %vecins5 Aligned 16 + %49 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %49 %uint_6 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %51 %uint_7 Aligned 4 + %53 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 + OpStore %53 %uint_8 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %55 %uint_9 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %57 %uint_10 Aligned 4 + %59 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 + OpStore %59 %uint_11 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %61 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + %63 = OpPtrCastToGeneric %_ptr_Generic_uint %61 + %64 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + %65 = OpPtrCastToGeneric %_ptr_Generic_uint %64 + OpBranch %for_cond + %for_cond = OpLabel + %66 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %66 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %69 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %63 %69 + %71 = OpLoad %uint %add_ptr Aligned 4 + %72 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %73 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %72 %73 + OpStore %arrayidx %71 Aligned 4 + %75 = OpLoad %uint %i Aligned 4 + %add_ptr6 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %65 %75 + %77 = OpLoad %uint %add_ptr6 Aligned 4 + %78 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %79 = OpLoad %uint %i Aligned 4 + %arrayidx7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %78 %79 + OpStore %arrayidx7 %77 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %81 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %81 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-pointer.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-pointer.spvasm new file mode 100644 index 0000000000..cf4d418e68 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-array-pointer.spvasm @@ -0,0 +1,198 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2) +; @Output: forall (%r_aligned[4] == 3 and %r_aligned[5] == 4 and %r_aligned[6] == 5) +; @Output: forall (%r_unaligned[0] == 6 and %r_unaligned[1] == 7 and %r_unaligned[2] == 8) +; @Output: forall (%r_unaligned[3] == 9 and %r_unaligned[4] == 10 and %r_unaligned[5] == 11) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 107 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %11 "test" + OpSource OpenCL_C 200000 + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %aligned_addr "aligned.addr" + OpName %unaligned_addr "unaligned.addr" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %arrayidx "arrayidx" + OpName %vecins "vecins" + OpName %arrayidx1 "arrayidx1" + OpName %vecins2 "vecins2" + OpName %arrayidx3 "arrayidx3" + OpName %vecins4 "vecins4" + OpName %arrayidx5 "arrayidx5" + OpName %vecins6 "vecins6" + OpName %arrayidx7 "arrayidx7" + OpName %vecins8 "vecins8" + OpName %arrayidx9 "arrayidx9" + OpName %vecins10 "vecins10" + OpName %arrayidx11 "arrayidx11" + OpName %arrayidx12 "arrayidx12" + OpName %arrayidx13 "arrayidx13" + OpName %arrayidx14 "arrayidx14" + OpName %arrayidx15 "arrayidx15" + OpName %arrayidx16 "arrayidx16" + OpName %arrayidx17 "arrayidx17" + OpName %arrayidx18 "arrayidx18" + OpName %arrayidx19 "arrayidx19" + OpName %arrayidx20 "arrayidx20" + OpName %arrayidx21 "arrayidx21" + OpName %arrayidx22 "arrayidx22" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx23 "arrayidx23" + OpName %add_ptr24 "add.ptr24" + OpName %arrayidx25 "arrayidx25" + OpName %inc "inc" + OpDecorate %aligned_addr Alignment 4 + OpDecorate %unaligned_addr Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %void = OpTypeVoid + %v3uint = OpTypeVector %uint 3 +%_ptr_CrossWorkgroup_v3uint = OpTypePointer CrossWorkgroup %v3uint +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_ptr_CrossWorkgroup__arr_uint_uint_3 = OpTypePointer CrossWorkgroup %_arr_uint_uint_3 +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %10 = OpTypeFunction %void %_ptr_CrossWorkgroup_v3uint %_ptr_CrossWorkgroup__arr_uint_uint_3 %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_v3uint = OpTypePointer Function %_ptr_CrossWorkgroup_v3uint +%_ptr_Function__ptr_CrossWorkgroup__arr_uint_uint_3 = OpTypePointer Function %_ptr_CrossWorkgroup__arr_uint_uint_3 +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint + %bool = OpTypeBool +%_ptr_Generic_uint = OpTypePointer Generic %uint + %11 = OpFunction %void DontInline %10 + %aligned = OpFunctionParameter %_ptr_CrossWorkgroup_v3uint + %unaligned = OpFunctionParameter %_ptr_CrossWorkgroup__arr_uint_uint_3 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_v3uint Function +%unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup__arr_uint_uint_3 Function +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %aligned_addr %aligned Aligned 4 + OpStore %unaligned_addr %unaligned Aligned 4 + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %30 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %30 %uint_0 + %33 = OpLoad %v3uint %arrayidx Aligned 16 + %vecins = OpCompositeInsert %v3uint %uint_0 %33 0 + OpStore %arrayidx %vecins Aligned 16 + %35 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %arrayidx1 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %35 %uint_0 + %37 = OpLoad %v3uint %arrayidx1 Aligned 16 + %vecins2 = OpCompositeInsert %v3uint %uint_1 %37 1 + OpStore %arrayidx1 %vecins2 Aligned 16 + %40 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %arrayidx3 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %40 %uint_0 + %42 = OpLoad %v3uint %arrayidx3 Aligned 16 + %vecins4 = OpCompositeInsert %v3uint %uint_2 %42 2 + OpStore %arrayidx3 %vecins4 Aligned 16 + %45 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %arrayidx5 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %45 %uint_1 + %47 = OpLoad %v3uint %arrayidx5 Aligned 16 + %vecins6 = OpCompositeInsert %v3uint %uint_3 %47 0 + OpStore %arrayidx5 %vecins6 Aligned 16 + %49 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %arrayidx7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %49 %uint_1 + %51 = OpLoad %v3uint %arrayidx7 Aligned 16 + %vecins8 = OpCompositeInsert %v3uint %uint_4 %51 1 + OpStore %arrayidx7 %vecins8 Aligned 16 + %54 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %arrayidx9 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %54 %uint_1 + %56 = OpLoad %v3uint %arrayidx9 Aligned 16 + %vecins10 = OpCompositeInsert %v3uint %uint_5 %56 2 + OpStore %arrayidx9 %vecins10 Aligned 16 + %59 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %arrayidx11 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %59 %uint_0 + %arrayidx12 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx11 %uint_0 %uint_0 + OpStore %arrayidx12 %uint_6 Aligned 4 + %63 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %arrayidx13 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %63 %uint_0 + %arrayidx14 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx13 %uint_0 %uint_1 + OpStore %arrayidx14 %uint_7 Aligned 4 + %67 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %arrayidx15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %67 %uint_0 + %arrayidx16 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx15 %uint_0 %uint_2 + OpStore %arrayidx16 %uint_8 Aligned 4 + %71 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %arrayidx17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %71 %uint_1 + %arrayidx18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx17 %uint_0 %uint_0 + OpStore %arrayidx18 %uint_9 Aligned 4 + %75 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %arrayidx19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %75 %uint_1 + %arrayidx20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx19 %uint_0 %uint_1 + OpStore %arrayidx20 %uint_10 Aligned 4 + %79 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %arrayidx21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %79 %uint_1 + %arrayidx22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx21 %uint_0 %uint_2 + OpStore %arrayidx22 %uint_11 Aligned 4 + OpStore %i %uint_0 Aligned 4 + OpBranch %for_cond + %for_cond = OpLabel + %83 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %83 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %86 = OpLoad %_ptr_CrossWorkgroup_v3uint %aligned_addr Aligned 4 + %87 = OpBitcast %_ptr_CrossWorkgroup_uint %86 + %89 = OpPtrCastToGeneric %_ptr_Generic_uint %87 + %90 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %89 %90 + %92 = OpLoad %uint %add_ptr Aligned 4 + %93 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %94 = OpLoad %uint %i Aligned 4 + %arrayidx23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %93 %94 + OpStore %arrayidx23 %92 Aligned 4 + %96 = OpLoad %_ptr_CrossWorkgroup__arr_uint_uint_3 %unaligned_addr Aligned 4 + %97 = OpBitcast %_ptr_CrossWorkgroup_uint %96 + %98 = OpPtrCastToGeneric %_ptr_Generic_uint %97 + %99 = OpLoad %uint %i Aligned 4 + %add_ptr24 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %98 %99 + %101 = OpLoad %uint %add_ptr24 Aligned 4 + %102 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %103 = OpLoad %uint %i Aligned 4 + %arrayidx25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %102 %103 + OpStore %arrayidx25 %101 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %105 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %105 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-global.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-global.spvasm new file mode 100644 index 0000000000..4b64292520 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-global.spvasm @@ -0,0 +1,146 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2) +; @Output: forall (%r_aligned[4] == 3 and %r_aligned[5] == 4 and %r_aligned[6] == 5) +; @Output: forall (%r_unaligned[0] == 6 and %r_unaligned[1] == 7 and %r_unaligned[2] == 8) +; @Output: forall (%r_unaligned[3] == 9 and %r_unaligned[4] == 10 and %r_unaligned[5] == 11) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 77 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %20 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %aligned "aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %unaligned LinkageAttributes "unaligned" Export + OpDecorate %unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_t = OpTypeStruct %uint %uint %uint %_arr_uchar_uint_4 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %19 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool + %9 = OpConstantNull %_arr_struct_aligned_t_uint_3 + %aligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 CrossWorkgroup %9 + %14 = OpConstantNull %_arr_struct_unaligned_t_uint_3 + %unaligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 CrossWorkgroup %14 + %20 = OpFunction %void DontInline %19 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + OpStore %34 %uint_0 Aligned 16 + %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_1 + OpStore %36 %uint_1 Aligned 4 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_2 + OpStore %38 %uint_2 Aligned 8 + %39 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_0 + OpStore %39 %uint_3 Aligned 16 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_1 + OpStore %40 %uint_4 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_2 + OpStore %41 %uint_5 Aligned 8 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + OpStore %43 %uint_6 Aligned 4 + %45 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_1 + OpStore %45 %uint_7 Aligned 4 + %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_2 + OpStore %47 %uint_8 Aligned 4 + %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_0 + OpStore %49 %uint_9 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_1 + OpStore %51 %uint_10 Aligned 4 + %53 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_2 + OpStore %53 %uint_11 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + %57 = OpPtrCastToGeneric %_ptr_Generic_uint %55 + %58 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + %59 = OpPtrCastToGeneric %_ptr_Generic_uint %58 + OpBranch %for_cond + %for_cond = OpLabel + %60 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %60 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %63 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %57 %63 + %65 = OpLoad %uint %add_ptr Aligned 4 + %66 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %67 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %66 %67 + OpStore %arrayidx %65 Aligned 4 + %69 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %59 %69 + %71 = OpLoad %uint %add_ptr1 Aligned 4 + %72 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %73 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %72 %73 + OpStore %arrayidx2 %71 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %75 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %75 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-local.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-local.spvasm new file mode 100644 index 0000000000..79b20bd0c0 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-local.spvasm @@ -0,0 +1,142 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2) +; @Output: forall (%r_aligned[4] == 3 and %r_aligned[5] == 4 and %r_aligned[6] == 5) +; @Output: forall (%r_unaligned[0] == 6 and %r_unaligned[1] == 7 and %r_unaligned[2] == 8) +; @Output: forall (%r_unaligned[3] == 9 and %r_unaligned[4] == 10 and %r_unaligned[5] == 11) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 76 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %18 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %test_aligned "test.aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %test_unaligned "test.unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %test_aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_t = OpTypeStruct %uint %uint %uint %_arr_uchar_uint_4 +%_arr_struct_aligned_t_uint_2 = OpTypeArray %struct_aligned_t %uint_2 +%_ptr_Workgroup__arr_struct_aligned_t_uint_2 = OpTypePointer Workgroup %_arr_struct_aligned_t_uint_2 +%struct_unaligned_t = OpTypeStruct %uint %uint %uint +%_arr_struct_unaligned_t_uint_2 = OpTypeArray %struct_unaligned_t %uint_2 +%_ptr_Workgroup__arr_struct_unaligned_t_uint_2 = OpTypePointer Workgroup %_arr_struct_unaligned_t_uint_2 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %17 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool +%test_aligned = OpVariable %_ptr_Workgroup__arr_struct_aligned_t_uint_2 Workgroup +%test_unaligned = OpVariable %_ptr_Workgroup__arr_struct_unaligned_t_uint_2 Workgroup + %18 = OpFunction %void DontInline %17 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + OpStore %33 %uint_0 Aligned 16 + %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_1 + OpStore %35 %uint_1 Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_2 + OpStore %36 %uint_2 Aligned 8 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_0 + OpStore %37 %uint_3 Aligned 16 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_1 + OpStore %39 %uint_4 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_2 + OpStore %40 %uint_5 Aligned 8 + %42 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %42 %uint_6 Aligned 4 + %44 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %44 %uint_7 Aligned 4 + %46 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 + OpStore %46 %uint_8 Aligned 4 + %48 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %48 %uint_9 Aligned 4 + %50 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %50 %uint_10 Aligned 4 + %52 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 + OpStore %52 %uint_11 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %54 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + %56 = OpPtrCastToGeneric %_ptr_Generic_uint %54 + %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + %58 = OpPtrCastToGeneric %_ptr_Generic_uint %57 + OpBranch %for_cond + %for_cond = OpLabel + %59 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %59 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %62 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %56 %62 + %64 = OpLoad %uint %add_ptr Aligned 4 + %65 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %66 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %65 %66 + OpStore %arrayidx %64 Aligned 4 + %68 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %58 %68 + %70 = OpLoad %uint %add_ptr1 Aligned 4 + %71 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %72 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %71 %72 + OpStore %arrayidx2 %70 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %74 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %74 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-pointer.spvasm new file mode 100644 index 0000000000..ed5246bad5 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment1-struct-pointer.spvasm @@ -0,0 +1,197 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2) +; @Output: forall (%r_aligned[4] == 3 and %r_aligned[5] == 4 and %r_aligned[6] == 5) +; @Output: forall (%r_unaligned[0] == 6 and %r_unaligned[1] == 7 and %r_unaligned[2] == 8) +; @Output: forall (%r_unaligned[3] == 9 and %r_unaligned[4] == 10 and %r_unaligned[5] == 11) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 103 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %13 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %aligned_addr "aligned.addr" + OpName %unaligned_addr "unaligned.addr" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %arrayidx "arrayidx" + OpName %x "x" + OpName %arrayidx1 "arrayidx1" + OpName %y "y" + OpName %arrayidx2 "arrayidx2" + OpName %z "z" + OpName %arrayidx3 "arrayidx3" + OpName %x4 "x4" + OpName %arrayidx5 "arrayidx5" + OpName %y6 "y6" + OpName %arrayidx7 "arrayidx7" + OpName %z8 "z8" + OpName %arrayidx9 "arrayidx9" + OpName %x10 "x10" + OpName %arrayidx11 "arrayidx11" + OpName %y12 "y12" + OpName %arrayidx13 "arrayidx13" + OpName %z14 "z14" + OpName %arrayidx15 "arrayidx15" + OpName %x16 "x16" + OpName %arrayidx17 "arrayidx17" + OpName %y18 "y18" + OpName %arrayidx19 "arrayidx19" + OpName %z20 "z20" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx21 "arrayidx21" + OpName %add_ptr22 "add.ptr22" + OpName %arrayidx23 "arrayidx23" + OpName %inc "inc" + OpDecorate %aligned_addr Alignment 4 + OpDecorate %unaligned_addr Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %void = OpTypeVoid +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_t = OpTypeStruct %uint %uint %uint %_arr_uchar_uint_4 +%_ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer CrossWorkgroup %struct_aligned_t +%struct_unaligned_t = OpTypeStruct %uint %uint %uint +%_ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer CrossWorkgroup %struct_unaligned_t +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %12 = OpTypeFunction %void %_ptr_CrossWorkgroup_struct_aligned_t %_ptr_CrossWorkgroup_struct_unaligned_t %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_t +%_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint + %bool = OpTypeBool +%_ptr_Generic_uint = OpTypePointer Generic %uint + %13 = OpFunction %void DontInline %12 + %aligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_t + %unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_unaligned_t + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t Function +%unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t Function +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %aligned_addr %aligned Aligned 4 + OpStore %unaligned_addr %unaligned Aligned 4 + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %32 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %32 %uint_0 + %x = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx %uint_0 %uint_0 + OpStore %x %uint_0 Aligned 16 + %36 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx1 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %36 %uint_0 + %y = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx1 %uint_0 %uint_1 + OpStore %y %uint_1 Aligned 4 + %40 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %40 %uint_0 + %z = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx2 %uint_0 %uint_2 + OpStore %z %uint_2 Aligned 8 + %44 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx3 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %44 %uint_1 + %x4 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx3 %uint_0 %uint_0 + OpStore %x4 %uint_3 Aligned 16 + %48 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx5 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %48 %uint_1 + %y6 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx5 %uint_0 %uint_1 + OpStore %y6 %uint_4 Aligned 4 + %51 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %51 %uint_1 + %z8 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx7 %uint_0 %uint_2 + OpStore %z8 %uint_5 Aligned 8 + %55 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx9 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %55 %uint_0 + %x10 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx9 %uint_0 %uint_0 + OpStore %x10 %uint_6 Aligned 4 + %59 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx11 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %59 %uint_0 + %y12 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx11 %uint_0 %uint_1 + OpStore %y12 %uint_7 Aligned 4 + %63 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx13 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %63 %uint_0 + %z14 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx13 %uint_0 %uint_2 + OpStore %z14 %uint_8 Aligned 4 + %67 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %67 %uint_1 + %x16 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx15 %uint_0 %uint_0 + OpStore %x16 %uint_9 Aligned 4 + %71 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %71 %uint_1 + %y18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx17 %uint_0 %uint_1 + OpStore %y18 %uint_10 Aligned 4 + %75 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %75 %uint_1 + %z20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx19 %uint_0 %uint_2 + OpStore %z20 %uint_11 Aligned 4 + OpStore %i %uint_0 Aligned 4 + OpBranch %for_cond + %for_cond = OpLabel + %79 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %79 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %82 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %83 = OpBitcast %_ptr_CrossWorkgroup_uint %82 + %85 = OpPtrCastToGeneric %_ptr_Generic_uint %83 + %86 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %85 %86 + %88 = OpLoad %uint %add_ptr Aligned 4 + %89 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %90 = OpLoad %uint %i Aligned 4 + %arrayidx21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %89 %90 + OpStore %arrayidx21 %88 Aligned 4 + %92 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %93 = OpBitcast %_ptr_CrossWorkgroup_uint %92 + %94 = OpPtrCastToGeneric %_ptr_Generic_uint %93 + %95 = OpLoad %uint %i Aligned 4 + %add_ptr22 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %94 %95 + %97 = OpLoad %uint %add_ptr22 Aligned 4 + %98 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %99 = OpLoad %uint %i Aligned 4 + %arrayidx23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %98 %99 + OpStore %arrayidx23 %97 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %101 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %101 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-global.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-global.spvasm new file mode 100644 index 0000000000..c65a6c36a2 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-global.spvasm @@ -0,0 +1,170 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2 and %r_aligned[3] == 3 and %r_aligned[4] == 4) +; @Output: forall (%r_aligned[8] == 5 and %r_aligned[9] == 6 and %r_aligned[10] == 7 and %r_aligned[11] == 8 and %r_aligned[12] == 9) +; @Output: forall (%r_unaligned[0] == 10 and %r_unaligned[1] == 11 and %r_unaligned[2] == 12 and %r_unaligned[3] == 13 and %r_unaligned[4] == 14) +; @Output: forall (%r_unaligned[5] == 15 and %r_unaligned[6] == 16 and %r_unaligned[7] == 17 and %r_unaligned[8] == 18 and %r_unaligned[9] == 19) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 93 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %20 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %aligned "aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %unaligned LinkageAttributes "unaligned" Export + OpDecorate %unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %aligned Alignment 32 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_16 = OpConstant %uint 16 + %uint_17 = OpConstant %uint 17 + %uint_18 = OpConstant %uint 18 + %uint_19 = OpConstant %uint 19 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_t = OpTypeStruct %uint %uint %uint %uint %uint %_arr_uchar_uint_12 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint %uint %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %19 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool + %9 = OpConstantNull %_arr_struct_aligned_t_uint_3 + %aligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 CrossWorkgroup %9 + %14 = OpConstantNull %_arr_struct_unaligned_t_uint_3 + %unaligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 CrossWorkgroup %14 + %20 = OpFunction %void DontInline %19 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + OpStore %34 %uint_0 Aligned 32 + %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_1 + OpStore %36 %uint_1 Aligned 4 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_2 + OpStore %38 %uint_2 Aligned 8 + %39 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_3 + OpStore %39 %uint_3 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_4 + OpStore %41 %uint_4 Aligned 16 + %42 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_0 + OpStore %42 %uint_5 Aligned 32 + %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_1 + OpStore %44 %uint_6 Aligned 4 + %46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_2 + OpStore %46 %uint_7 Aligned 8 + %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_3 + OpStore %48 %uint_8 Aligned 4 + %50 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_4 + OpStore %50 %uint_9 Aligned 16 + %52 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + OpStore %52 %uint_10 Aligned 4 + %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_1 + OpStore %54 %uint_11 Aligned 4 + %56 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_2 + OpStore %56 %uint_12 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_3 + OpStore %57 %uint_13 Aligned 4 + %59 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_4 + OpStore %59 %uint_14 Aligned 4 + %61 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_0 + OpStore %61 %uint_15 Aligned 4 + %63 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_1 + OpStore %63 %uint_16 Aligned 4 + %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_2 + OpStore %65 %uint_17 Aligned 4 + %67 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_3 + OpStore %67 %uint_18 Aligned 4 + %69 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_4 + OpStore %69 %uint_19 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %71 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + %73 = OpPtrCastToGeneric %_ptr_Generic_uint %71 + %74 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + %75 = OpPtrCastToGeneric %_ptr_Generic_uint %74 + OpBranch %for_cond + %for_cond = OpLabel + %76 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %76 %uint_16 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %79 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %73 %79 + %81 = OpLoad %uint %add_ptr Aligned 4 + %82 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %83 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %82 %83 + OpStore %arrayidx %81 Aligned 4 + %85 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %75 %85 + %87 = OpLoad %uint %add_ptr1 Aligned 4 + %88 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %89 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %88 %89 + OpStore %arrayidx2 %87 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %91 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %91 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-local.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-local.spvasm new file mode 100644 index 0000000000..9784bdaacd --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-local.spvasm @@ -0,0 +1,166 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2 and %r_aligned[3] == 3 and %r_aligned[4] == 4) +; @Output: forall (%r_aligned[8] == 5 and %r_aligned[9] == 6 and %r_aligned[10] == 7 and %r_aligned[11] == 8 and %r_aligned[12] == 9) +; @Output: forall (%r_unaligned[0] == 10 and %r_unaligned[1] == 11 and %r_unaligned[2] == 12 and %r_unaligned[3] == 13 and %r_unaligned[4] == 14) +; @Output: forall (%r_unaligned[5] == 15 and %r_unaligned[6] == 16 and %r_unaligned[7] == 17 and %r_unaligned[8] == 18 and %r_unaligned[9] == 19) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 92 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %18 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %test_aligned "test.aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %test_unaligned "test.unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %test_aligned Alignment 32 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_16 = OpConstant %uint 16 + %uint_17 = OpConstant %uint 17 + %uint_18 = OpConstant %uint 18 + %uint_19 = OpConstant %uint 19 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_t = OpTypeStruct %uint %uint %uint %uint %uint %_arr_uchar_uint_12 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_Workgroup__arr_struct_aligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint %uint %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_Workgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %17 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool +%test_aligned = OpVariable %_ptr_Workgroup__arr_struct_aligned_t_uint_3 Workgroup +%test_unaligned = OpVariable %_ptr_Workgroup__arr_struct_unaligned_t_uint_3 Workgroup + %18 = OpFunction %void DontInline %17 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + OpStore %33 %uint_0 Aligned 32 + %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_1 + OpStore %35 %uint_1 Aligned 4 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_2 + OpStore %37 %uint_2 Aligned 8 + %38 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_3 + OpStore %38 %uint_3 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_4 + OpStore %40 %uint_4 Aligned 16 + %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_0 + OpStore %41 %uint_5 Aligned 32 + %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_1 + OpStore %43 %uint_6 Aligned 4 + %45 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_2 + OpStore %45 %uint_7 Aligned 8 + %47 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_3 + OpStore %47 %uint_8 Aligned 4 + %49 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_4 + OpStore %49 %uint_9 Aligned 16 + %51 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %51 %uint_10 Aligned 4 + %53 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %53 %uint_11 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 + OpStore %55 %uint_12 Aligned 4 + %56 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_3 + OpStore %56 %uint_13 Aligned 4 + %58 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_4 + OpStore %58 %uint_14 Aligned 4 + %60 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %60 %uint_15 Aligned 4 + %62 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %62 %uint_16 Aligned 4 + %64 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 + OpStore %64 %uint_17 Aligned 4 + %66 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_3 + OpStore %66 %uint_18 Aligned 4 + %68 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_4 + OpStore %68 %uint_19 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %70 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + %72 = OpPtrCastToGeneric %_ptr_Generic_uint %70 + %73 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + %74 = OpPtrCastToGeneric %_ptr_Generic_uint %73 + OpBranch %for_cond + %for_cond = OpLabel + %75 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %75 %uint_16 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %78 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %72 %78 + %80 = OpLoad %uint %add_ptr Aligned 4 + %81 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %82 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %81 %82 + OpStore %arrayidx %80 Aligned 4 + %84 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %74 %84 + %86 = OpLoad %uint %add_ptr1 Aligned 4 + %87 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %88 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %87 %88 + OpStore %arrayidx2 %86 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %90 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %90 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-pointer.spvasm new file mode 100644 index 0000000000..4846f51dc2 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment2-struct-pointer.spvasm @@ -0,0 +1,253 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2 and %r_aligned[3] == 3 and %r_aligned[4] == 4) +; @Output: forall (%r_aligned[8] == 5 and %r_aligned[9] == 6 and %r_aligned[10] == 7 and %r_aligned[11] == 8 and %r_aligned[12] == 9) +; @Output: forall (%r_unaligned[0] == 10 and %r_unaligned[1] == 11 and %r_unaligned[2] == 12 and %r_unaligned[3] == 13 and %r_unaligned[4] == 14) +; @Output: forall (%r_unaligned[5] == 15 and %r_unaligned[6] == 16 and %r_unaligned[7] == 17 and %r_unaligned[8] == 18 and %r_unaligned[9] == 19) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 135 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %13 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %aligned_addr "aligned.addr" + OpName %unaligned_addr "unaligned.addr" + OpName %i "i" + OpName %arrayidx "arrayidx" + OpName %a "a" + OpName %arrayidx1 "arrayidx1" + OpName %b "b" + OpName %arrayidx2 "arrayidx2" + OpName %c "c" + OpName %arrayidx3 "arrayidx3" + OpName %d "d" + OpName %arrayidx4 "arrayidx4" + OpName %e "e" + OpName %arrayidx5 "arrayidx5" + OpName %a6 "a6" + OpName %arrayidx7 "arrayidx7" + OpName %b8 "b8" + OpName %arrayidx9 "arrayidx9" + OpName %c10 "c10" + OpName %arrayidx11 "arrayidx11" + OpName %d12 "d12" + OpName %arrayidx13 "arrayidx13" + OpName %e14 "e14" + OpName %arrayidx15 "arrayidx15" + OpName %a16 "a16" + OpName %arrayidx17 "arrayidx17" + OpName %b18 "b18" + OpName %arrayidx19 "arrayidx19" + OpName %c20 "c20" + OpName %arrayidx21 "arrayidx21" + OpName %d22 "d22" + OpName %arrayidx23 "arrayidx23" + OpName %e24 "e24" + OpName %arrayidx25 "arrayidx25" + OpName %a26 "a26" + OpName %arrayidx27 "arrayidx27" + OpName %b28 "b28" + OpName %arrayidx29 "arrayidx29" + OpName %c30 "c30" + OpName %arrayidx31 "arrayidx31" + OpName %d32 "d32" + OpName %arrayidx33 "arrayidx33" + OpName %e34 "e34" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx35 "arrayidx35" + OpName %add_ptr36 "add.ptr36" + OpName %arrayidx37 "arrayidx37" + OpName %inc "inc" + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %aligned_addr Alignment 4 + OpDecorate %unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_16 = OpConstant %uint 16 + %uint_17 = OpConstant %uint 17 + %uint_18 = OpConstant %uint 18 + %uint_19 = OpConstant %uint 19 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_t = OpTypeStruct %uint %uint %uint %uint %uint %_arr_uchar_uint_12 +%_ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer CrossWorkgroup %struct_aligned_t +%struct_unaligned_t = OpTypeStruct %uint %uint %uint %uint %uint +%_ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer CrossWorkgroup %struct_unaligned_t + %12 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_t %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_t +%_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function_uint = OpTypePointer Function %uint + %bool = OpTypeBool +%_ptr_Generic_uint = OpTypePointer Generic %uint + %13 = OpFunction %void DontInline %12 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %aligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_t + %unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_unaligned_t + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t Function +%unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + OpStore %aligned_addr %aligned Aligned 4 + OpStore %unaligned_addr %unaligned Aligned 4 + %32 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %32 %uint_0 + %a = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx %uint_0 %uint_0 + OpStore %a %uint_0 Aligned 32 + %36 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx1 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %36 %uint_0 + %b = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx1 %uint_0 %uint_1 + OpStore %b %uint_1 Aligned 4 + %40 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %40 %uint_0 + %c = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx2 %uint_0 %uint_2 + OpStore %c %uint_2 Aligned 8 + %44 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx3 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %44 %uint_0 + %d = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx3 %uint_0 %uint_3 + OpStore %d %uint_3 Aligned 4 + %48 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx4 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %48 %uint_0 + %e = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx4 %uint_0 %uint_4 + OpStore %e %uint_4 Aligned 16 + %52 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx5 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %52 %uint_1 + %a6 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx5 %uint_0 %uint_0 + OpStore %a6 %uint_5 Aligned 32 + %56 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %56 %uint_1 + %b8 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx7 %uint_0 %uint_1 + OpStore %b8 %uint_6 Aligned 4 + %60 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx9 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %60 %uint_1 + %c10 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx9 %uint_0 %uint_2 + OpStore %c10 %uint_7 Aligned 8 + %64 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx11 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %64 %uint_1 + %d12 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx11 %uint_0 %uint_3 + OpStore %d12 %uint_8 Aligned 4 + %68 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx13 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %68 %uint_1 + %e14 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx13 %uint_0 %uint_4 + OpStore %e14 %uint_9 Aligned 16 + %72 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %72 %uint_0 + %a16 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx15 %uint_0 %uint_0 + OpStore %a16 %uint_10 Aligned 4 + %76 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %76 %uint_0 + %b18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx17 %uint_0 %uint_1 + OpStore %b18 %uint_11 Aligned 4 + %80 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %80 %uint_0 + %c20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx19 %uint_0 %uint_2 + OpStore %c20 %uint_12 Aligned 4 + %83 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %83 %uint_0 + %d22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx21 %uint_0 %uint_3 + OpStore %d22 %uint_13 Aligned 4 + %87 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %87 %uint_0 + %e24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx23 %uint_0 %uint_4 + OpStore %e24 %uint_14 Aligned 4 + %91 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %91 %uint_1 + %a26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx25 %uint_0 %uint_0 + OpStore %a26 %uint_15 Aligned 4 + %95 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %95 %uint_1 + %b28 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx27 %uint_0 %uint_1 + OpStore %b28 %uint_16 Aligned 4 + %99 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx29 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %99 %uint_1 + %c30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx29 %uint_0 %uint_2 + OpStore %c30 %uint_17 Aligned 4 + %103 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx31 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %103 %uint_1 + %d32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx31 %uint_0 %uint_3 + OpStore %d32 %uint_18 Aligned 4 + %107 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx33 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %107 %uint_1 + %e34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx33 %uint_0 %uint_4 + OpStore %e34 %uint_19 Aligned 4 + OpStore %i %uint_0 Aligned 4 + OpBranch %for_cond + %for_cond = OpLabel + %111 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %111 %uint_16 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %114 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %115 = OpBitcast %_ptr_CrossWorkgroup_uint %114 + %117 = OpPtrCastToGeneric %_ptr_Generic_uint %115 + %118 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %117 %118 + %120 = OpLoad %uint %add_ptr Aligned 4 + %121 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %122 = OpLoad %uint %i Aligned 4 + %arrayidx35 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %121 %122 + OpStore %arrayidx35 %120 Aligned 4 + %124 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %125 = OpBitcast %_ptr_CrossWorkgroup_uint %124 + %126 = OpPtrCastToGeneric %_ptr_Generic_uint %125 + %127 = OpLoad %uint %i Aligned 4 + %add_ptr36 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %126 %127 + %129 = OpLoad %uint %add_ptr36 Aligned 4 + %130 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %131 = OpLoad %uint %i Aligned 4 + %arrayidx37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %130 %131 + OpStore %arrayidx37 %129 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %133 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %133 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-global.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-global.spvasm new file mode 100644 index 0000000000..5438e52243 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-global.spvasm @@ -0,0 +1,135 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[2] == 1) +; @Output: forall (%r_aligned[4] == 2 and %r_aligned[6] == 3) +; @Output: forall (%r_unaligned[0] == 4 and %r_unaligned[1] == 5) +; @Output: forall (%r_unaligned[2] == 6 and %r_unaligned[3] == 7) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 70 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %20 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %aligned "aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %unaligned LinkageAttributes "unaligned" Export + OpDecorate %unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %aligned Alignment 8 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_t = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %19 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool + %9 = OpConstantNull %_arr_struct_aligned_t_uint_3 + %aligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 CrossWorkgroup %9 + %14 = OpConstantNull %_arr_struct_unaligned_t_uint_3 + %unaligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 CrossWorkgroup %14 + %20 = OpFunction %void DontInline %19 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + OpStore %34 %uint_0 Aligned 8 + %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_2 + OpStore %36 %uint_1 Aligned 8 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_0 + OpStore %38 %uint_2 Aligned 8 + %39 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_2 + OpStore %39 %uint_3 Aligned 8 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + OpStore %40 %uint_4 Aligned 4 + %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_1 + OpStore %41 %uint_5 Aligned 4 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_0 + OpStore %43 %uint_6 Aligned 4 + %45 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_1 + OpStore %45 %uint_7 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + %49 = OpPtrCastToGeneric %_ptr_Generic_uint %47 + %50 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + %51 = OpPtrCastToGeneric %_ptr_Generic_uint %50 + OpBranch %for_cond + %for_cond = OpLabel + %52 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %52 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %56 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %49 %56 + %58 = OpLoad %uint %add_ptr Aligned 4 + %59 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %60 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %59 %60 + OpStore %arrayidx %58 Aligned 4 + %62 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %51 %62 + %64 = OpLoad %uint %add_ptr1 Aligned 4 + %65 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %66 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %65 %66 + OpStore %arrayidx2 %64 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %68 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %68 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-local.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-local.spvasm new file mode 100644 index 0000000000..060327c531 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-local.spvasm @@ -0,0 +1,131 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[2] == 1) +; @Output: forall (%r_aligned[4] == 2 and %r_aligned[6] == 3) +; @Output: forall (%r_unaligned[0] == 4 and %r_unaligned[1] == 5) +; @Output: forall (%r_unaligned[2] == 6 and %r_unaligned[3] == 7) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 69 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %18 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %test_aligned "test.aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %test_unaligned "test.unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %test_aligned Alignment 8 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_t = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_Workgroup__arr_struct_aligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_Workgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %17 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool +%test_aligned = OpVariable %_ptr_Workgroup__arr_struct_aligned_t_uint_3 Workgroup +%test_unaligned = OpVariable %_ptr_Workgroup__arr_struct_unaligned_t_uint_3 Workgroup + %18 = OpFunction %void DontInline %17 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + OpStore %33 %uint_0 Aligned 8 + %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_2 + OpStore %35 %uint_1 Aligned 8 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_0 + OpStore %37 %uint_2 Aligned 8 + %38 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_2 + OpStore %38 %uint_3 Aligned 8 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %39 %uint_4 Aligned 4 + %40 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %40 %uint_5 Aligned 4 + %42 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %42 %uint_6 Aligned 4 + %44 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %44 %uint_7 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %46 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + %48 = OpPtrCastToGeneric %_ptr_Generic_uint %46 + %49 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + %50 = OpPtrCastToGeneric %_ptr_Generic_uint %49 + OpBranch %for_cond + %for_cond = OpLabel + %51 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %51 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %55 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %48 %55 + %57 = OpLoad %uint %add_ptr Aligned 4 + %58 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %59 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %58 %59 + OpStore %arrayidx %57 Aligned 4 + %61 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %50 %61 + %63 = OpLoad %uint %add_ptr1 Aligned 4 + %64 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %65 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %64 %65 + OpStore %arrayidx2 %63 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %67 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %67 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-pointer.spvasm new file mode 100644 index 0000000000..ee488a22e3 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment3-struct-pointer.spvasm @@ -0,0 +1,170 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[2] == 1) +; @Output: forall (%r_aligned[4] == 2 and %r_aligned[6] == 3) +; @Output: forall (%r_unaligned[0] == 4 and %r_unaligned[1] == 5) +; @Output: forall (%r_unaligned[2] == 6 and %r_unaligned[3] == 7) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 88 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %13 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %aligned_addr "aligned.addr" + OpName %unaligned_addr "unaligned.addr" + OpName %i "i" + OpName %arrayidx "arrayidx" + OpName %a "a" + OpName %arrayidx1 "arrayidx1" + OpName %b "b" + OpName %arrayidx2 "arrayidx2" + OpName %a3 "a3" + OpName %arrayidx4 "arrayidx4" + OpName %b5 "b5" + OpName %arrayidx6 "arrayidx6" + OpName %a7 "a7" + OpName %arrayidx8 "arrayidx8" + OpName %b9 "b9" + OpName %arrayidx10 "arrayidx10" + OpName %a11 "a11" + OpName %arrayidx12 "arrayidx12" + OpName %b13 "b13" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx14 "arrayidx14" + OpName %add_ptr15 "add.ptr15" + OpName %arrayidx16 "arrayidx16" + OpName %inc "inc" + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %aligned_addr Alignment 4 + OpDecorate %unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%struct_aligned_t = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 +%_ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer CrossWorkgroup %struct_aligned_t +%struct_unaligned_t = OpTypeStruct %uint %uint +%_ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer CrossWorkgroup %struct_unaligned_t + %12 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_t %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_t +%_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function_uint = OpTypePointer Function %uint + %bool = OpTypeBool +%_ptr_Generic_uint = OpTypePointer Generic %uint + %13 = OpFunction %void DontInline %12 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %aligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_t + %unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_unaligned_t + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t Function +%unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + OpStore %aligned_addr %aligned Aligned 4 + OpStore %unaligned_addr %unaligned Aligned 4 + %32 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %32 %uint_0 + %a = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx %uint_0 %uint_0 + OpStore %a %uint_0 Aligned 8 + %36 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx1 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %36 %uint_0 + %b = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx1 %uint_0 %uint_2 + OpStore %b %uint_1 Aligned 8 + %41 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %41 %uint_1 + %a3 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx2 %uint_0 %uint_0 + OpStore %a3 %uint_2 Aligned 8 + %44 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx4 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %44 %uint_1 + %b5 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx4 %uint_0 %uint_2 + OpStore %b5 %uint_3 Aligned 8 + %48 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx6 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %48 %uint_0 + %a7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx6 %uint_0 %uint_0 + OpStore %a7 %uint_4 Aligned 4 + %51 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx8 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %51 %uint_0 + %b9 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx8 %uint_0 %uint_1 + OpStore %b9 %uint_5 Aligned 4 + %55 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx10 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %55 %uint_1 + %a11 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx10 %uint_0 %uint_0 + OpStore %a11 %uint_6 Aligned 4 + %59 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx12 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %59 %uint_1 + %b13 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx12 %uint_0 %uint_1 + OpStore %b13 %uint_7 Aligned 4 + OpStore %i %uint_0 Aligned 4 + OpBranch %for_cond + %for_cond = OpLabel + %63 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %63 %uint_8 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %67 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %68 = OpBitcast %_ptr_CrossWorkgroup_uint %67 + %70 = OpPtrCastToGeneric %_ptr_Generic_uint %68 + %71 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %70 %71 + %73 = OpLoad %uint %add_ptr Aligned 4 + %74 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %75 = OpLoad %uint %i Aligned 4 + %arrayidx14 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %74 %75 + OpStore %arrayidx14 %73 Aligned 4 + %77 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %78 = OpBitcast %_ptr_CrossWorkgroup_uint %77 + %79 = OpPtrCastToGeneric %_ptr_Generic_uint %78 + %80 = OpLoad %uint %i Aligned 4 + %add_ptr15 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %79 %80 + %82 = OpLoad %uint %add_ptr15 Aligned 4 + %83 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %84 = OpLoad %uint %i Aligned 4 + %arrayidx16 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %83 %84 + OpStore %arrayidx16 %82 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %86 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %86 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-global.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-global.spvasm new file mode 100644 index 0000000000..5cbcec743d --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-global.spvasm @@ -0,0 +1,160 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[2] == 1 and %r_aligned[4] == 2 and %r_aligned[8] == 3) +; @Output: forall (%r_aligned[12] == 4 and %r_aligned[14] == 5 and %r_aligned[16] == 6 and %r_aligned[20] == 7) +; @Output: forall (%r_unaligned[0] == 8 and %r_unaligned[1] == 9 and %r_unaligned[2] == 10 and %r_unaligned[3] == 11) +; @Output: forall (%r_unaligned[4] == 12 and %r_unaligned[5] == 13 and %r_unaligned[6] == 14 and %r_unaligned[7] == 15) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 87 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %22 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %aligned "aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %aligned LinkageAttributes "aligned" Export + OpDecorate %unaligned LinkageAttributes "unaligned" Export + OpDecorate %unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_6 = OpConstant %uint 6 + %uint_5 = OpConstant %uint 5 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_24 = OpConstant %uint 24 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_t = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %21 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool + %11 = OpConstantNull %_arr_struct_aligned_t_uint_3 + %aligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 CrossWorkgroup %11 + %16 = OpConstantNull %_arr_struct_unaligned_t_uint_3 + %unaligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 CrossWorkgroup %16 + %22 = OpFunction %void DontInline %21 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + OpStore %36 %uint_0 Aligned 16 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_2 + OpStore %38 %uint_1 Aligned 8 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_4 + OpStore %40 %uint_2 Aligned 16 + %42 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_6 + OpStore %42 %uint_3 Aligned 16 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_0 + OpStore %43 %uint_4 Aligned 16 + %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_2 + OpStore %44 %uint_5 Aligned 8 + %46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_4 + OpStore %46 %uint_6 Aligned 16 + %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_1 %uint_6 + OpStore %47 %uint_7 Aligned 16 + %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + OpStore %49 %uint_8 Aligned 4 + %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_1 + OpStore %51 %uint_9 Aligned 4 + %53 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_2 + OpStore %53 %uint_10 Aligned 4 + %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_3 + OpStore %55 %uint_11 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_0 + OpStore %57 %uint_12 Aligned 4 + %58 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_1 + OpStore %58 %uint_13 Aligned 4 + %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_2 + OpStore %60 %uint_14 Aligned 4 + %62 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_1 %uint_3 + OpStore %62 %uint_15 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %64 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %aligned %uint_0 %uint_0 %uint_0 + %66 = OpPtrCastToGeneric %_ptr_Generic_uint %64 + %67 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %unaligned %uint_0 %uint_0 %uint_0 + %68 = OpPtrCastToGeneric %_ptr_Generic_uint %67 + OpBranch %for_cond + %for_cond = OpLabel + %69 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %69 %uint_24 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %73 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %66 %73 + %75 = OpLoad %uint %add_ptr Aligned 4 + %76 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %77 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %76 %77 + OpStore %arrayidx %75 Aligned 4 + %79 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %68 %79 + %81 = OpLoad %uint %add_ptr1 Aligned 4 + %82 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %83 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %82 %83 + OpStore %arrayidx2 %81 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %85 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %85 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-local.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-local.spvasm new file mode 100644 index 0000000000..5a5629cd9c --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-local.spvasm @@ -0,0 +1,156 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[2] == 1 and %r_aligned[4] == 2 and %r_aligned[8] == 3) +; @Output: forall (%r_aligned[12] == 4 and %r_aligned[14] == 5 and %r_aligned[16] == 6 and %r_aligned[20] == 7) +; @Output: forall (%r_unaligned[0] == 8 and %r_unaligned[1] == 9 and %r_unaligned[2] == 10 and %r_unaligned[3] == 11) +; @Output: forall (%r_unaligned[4] == 12 and %r_unaligned[5] == 13 and %r_unaligned[6] == 14 and %r_unaligned[7] == 15) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 86 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %20 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %test_aligned "test.aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %test_unaligned "test.unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %test_unaligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + OpDecorate %test_aligned Alignment 16 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_6 = OpConstant %uint 6 + %uint_5 = OpConstant %uint 5 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_24 = OpConstant %uint 24 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_t = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_Workgroup__arr_struct_aligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uint %uint %uint %uint +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_Workgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %19 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint +%_ptr_Generic_uint = OpTypePointer Generic %uint + %bool = OpTypeBool +%test_aligned = OpVariable %_ptr_Workgroup__arr_struct_aligned_t_uint_3 Workgroup +%test_unaligned = OpVariable %_ptr_Workgroup__arr_struct_unaligned_t_uint_3 Workgroup + %20 = OpFunction %void DontInline %19 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + OpStore %35 %uint_0 Aligned 16 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_2 + OpStore %37 %uint_1 Aligned 8 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_4 + OpStore %39 %uint_2 Aligned 16 + %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_6 + OpStore %41 %uint_3 Aligned 16 + %42 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_0 + OpStore %42 %uint_4 Aligned 16 + %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_2 + OpStore %43 %uint_5 Aligned 8 + %45 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_4 + OpStore %45 %uint_6 Aligned 16 + %46 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_1 %uint_6 + OpStore %46 %uint_7 Aligned 16 + %48 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %48 %uint_8 Aligned 4 + %50 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 + OpStore %50 %uint_9 Aligned 4 + %52 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 + OpStore %52 %uint_10 Aligned 4 + %54 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_3 + OpStore %54 %uint_11 Aligned 4 + %56 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %56 %uint_12 Aligned 4 + %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 + OpStore %57 %uint_13 Aligned 4 + %59 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 + OpStore %59 %uint_14 Aligned 4 + %61 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_3 + OpStore %61 %uint_15 Aligned 4 + OpStore %i %uint_0 Aligned 4 + %63 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 + %65 = OpPtrCastToGeneric %_ptr_Generic_uint %63 + %66 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 + %67 = OpPtrCastToGeneric %_ptr_Generic_uint %66 + OpBranch %for_cond + %for_cond = OpLabel + %68 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %68 %uint_24 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %72 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %65 %72 + %74 = OpLoad %uint %add_ptr Aligned 4 + %75 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %76 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %75 %76 + OpStore %arrayidx %74 Aligned 4 + %78 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %67 %78 + %80 = OpLoad %uint %add_ptr1 Aligned 4 + %81 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %82 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %81 %82 + OpStore %arrayidx2 %80 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %84 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %84 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-pointer.spvasm new file mode 100644 index 0000000000..5979e8c4eb --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment4-struct-pointer.spvasm @@ -0,0 +1,227 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[2] == 1 and %r_aligned[4] == 2 and %r_aligned[8] == 3) +; @Output: forall (%r_aligned[12] == 4 and %r_aligned[14] == 5 and %r_aligned[16] == 6 and %r_aligned[20] == 7) +; @Output: forall (%r_unaligned[0] == 8 and %r_unaligned[1] == 9 and %r_unaligned[2] == 10 and %r_unaligned[3] == 11) +; @Output: forall (%r_unaligned[4] == 12 and %r_unaligned[5] == 13 and %r_unaligned[6] == 14 and %r_unaligned[7] == 15) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 121 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %15 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %aligned_addr "aligned.addr" + OpName %unaligned_addr "unaligned.addr" + OpName %i "i" + OpName %arrayidx "arrayidx" + OpName %a "a" + OpName %arrayidx1 "arrayidx1" + OpName %b "b" + OpName %arrayidx2 "arrayidx2" + OpName %c "c" + OpName %arrayidx3 "arrayidx3" + OpName %d "d" + OpName %arrayidx4 "arrayidx4" + OpName %a5 "a5" + OpName %arrayidx6 "arrayidx6" + OpName %b7 "b7" + OpName %arrayidx8 "arrayidx8" + OpName %c9 "c9" + OpName %arrayidx10 "arrayidx10" + OpName %d11 "d11" + OpName %arrayidx12 "arrayidx12" + OpName %a13 "a13" + OpName %arrayidx14 "arrayidx14" + OpName %b15 "b15" + OpName %arrayidx16 "arrayidx16" + OpName %c17 "c17" + OpName %arrayidx18 "arrayidx18" + OpName %d19 "d19" + OpName %arrayidx20 "arrayidx20" + OpName %a21 "a21" + OpName %arrayidx22 "arrayidx22" + OpName %b23 "b23" + OpName %arrayidx24 "arrayidx24" + OpName %c25 "c25" + OpName %arrayidx26 "arrayidx26" + OpName %d27 "d27" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx28 "arrayidx28" + OpName %add_ptr29 "add.ptr29" + OpName %arrayidx30 "arrayidx30" + OpName %inc "inc" + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %aligned_addr Alignment 4 + OpDecorate %unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_4 = OpConstant %uint 4 + %uint_12 = OpConstant %uint 12 + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_6 = OpConstant %uint 6 + %uint_3 = OpConstant %uint 3 + %uint_5 = OpConstant %uint 5 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_24 = OpConstant %uint 24 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 +%struct_aligned_t = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 +%_ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer CrossWorkgroup %struct_aligned_t +%struct_unaligned_t = OpTypeStruct %uint %uint %uint %uint +%_ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer CrossWorkgroup %struct_unaligned_t + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_t %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_t +%_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function_uint = OpTypePointer Function %uint + %bool = OpTypeBool +%_ptr_Generic_uint = OpTypePointer Generic %uint + %15 = OpFunction %void DontInline %14 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %aligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_t + %unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_unaligned_t + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function +%aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t Function +%unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + OpStore %aligned_addr %aligned Aligned 4 + OpStore %unaligned_addr %unaligned Aligned 4 + %34 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %34 %uint_0 + %a = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx %uint_0 %uint_0 + OpStore %a %uint_0 Aligned 16 + %38 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx1 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %38 %uint_0 + %b = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx1 %uint_0 %uint_2 + OpStore %b %uint_1 Aligned 8 + %43 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %43 %uint_0 + %c = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx2 %uint_0 %uint_4 + OpStore %c %uint_2 Aligned 16 + %46 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx3 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %46 %uint_0 + %d = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx3 %uint_0 %uint_6 + OpStore %d %uint_3 Aligned 16 + %51 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx4 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %51 %uint_1 + %a5 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx4 %uint_0 %uint_0 + OpStore %a5 %uint_4 Aligned 16 + %54 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx6 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %54 %uint_1 + %b7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx6 %uint_0 %uint_2 + OpStore %b7 %uint_5 Aligned 8 + %58 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx8 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %58 %uint_1 + %c9 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx8 %uint_0 %uint_4 + OpStore %c9 %uint_6 Aligned 16 + %61 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx10 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %61 %uint_1 + %d11 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx10 %uint_0 %uint_6 + OpStore %d11 %uint_7 Aligned 16 + %65 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx12 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %65 %uint_0 + %a13 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx12 %uint_0 %uint_0 + OpStore %a13 %uint_8 Aligned 4 + %69 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx14 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %69 %uint_0 + %b15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx14 %uint_0 %uint_1 + OpStore %b15 %uint_9 Aligned 4 + %73 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx16 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %73 %uint_0 + %c17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx16 %uint_0 %uint_2 + OpStore %c17 %uint_10 Aligned 4 + %77 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %77 %uint_0 + %d19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx18 %uint_0 %uint_3 + OpStore %d19 %uint_11 Aligned 4 + %81 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %81 %uint_1 + %a21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx20 %uint_0 %uint_0 + OpStore %a21 %uint_12 Aligned 4 + %84 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %84 %uint_1 + %b23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx22 %uint_0 %uint_1 + OpStore %b23 %uint_13 Aligned 4 + %88 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %88 %uint_1 + %c25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx24 %uint_0 %uint_2 + OpStore %c25 %uint_14 Aligned 4 + %92 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %92 %uint_1 + %d27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %arrayidx26 %uint_0 %uint_3 + OpStore %d27 %uint_15 Aligned 4 + OpStore %i %uint_0 Aligned 4 + OpBranch %for_cond + %for_cond = OpLabel + %96 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %96 %uint_24 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %100 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %101 = OpBitcast %_ptr_CrossWorkgroup_uint %100 + %103 = OpPtrCastToGeneric %_ptr_Generic_uint %101 + %104 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uint %103 %104 + %106 = OpLoad %uint %add_ptr Aligned 4 + %107 = OpLoad %_ptr_CrossWorkgroup_uint %r_aligned_addr Aligned 4 + %108 = OpLoad %uint %i Aligned 4 + %arrayidx28 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %107 %108 + OpStore %arrayidx28 %106 Aligned 4 + %110 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %111 = OpBitcast %_ptr_CrossWorkgroup_uint %110 + %112 = OpPtrCastToGeneric %_ptr_Generic_uint %111 + %113 = OpLoad %uint %i Aligned 4 + %add_ptr29 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %112 %113 + %115 = OpLoad %uint %add_ptr29 Aligned 4 + %116 = OpLoad %_ptr_CrossWorkgroup_uint %r_unaligned_addr Aligned 4 + %117 = OpLoad %uint %i Aligned 4 + %arrayidx30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %116 %117 + OpStore %arrayidx30 %115 Aligned 4 + OpBranch %for_inc + %for_inc = OpLabel + %119 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %119 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-global.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-global.spvasm new file mode 100644 index 0000000000..e3bcaa5477 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-global.spvasm @@ -0,0 +1,174 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2 and %r_aligned[3] == 3 and %r_aligned[4] == 4) +; @Output: forall (%r_aligned[8] == 5 and %r_aligned[9] == 6 and %r_aligned[10] == 7 and %r_aligned[11] == 8 and %r_aligned[12] == 9) +; @Output: forall (%r_unaligned[0] == 10 and %r_unaligned[1] == 11 and %r_unaligned[2] == 12 and %r_unaligned[3] == 13 and %r_unaligned[4] == 14) +; @Output: forall (%r_unaligned[5] == 15 and %r_unaligned[6] == 16 and %r_unaligned[7] == 17 and %r_unaligned[8] == 18 and %r_unaligned[9] == 19) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 100 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %21 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %aligned "aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %unaligned "unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %unaligned Alignment 1 + OpDecorate %aligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uchar_0 = OpConstant %uchar 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uchar_2 = OpConstant %uchar 2 + %uint_2 = OpConstant %uint 2 + %uchar_3 = OpConstant %uchar 3 + %uchar_4 = OpConstant %uchar 4 + %uchar_5 = OpConstant %uchar 5 + %uchar_6 = OpConstant %uchar 6 + %uchar_7 = OpConstant %uchar 7 + %uchar_8 = OpConstant %uchar 8 + %uchar_9 = OpConstant %uchar 9 + %uchar_10 = OpConstant %uchar 10 + %uchar_11 = OpConstant %uchar 11 + %uchar_12 = OpConstant %uchar 12 + %uchar_13 = OpConstant %uchar 13 + %uchar_14 = OpConstant %uchar 14 + %uchar_15 = OpConstant %uchar 15 + %uchar_16 = OpConstant %uchar 16 + %uchar_17 = OpConstant %uchar 17 + %uchar_18 = OpConstant %uchar 18 + %uchar_19 = OpConstant %uchar 19 + %uint_16 = OpConstant %uint 16 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%_arr_uchar_uint_3 = OpTypeArray %uchar %uint_3 +%struct_aligned_t = OpTypeStruct %uchar %_arr_uchar_uint_4 %_arr_uchar_uint_3 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uchar %_arr_uchar_uint_4 +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer CrossWorkgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %20 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_uchar +%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Generic_uchar = OpTypePointer Generic %uchar + %bool = OpTypeBool + %10 = OpConstantNull %_arr_struct_aligned_t_uint_3 + %aligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_aligned_t_uint_3 CrossWorkgroup %10 + %15 = OpConstantNull %_arr_struct_unaligned_t_uint_3 + %unaligned = OpVariable %_ptr_CrossWorkgroup__arr_struct_unaligned_t_uint_3 CrossWorkgroup %15 + %21 = OpFunction %void DontInline %20 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uchar +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %35 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_0 %uint_0 + OpStore %35 %uchar_0 Aligned 4 + %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_0 %uint_1 %uint_0 + OpStore %38 %uchar_1 Aligned 1 + %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_0 %uint_1 %uint_1 + OpStore %40 %uchar_2 Aligned 1 + %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_0 %uint_1 %uint_2 + OpStore %43 %uchar_3 Aligned 1 + %45 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_0 %uint_1 %uint_3 + OpStore %45 %uchar_4 Aligned 1 + %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_1 %uint_0 + OpStore %47 %uchar_5 Aligned 4 + %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_1 %uint_1 %uint_0 + OpStore %49 %uchar_6 Aligned 1 + %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_1 %uint_1 %uint_1 + OpStore %51 %uchar_7 Aligned 1 + %53 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_1 %uint_1 %uint_2 + OpStore %53 %uchar_8 Aligned 1 + %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_1 %uint_1 %uint_3 + OpStore %55 %uchar_9 Aligned 1 + %57 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_0 %uint_0 + OpStore %57 %uchar_10 Aligned 1 + %59 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_0 %uint_1 %uint_0 + OpStore %59 %uchar_11 Aligned 1 + %61 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_0 %uint_1 %uint_1 + OpStore %61 %uchar_12 Aligned 1 + %63 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_0 %uint_1 %uint_2 + OpStore %63 %uchar_13 Aligned 1 + %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_0 %uint_1 %uint_3 + OpStore %65 %uchar_14 Aligned 1 + %67 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_1 %uint_0 + OpStore %67 %uchar_15 Aligned 1 + %69 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_1 %uint_1 %uint_0 + OpStore %69 %uchar_16 Aligned 1 + %71 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_1 %uint_1 %uint_1 + OpStore %71 %uchar_17 Aligned 1 + %73 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_1 %uint_1 %uint_2 + OpStore %73 %uchar_18 Aligned 1 + %75 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_1 %uint_1 %uint_3 + OpStore %75 %uchar_19 Aligned 1 + OpStore %i %uint_0 Aligned 4 + %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %aligned %uint_0 %uint_0 %uint_0 + %79 = OpPtrCastToGeneric %_ptr_Generic_uchar %77 + %80 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %unaligned %uint_0 %uint_0 %uint_0 + %81 = OpPtrCastToGeneric %_ptr_Generic_uchar %80 + OpBranch %for_cond + %for_cond = OpLabel + %82 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %82 %uint_16 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %86 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uchar %79 %86 + %88 = OpLoad %uchar %add_ptr Aligned 1 + %89 = OpLoad %_ptr_CrossWorkgroup_uchar %r_aligned_addr Aligned 4 + %90 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %89 %90 + OpStore %arrayidx %88 Aligned 1 + %92 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uchar %81 %92 + %94 = OpLoad %uchar %add_ptr1 Aligned 1 + %95 = OpLoad %_ptr_CrossWorkgroup_uchar %r_unaligned_addr Aligned 4 + %96 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %95 %96 + OpStore %arrayidx2 %94 Aligned 1 + OpBranch %for_inc + %for_inc = OpLabel + %98 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %98 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-local.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-local.spvasm new file mode 100644 index 0000000000..5745d55553 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-local.spvasm @@ -0,0 +1,173 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2 and %r_aligned[3] == 3 and %r_aligned[4] == 4) +; @Output: forall (%r_aligned[8] == 5 and %r_aligned[9] == 6 and %r_aligned[10] == 7 and %r_aligned[11] == 8 and %r_aligned[12] == 9) +; @Output: forall (%r_unaligned[0] == 10 and %r_unaligned[1] == 11 and %r_unaligned[2] == 12 and %r_unaligned[3] == 13 and %r_unaligned[4] == 14) +; @Output: forall (%r_unaligned[5] == 15 and %r_unaligned[6] == 16 and %r_unaligned[7] == 17 and %r_unaligned[8] == 18 and %r_unaligned[9] == 19) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 99 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %19 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %test_aligned "test.aligned" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %test_unaligned "test.unaligned" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %i "i" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx "arrayidx" + OpName %add_ptr1 "add.ptr1" + OpName %arrayidx2 "arrayidx2" + OpName %inc "inc" + OpDecorate %test_unaligned Alignment 1 + OpDecorate %test_aligned Alignment 4 + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_0 = OpConstant %uint 0 + %uchar_0 = OpConstant %uchar 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uchar_2 = OpConstant %uchar 2 + %uint_2 = OpConstant %uint 2 + %uchar_3 = OpConstant %uchar 3 + %uchar_4 = OpConstant %uchar 4 + %uchar_5 = OpConstant %uchar 5 + %uchar_6 = OpConstant %uchar 6 + %uchar_7 = OpConstant %uchar 7 + %uchar_8 = OpConstant %uchar 8 + %uchar_9 = OpConstant %uchar 9 + %uchar_10 = OpConstant %uchar 10 + %uchar_11 = OpConstant %uchar 11 + %uchar_12 = OpConstant %uchar 12 + %uchar_13 = OpConstant %uchar 13 + %uchar_14 = OpConstant %uchar 14 + %uchar_15 = OpConstant %uchar 15 + %uchar_16 = OpConstant %uchar 16 + %uchar_17 = OpConstant %uchar 17 + %uchar_18 = OpConstant %uchar 18 + %uchar_19 = OpConstant %uchar 19 + %uint_16 = OpConstant %uint 16 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%_arr_uchar_uint_3 = OpTypeArray %uchar %uint_3 +%struct_aligned_t = OpTypeStruct %uchar %_arr_uchar_uint_4 %_arr_uchar_uint_3 +%_arr_struct_aligned_t_uint_3 = OpTypeArray %struct_aligned_t %uint_3 +%_ptr_Workgroup__arr_struct_aligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_aligned_t_uint_3 +%struct_unaligned_t = OpTypeStruct %uchar %_arr_uchar_uint_4 +%_arr_struct_unaligned_t_uint_3 = OpTypeArray %struct_unaligned_t %uint_3 +%_ptr_Workgroup__arr_struct_unaligned_t_uint_3 = OpTypePointer Workgroup %_arr_struct_unaligned_t_uint_3 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %18 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_uchar +%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_Workgroup_uchar = OpTypePointer Workgroup %uchar +%_ptr_Generic_uchar = OpTypePointer Generic %uchar + %bool = OpTypeBool +%test_aligned = OpVariable %_ptr_Workgroup__arr_struct_aligned_t_uint_3 Workgroup +%test_unaligned = OpVariable %_ptr_Workgroup__arr_struct_unaligned_t_uint_3 Workgroup + %19 = OpFunction %void DontInline %18 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uchar +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + %34 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_0 %uint_0 + OpStore %34 %uchar_0 Aligned 4 + %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_0 %uint_1 %uint_0 + OpStore %37 %uchar_1 Aligned 1 + %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_0 %uint_1 %uint_1 + OpStore %39 %uchar_2 Aligned 1 + %42 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_0 %uint_1 %uint_2 + OpStore %42 %uchar_3 Aligned 1 + %44 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_0 %uint_1 %uint_3 + OpStore %44 %uchar_4 Aligned 1 + %46 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_1 %uint_0 + OpStore %46 %uchar_5 Aligned 4 + %48 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_1 %uint_1 %uint_0 + OpStore %48 %uchar_6 Aligned 1 + %50 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_1 %uint_1 %uint_1 + OpStore %50 %uchar_7 Aligned 1 + %52 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_1 %uint_1 %uint_2 + OpStore %52 %uchar_8 Aligned 1 + %54 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_1 %uint_1 %uint_3 + OpStore %54 %uchar_9 Aligned 1 + %56 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_0 %uint_0 + OpStore %56 %uchar_10 Aligned 1 + %58 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_0 %uint_1 %uint_0 + OpStore %58 %uchar_11 Aligned 1 + %60 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_0 %uint_1 %uint_1 + OpStore %60 %uchar_12 Aligned 1 + %62 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_0 %uint_1 %uint_2 + OpStore %62 %uchar_13 Aligned 1 + %64 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_0 %uint_1 %uint_3 + OpStore %64 %uchar_14 Aligned 1 + %66 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_1 %uint_0 + OpStore %66 %uchar_15 Aligned 1 + %68 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_1 %uint_1 %uint_0 + OpStore %68 %uchar_16 Aligned 1 + %70 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_1 %uint_1 %uint_1 + OpStore %70 %uchar_17 Aligned 1 + %72 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_1 %uint_1 %uint_2 + OpStore %72 %uchar_18 Aligned 1 + %74 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_1 %uint_1 %uint_3 + OpStore %74 %uchar_19 Aligned 1 + OpStore %i %uint_0 Aligned 4 + %76 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_aligned %uint_0 %uint_0 %uint_0 + %78 = OpPtrCastToGeneric %_ptr_Generic_uchar %76 + %79 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %test_unaligned %uint_0 %uint_0 %uint_0 + %80 = OpPtrCastToGeneric %_ptr_Generic_uchar %79 + OpBranch %for_cond + %for_cond = OpLabel + %81 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %81 %uint_16 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %85 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uchar %78 %85 + %87 = OpLoad %uchar %add_ptr Aligned 1 + %88 = OpLoad %_ptr_CrossWorkgroup_uchar %r_aligned_addr Aligned 4 + %89 = OpLoad %uint %i Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %88 %89 + OpStore %arrayidx %87 Aligned 1 + %91 = OpLoad %uint %i Aligned 4 + %add_ptr1 = OpInBoundsPtrAccessChain %_ptr_Generic_uchar %80 %91 + %93 = OpLoad %uchar %add_ptr1 Aligned 1 + %94 = OpLoad %_ptr_CrossWorkgroup_uchar %r_unaligned_addr Aligned 4 + %95 = OpLoad %uint %i Aligned 4 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %94 %95 + OpStore %arrayidx2 %93 Aligned 1 + OpBranch %for_inc + %for_inc = OpLabel + %97 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %97 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-pointer.spvasm new file mode 100644 index 0000000000..8a834ca802 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/opencl/alignment/alignment5-struct-pointer.spvasm @@ -0,0 +1,293 @@ +; @Input: %r_aligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Input: %r_unaligned={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +; @Output: forall (%r_aligned[0] == 0 and %r_aligned[1] == 1 and %r_aligned[2] == 2 and %r_aligned[3] == 3 and %r_aligned[4] == 4) +; @Output: forall (%r_aligned[8] == 5 and %r_aligned[9] == 6 and %r_aligned[10] == 7 and %r_aligned[11] == 8 and %r_aligned[12] == 9) +; @Output: forall (%r_unaligned[0] == 10 and %r_unaligned[1] == 11 and %r_unaligned[2] == 12 and %r_unaligned[3] == 13 and %r_unaligned[4] == 14) +; @Output: forall (%r_unaligned[5] == 15 and %r_unaligned[6] == 16 and %r_unaligned[7] == 17 and %r_unaligned[8] == 18 and %r_unaligned[9] == 19) +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 159 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability GenericPointer + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %15 "test" + OpSource OpenCL_C 200000 + OpName %struct_aligned_t "struct.aligned_t" + OpName %struct_unaligned_t "struct.unaligned_t" + OpName %r_aligned "r_aligned" + OpName %r_unaligned "r_unaligned" + OpName %aligned "aligned" + OpName %unaligned "unaligned" + OpName %entry "entry" + OpName %for_cond "for.cond" + OpName %for_body "for.body" + OpName %for_inc "for.inc" + OpName %for_end "for.end" + OpName %r_aligned_addr "r_aligned.addr" + OpName %r_unaligned_addr "r_unaligned.addr" + OpName %aligned_addr "aligned.addr" + OpName %unaligned_addr "unaligned.addr" + OpName %i "i" + OpName %arrayidx "arrayidx" + OpName %a "a" + OpName %arrayidx1 "arrayidx1" + OpName %b "b" + OpName %arrayidx2 "arrayidx2" + OpName %arrayidx3 "arrayidx3" + OpName %b4 "b4" + OpName %arrayidx5 "arrayidx5" + OpName %arrayidx6 "arrayidx6" + OpName %b7 "b7" + OpName %arrayidx8 "arrayidx8" + OpName %arrayidx9 "arrayidx9" + OpName %b10 "b10" + OpName %arrayidx11 "arrayidx11" + OpName %arrayidx12 "arrayidx12" + OpName %a13 "a13" + OpName %arrayidx14 "arrayidx14" + OpName %b15 "b15" + OpName %arrayidx16 "arrayidx16" + OpName %arrayidx17 "arrayidx17" + OpName %b18 "b18" + OpName %arrayidx19 "arrayidx19" + OpName %arrayidx20 "arrayidx20" + OpName %b21 "b21" + OpName %arrayidx22 "arrayidx22" + OpName %arrayidx23 "arrayidx23" + OpName %b24 "b24" + OpName %arrayidx25 "arrayidx25" + OpName %arrayidx26 "arrayidx26" + OpName %a27 "a27" + OpName %arrayidx28 "arrayidx28" + OpName %b29 "b29" + OpName %arrayidx30 "arrayidx30" + OpName %arrayidx31 "arrayidx31" + OpName %b32 "b32" + OpName %arrayidx33 "arrayidx33" + OpName %arrayidx34 "arrayidx34" + OpName %b35 "b35" + OpName %arrayidx36 "arrayidx36" + OpName %arrayidx37 "arrayidx37" + OpName %b38 "b38" + OpName %arrayidx39 "arrayidx39" + OpName %arrayidx40 "arrayidx40" + OpName %a41 "a41" + OpName %arrayidx42 "arrayidx42" + OpName %b43 "b43" + OpName %arrayidx44 "arrayidx44" + OpName %arrayidx45 "arrayidx45" + OpName %b46 "b46" + OpName %arrayidx47 "arrayidx47" + OpName %arrayidx48 "arrayidx48" + OpName %b49 "b49" + OpName %arrayidx50 "arrayidx50" + OpName %arrayidx51 "arrayidx51" + OpName %b52 "b52" + OpName %arrayidx53 "arrayidx53" + OpName %cmp "cmp" + OpName %add_ptr "add.ptr" + OpName %arrayidx54 "arrayidx54" + OpName %add_ptr55 "add.ptr55" + OpName %arrayidx56 "arrayidx56" + OpName %inc "inc" + OpDecorate %r_aligned_addr Alignment 4 + OpDecorate %r_unaligned_addr Alignment 4 + OpDecorate %aligned_addr Alignment 4 + OpDecorate %unaligned_addr Alignment 4 + OpDecorate %i Alignment 4 + %uchar = OpTypeInt 8 0 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 + %uint_3 = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uchar_0 = OpConstant %uchar 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uchar_2 = OpConstant %uchar 2 + %uint_2 = OpConstant %uint 2 + %uchar_3 = OpConstant %uchar 3 + %uchar_4 = OpConstant %uchar 4 + %uchar_5 = OpConstant %uchar 5 + %uchar_6 = OpConstant %uchar 6 + %uchar_7 = OpConstant %uchar 7 + %uchar_8 = OpConstant %uchar 8 + %uchar_9 = OpConstant %uchar 9 + %uchar_10 = OpConstant %uchar 10 + %uchar_11 = OpConstant %uchar 11 + %uchar_12 = OpConstant %uchar 12 + %uchar_13 = OpConstant %uchar 13 + %uchar_14 = OpConstant %uchar 14 + %uchar_15 = OpConstant %uchar 15 + %uchar_16 = OpConstant %uchar 16 + %uchar_17 = OpConstant %uchar 17 + %uchar_18 = OpConstant %uchar 18 + %uchar_19 = OpConstant %uchar 19 + %uint_16 = OpConstant %uint 16 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 +%_arr_uchar_uint_3 = OpTypeArray %uchar %uint_3 +%struct_aligned_t = OpTypeStruct %uchar %_arr_uchar_uint_4 %_arr_uchar_uint_3 +%_ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer CrossWorkgroup %struct_aligned_t +%struct_unaligned_t = OpTypeStruct %uchar %_arr_uchar_uint_4 +%_ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer CrossWorkgroup %struct_unaligned_t + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_struct_aligned_t %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar +%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_t +%_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t = OpTypePointer Function %_ptr_CrossWorkgroup_struct_unaligned_t +%_ptr_Function_uint = OpTypePointer Function %uint +%_ptr_CrossWorkgroup__arr_uchar_uint_4 = OpTypePointer CrossWorkgroup %_arr_uchar_uint_4 + %bool = OpTypeBool +%_ptr_Generic_uchar = OpTypePointer Generic %uchar + %15 = OpFunction %void DontInline %14 + %r_aligned = OpFunctionParameter %_ptr_CrossWorkgroup_uchar +%r_unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %aligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_t + %unaligned = OpFunctionParameter %_ptr_CrossWorkgroup_struct_unaligned_t + %entry = OpLabel +%r_aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function +%r_unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function +%aligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_t Function +%unaligned_addr = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_unaligned_t Function + %i = OpVariable %_ptr_Function_uint Function + OpStore %r_aligned_addr %r_aligned Aligned 4 + OpStore %r_unaligned_addr %r_unaligned Aligned 4 + OpStore %aligned_addr %aligned Aligned 4 + OpStore %unaligned_addr %unaligned Aligned 4 + %34 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %34 %uint_0 + %a = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %arrayidx %uint_0 %uint_0 + OpStore %a %uchar_0 Aligned 4 + %39 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx1 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %39 %uint_0 + %b = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx1 %uint_0 %uint_1 + %arrayidx2 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b %uint_0 %uint_0 + OpStore %arrayidx2 %uchar_1 Aligned 1 + %46 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx3 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %46 %uint_0 + %b4 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx3 %uint_0 %uint_1 + %arrayidx5 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b4 %uint_0 %uint_1 + OpStore %arrayidx5 %uchar_2 Aligned 1 + %51 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx6 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %51 %uint_0 + %b7 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx6 %uint_0 %uint_1 + %arrayidx8 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b7 %uint_0 %uint_2 + OpStore %arrayidx8 %uchar_3 Aligned 1 + %57 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx9 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %57 %uint_0 + %b10 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx9 %uint_0 %uint_1 + %arrayidx11 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b10 %uint_0 %uint_3 + OpStore %arrayidx11 %uchar_4 Aligned 1 + %62 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx12 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %62 %uint_1 + %a13 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %arrayidx12 %uint_0 %uint_0 + OpStore %a13 %uchar_5 Aligned 4 + %66 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx14 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %66 %uint_1 + %b15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx14 %uint_0 %uint_1 + %arrayidx16 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b15 %uint_0 %uint_0 + OpStore %arrayidx16 %uchar_6 Aligned 1 + %71 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %71 %uint_1 + %b18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx17 %uint_0 %uint_1 + %arrayidx19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b18 %uint_0 %uint_1 + OpStore %arrayidx19 %uchar_7 Aligned 1 + %76 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %76 %uint_1 + %b21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx20 %uint_0 %uint_1 + %arrayidx22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b21 %uint_0 %uint_2 + OpStore %arrayidx22 %uchar_8 Aligned 1 + %81 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %arrayidx23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_aligned_t %81 %uint_1 + %b24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx23 %uint_0 %uint_1 + %arrayidx25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b24 %uint_0 %uint_3 + OpStore %arrayidx25 %uchar_9 Aligned 1 + %86 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %86 %uint_0 + %a27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %arrayidx26 %uint_0 %uint_0 + OpStore %a27 %uchar_10 Aligned 1 + %90 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx28 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %90 %uint_0 + %b29 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx28 %uint_0 %uint_1 + %arrayidx30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b29 %uint_0 %uint_0 + OpStore %arrayidx30 %uchar_11 Aligned 1 + %95 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx31 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %95 %uint_0 + %b32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx31 %uint_0 %uint_1 + %arrayidx33 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b32 %uint_0 %uint_1 + OpStore %arrayidx33 %uchar_12 Aligned 1 + %100 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %100 %uint_0 + %b35 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx34 %uint_0 %uint_1 + %arrayidx36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b35 %uint_0 %uint_2 + OpStore %arrayidx36 %uchar_13 Aligned 1 + %105 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %105 %uint_0 + %b38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx37 %uint_0 %uint_1 + %arrayidx39 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b38 %uint_0 %uint_3 + OpStore %arrayidx39 %uchar_14 Aligned 1 + %110 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %110 %uint_1 + %a41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %arrayidx40 %uint_0 %uint_0 + OpStore %a41 %uchar_15 Aligned 1 + %114 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx42 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %114 %uint_1 + %b43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx42 %uint_0 %uint_1 + %arrayidx44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b43 %uint_0 %uint_0 + OpStore %arrayidx44 %uchar_16 Aligned 1 + %119 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx45 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %119 %uint_1 + %b46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx45 %uint_0 %uint_1 + %arrayidx47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b46 %uint_0 %uint_1 + OpStore %arrayidx47 %uchar_17 Aligned 1 + %124 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %124 %uint_1 + %b49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx48 %uint_0 %uint_1 + %arrayidx50 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b49 %uint_0 %uint_2 + OpStore %arrayidx50 %uchar_18 Aligned 1 + %129 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %arrayidx51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_struct_unaligned_t %129 %uint_1 + %b52 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uchar_uint_4 %arrayidx51 %uint_0 %uint_1 + %arrayidx53 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %b52 %uint_0 %uint_3 + OpStore %arrayidx53 %uchar_19 Aligned 1 + OpStore %i %uint_0 Aligned 4 + OpBranch %for_cond + %for_cond = OpLabel + %134 = OpLoad %uint %i Aligned 4 + %cmp = OpSLessThan %bool %134 %uint_16 + OpBranchConditional %cmp %for_body %for_end + %for_body = OpLabel + %138 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_t %aligned_addr Aligned 4 + %139 = OpBitcast %_ptr_CrossWorkgroup_uchar %138 + %141 = OpPtrCastToGeneric %_ptr_Generic_uchar %139 + %142 = OpLoad %uint %i Aligned 4 + %add_ptr = OpInBoundsPtrAccessChain %_ptr_Generic_uchar %141 %142 + %144 = OpLoad %uchar %add_ptr Aligned 1 + %145 = OpLoad %_ptr_CrossWorkgroup_uchar %r_aligned_addr Aligned 4 + %146 = OpLoad %uint %i Aligned 4 + %arrayidx54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %145 %146 + OpStore %arrayidx54 %144 Aligned 1 + %148 = OpLoad %_ptr_CrossWorkgroup_struct_unaligned_t %unaligned_addr Aligned 4 + %149 = OpBitcast %_ptr_CrossWorkgroup_uchar %148 + %150 = OpPtrCastToGeneric %_ptr_Generic_uchar %149 + %151 = OpLoad %uint %i Aligned 4 + %add_ptr55 = OpInBoundsPtrAccessChain %_ptr_Generic_uchar %150 %151 + %153 = OpLoad %uchar %add_ptr55 Aligned 1 + %154 = OpLoad %_ptr_CrossWorkgroup_uchar %r_unaligned_addr Aligned 4 + %155 = OpLoad %uint %i Aligned 4 + %arrayidx56 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %154 %155 + OpStore %arrayidx56 %153 Aligned 1 + OpBranch %for_inc + %for_inc = OpLabel + %157 = OpLoad %uint %i Aligned 4 + %inc = OpIAdd %uint %157 %uint_1 + OpStore %i %inc Aligned 4 + OpBranch %for_cond + %for_end = OpLabel + OpReturn + OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm deleted file mode 100644 index 79edae0dd8..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment1.spvasm +++ /dev/null @@ -1,91 +0,0 @@ -; @Input: %12={0, 0, 0, 0, 0, 0, 0, 0} -; @Output: forall (%12[0] == 0 and %12[1] == 1 and %12[2] == 2 and %12[4] == 3 and %12[5] == 4 and %12[6] == 5) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 58 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability GenericPointer - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %11 "test" - OpSource OpenCL_C 200000 - OpName %test_data "test.data" - OpDecorate %19 Alignment 4 - OpDecorate %21 Alignment 4 - OpDecorate %test_data Alignment 16 - %uint = OpTypeInt 32 0 - %uint_2 = OpConstant %uint 2 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_5 = OpConstant %uint 5 - %uint_8 = OpConstant %uint 8 - %v3uint = OpTypeVector %uint 3 -%_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2 -%_ptr_Workgroup__arr_v3uint_uint_2 = OpTypePointer Workgroup %_arr_v3uint_uint_2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %10 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Function_uint = OpTypePointer Function %uint -%_ptr_Workgroup_v3uint = OpTypePointer Workgroup %v3uint -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint -%_ptr_Generic_uint = OpTypePointer Generic %uint - %bool = OpTypeBool - %test_data = OpVariable %_ptr_Workgroup__arr_v3uint_uint_2 Workgroup - %11 = OpFunction %void DontInline %10 - %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %13 = OpLabel - %19 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - %21 = OpVariable %_ptr_Function_uint Function - OpStore %19 %12 Aligned 4 - %24 = OpInBoundsPtrAccessChain %_ptr_Workgroup_v3uint %test_data %uint_0 %uint_0 - %25 = OpLoad %v3uint %24 Aligned 16 - %26 = OpCompositeInsert %v3uint %uint_0 %25 0 - OpStore %24 %26 Aligned 16 - %27 = OpLoad %v3uint %24 Aligned 16 - %29 = OpCompositeInsert %v3uint %uint_1 %27 1 - OpStore %24 %29 Aligned 16 - %30 = OpLoad %v3uint %24 Aligned 16 - %31 = OpCompositeInsert %v3uint %uint_2 %30 2 - OpStore %24 %31 Aligned 16 - %32 = OpInBoundsPtrAccessChain %_ptr_Workgroup_v3uint %test_data %uint_0 %uint_1 - %33 = OpLoad %v3uint %32 Aligned 16 - %35 = OpCompositeInsert %v3uint %uint_3 %33 0 - OpStore %32 %35 Aligned 16 - %36 = OpLoad %v3uint %32 Aligned 16 - %38 = OpCompositeInsert %v3uint %uint_4 %36 1 - OpStore %32 %38 Aligned 16 - %39 = OpLoad %v3uint %32 Aligned 16 - %41 = OpCompositeInsert %v3uint %uint_5 %39 2 - OpStore %32 %41 Aligned 16 - OpStore %21 %uint_0 Aligned 4 - %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_data %uint_0 %uint_0 %uint_0 - %45 = OpPtrCastToGeneric %_ptr_Generic_uint %43 - OpBranch %14 - %14 = OpLabel - %46 = OpLoad %uint %21 Aligned 4 - %49 = OpSLessThan %bool %46 %uint_8 - OpBranchConditional %49 %15 %17 - %15 = OpLabel - %50 = OpLoad %uint %21 Aligned 4 - %51 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %45 %50 - %52 = OpLoad %uint %51 Aligned 4 - %53 = OpLoad %_ptr_CrossWorkgroup_uint %19 Aligned 4 - %54 = OpLoad %uint %21 Aligned 4 - %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %53 %54 - OpStore %55 %52 Aligned 4 - OpBranch %16 - %16 = OpLabel - %56 = OpLoad %uint %21 Aligned 4 - %57 = OpIAdd %uint %56 %uint_1 - OpStore %21 %57 Aligned 4 - OpBranch %14 - %17 = OpLabel - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm deleted file mode 100644 index 73a7784315..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment10.spvasm +++ /dev/null @@ -1,74 +0,0 @@ -; @Input: %22 = {0, 0} -; @Output: forall (%22[0] == 1 and %22[1] == 2) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 45 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability GenericPointer - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %21 "test" - OpSource OpenCL_C 200000 - OpName %struct_struct1 "struct.struct1" - OpName %test_s1 "test.s1" - OpName %struct_struct2 "struct.struct2" - OpName %test_s2 "test.s2" - OpDecorate %test_s2 Alignment 4 - OpDecorate %25 Alignment 4 - OpDecorate %test_s1 Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_2 = OpConstant %uint 2 -%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 -%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 -%struct_struct1 = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 -%_ptr_Workgroup_struct_struct1 = OpTypePointer Workgroup %struct_struct1 -%struct_struct2 = OpTypeStruct %_arr_uint_uint_3 %_arr_uint_uint_3 -%_ptr_Workgroup_struct_struct2 = OpTypePointer Workgroup %struct_struct2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %20 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint -%_ptr_Generic_uint = OpTypePointer Generic %uint - %5 = OpUndef %_arr_uint_uint_3 - %9 = OpUndef %_arr_uchar_uint_4 - %11 = OpConstantComposite %struct_struct1 %5 %9 %5 %9 - %test_s1 = OpVariable %_ptr_Workgroup_struct_struct1 Workgroup %11 - %15 = OpConstantComposite %struct_struct2 %5 %5 - %test_s2 = OpVariable %_ptr_Workgroup_struct_struct2 Workgroup %15 - %21 = OpFunction %void DontInline %20 - %22 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %23 = OpLabel - %25 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - OpStore %25 %22 Aligned 4 - %28 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s1 %uint_0 %uint_0 %uint_0 - %30 = OpPtrCastToGeneric %_ptr_Generic_uint %28 - %31 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %30 %uint_4 - OpStore %31 %uint_1 Aligned 4 - %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s2 %uint_0 %uint_0 %uint_0 - %34 = OpPtrCastToGeneric %_ptr_Generic_uint %33 - %35 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %34 %uint_3 - OpStore %35 %uint_2 Aligned 4 - %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s1 %uint_0 %uint_2 %uint_0 - %38 = OpLoad %uint %37 Aligned 16 - %39 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %39 %uint_0 - OpStore %40 %38 Aligned 4 - %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_s2 %uint_0 %uint_1 %uint_0 - %42 = OpLoad %uint %41 Aligned 4 - %43 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %43 %uint_1 - OpStore %44 %42 Aligned 4 - OpReturn - OpFunctionEnd - diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm deleted file mode 100644 index ed1e9c3488..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment2.spvasm +++ /dev/null @@ -1,77 +0,0 @@ -; @Input: %20={0, 0, 0, 0} -; @Output: forall (%20[0] == 1 and %20[1] == 2 and %20[2] == 3 and %20[3] == 4) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 47 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %19 "test" - OpSource OpenCL_C 200000 - OpName %struct_aligned_struct "struct.aligned_struct" - OpName %test_aligned "test.aligned" - OpName %test_unaligned "test.unaligned" - OpDecorate %test_unaligned Alignment 4 - OpDecorate %23 Alignment 4 - OpDecorate %test_aligned Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %3 = OpUndef %uint - %uint_12 = OpConstant %uint 12 - %uint_2 = OpConstant %uint 2 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_4 = OpConstant %uint 4 - %uint_3 = OpConstant %uint 3 -%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 -%struct_aligned_struct = OpTypeStruct %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 -%_ptr_Workgroup_struct_aligned_struct = OpTypePointer Workgroup %struct_aligned_struct -%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 -%_ptr_Workgroup__arr_uint_uint_2 = OpTypePointer Workgroup %_arr_uint_uint_2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %18 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint - %7 = OpUndef %_arr_uchar_uint_12 - %9 = OpConstantComposite %struct_aligned_struct %3 %7 %3 %7 -%test_aligned = OpVariable %_ptr_Workgroup_struct_aligned_struct Workgroup %9 -%test_unaligned = OpVariable %_ptr_Workgroup__arr_uint_uint_2 Workgroup - %19 = OpFunction %void DontInline %18 - %20 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %21 = OpLabel - %23 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - OpStore %23 %20 Aligned 4 - %26 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 - OpStore %26 %uint_1 Aligned 16 - %28 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 - %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %28 %uint_4 - OpStore %30 %uint_2 Aligned 4 - %31 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 - OpStore %31 %uint_3 Aligned 4 - %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 - OpStore %33 %uint_4 Aligned 4 - %34 = OpLoad %uint %26 Aligned 16 - %35 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 - %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %35 %uint_0 - OpStore %36 %34 Aligned 4 - %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 - %38 = OpLoad %uint %37 Aligned 16 - %39 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 - %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %39 %uint_1 - OpStore %40 %38 Aligned 4 - %41 = OpLoad %uint %31 Aligned 4 - %42 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 - %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %42 %uint_2 - OpStore %43 %41 Aligned 4 - %44 = OpLoad %uint %33 Aligned 4 - %45 = OpLoad %_ptr_CrossWorkgroup_uint %23 Aligned 4 - %46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %45 %uint_3 - OpStore %46 %44 Aligned 4 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm deleted file mode 100644 index 5e23e48799..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment3.spvasm +++ /dev/null @@ -1,134 +0,0 @@ -; @Input: %22={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -; @Output: forall (%22[0] == 0 and %22[1] == 1 and %22[2] == 2 and %22[3] == 4 and %22[4] == 5 and %22[5] == 6 and %22[6] == 10 and %22[7] == 11 and %22[8] == 12 and %22[9] == 13 and %22[10] == 14 and %22[11] == 15) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 88 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %21 "test" - OpSource OpenCL_C 200000 - OpName %struct_aligned_struct "struct.aligned_struct" - OpName %test_aligned "test.aligned" - OpName %test_unaligned "test.unaligned" - OpDecorate %test_unaligned Alignment 4 - OpDecorate %25 Alignment 4 - OpDecorate %test_aligned Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_2 = OpConstant %uint 2 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_5 = OpConstant %uint 5 - %uint_6 = OpConstant %uint 6 - %uint_10 = OpConstant %uint 10 - %uint_11 = OpConstant %uint 11 - %uint_12 = OpConstant %uint 12 - %uint_13 = OpConstant %uint 13 - %uint_14 = OpConstant %uint 14 - %uint_15 = OpConstant %uint 15 - %uint_7 = OpConstant %uint 7 - %uint_8 = OpConstant %uint 8 - %uint_9 = OpConstant %uint 9 -%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 -%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 -%struct_aligned_struct = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 -%_ptr_Workgroup_struct_aligned_struct = OpTypePointer Workgroup %struct_aligned_struct -%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2 -%_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 = OpTypePointer Workgroup %_arr__arr_uint_uint_3_uint_2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %20 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint - %5 = OpUndef %_arr_uint_uint_3 - %9 = OpUndef %_arr_uchar_uint_4 - %11 = OpConstantComposite %struct_aligned_struct %5 %9 %5 %9 -%test_aligned = OpVariable %_ptr_Workgroup_struct_aligned_struct Workgroup %11 -%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 Workgroup - %21 = OpFunction %void DontInline %20 - %22 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %23 = OpLabel - %25 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - OpStore %25 %22 Aligned 4 - %28 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_0 - OpStore %28 %uint_0 Aligned 16 - %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_1 - OpStore %30 %uint_1 Aligned 4 - %31 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_0 %uint_2 - OpStore %31 %uint_2 Aligned 8 - %32 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 %uint_0 - OpStore %32 %uint_4 Aligned 16 - %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 %uint_1 - OpStore %33 %uint_5 Aligned 4 - %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_aligned %uint_0 %uint_2 %uint_2 - OpStore %35 %uint_6 Aligned 8 - %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 - OpStore %37 %uint_10 Aligned 4 - %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 - OpStore %39 %uint_11 Aligned 4 - %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 - OpStore %41 %uint_12 Aligned 4 - %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 - OpStore %43 %uint_13 Aligned 4 - %45 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 - OpStore %45 %uint_14 Aligned 4 - %47 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 - OpStore %47 %uint_15 Aligned 4 - %49 = OpLoad %uint %28 Aligned 16 - %50 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %50 %uint_0 - OpStore %51 %49 Aligned 4 - %52 = OpLoad %uint %30 Aligned 4 - %53 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %53 %uint_1 - OpStore %54 %52 Aligned 4 - %55 = OpLoad %uint %31 Aligned 8 - %56 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %57 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %56 %uint_2 - OpStore %57 %55 Aligned 4 - %58 = OpLoad %uint %32 Aligned 16 - %59 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %59 %uint_3 - OpStore %60 %58 Aligned 4 - %61 = OpLoad %uint %33 Aligned 4 - %62 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %63 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %62 %uint_4 - OpStore %63 %61 Aligned 4 - %64 = OpLoad %uint %35 Aligned 8 - %65 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %66 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %65 %uint_5 - OpStore %66 %64 Aligned 4 - %67 = OpLoad %uint %37 Aligned 4 - %68 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %69 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %68 %uint_6 - OpStore %69 %67 Aligned 4 - %70 = OpLoad %uint %39 Aligned 4 - %71 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %73 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %71 %uint_7 - OpStore %73 %70 Aligned 4 - %74 = OpLoad %uint %41 Aligned 4 - %75 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %75 %uint_8 - OpStore %77 %74 Aligned 4 - %78 = OpLoad %uint %43 Aligned 4 - %79 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %81 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %79 %uint_9 - OpStore %81 %78 Aligned 4 - %82 = OpLoad %uint %45 Aligned 4 - %83 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %84 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %83 %uint_10 - OpStore %84 %82 Aligned 4 - %85 = OpLoad %uint %47 Aligned 4 - %86 = OpLoad %_ptr_CrossWorkgroup_uint %25 Aligned 4 - %87 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %86 %uint_11 - OpStore %87 %85 Aligned 4 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm deleted file mode 100644 index 082e5013d2..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment4.spvasm +++ /dev/null @@ -1,387 +0,0 @@ -; @Input: %27={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -; @Output: forall (%27[0] == 0 and %27[1] == 1 and %27[2] == 2 and %27[3] == 3 and %27[4] == 4 and %27[5] == 5 and %27[6] == 6 and %27[7] == 7 and %27[8] == 8 and %27[9] == 9 and %27[10] == 10 and %27[11] == 11 and %27[12] == 12 and %27[13] == 13 and %27[14] == 14 and %27[15] == 15 and %27[16] == 16 and %27[17] == 17 and %27[18] == 18 and %27[19] == 19 and %27[20] == 20 and %27[21] == 21 and %27[22] == 22 and %27[23] == 23 and %27[24] == 24 and %27[25] == 25 and %27[26] == 26 and %27[27] == 27 and %27[28] == 28 and %27[29] == 29 and %27[30] == 30 and %27[31] == 31 and %27[32] == 32 and %27[33] == 33 and %27[34] == 34 and %27[35] == 35 and %27[36] == 36 and %27[37] == 37 and %27[38] == 38 and %27[39] == 39 and %27[40] == 40 and %27[41] == 41 and %27[42] == 42 and %27[43] == 43 and %27[44] == 44 and %27[45] == 45 and %27[46] == 46 and %27[47] == 47) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 268 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %26 "test" - OpSource OpenCL_C 200000 - OpName %struct_aligned_struct "struct.aligned_struct" - OpName %struct_nested_aligned_struct "struct.nested_aligned_struct" - OpName %test_nested_aligned "test.nested_aligned" - OpName %test_unaligned "test.unaligned" - OpDecorate %test_unaligned Alignment 4 - OpDecorate %30 Alignment 4 - OpDecorate %test_nested_aligned Alignment 64 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_32 = OpConstant %uint 32 - %uint_2 = OpConstant %uint 2 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_5 = OpConstant %uint 5 - %uint_6 = OpConstant %uint 6 - %uint_7 = OpConstant %uint 7 - %uint_8 = OpConstant %uint 8 - %uint_9 = OpConstant %uint 9 - %uint_10 = OpConstant %uint 10 - %uint_11 = OpConstant %uint 11 - %uint_12 = OpConstant %uint 12 - %uint_13 = OpConstant %uint 13 - %uint_14 = OpConstant %uint 14 - %uint_15 = OpConstant %uint 15 - %uint_16 = OpConstant %uint 16 - %uint_17 = OpConstant %uint 17 - %uint_18 = OpConstant %uint 18 - %uint_19 = OpConstant %uint 19 - %uint_20 = OpConstant %uint 20 - %uint_21 = OpConstant %uint 21 - %uint_22 = OpConstant %uint 22 - %uint_23 = OpConstant %uint 23 - %uint_24 = OpConstant %uint 24 - %uint_25 = OpConstant %uint 25 - %uint_26 = OpConstant %uint 26 - %uint_27 = OpConstant %uint 27 - %uint_28 = OpConstant %uint 28 - %uint_29 = OpConstant %uint 29 - %uint_30 = OpConstant %uint 30 - %uint_31 = OpConstant %uint 31 - %uint_33 = OpConstant %uint 33 - %uint_34 = OpConstant %uint 34 - %uint_35 = OpConstant %uint 35 - %uint_36 = OpConstant %uint 36 - %uint_37 = OpConstant %uint 37 - %uint_38 = OpConstant %uint 38 - %uint_39 = OpConstant %uint 39 - %uint_40 = OpConstant %uint 40 - %uint_41 = OpConstant %uint 41 - %uint_42 = OpConstant %uint 42 - %uint_43 = OpConstant %uint 43 - %uint_44 = OpConstant %uint 44 - %uint_45 = OpConstant %uint 45 - %uint_46 = OpConstant %uint 46 - %uint_47 = OpConstant %uint 47 -%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 -%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 -%struct_aligned_struct = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 -%_arr_struct_aligned_struct_uint_3 = OpTypeArray %struct_aligned_struct %uint_3 -%_arr_uchar_uint_32 = OpTypeArray %uchar %uint_32 -%struct_nested_aligned_struct = OpTypeStruct %_arr_struct_aligned_struct_uint_3 %_arr_uchar_uint_32 %_arr_struct_aligned_struct_uint_3 %_arr_uchar_uint_32 -%_ptr_Workgroup_struct_nested_aligned_struct = OpTypePointer Workgroup %struct_nested_aligned_struct -%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2 -%_arr__arr__arr_uint_uint_3_uint_2_uint_2 = OpTypeArray %_arr__arr_uint_uint_3_uint_2 %uint_2 -%_ptr_Workgroup__arr__arr__arr_uint_uint_3_uint_2_uint_2 = OpTypePointer Workgroup %_arr__arr__arr_uint_uint_3_uint_2_uint_2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %25 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint - %10 = OpUndef %_arr_struct_aligned_struct_uint_3 - %13 = OpUndef %_arr_uchar_uint_32 - %15 = OpConstantComposite %struct_nested_aligned_struct %10 %13 %10 %13 -%test_nested_aligned = OpVariable %_ptr_Workgroup_struct_nested_aligned_struct Workgroup %15 -%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr__arr_uint_uint_3_uint_2_uint_2 Workgroup - %26 = OpFunction %void DontInline %25 - %27 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %28 = OpLabel - %30 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - OpStore %30 %27 Aligned 4 - %33 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_0 %uint_0 - OpStore %33 %uint_0 Aligned 64 - %35 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_0 %uint_1 - OpStore %35 %uint_1 Aligned 4 - %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_0 %uint_2 - OpStore %36 %uint_2 Aligned 8 - %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_2 %uint_0 - OpStore %37 %uint_3 Aligned 16 - %38 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_2 %uint_1 - OpStore %38 %uint_4 Aligned 4 - %39 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_0 %uint_2 %uint_2 - OpStore %39 %uint_5 Aligned 8 - %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_0 %uint_0 - OpStore %41 %uint_6 Aligned 32 - %43 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_0 %uint_1 - OpStore %43 %uint_7 Aligned 4 - %45 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_0 %uint_2 - OpStore %45 %uint_8 Aligned 8 - %47 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_2 %uint_0 - OpStore %47 %uint_9 Aligned 16 - %49 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_2 %uint_1 - OpStore %49 %uint_10 Aligned 4 - %51 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_1 %uint_2 %uint_2 - OpStore %51 %uint_11 Aligned 8 - %53 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_0 %uint_0 - OpStore %53 %uint_12 Aligned 64 - %55 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_0 %uint_1 - OpStore %55 %uint_13 Aligned 4 - %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_0 %uint_2 - OpStore %57 %uint_14 Aligned 8 - %59 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_2 %uint_0 - OpStore %59 %uint_15 Aligned 16 - %61 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_2 %uint_1 - OpStore %61 %uint_16 Aligned 4 - %63 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_0 %uint_2 %uint_2 %uint_2 - OpStore %63 %uint_17 Aligned 8 - %65 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_0 %uint_0 - OpStore %65 %uint_18 Aligned 64 - %67 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_0 %uint_1 - OpStore %67 %uint_19 Aligned 4 - %69 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_0 %uint_2 - OpStore %69 %uint_20 Aligned 8 - %71 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_2 %uint_0 - OpStore %71 %uint_21 Aligned 16 - %73 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_2 %uint_1 - OpStore %73 %uint_22 Aligned 4 - %75 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_0 %uint_2 %uint_2 - OpStore %75 %uint_23 Aligned 8 - %77 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_0 %uint_0 - OpStore %77 %uint_24 Aligned 32 - %79 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_0 %uint_1 - OpStore %79 %uint_25 Aligned 4 - %81 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_0 %uint_2 - OpStore %81 %uint_26 Aligned 8 - %83 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_2 %uint_0 - OpStore %83 %uint_27 Aligned 16 - %85 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_2 %uint_1 - OpStore %85 %uint_28 Aligned 4 - %87 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_1 %uint_2 %uint_2 - OpStore %87 %uint_29 Aligned 8 - %89 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_0 %uint_0 - OpStore %89 %uint_30 Aligned 64 - %91 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_0 %uint_1 - OpStore %91 %uint_31 Aligned 4 - %93 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_0 %uint_2 - OpStore %93 %uint_32 Aligned 8 - %94 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_2 %uint_0 - OpStore %94 %uint_33 Aligned 16 - %96 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_2 %uint_1 - OpStore %96 %uint_34 Aligned 4 - %98 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_nested_aligned %uint_0 %uint_2 %uint_2 %uint_2 %uint_2 - OpStore %98 %uint_35 Aligned 8 - %100 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 %uint_0 - OpStore %100 %uint_36 Aligned 4 - %102 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 %uint_1 - OpStore %102 %uint_37 Aligned 4 - %104 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 %uint_2 - OpStore %104 %uint_38 Aligned 4 - %106 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 %uint_0 - OpStore %106 %uint_39 Aligned 4 - %108 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 %uint_1 - OpStore %108 %uint_40 Aligned 4 - %110 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 %uint_2 - OpStore %110 %uint_41 Aligned 4 - %112 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 %uint_0 - OpStore %112 %uint_42 Aligned 4 - %114 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 %uint_1 - OpStore %114 %uint_43 Aligned 4 - %116 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 %uint_2 - OpStore %116 %uint_44 Aligned 4 - %118 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 %uint_0 - OpStore %118 %uint_45 Aligned 4 - %120 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 %uint_1 - OpStore %120 %uint_46 Aligned 4 - %122 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 %uint_2 - OpStore %122 %uint_47 Aligned 4 - %124 = OpLoad %uint %33 Aligned 64 - %125 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %126 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %125 %uint_0 - OpStore %126 %124 Aligned 4 - %127 = OpLoad %uint %35 Aligned 4 - %128 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %129 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %128 %uint_1 - OpStore %129 %127 Aligned 4 - %130 = OpLoad %uint %36 Aligned 8 - %131 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %132 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %131 %uint_2 - OpStore %132 %130 Aligned 4 - %133 = OpLoad %uint %37 Aligned 16 - %134 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %135 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %134 %uint_3 - OpStore %135 %133 Aligned 4 - %136 = OpLoad %uint %38 Aligned 4 - %137 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %138 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %137 %uint_4 - OpStore %138 %136 Aligned 4 - %139 = OpLoad %uint %39 Aligned 8 - %140 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %141 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %140 %uint_5 - OpStore %141 %139 Aligned 4 - %142 = OpLoad %uint %41 Aligned 32 - %143 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %144 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %143 %uint_6 - OpStore %144 %142 Aligned 4 - %145 = OpLoad %uint %43 Aligned 4 - %146 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %147 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %146 %uint_7 - OpStore %147 %145 Aligned 4 - %148 = OpLoad %uint %45 Aligned 8 - %149 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %150 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %149 %uint_8 - OpStore %150 %148 Aligned 4 - %151 = OpLoad %uint %47 Aligned 16 - %152 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %153 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %152 %uint_9 - OpStore %153 %151 Aligned 4 - %154 = OpLoad %uint %49 Aligned 4 - %155 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %156 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %155 %uint_10 - OpStore %156 %154 Aligned 4 - %157 = OpLoad %uint %51 Aligned 8 - %158 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %159 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %158 %uint_11 - OpStore %159 %157 Aligned 4 - %160 = OpLoad %uint %53 Aligned 64 - %161 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %162 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %161 %uint_12 - OpStore %162 %160 Aligned 4 - %163 = OpLoad %uint %55 Aligned 4 - %164 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %165 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %164 %uint_13 - OpStore %165 %163 Aligned 4 - %166 = OpLoad %uint %57 Aligned 8 - %167 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %168 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %167 %uint_14 - OpStore %168 %166 Aligned 4 - %169 = OpLoad %uint %59 Aligned 16 - %170 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %171 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %170 %uint_15 - OpStore %171 %169 Aligned 4 - %172 = OpLoad %uint %61 Aligned 4 - %173 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %174 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %173 %uint_16 - OpStore %174 %172 Aligned 4 - %175 = OpLoad %uint %63 Aligned 8 - %176 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %177 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %176 %uint_17 - OpStore %177 %175 Aligned 4 - %178 = OpLoad %uint %65 Aligned 64 - %179 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %180 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %179 %uint_18 - OpStore %180 %178 Aligned 4 - %181 = OpLoad %uint %67 Aligned 4 - %182 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %183 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %182 %uint_19 - OpStore %183 %181 Aligned 4 - %184 = OpLoad %uint %69 Aligned 8 - %185 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %186 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %185 %uint_20 - OpStore %186 %184 Aligned 4 - %187 = OpLoad %uint %71 Aligned 16 - %188 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %189 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %188 %uint_21 - OpStore %189 %187 Aligned 4 - %190 = OpLoad %uint %73 Aligned 4 - %191 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %192 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %191 %uint_22 - OpStore %192 %190 Aligned 4 - %193 = OpLoad %uint %75 Aligned 8 - %194 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %195 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %194 %uint_23 - OpStore %195 %193 Aligned 4 - %196 = OpLoad %uint %77 Aligned 32 - %197 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %198 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %197 %uint_24 - OpStore %198 %196 Aligned 4 - %199 = OpLoad %uint %79 Aligned 4 - %200 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %201 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %200 %uint_25 - OpStore %201 %199 Aligned 4 - %202 = OpLoad %uint %81 Aligned 8 - %203 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %204 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %203 %uint_26 - OpStore %204 %202 Aligned 4 - %205 = OpLoad %uint %83 Aligned 16 - %206 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %207 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %206 %uint_27 - OpStore %207 %205 Aligned 4 - %208 = OpLoad %uint %85 Aligned 4 - %209 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %210 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %209 %uint_28 - OpStore %210 %208 Aligned 4 - %211 = OpLoad %uint %87 Aligned 8 - %212 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %213 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %212 %uint_29 - OpStore %213 %211 Aligned 4 - %214 = OpLoad %uint %89 Aligned 64 - %215 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %216 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %215 %uint_30 - OpStore %216 %214 Aligned 4 - %217 = OpLoad %uint %91 Aligned 4 - %218 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %219 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %218 %uint_31 - OpStore %219 %217 Aligned 4 - %220 = OpLoad %uint %93 Aligned 8 - %221 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %222 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %221 %uint_32 - OpStore %222 %220 Aligned 4 - %223 = OpLoad %uint %94 Aligned 16 - %224 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %225 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %224 %uint_33 - OpStore %225 %223 Aligned 4 - %226 = OpLoad %uint %96 Aligned 4 - %227 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %228 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %227 %uint_34 - OpStore %228 %226 Aligned 4 - %229 = OpLoad %uint %98 Aligned 8 - %230 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %231 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %230 %uint_35 - OpStore %231 %229 Aligned 4 - %232 = OpLoad %uint %100 Aligned 4 - %233 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %234 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %233 %uint_36 - OpStore %234 %232 Aligned 4 - %235 = OpLoad %uint %102 Aligned 4 - %236 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %237 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %236 %uint_37 - OpStore %237 %235 Aligned 4 - %238 = OpLoad %uint %104 Aligned 4 - %239 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %240 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %239 %uint_38 - OpStore %240 %238 Aligned 4 - %241 = OpLoad %uint %106 Aligned 4 - %242 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %243 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %242 %uint_39 - OpStore %243 %241 Aligned 4 - %244 = OpLoad %uint %108 Aligned 4 - %245 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %246 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %245 %uint_40 - OpStore %246 %244 Aligned 4 - %247 = OpLoad %uint %110 Aligned 4 - %248 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %249 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %248 %uint_41 - OpStore %249 %247 Aligned 4 - %250 = OpLoad %uint %112 Aligned 4 - %251 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %252 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %251 %uint_42 - OpStore %252 %250 Aligned 4 - %253 = OpLoad %uint %114 Aligned 4 - %254 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %255 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %254 %uint_43 - OpStore %255 %253 Aligned 4 - %256 = OpLoad %uint %116 Aligned 4 - %257 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %258 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %257 %uint_44 - OpStore %258 %256 Aligned 4 - %259 = OpLoad %uint %118 Aligned 4 - %260 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %261 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %260 %uint_45 - OpStore %261 %259 Aligned 4 - %262 = OpLoad %uint %120 Aligned 4 - %263 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %264 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %263 %uint_46 - OpStore %264 %262 Aligned 4 - %265 = OpLoad %uint %122 Aligned 4 - %266 = OpLoad %_ptr_CrossWorkgroup_uint %30 Aligned 4 - %267 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %266 %uint_47 - OpStore %267 %265 Aligned 4 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm deleted file mode 100644 index 16552936c0..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment5.spvasm +++ /dev/null @@ -1,94 +0,0 @@ -; @Input: %21={0, 0, 0, 0} -; @Output: forall (%21[0] == 0 and %21[1] == 22 and %21[2] == 2 and %21[3] == 3) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 60 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability GenericPointer - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %20 "manual_vs_struct" - OpSource OpenCL_C 200000 - OpName %struct_struct1 "struct.struct1" - OpName %manual_vs_struct_s1 "manual_vs_struct.s1" - OpName %struct_struct2 "struct.struct2" - OpName %manual_vs_struct_s2 "manual_vs_struct.s2" - OpDecorate %manual_vs_struct_s2 Alignment 4 - OpDecorate %24 Alignment 4 - OpDecorate %manual_vs_struct_s1 Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %3 = OpUndef %uint - %5 = OpUndef %uchar - %uint_11 = OpConstant %uint 11 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uchar_1 = OpConstant %uchar 1 - %uint_2 = OpConstant %uint 2 - %uchar_3 = OpConstant %uchar 3 - %uint_22 = OpConstant %uint 22 - %uint_33 = OpConstant %uint 33 - %uint_3 = OpConstant %uint 3 -%_arr_uchar_uint_11 = OpTypeArray %uchar %uint_11 -%struct_struct1 = OpTypeStruct %uint %uchar %_arr_uchar_uint_11 -%_ptr_Workgroup_struct_struct1 = OpTypePointer Workgroup %struct_struct1 -%struct_struct2 = OpTypeStruct %uchar %uint -%_ptr_Workgroup_struct_struct2 = OpTypePointer Workgroup %struct_struct2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar - %19 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar -%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint -%_ptr_Workgroup_uchar = OpTypePointer Workgroup %uchar -%_ptr_Generic_uint = OpTypePointer Generic %uint - %8 = OpUndef %_arr_uchar_uint_11 - %10 = OpConstantComposite %struct_struct1 %3 %5 %8 -%manual_vs_struct_s1 = OpVariable %_ptr_Workgroup_struct_struct1 Workgroup %10 - %14 = OpConstantComposite %struct_struct2 %5 %3 -%manual_vs_struct_s2 = OpVariable %_ptr_Workgroup_struct_struct2 Workgroup %14 - %20 = OpFunction %void DontInline %19 - %21 = OpFunctionParameter %_ptr_CrossWorkgroup_uchar - %22 = OpLabel - %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function - OpStore %24 %21 Aligned 4 - %27 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s1 %uint_0 %uint_0 - OpStore %27 %uint_0 Aligned 16 - %30 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %manual_vs_struct_s1 %uint_0 %uint_1 - OpStore %30 %uchar_1 Aligned 4 - %32 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s2 %uint_0 %uint_1 - OpStore %32 %uint_2 Aligned 4 - %34 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uchar %manual_vs_struct_s2 %uint_0 %uint_0 - OpStore %34 %uchar_3 Aligned 4 - %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s1 %uint_0 %uint_0 - %37 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %36 %uint_1 - %39 = OpPtrCastToGeneric %_ptr_Generic_uint %37 - OpStore %39 %uint_22 Aligned 4 - %41 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %manual_vs_struct_s2 %uint_0 %uint_1 - %42 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %41 %uint_1 - %43 = OpPtrCastToGeneric %_ptr_Generic_uint %42 - OpStore %43 %uint_33 Aligned 4 - %45 = OpLoad %uint %27 Aligned 16 - %46 = OpUConvert %uchar %45 - %47 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 - %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %47 %uint_0 - OpStore %48 %46 Aligned 1 - %49 = OpLoad %uchar %30 Aligned 4 - %50 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 - %51 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %50 %uint_1 - OpStore %51 %49 Aligned 1 - %52 = OpLoad %uint %32 Aligned 4 - %53 = OpUConvert %uchar %52 - %54 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 - %55 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %54 %uint_2 - OpStore %55 %53 Aligned 1 - %56 = OpLoad %uchar %34 Aligned 4 - %57 = OpLoad %_ptr_CrossWorkgroup_uchar %24 Aligned 4 - %59 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %57 %uint_3 - OpStore %59 %56 Aligned 1 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm deleted file mode 100644 index 71a7ae5d7f..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment6.spvasm +++ /dev/null @@ -1,169 +0,0 @@ -; @Input: %20={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -; @Output: forall (%20[0] == 0 and %20[1] == 1 and %20[2] == 2 and %20[3] == 4 and %20[4] == 5 and %20[5] == 6 and %20[6] == 10 and %20[7] == 11 and %20[8] == 12 and %20[9] == 13 and %20[10] == 14 and %20[11] == 15) -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 120 -; Schema: 0 - OpCapability Addresses - OpCapability Linkage - OpCapability Kernel - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %19 "test" - OpSource OpenCL_C 200000 - OpName %test_unaligned "test.unaligned" - OpName %struct_aligned_struct "struct.aligned_struct" - OpName %aligned "aligned" - OpDecorate %aligned LinkageAttributes "aligned" Export - OpDecorate %test_unaligned Alignment 4 - OpDecorate %24 Alignment 4 - OpDecorate %26 Alignment 4 - OpDecorate %aligned Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %uint_2 = OpConstant %uint 2 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_5 = OpConstant %uint 5 - %uint_6 = OpConstant %uint 6 - %uint_10 = OpConstant %uint 10 - %uint_11 = OpConstant %uint 11 - %uint_12 = OpConstant %uint 12 - %uint_13 = OpConstant %uint 13 - %uint_14 = OpConstant %uint 14 - %uint_15 = OpConstant %uint 15 - %uint_7 = OpConstant %uint 7 - %uint_8 = OpConstant %uint 8 - %uint_9 = OpConstant %uint 9 -%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 -%_arr__arr_uint_uint_3_uint_2 = OpTypeArray %_arr_uint_uint_3 %uint_2 -%_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 = OpTypePointer Workgroup %_arr__arr_uint_uint_3_uint_2 -%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 -%struct_aligned_struct = OpTypeStruct %_arr_uint_uint_3 %_arr_uchar_uint_4 %_arr_uint_uint_3 %_arr_uchar_uint_4 -%_ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer CrossWorkgroup %struct_aligned_struct - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %18 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_struct -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_struct -%_ptr_CrossWorkgroup__arr_uint_uint_3 = OpTypePointer CrossWorkgroup %_arr_uint_uint_3 -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint -%test_unaligned = OpVariable %_ptr_Workgroup__arr__arr_uint_uint_3_uint_2 Workgroup - %13 = OpConstantNull %struct_aligned_struct - %aligned = OpVariable %_ptr_CrossWorkgroup_struct_aligned_struct CrossWorkgroup %13 - %19 = OpFunction %void DontInline %18 - %20 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %21 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_struct - %22 = OpLabel - %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - %26 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct Function - OpStore %24 %20 Aligned 4 - OpStore %26 %21 Aligned 4 - %27 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %27 %uint_0 %uint_0 - %31 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %30 %uint_0 %uint_0 - OpStore %31 %uint_0 Aligned 16 - %32 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %33 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %32 %uint_0 %uint_0 - %35 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %33 %uint_0 %uint_1 - OpStore %35 %uint_1 Aligned 4 - %36 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %36 %uint_0 %uint_0 - %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %37 %uint_0 %uint_2 - OpStore %38 %uint_2 Aligned 8 - %39 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %39 %uint_0 %uint_2 - %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %40 %uint_0 %uint_0 - OpStore %41 %uint_4 Aligned 16 - %42 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %42 %uint_0 %uint_2 - %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %43 %uint_0 %uint_1 - OpStore %44 %uint_5 Aligned 4 - %46 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %46 %uint_0 %uint_2 - %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %47 %uint_0 %uint_2 - OpStore %48 %uint_6 Aligned 8 - %51 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_0 - OpStore %51 %uint_10 Aligned 4 - %53 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_1 - OpStore %53 %uint_11 Aligned 4 - %55 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 %uint_2 - OpStore %55 %uint_12 Aligned 4 - %57 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_0 - OpStore %57 %uint_13 Aligned 4 - %59 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_1 - OpStore %59 %uint_14 Aligned 4 - %61 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 %uint_2 - OpStore %61 %uint_15 Aligned 4 - %63 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %64 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %63 %uint_0 %uint_0 - %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %64 %uint_0 %uint_0 - %66 = OpLoad %uint %65 Aligned 16 - %67 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %68 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %67 %uint_0 - OpStore %68 %66 Aligned 4 - %69 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %70 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %69 %uint_0 %uint_0 - %71 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %70 %uint_0 %uint_1 - %72 = OpLoad %uint %71 Aligned 4 - %73 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %74 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %73 %uint_1 - OpStore %74 %72 Aligned 4 - %75 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %76 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %75 %uint_0 %uint_0 - %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %76 %uint_0 %uint_2 - %78 = OpLoad %uint %77 Aligned 8 - %79 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %80 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %79 %uint_2 - OpStore %80 %78 Aligned 4 - %81 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %82 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %81 %uint_0 %uint_2 - %83 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %82 %uint_0 %uint_0 - %84 = OpLoad %uint %83 Aligned 16 - %85 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %86 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %85 %uint_3 - OpStore %86 %84 Aligned 4 - %87 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %88 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %87 %uint_0 %uint_2 - %89 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %88 %uint_0 %uint_1 - %90 = OpLoad %uint %89 Aligned 4 - %91 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %92 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %91 %uint_4 - OpStore %92 %90 Aligned 4 - %93 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %26 Aligned 4 - %94 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_uint_uint_3 %93 %uint_0 %uint_2 - %95 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %94 %uint_0 %uint_2 - %96 = OpLoad %uint %95 Aligned 8 - %97 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %98 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %97 %uint_5 - OpStore %98 %96 Aligned 4 - %99 = OpLoad %uint %51 Aligned 4 - %100 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %101 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %100 %uint_6 - OpStore %101 %99 Aligned 4 - %102 = OpLoad %uint %53 Aligned 4 - %103 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %105 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %103 %uint_7 - OpStore %105 %102 Aligned 4 - %106 = OpLoad %uint %55 Aligned 4 - %107 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %109 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %107 %uint_8 - OpStore %109 %106 Aligned 4 - %110 = OpLoad %uint %57 Aligned 4 - %111 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %113 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %111 %uint_9 - OpStore %113 %110 Aligned 4 - %114 = OpLoad %uint %59 Aligned 4 - %115 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %116 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %115 %uint_10 - OpStore %116 %114 Aligned 4 - %117 = OpLoad %uint %61 Aligned 4 - %118 = OpLoad %_ptr_CrossWorkgroup_uint %24 Aligned 4 - %119 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %118 %uint_11 - OpStore %119 %117 Aligned 4 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm deleted file mode 100644 index 56d99a59ce..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment7.spvasm +++ /dev/null @@ -1,119 +0,0 @@ -; @Input: %18={0, 0, 0, 0} -; @Input: %19={{0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}} -; @Input: %20={{0, 0}} -; @Output: forall (%18[0] == 0 and %18[1] == 22 and %18[2] == 2 and %18[3] == 3) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 76 -; Schema: 0 - OpCapability Addresses - OpCapability Linkage - OpCapability Kernel - OpCapability GenericPointer - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %17 "manual_vs_struct" - OpSource OpenCL_C 200000 - OpName %struct_struct1 "struct.struct1" - OpName %s1 "s1" - OpName %struct_struct2 "struct.struct2" - OpName %s2 "s2" - OpDecorate %s1 LinkageAttributes "s1" Export - OpDecorate %s2 LinkageAttributes "s2" Export - OpDecorate %s2 Alignment 4 - OpDecorate %23 Alignment 4 - OpDecorate %25 Alignment 4 - OpDecorate %27 Alignment 4 - OpDecorate %s1 Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %uint_11 = OpConstant %uint 11 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uchar_1 = OpConstant %uchar 1 - %uint_2 = OpConstant %uint 2 - %uchar_3 = OpConstant %uchar 3 - %uint_22 = OpConstant %uint 22 - %uint_33 = OpConstant %uint 33 - %uint_3 = OpConstant %uint 3 -%_arr_uchar_uint_11 = OpTypeArray %uchar %uint_11 -%struct_struct1 = OpTypeStruct %uint %uchar %_arr_uchar_uint_11 -%_ptr_CrossWorkgroup_struct_struct1 = OpTypePointer CrossWorkgroup %struct_struct1 -%struct_struct2 = OpTypeStruct %uchar %uint -%_ptr_CrossWorkgroup_struct_struct2 = OpTypePointer CrossWorkgroup %struct_struct2 - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar - %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_struct_struct1 %_ptr_CrossWorkgroup_struct_struct2 -%_ptr_Function__ptr_CrossWorkgroup_uchar = OpTypePointer Function %_ptr_CrossWorkgroup_uchar -%_ptr_Function__ptr_CrossWorkgroup_struct_struct1 = OpTypePointer Function %_ptr_CrossWorkgroup_struct_struct1 -%_ptr_Function__ptr_CrossWorkgroup_struct_struct2 = OpTypePointer Function %_ptr_CrossWorkgroup_struct_struct2 -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint -%_ptr_Generic_uint = OpTypePointer Generic %uint - %7 = OpConstantNull %struct_struct1 - %s1 = OpVariable %_ptr_CrossWorkgroup_struct_struct1 CrossWorkgroup %7 - %11 = OpConstantNull %struct_struct2 - %s2 = OpVariable %_ptr_CrossWorkgroup_struct_struct2 CrossWorkgroup %11 - %17 = OpFunction %void DontInline %16 - %18 = OpFunctionParameter %_ptr_CrossWorkgroup_uchar - %19 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_struct1 - %20 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_struct2 - %21 = OpLabel - %23 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uchar Function - %25 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_struct1 Function - %27 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_struct2 Function - OpStore %23 %18 Aligned 4 - OpStore %25 %19 Aligned 4 - OpStore %27 %20 Aligned 4 - %28 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 - %31 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %28 %uint_0 %uint_0 - OpStore %31 %uint_0 Aligned 16 - %32 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 - %34 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %32 %uint_0 %uint_1 - OpStore %34 %uchar_1 Aligned 4 - %36 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 - %37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %36 %uint_0 %uint_1 - OpStore %37 %uint_2 Aligned 4 - %39 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 - %40 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %39 %uint_0 %uint_0 - OpStore %40 %uchar_3 Aligned 4 - %42 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 - %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %42 %uint_0 %uint_0 - %44 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %43 %uint_1 - %46 = OpPtrCastToGeneric %_ptr_Generic_uint %44 - OpStore %46 %uint_22 Aligned 4 - %48 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 - %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %48 %uint_0 %uint_1 - %50 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %49 %uint_1 - %51 = OpPtrCastToGeneric %_ptr_Generic_uint %50 - OpStore %51 %uint_33 Aligned 4 - %53 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 - %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %53 %uint_0 %uint_0 - %55 = OpLoad %uint %54 Aligned 16 - %56 = OpUConvert %uchar %55 - %57 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 - %58 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %57 %uint_0 - OpStore %58 %56 Aligned 1 - %59 = OpLoad %_ptr_CrossWorkgroup_struct_struct1 %25 Aligned 4 - %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %59 %uint_0 %uint_1 - %61 = OpLoad %uchar %60 Aligned 4 - %62 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 - %63 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %62 %uint_1 - OpStore %63 %61 Aligned 1 - %64 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 - %65 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %64 %uint_0 %uint_1 - %66 = OpLoad %uint %65 Aligned 4 - %67 = OpUConvert %uchar %66 - %68 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 - %69 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %68 %uint_2 - OpStore %69 %67 Aligned 1 - %70 = OpLoad %_ptr_CrossWorkgroup_struct_struct2 %27 Aligned 4 - %71 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %70 %uint_0 %uint_0 - %72 = OpLoad %uchar %71 Aligned 4 - %73 = OpLoad %_ptr_CrossWorkgroup_uchar %23 Aligned 4 - %75 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %73 %uint_3 - OpStore %75 %72 Aligned 1 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm deleted file mode 100644 index aa34b49e44..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment8.spvasm +++ /dev/null @@ -1,88 +0,0 @@ -; @Input: %18={0, 0, 0, 0} -; @Input: %19={{0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}} -; @Output: forall (%18[0] == 1 and %18[1] == 2 and %18[2] == 3 and %18[3] == 4) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 53 -; Schema: 0 - OpCapability Addresses - OpCapability Linkage - OpCapability Kernel - OpCapability Int8 - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %17 "test" - OpSource OpenCL_C 200000 - OpName %test_unaligned "test.unaligned" - OpName %struct_aligned_struct "struct.aligned_struct" - OpName %aligned "aligned" - OpDecorate %aligned LinkageAttributes "aligned" Export - OpDecorate %test_unaligned Alignment 4 - OpDecorate %22 Alignment 4 - OpDecorate %24 Alignment 4 - OpDecorate %aligned Alignment 16 - %uint = OpTypeInt 32 0 - %uchar = OpTypeInt 8 0 - %uint_2 = OpConstant %uint 2 - %uint_12 = OpConstant %uint 12 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_4 = OpConstant %uint 4 - %uint_3 = OpConstant %uint 3 -%_arr_uint_uint_2 = OpTypeArray %uint %uint_2 -%_ptr_Workgroup__arr_uint_uint_2 = OpTypePointer Workgroup %_arr_uint_uint_2 -%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 -%struct_aligned_struct = OpTypeStruct %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 -%_ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer CrossWorkgroup %struct_aligned_struct - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_struct -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_struct -%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint -%test_unaligned = OpVariable %_ptr_Workgroup__arr_uint_uint_2 Workgroup - %11 = OpConstantNull %struct_aligned_struct - %aligned = OpVariable %_ptr_CrossWorkgroup_struct_aligned_struct CrossWorkgroup %11 - %17 = OpFunction %void DontInline %16 - %18 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %19 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_struct - %20 = OpLabel - %22 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct Function - OpStore %22 %18 Aligned 4 - OpStore %24 %19 Aligned 4 - %25 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %25 %uint_0 %uint_0 - OpStore %27 %uint_1 Aligned 16 - %29 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %29 %uint_0 %uint_0 - %32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %30 %uint_4 - OpStore %32 %uint_2 Aligned 4 - %34 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_0 - OpStore %34 %uint_3 Aligned 4 - %36 = OpInBoundsPtrAccessChain %_ptr_Workgroup_uint %test_unaligned %uint_0 %uint_1 - OpStore %36 %uint_4 Aligned 4 - %37 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %38 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %37 %uint_0 %uint_0 - %39 = OpLoad %uint %38 Aligned 16 - %40 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 - %41 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %40 %uint_0 - OpStore %41 %39 Aligned 4 - %42 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %42 %uint_0 %uint_2 - %44 = OpLoad %uint %43 Aligned 16 - %45 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 - %46 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %45 %uint_1 - OpStore %46 %44 Aligned 4 - %47 = OpLoad %uint %34 Aligned 4 - %48 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 - %49 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %48 %uint_2 - OpStore %49 %47 Aligned 4 - %50 = OpLoad %uint %36 Aligned 4 - %51 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 - %52 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %51 %uint_3 - OpStore %52 %50 Aligned 4 - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm deleted file mode 100644 index a36802f06f..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/alignment9.spvasm +++ /dev/null @@ -1,119 +0,0 @@ -; @Input: %14={0, 0, 0, 0, 0, 0, 0, 0} -; @Input: %15={{{{0, 0, 0}, {0, 0, 0}}}} -; @Output: forall (%14[0] == 0 and %14[1] == 1 and %14[2] == 2 and %14[3] == 3 and %14[4] == 4 and %14[5] == 5 and %14[6] == 0 and %14[7] == 0) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Generator: Khronos LLVM/SPIR-V Translator; 14 -; Bound: 80 -; Schema: 0 - OpCapability Addresses - OpCapability Linkage - OpCapability Kernel - OpCapability GenericPointer - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %13 "test" - OpSource OpenCL_C 200000 - OpName %struct_aligned_struct "struct.aligned_struct" - OpName %aligned "aligned" - OpDecorate %aligned LinkageAttributes "aligned" Export - OpDecorate %22 Alignment 4 - OpDecorate %24 Alignment 4 - OpDecorate %26 Alignment 4 - OpDecorate %aligned Alignment 16 - %uint = OpTypeInt 32 0 - %uint_2 = OpConstant %uint 2 - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_5 = OpConstant %uint 5 - %uint_8 = OpConstant %uint 8 - %v3uint = OpTypeVector %uint 3 -%_arr_v3uint_uint_2 = OpTypeArray %v3uint %uint_2 -%struct_aligned_struct = OpTypeStruct %_arr_v3uint_uint_2 -%_ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer CrossWorkgroup %struct_aligned_struct - %void = OpTypeVoid -%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint - %12 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_struct_aligned_struct -%_ptr_Function__ptr_CrossWorkgroup_uint = OpTypePointer Function %_ptr_CrossWorkgroup_uint -%_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct = OpTypePointer Function %_ptr_CrossWorkgroup_struct_aligned_struct -%_ptr_Function_uint = OpTypePointer Function %uint -%_ptr_CrossWorkgroup__arr_v3uint_uint_2 = OpTypePointer CrossWorkgroup %_arr_v3uint_uint_2 -%_ptr_CrossWorkgroup_v3uint = OpTypePointer CrossWorkgroup %v3uint - %bool = OpTypeBool -%_ptr_Generic_uint = OpTypePointer Generic %uint - %7 = OpConstantNull %struct_aligned_struct - %aligned = OpVariable %_ptr_CrossWorkgroup_struct_aligned_struct CrossWorkgroup %7 - %13 = OpFunction %void DontInline %12 - %14 = OpFunctionParameter %_ptr_CrossWorkgroup_uint - %15 = OpFunctionParameter %_ptr_CrossWorkgroup_struct_aligned_struct - %16 = OpLabel - %22 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_uint Function - %24 = OpVariable %_ptr_Function__ptr_CrossWorkgroup_struct_aligned_struct Function - %26 = OpVariable %_ptr_Function_uint Function - OpStore %22 %14 Aligned 4 - OpStore %24 %15 Aligned 4 - %27 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %30 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %27 %uint_0 %uint_0 - %32 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %30 %uint_0 %uint_0 - %33 = OpLoad %v3uint %32 Aligned 16 - %34 = OpCompositeInsert %v3uint %uint_0 %33 0 - OpStore %32 %34 Aligned 16 - %35 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %36 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %35 %uint_0 %uint_0 - %37 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %36 %uint_0 %uint_0 - %38 = OpLoad %v3uint %37 Aligned 16 - %40 = OpCompositeInsert %v3uint %uint_1 %38 1 - OpStore %37 %40 Aligned 16 - %41 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %42 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %41 %uint_0 %uint_0 - %43 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %42 %uint_0 %uint_0 - %44 = OpLoad %v3uint %43 Aligned 16 - %45 = OpCompositeInsert %v3uint %uint_2 %44 2 - OpStore %43 %45 Aligned 16 - %46 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %47 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %46 %uint_0 %uint_0 - %48 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %47 %uint_0 %uint_1 - %49 = OpLoad %v3uint %48 Aligned 16 - %51 = OpCompositeInsert %v3uint %uint_3 %49 0 - OpStore %48 %51 Aligned 16 - %52 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %53 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %52 %uint_0 %uint_0 - %54 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %53 %uint_0 %uint_1 - %55 = OpLoad %v3uint %54 Aligned 16 - %57 = OpCompositeInsert %v3uint %uint_4 %55 1 - OpStore %54 %57 Aligned 16 - %58 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %59 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup__arr_v3uint_uint_2 %58 %uint_0 %uint_0 - %60 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v3uint %59 %uint_0 %uint_1 - %61 = OpLoad %v3uint %60 Aligned 16 - %63 = OpCompositeInsert %v3uint %uint_5 %61 2 - OpStore %60 %63 Aligned 16 - OpStore %26 %uint_0 Aligned 4 - OpBranch %17 - %17 = OpLabel - %64 = OpLoad %uint %26 Aligned 4 - %67 = OpSLessThan %bool %64 %uint_8 - OpBranchConditional %67 %18 %20 - %18 = OpLabel - %68 = OpLoad %_ptr_CrossWorkgroup_struct_aligned_struct %24 Aligned 4 - %69 = OpBitcast %_ptr_CrossWorkgroup_uint %68 - %71 = OpPtrCastToGeneric %_ptr_Generic_uint %69 - %72 = OpLoad %uint %26 Aligned 4 - %73 = OpInBoundsPtrAccessChain %_ptr_Generic_uint %71 %72 - %74 = OpLoad %uint %73 Aligned 4 - %75 = OpLoad %_ptr_CrossWorkgroup_uint %22 Aligned 4 - %76 = OpLoad %uint %26 Aligned 4 - %77 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %75 %76 - OpStore %77 %74 Aligned 4 - OpBranch %19 - %19 = OpLabel - %78 = OpLoad %uint %26 Aligned 4 - %79 = OpIAdd %uint %78 %uint_1 - OpStore %26 %79 Aligned 4 - OpBranch %17 - %20 = OpLabel - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm b/dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm deleted file mode 100644 index 9d4ee6109c..0000000000 --- a/dartagnan/src/test/resources/spirv/opencl/basic/vector-aligned.spvasm +++ /dev/null @@ -1,70 +0,0 @@ -; @Input: %output = {0, 0} -; @Output: forall (%output[0] == 5 and %output[1] == 11) -; @Config: 1, 1, 1 -; SPIR-V -; Version: 1.0 -; Schema: 0 - OpCapability Addresses - OpCapability Kernel - OpCapability GenericPointer - %1 = OpExtInstImport "OpenCL.std" - OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %main "main" - OpSource OpenCL_C 200000 - - OpDecorate %aligned_data Alignment 16 - - %void = OpTypeVoid - %func = OpTypeFunction %void - %uint = OpTypeInt 32 0 - - %uint_0 = OpConstant %uint 0 - %uint_1 = OpConstant %uint 1 - %uint_2 = OpConstant %uint 2 - %uint_3 = OpConstant %uint 3 - %uint_4 = OpConstant %uint 4 - %uint_5 = OpConstant %uint 5 - %uint_6 = OpConstant %uint 6 - %uint_7 = OpConstant %uint 7 - %uint_8 = OpConstant %uint 8 - %uint_9 = OpConstant %uint 9 - %uint_10 = OpConstant %uint 10 - %uint_11 = OpConstant %uint 11 - - %v3uint = OpTypeVector %uint 3 -%_arr2_v3uint = OpTypeArray %v3uint %uint_2 -%output_type = OpTypeRuntimeArray %uint - - %ptr_uint = OpTypePointer CrossWorkgroup %uint -%_ptr_CrossWorkgroup__arr2_v3uint = OpTypePointer CrossWorkgroup %_arr2_v3uint -%_ptr_CrossWorkgroup_v3uint = OpTypePointer CrossWorkgroup %v3uint - %ptr_output = OpTypePointer CrossWorkgroup %output_type - - %arr1 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2 - %arr2 = OpConstantComposite %v3uint %uint_3 %uint_4 %uint_5 - %arr3 = OpConstantComposite %v3uint %uint_6 %uint_7 %uint_8 - %arr4 = OpConstantComposite %v3uint %uint_9 %uint_10 %uint_11 - %value1 = OpConstantComposite %_arr2_v3uint %arr1 %arr2 - %value2 = OpConstantComposite %_arr2_v3uint %arr3 %arr4 - -%aligned_data = OpVariable %_ptr_CrossWorkgroup__arr2_v3uint CrossWorkgroup %value1 -%normal_data = OpVariable %_ptr_CrossWorkgroup__arr2_v3uint CrossWorkgroup %value2 - %output = OpVariable %ptr_output CrossWorkgroup - - %main = OpFunction %void None %func - %label = OpLabel - - %output_0 = OpAccessChain %ptr_uint %output %uint_0 - %output_1 = OpAccessChain %ptr_uint %output %uint_1 - - %aligned_12 = OpInBoundsAccessChain %ptr_uint %aligned_data %uint_1 %uint_2 - %normal_12 = OpInBoundsAccessChain %ptr_uint %normal_data %uint_1 %uint_2 - - %v0 = OpLoad %uint %aligned_12 - %v1 = OpLoad %uint %normal_12 - - OpStore %output_0 %v0 - OpStore %output_1 %v1 - - OpReturn - OpFunctionEnd diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-local.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-local.spvasm new file mode 100644 index 0000000000..c7d7874c33 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-local.spvasm @@ -0,0 +1,141 @@ +; @Input: %6={{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}} +; @Input: %10={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} +; @Input: %21={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %22={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%21[0][0] == 0 and %21[0][1] == 1 and %21[0][2] == 2) +; @Output: forall (%21[0][4] == 3 and %21[0][5] == 4 and %21[0][6] == 5) +; @Output: forall (%22[0][0] == 6 and %22[0][1] == 7 and %22[0][2] == 8) +; @Output: forall (%22[0][3] == 9 and %22[0][4] == 10 and %22[0][5] == 11) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 100 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %89 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %25 "test" %6 %10 %17 %21 %22 + OpSource OpenCL_C 200 + %90 = OpString "test" + %91 = OpString "__kernel" + %93 = OpString "r_aligned" + %96 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_19 0 Offset 0 + OpDecorate %_struct_19 Block + OpDecorate %21 DescriptorSet 0 + OpDecorate %21 Binding 0 + OpDecorate %22 DescriptorSet 0 + OpDecorate %22 Binding 1 + OpDecorate %11 SpecId 0 + OpDecorate %12 SpecId 1 + OpDecorate %13 SpecId 2 + %uint = OpTypeInt 32 0 + %v4uint = OpTypeVector %uint 4 + %uint_3 = OpConstant %uint 3 +%_arr_v4uint_uint_3 = OpTypeArray %v4uint %uint_3 +%_ptr_Workgroup__arr_v4uint_uint_3 = OpTypePointer Workgroup %_arr_v4uint_uint_3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_3 = OpTypeArray %_arr_uint_uint_3 %uint_3 +%_ptr_Workgroup__arr__arr_uint_uint_3_uint_3 = OpTypePointer Workgroup %_arr__arr_uint_uint_3_uint_3 + %11 = OpSpecConstant %uint 1 + %12 = OpSpecConstant %uint 1 + %13 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %11 %12 %13 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_19 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19 + %void = OpTypeVoid + %24 = OpTypeFunction %void +%_ptr_Workgroup_v4uint = OpTypePointer Workgroup %v4uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %32 = OpUndef %uint + %33 = OpConstantComposite %v4uint %uint_0 %uint_1 %32 %32 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %41 = OpConstantComposite %v4uint %uint_3 %uint_4 %32 %32 + %uint_5 = OpConstant %uint 5 +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %bool = OpTypeBool +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %6 = OpVariable %_ptr_Workgroup__arr_v4uint_uint_3 Workgroup + %10 = OpVariable %_ptr_Workgroup__arr__arr_uint_uint_3_uint_3 Workgroup + %17 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %21 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %22 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %25 = OpFunction %void None %24 + %26 = OpLabel + %29 = OpAccessChain %_ptr_Workgroup_v4uint %6 %uint_0 + %30 = OpLoad %v4uint %29 Aligned|MakePointerVisible|NonPrivatePointer 16 %uint_2 + %34 = OpVectorShuffle %v4uint %33 %30 0 1 4294967295 7 + %36 = OpCompositeInsert %v4uint %uint_2 %34 2 + %37 = OpAccessChain %_ptr_Workgroup_v4uint %6 %uint_0 + OpStore %37 %36 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %38 = OpAccessChain %_ptr_Workgroup_v4uint %6 %uint_1 + %39 = OpLoad %v4uint %38 Aligned|MakePointerVisible|NonPrivatePointer 16 %uint_2 + %42 = OpVectorShuffle %v4uint %41 %39 0 1 4294967295 7 + %44 = OpCompositeInsert %v4uint %uint_5 %42 2 + %45 = OpAccessChain %_ptr_Workgroup_v4uint %6 %uint_1 + OpStore %45 %44 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %47 = OpAccessChain %_ptr_Workgroup_uint %10 %uint_0 %uint_0 + OpStore %47 %uint_6 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %49 = OpAccessChain %_ptr_Workgroup_uint %10 %uint_0 %uint_1 + OpStore %49 %uint_7 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %51 = OpAccessChain %_ptr_Workgroup_uint %10 %uint_0 %uint_2 + OpStore %51 %uint_8 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %53 = OpAccessChain %_ptr_Workgroup_uint %10 %uint_1 %uint_0 + OpStore %53 %uint_9 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %55 = OpAccessChain %_ptr_Workgroup_uint %10 %uint_1 %uint_1 + OpStore %55 %uint_10 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %57 = OpAccessChain %_ptr_Workgroup_uint %10 %uint_1 %uint_2 + OpStore %57 %uint_11 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + OpBranch %60 + %60 = OpLabel + %61 = OpPhi %uint %uint_0 %26 %83 %82 + %63 = OpULessThan %bool %61 %uint_8 + OpLoopMerge %86 %82 None + OpBranchConditional %63 %66 %82 + %66 = OpLabel + %67 = OpShiftRightLogical %uint %61 %uint_2 + %68 = OpBitwiseAnd %uint %61 %uint_3 + %69 = OpAccessChain %_ptr_Workgroup_uint %6 %67 %68 + %70 = OpLoad %uint %69 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %72 = OpAccessChain %_ptr_StorageBuffer_uint %21 %uint_0 %61 + OpStore %72 %70 Aligned 4 + %73 = OpUDiv %uint %61 %uint_3 + %74 = OpUMod %uint %61 %uint_3 + %75 = OpAccessChain %_ptr_Workgroup_uint %10 %73 %74 + %76 = OpLoad %uint %75 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %77 = OpAccessChain %_ptr_StorageBuffer_uint %22 %uint_0 %61 + OpStore %77 %76 Aligned 4 + OpBranch %79 + %79 = OpLabel + %80 = OpIAdd %uint %61 %uint_1 + OpBranch %82 + %82 = OpLabel + %83 = OpPhi %uint %80 %79 %32 %60 + %84 = OpPhi %bool %false %79 %true %60 + OpBranchConditional %84 %86 %60 + %86 = OpLabel + OpReturn + OpFunctionEnd + %92 = OpExtInst %void %89 Kernel %25 %90 %uint_2 %uint_0 %91 + %94 = OpExtInst %void %89 ArgumentInfo %93 + %95 = OpExtInst %void %89 ArgumentStorageBuffer %92 %uint_0 %uint_0 %uint_0 %94 + %97 = OpExtInst %void %89 ArgumentInfo %96 + %98 = OpExtInst %void %89 ArgumentStorageBuffer %92 %uint_1 %uint_0 %uint_1 %97 + %99 = OpExtInst %void %89 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-pointer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-pointer.spvasm new file mode 100644 index 0000000000..dc33836861 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-array-pointer.spvasm @@ -0,0 +1,163 @@ +; @Input: %13={{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}} +; @Input: %19={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %23={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %24={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%13[0][0][0] == 0 and %13[0][0][1] == 1 and %13[0][0][2] == 2) +; @Output: forall (%13[0][1][0] == 3 and %13[0][1][1] == 4 and %13[0][1][2] == 5) +; @Output: forall (%19[0][0][0] == 6 and %19[0][0][1] == 7 and %19[0][0][2] == 8) +; @Output: forall (%19[0][1][0] == 9 and %19[0][1][1] == 10 and %19[0][1][2] == 11) +; @Output: forall (%23[0][0] == 0 and %23[0][1] == 1 and %23[0][2] == 2) +; @Output: forall (%23[0][4] == 3 and %23[0][5] == 4 and %23[0][6] == 5) +; @Output: forall (%24[0][0] == 6 and %24[0][1] == 7 and %24[0][2] == 8) +; @Output: forall (%24[0][3] == 9 and %24[0][4] == 10 and %24[0][5] == 11) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 107 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %90 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %27 "test" %8 %13 %19 %23 %24 + OpSource OpenCL_C 200 + %91 = OpString "test" + %92 = OpString "__kernel" + %94 = OpString "aligned" + %97 = OpString "unaligned" + %100 = OpString "r_aligned" + %103 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_v4uint ArrayStride 16 + OpMemberDecorate %_struct_11 0 Offset 0 + OpDecorate %_struct_11 Block + OpDecorate %_runtimearr__arr_uint_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_17 0 Offset 0 + OpDecorate %_struct_17 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_21 0 Offset 0 + OpDecorate %_struct_21 Block + OpDecorate %13 DescriptorSet 0 + OpDecorate %13 Binding 0 + OpDecorate %19 DescriptorSet 0 + OpDecorate %19 Binding 1 + OpDecorate %23 DescriptorSet 0 + OpDecorate %23 Binding 2 + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 3 + OpDecorate %_arr_uint_uint_3 ArrayStride 4 + OpDecorate %2 SpecId 0 + OpDecorate %3 SpecId 1 + OpDecorate %4 SpecId 2 + %uint = OpTypeInt 32 0 + %2 = OpSpecConstant %uint 1 + %3 = OpSpecConstant %uint 1 + %4 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %2 %3 %4 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint + %v4uint = OpTypeVector %uint 4 +%_runtimearr_v4uint = OpTypeRuntimeArray %v4uint + %_struct_11 = OpTypeStruct %_runtimearr_v4uint +%_ptr_StorageBuffer__struct_11 = OpTypePointer StorageBuffer %_struct_11 + %uint_3 = OpConstant %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_runtimearr__arr_uint_uint_3 = OpTypeRuntimeArray %_arr_uint_uint_3 + %_struct_17 = OpTypeStruct %_runtimearr__arr_uint_uint_3 +%_ptr_StorageBuffer__struct_17 = OpTypePointer StorageBuffer %_struct_17 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_21 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_21 = OpTypePointer StorageBuffer %_struct_21 + %void = OpTypeVoid + %26 = OpTypeFunction %void +%_ptr_StorageBuffer_v4uint = OpTypePointer StorageBuffer %v4uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %34 = OpUndef %uint + %35 = OpConstantComposite %v4uint %uint_0 %uint_1 %34 %34 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %43 = OpConstantComposite %v4uint %uint_3 %uint_4 %34 %34 + %uint_5 = OpConstant %uint 5 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %8 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %13 = OpVariable %_ptr_StorageBuffer__struct_11 StorageBuffer + %19 = OpVariable %_ptr_StorageBuffer__struct_17 StorageBuffer + %23 = OpVariable %_ptr_StorageBuffer__struct_21 StorageBuffer + %24 = OpVariable %_ptr_StorageBuffer__struct_21 StorageBuffer + %27 = OpFunction %void None %26 + %28 = OpLabel + %31 = OpAccessChain %_ptr_StorageBuffer_v4uint %13 %uint_0 %uint_0 + %32 = OpLoad %v4uint %31 Aligned 16 + %36 = OpVectorShuffle %v4uint %35 %32 0 1 4294967295 7 + %38 = OpCompositeInsert %v4uint %uint_2 %36 2 + %39 = OpAccessChain %_ptr_StorageBuffer_v4uint %13 %uint_0 %uint_0 + OpStore %39 %38 Aligned 16 + %40 = OpAccessChain %_ptr_StorageBuffer_v4uint %13 %uint_0 %uint_1 + %41 = OpLoad %v4uint %40 Aligned 16 + %44 = OpVectorShuffle %v4uint %43 %41 0 1 4294967295 7 + %45 = OpAccessChain %_ptr_StorageBuffer_v4uint %13 %uint_0 %uint_1 + %47 = OpCompositeInsert %v4uint %uint_5 %44 2 + OpStore %45 %47 Aligned 16 + %49 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %uint_0 %uint_0 + OpStore %49 %uint_6 Aligned 4 + %51 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %uint_0 %uint_1 + OpStore %51 %uint_7 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %uint_0 %uint_2 + OpStore %53 %uint_8 Aligned 4 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %uint_1 %uint_0 + OpStore %55 %uint_9 Aligned 4 + %57 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %uint_1 %uint_1 + OpStore %57 %uint_10 Aligned 4 + %59 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %uint_1 %uint_2 + OpStore %59 %uint_11 Aligned 4 + OpBranch %62 + %62 = OpLabel + %63 = OpPhi %uint %uint_0 %28 %84 %83 + %65 = OpULessThan %bool %63 %uint_8 + OpLoopMerge %87 %83 None + OpBranchConditional %65 %68 %83 + %68 = OpLabel + %69 = OpShiftRightLogical %uint %63 %uint_2 + %70 = OpBitwiseAnd %uint %63 %uint_3 + %71 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %69 %70 + %72 = OpLoad %uint %71 Aligned 4 + %73 = OpAccessChain %_ptr_StorageBuffer_uint %23 %uint_0 %63 + OpStore %73 %72 Aligned 4 + %74 = OpUDiv %uint %63 %uint_3 + %75 = OpUMod %uint %63 %uint_3 + %76 = OpAccessChain %_ptr_StorageBuffer_uint %19 %uint_0 %74 %75 + %77 = OpLoad %uint %76 Aligned 4 + %78 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %63 + OpStore %78 %77 Aligned 4 + OpBranch %80 + %80 = OpLabel + %81 = OpIAdd %uint %63 %uint_1 + OpBranch %83 + %83 = OpLabel + %84 = OpPhi %uint %81 %80 %34 %62 + %85 = OpPhi %bool %false %80 %true %62 + OpBranchConditional %85 %87 %62 + %87 = OpLabel + OpReturn + OpFunctionEnd + %93 = OpExtInst %void %90 Kernel %27 %91 %uint_4 %uint_0 %92 + %95 = OpExtInst %void %90 ArgumentInfo %94 + %96 = OpExtInst %void %90 ArgumentStorageBuffer %93 %uint_0 %uint_0 %uint_0 %95 + %98 = OpExtInst %void %90 ArgumentInfo %97 + %99 = OpExtInst %void %90 ArgumentStorageBuffer %93 %uint_1 %uint_0 %uint_1 %98 + %101 = OpExtInst %void %90 ArgumentInfo %100 + %102 = OpExtInst %void %90 ArgumentStorageBuffer %93 %uint_2 %uint_0 %uint_2 %101 + %104 = OpExtInst %void %90 ArgumentInfo %103 + %105 = OpExtInst %void %90 ArgumentStorageBuffer %93 %uint_3 %uint_0 %uint_3 %104 + %106 = OpExtInst %void %90 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-local.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-local.spvasm new file mode 100644 index 0000000000..972edf4144 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-local.spvasm @@ -0,0 +1,140 @@ +; @Input: %9={{0, 0, 0, {0, 0, 0, 0}}, {0, 0, 0, {0, 0, 0, 0}}, {0, 0, 0, {0, 0, 0, 0}}} +; @Input: %13={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} +; @Input: %24={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %25={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%24[0][0] == 0 and %24[0][1] == 1 and %24[0][2] == 2) +; @Output: forall (%24[0][4] == 3 and %24[0][5] == 4 and %24[0][6] == 5) +; @Output: forall (%25[0][0] == 6 and %25[0][1] == 7 and %25[0][2] == 8) +; @Output: forall (%25[0][3] == 9 and %25[0][4] == 10 and %25[0][5] == 11) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 93 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %82 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %28 "test" %9 %13 %20 %24 %25 + OpSource OpenCL_C 200 + %83 = OpString "test" + %84 = OpString "__kernel" + %86 = OpString "r_aligned" + %89 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_22 0 Offset 0 + OpDecorate %_struct_22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + OpDecorate %14 SpecId 0 + OpDecorate %15 SpecId 1 + OpDecorate %16 SpecId 2 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_4 = OpConstant %uint 4 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 + %_struct_5 = OpTypeStruct %uint %uint %uint %_arr_uchar_uint_4 + %uint_3 = OpConstant %uint 3 +%_arr__struct_5_uint_3 = OpTypeArray %_struct_5 %uint_3 +%_ptr_Workgroup__arr__struct_5_uint_3 = OpTypePointer Workgroup %_arr__struct_5_uint_3 + %_struct_10 = OpTypeStruct %uint %uint %uint +%_arr__struct_10_uint_3 = OpTypeArray %_struct_10 %uint_3 +%_ptr_Workgroup__arr__struct_10_uint_3 = OpTypePointer Workgroup %_arr__struct_10_uint_3 + %14 = OpSpecConstant %uint 1 + %15 = OpSpecConstant %uint 1 + %16 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %14 %15 %16 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_22 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_22 = OpTypePointer StorageBuffer %_struct_22 + %void = OpTypeVoid + %27 = OpTypeFunction %void +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %bool = OpTypeBool +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %79 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %9 = OpVariable %_ptr_Workgroup__arr__struct_5_uint_3 Workgroup + %13 = OpVariable %_ptr_Workgroup__arr__struct_10_uint_3 Workgroup + %20 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %24 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %25 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %28 = OpFunction %void None %27 + %29 = OpLabel + %32 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_0 + OpStore %32 %uint_0 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %34 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_1 + OpStore %34 %uint_1 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %36 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_2 + OpStore %36 %uint_2 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %37 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_0 + OpStore %37 %uint_3 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %38 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_1 + OpStore %38 %uint_4 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %39 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_2 + OpStore %39 %uint_5 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %41 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_0 + OpStore %41 %uint_6 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %43 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_1 + OpStore %43 %uint_7 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %45 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_2 + OpStore %45 %uint_8 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %47 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_0 + OpStore %47 %uint_9 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %49 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_1 + OpStore %49 %uint_10 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %51 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_2 + OpStore %51 %uint_11 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + OpBranch %54 + %54 = OpLabel + %55 = OpPhi %uint %uint_0 %29 %75 %74 + %57 = OpULessThan %bool %55 %uint_8 + OpLoopMerge %78 %74 None + OpBranchConditional %57 %60 %74 + %60 = OpLabel + %61 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_0 + %62 = OpPtrAccessChain %_ptr_Workgroup_uint %61 %55 + %63 = OpLoad %uint %62 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %65 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %55 + OpStore %65 %63 Aligned 4 + %66 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_0 + %67 = OpPtrAccessChain %_ptr_Workgroup_uint %66 %55 + %68 = OpLoad %uint %67 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %69 = OpAccessChain %_ptr_StorageBuffer_uint %25 %uint_0 %55 + OpStore %69 %68 Aligned 4 + OpBranch %71 + %71 = OpLabel + %72 = OpIAdd %uint %55 %uint_1 + OpBranch %74 + %74 = OpLabel + %75 = OpPhi %uint %72 %71 %79 %54 + %76 = OpPhi %bool %false %71 %true %54 + OpBranchConditional %76 %78 %54 + %78 = OpLabel + OpReturn + OpFunctionEnd + %85 = OpExtInst %void %82 Kernel %28 %83 %uint_2 %uint_0 %84 + %87 = OpExtInst %void %82 ArgumentInfo %86 + %88 = OpExtInst %void %82 ArgumentStorageBuffer %85 %uint_0 %uint_0 %uint_0 %87 + %90 = OpExtInst %void %82 ArgumentInfo %89 + %91 = OpExtInst %void %82 ArgumentStorageBuffer %85 %uint_1 %uint_0 %uint_1 %90 + %92 = OpExtInst %void %82 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-pointer.spvasm new file mode 100644 index 0000000000..ca3c86f590 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment1-struct-pointer.spvasm @@ -0,0 +1,137 @@ +; @Input: %12={{0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %13={{0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %14={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %15={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%14[0][0] == 0 and %14[0][1] == 1 and %14[0][2] == 2) +; @Output: forall (%14[0][4] == 3 and %14[0][5] == 4 and %14[0][6] == 5) +; @Output: forall (%15[0][0] == 6 and %15[0][1] == 7 and %15[0][2] == 8) +; @Output: forall (%15[0][3] == 9 and %15[0][4] == 10 and %15[0][5] == 11) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 88 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %71 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %18 "test" %8 %12 %13 %14 %15 + OpSource OpenCL_C 200 + %72 = OpString "test" + %73 = OpString "__kernel" + %75 = OpString "aligned" + %78 = OpString "unaligned" + %81 = OpString "r_aligned" + %84 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_10 0 Offset 0 + OpDecorate %_struct_10 Block + OpDecorate %12 DescriptorSet 0 + OpDecorate %12 Binding 0 + OpDecorate %13 DescriptorSet 0 + OpDecorate %13 Binding 1 + OpDecorate %14 DescriptorSet 0 + OpDecorate %14 Binding 2 + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 3 + OpDecorate %2 SpecId 0 + OpDecorate %3 SpecId 1 + OpDecorate %4 SpecId 2 + %uint = OpTypeInt 32 0 + %2 = OpSpecConstant %uint 1 + %3 = OpSpecConstant %uint 1 + %4 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %2 %3 %4 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_10 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_10 = OpTypePointer StorageBuffer %_struct_10 + %void = OpTypeVoid + %17 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_3 = OpConstant %uint 3 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %bool = OpTypeBool + %68 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %8 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %12 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %13 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %14 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %15 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %18 = OpFunction %void None %17 + %19 = OpLabel + %22 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %uint_0 + OpStore %22 %uint_0 Aligned 4 + %24 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %uint_1 + OpStore %24 %uint_1 Aligned 4 + %26 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %uint_2 + OpStore %26 %uint_2 Aligned 4 + %28 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %uint_4 + OpStore %28 %uint_3 Aligned 4 + %31 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %uint_5 + OpStore %31 %uint_4 Aligned 4 + %33 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %uint_6 + OpStore %33 %uint_5 Aligned 4 + %34 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %uint_0 + OpStore %34 %uint_6 Aligned 4 + %35 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %uint_1 + OpStore %35 %uint_7 Aligned 4 + %37 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %uint_2 + OpStore %37 %uint_8 Aligned 4 + %39 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %uint_3 + OpStore %39 %uint_9 Aligned 4 + %41 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %uint_4 + OpStore %41 %uint_10 Aligned 4 + %43 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %uint_5 + OpStore %43 %uint_11 Aligned 4 + OpBranch %46 + %46 = OpLabel + %47 = OpPhi %uint %uint_0 %19 %64 %63 + %49 = OpULessThan %bool %47 %uint_8 + OpLoopMerge %67 %63 None + OpBranchConditional %49 %52 %63 + %52 = OpLabel + %53 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %47 + %54 = OpLoad %uint %53 Aligned 4 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %47 + OpStore %55 %54 Aligned 4 + %56 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %47 + %57 = OpLoad %uint %56 Aligned 4 + %58 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %47 + OpStore %58 %57 Aligned 4 + OpBranch %60 + %60 = OpLabel + %61 = OpIAdd %uint %47 %uint_1 + OpBranch %63 + %63 = OpLabel + %64 = OpPhi %uint %61 %60 %68 %46 + %65 = OpPhi %bool %false %60 %true %46 + OpBranchConditional %65 %67 %46 + %67 = OpLabel + OpReturn + OpFunctionEnd + %74 = OpExtInst %void %71 Kernel %18 %72 %uint_4 %uint_0 %73 + %76 = OpExtInst %void %71 ArgumentInfo %75 + %77 = OpExtInst %void %71 ArgumentStorageBuffer %74 %uint_0 %uint_0 %uint_0 %76 + %79 = OpExtInst %void %71 ArgumentInfo %78 + %80 = OpExtInst %void %71 ArgumentStorageBuffer %74 %uint_1 %uint_0 %uint_1 %79 + %82 = OpExtInst %void %71 ArgumentInfo %81 + %83 = OpExtInst %void %71 ArgumentStorageBuffer %74 %uint_2 %uint_0 %uint_2 %82 + %85 = OpExtInst %void %71 ArgumentInfo %84 + %86 = OpExtInst %void %71 ArgumentStorageBuffer %74 %uint_3 %uint_0 %uint_3 %85 + %87 = OpExtInst %void %71 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-local.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-local.spvasm new file mode 100644 index 0000000000..e66c071ed9 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-local.spvasm @@ -0,0 +1,164 @@ +; @Input: %24={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %25={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %9={{0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, {0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}} +; @Input: %13={{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}} +; @Output: forall (%24[0][0] == 0 and %24[0][1] == 1 and %24[0][2] == 2 and %24[0][3] == 3 and %24[0][4] == 4) +; @Output: forall (%24[0][8] == 5 and %24[0][9] == 6 and %24[0][10] == 7 and %24[0][11] == 8 and %24[0][12] == 9) +; @Output: forall (%25[0][0] == 10 and %25[0][1] == 11 and %25[0][2] == 12 and %25[0][3] == 13 and %25[0][4] == 14) +; @Output: forall (%25[0][5] == 15 and %25[0][6] == 16 and %25[0][7] == 17 and %25[0][8] == 18 and %25[0][9] == 19) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 109 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %98 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %28 "test" %9 %13 %20 %24 %25 + OpSource OpenCL_C 200 + %99 = OpString "test" + %100 = OpString "__kernel" + %102 = OpString "r_aligned" + %105 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_22 0 Offset 0 + OpDecorate %_struct_22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + OpDecorate %14 SpecId 0 + OpDecorate %15 SpecId 1 + OpDecorate %16 SpecId 2 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_12 = OpConstant %uint 12 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 + %_struct_5 = OpTypeStruct %uint %uint %uint %uint %uint %_arr_uchar_uint_12 + %uint_3 = OpConstant %uint 3 +%_arr__struct_5_uint_3 = OpTypeArray %_struct_5 %uint_3 +%_ptr_Workgroup__arr__struct_5_uint_3 = OpTypePointer Workgroup %_arr__struct_5_uint_3 + %_struct_10 = OpTypeStruct %uint %uint %uint %uint %uint +%_arr__struct_10_uint_3 = OpTypeArray %_struct_10 %uint_3 +%_ptr_Workgroup__arr__struct_10_uint_3 = OpTypePointer Workgroup %_arr__struct_10_uint_3 + %14 = OpSpecConstant %uint 1 + %15 = OpSpecConstant %uint 1 + %16 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %14 %15 %16 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_22 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_22 = OpTypePointer StorageBuffer %_struct_22 + %void = OpTypeVoid + %27 = OpTypeFunction %void +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_16 = OpConstant %uint 16 + %uint_17 = OpConstant %uint 17 + %uint_18 = OpConstant %uint 18 + %uint_19 = OpConstant %uint 19 + %bool = OpTypeBool +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %95 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %9 = OpVariable %_ptr_Workgroup__arr__struct_5_uint_3 Workgroup + %13 = OpVariable %_ptr_Workgroup__arr__struct_10_uint_3 Workgroup + %20 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %24 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %25 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %28 = OpFunction %void None %27 + %29 = OpLabel + %32 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_0 + OpStore %32 %uint_0 Aligned|MakePointerAvailable|NonPrivatePointer 32 %uint_2 + %34 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_1 + OpStore %34 %uint_1 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %36 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_2 + OpStore %36 %uint_2 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %37 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_3 + OpStore %37 %uint_3 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %39 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_4 + OpStore %39 %uint_4 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %40 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_0 + OpStore %40 %uint_5 Aligned|MakePointerAvailable|NonPrivatePointer 32 %uint_2 + %42 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_1 + OpStore %42 %uint_6 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %44 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_2 + OpStore %44 %uint_7 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %46 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_3 + OpStore %46 %uint_8 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %48 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_4 + OpStore %48 %uint_9 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %50 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_0 + OpStore %50 %uint_10 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %52 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_1 + OpStore %52 %uint_11 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %54 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_2 + OpStore %54 %uint_12 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %55 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_3 + OpStore %55 %uint_13 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %57 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_4 + OpStore %57 %uint_14 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %59 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_0 + OpStore %59 %uint_15 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %61 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_1 + OpStore %61 %uint_16 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %63 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_2 + OpStore %63 %uint_17 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %65 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_3 + OpStore %65 %uint_18 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %67 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_4 + OpStore %67 %uint_19 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + OpBranch %70 + %70 = OpLabel + %71 = OpPhi %uint %uint_0 %29 %91 %90 + %73 = OpULessThan %bool %71 %uint_16 + OpLoopMerge %94 %90 None + OpBranchConditional %73 %76 %90 + %76 = OpLabel + %77 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_0 + %78 = OpPtrAccessChain %_ptr_Workgroup_uint %77 %71 + %79 = OpLoad %uint %78 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %81 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %71 + OpStore %81 %79 Aligned 4 + %82 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_0 + %83 = OpPtrAccessChain %_ptr_Workgroup_uint %82 %71 + %84 = OpLoad %uint %83 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %85 = OpAccessChain %_ptr_StorageBuffer_uint %25 %uint_0 %71 + OpStore %85 %84 Aligned 4 + OpBranch %87 + %87 = OpLabel + %88 = OpIAdd %uint %71 %uint_1 + OpBranch %90 + %90 = OpLabel + %91 = OpPhi %uint %88 %87 %95 %70 + %92 = OpPhi %bool %false %87 %true %70 + OpBranchConditional %92 %94 %70 + %94 = OpLabel + OpReturn + OpFunctionEnd + %101 = OpExtInst %void %98 Kernel %28 %99 %uint_2 %uint_0 %100 + %103 = OpExtInst %void %98 ArgumentInfo %102 + %104 = OpExtInst %void %98 ArgumentStorageBuffer %101 %uint_0 %uint_0 %uint_0 %103 + %106 = OpExtInst %void %98 ArgumentInfo %105 + %107 = OpExtInst %void %98 ArgumentStorageBuffer %101 %uint_1 %uint_0 %uint_1 %106 + %108 = OpExtInst %void %98 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-pointer.spvasm new file mode 100644 index 0000000000..4184d517bc --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment2-struct-pointer.spvasm @@ -0,0 +1,161 @@ +; @Input: %12={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %13={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %14={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %15={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%12[0][0] == 0 and %12[0][1] == 1 and %12[0][2] == 2 and %12[0][3] == 3 and %12[0][4] == 4) +; @Output: forall (%12[0][8] == 5 and %12[0][9] == 6 and %12[0][10] == 7 and %12[0][11] == 8 and %12[0][12] == 9) +; @Output: forall (%13[0][0] == 10 and %13[0][1] == 11 and %13[0][2] == 12 and %13[0][3] == 13 and %13[0][4] == 14) +; @Output: forall (%13[0][5] == 15 and %13[0][6] == 16 and %13[0][7] == 17 and %13[0][8] == 18 and %13[0][9] == 19) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 104 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %87 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %18 "test" %8 %12 %13 %14 %15 + OpSource OpenCL_C 200 + %88 = OpString "test" + %89 = OpString "__kernel" + %91 = OpString "r_aligned" + %94 = OpString "r_unaligned" + %97 = OpString "aligned" + %100 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_10 0 Offset 0 + OpDecorate %_struct_10 Block + OpDecorate %12 DescriptorSet 0 + OpDecorate %12 Binding 0 + OpDecorate %13 DescriptorSet 0 + OpDecorate %13 Binding 1 + OpDecorate %14 DescriptorSet 0 + OpDecorate %14 Binding 2 + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 3 + OpDecorate %2 SpecId 0 + OpDecorate %3 SpecId 1 + OpDecorate %4 SpecId 2 + %uint = OpTypeInt 32 0 + %2 = OpSpecConstant %uint 1 + %3 = OpSpecConstant %uint 1 + %4 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %2 %3 %4 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_10 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_10 = OpTypePointer StorageBuffer %_struct_10 + %void = OpTypeVoid + %17 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_8 = OpConstant %uint 8 + %uint_5 = OpConstant %uint 5 + %uint_9 = OpConstant %uint 9 + %uint_6 = OpConstant %uint 6 + %uint_10 = OpConstant %uint 10 + %uint_7 = OpConstant %uint 7 + %uint_11 = OpConstant %uint 11 + %uint_12 = OpConstant %uint 12 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %uint_16 = OpConstant %uint 16 + %uint_17 = OpConstant %uint 17 + %uint_18 = OpConstant %uint 18 + %uint_19 = OpConstant %uint 19 + %bool = OpTypeBool + %84 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %8 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %12 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %13 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %14 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %15 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %18 = OpFunction %void None %17 + %19 = OpLabel + %22 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_0 + OpStore %22 %uint_0 Aligned 4 + %24 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_1 + OpStore %24 %uint_1 Aligned 4 + %26 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_2 + OpStore %26 %uint_2 Aligned 4 + %28 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_3 + OpStore %28 %uint_3 Aligned 4 + %30 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_4 + OpStore %30 %uint_4 Aligned 4 + %32 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_8 + OpStore %32 %uint_5 Aligned 4 + %35 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_9 + OpStore %35 %uint_6 Aligned 4 + %38 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_10 + OpStore %38 %uint_7 Aligned 4 + %41 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_11 + OpStore %41 %uint_8 Aligned 4 + %43 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_12 + OpStore %43 %uint_9 Aligned 4 + %44 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_0 + OpStore %44 %uint_10 Aligned 4 + %45 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_1 + OpStore %45 %uint_11 Aligned 4 + %46 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_2 + OpStore %46 %uint_12 Aligned 4 + %47 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_3 + OpStore %47 %uint_13 Aligned 4 + %49 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_4 + OpStore %49 %uint_14 Aligned 4 + %51 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_5 + OpStore %51 %uint_15 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_6 + OpStore %53 %uint_16 Aligned 4 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_7 + OpStore %55 %uint_17 Aligned 4 + %57 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_8 + OpStore %57 %uint_18 Aligned 4 + %59 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_9 + OpStore %59 %uint_19 Aligned 4 + OpBranch %62 + %62 = OpLabel + %63 = OpPhi %uint %uint_0 %19 %80 %79 + %65 = OpULessThan %bool %63 %uint_16 + OpLoopMerge %83 %79 None + OpBranchConditional %65 %68 %79 + %68 = OpLabel + %69 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %63 + %70 = OpLoad %uint %69 Aligned 4 + %71 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %63 + OpStore %71 %70 Aligned 4 + %72 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %63 + %73 = OpLoad %uint %72 Aligned 4 + %74 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %63 + OpStore %74 %73 Aligned 4 + OpBranch %76 + %76 = OpLabel + %77 = OpIAdd %uint %63 %uint_1 + OpBranch %79 + %79 = OpLabel + %80 = OpPhi %uint %77 %76 %84 %62 + %81 = OpPhi %bool %false %76 %true %62 + OpBranchConditional %81 %83 %62 + %83 = OpLabel + OpReturn + OpFunctionEnd + %90 = OpExtInst %void %87 Kernel %18 %88 %uint_4 %uint_0 %89 + %92 = OpExtInst %void %87 ArgumentInfo %91 + %93 = OpExtInst %void %87 ArgumentStorageBuffer %90 %uint_0 %uint_0 %uint_0 %92 + %95 = OpExtInst %void %87 ArgumentInfo %94 + %96 = OpExtInst %void %87 ArgumentStorageBuffer %90 %uint_1 %uint_0 %uint_1 %95 + %98 = OpExtInst %void %87 ArgumentInfo %97 + %99 = OpExtInst %void %87 ArgumentStorageBuffer %90 %uint_2 %uint_0 %uint_2 %98 + %101 = OpExtInst %void %87 ArgumentInfo %100 + %102 = OpExtInst %void %87 ArgumentStorageBuffer %90 %uint_3 %uint_0 %uint_3 %101 + %103 = OpExtInst %void %87 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-local.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-local.spvasm new file mode 100644 index 0000000000..ae941f6a82 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-local.spvasm @@ -0,0 +1,129 @@ +; @Input: %24={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %25={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %9={{0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}}, {0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}}, {0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}}} +; @Input: %13={{0, 0}, {0, 0}, {0, 0}} +; @Output: forall (%24[0][0] == 0 and %24[0][2] == 1) +; @Output: forall (%24[0][4] == 2 and %24[0][6] == 3) +; @Output: forall (%25[0][0] == 4 and %25[0][1] == 5) +; @Output: forall (%25[0][2] == 6 and %25[0][3] == 7) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 86 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %75 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %28 "test" %9 %13 %20 %24 %25 + OpSource OpenCL_C 200 + %76 = OpString "test" + %77 = OpString "__kernel" + %79 = OpString "r_aligned" + %82 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_22 0 Offset 0 + OpDecorate %_struct_22 Block + OpDecorate %24 DescriptorSet 0 + OpDecorate %24 Binding 0 + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 1 + OpDecorate %14 SpecId 0 + OpDecorate %15 SpecId 1 + OpDecorate %16 SpecId 2 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_4 = OpConstant %uint 4 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 + %_struct_5 = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 + %uint_3 = OpConstant %uint 3 +%_arr__struct_5_uint_3 = OpTypeArray %_struct_5 %uint_3 +%_ptr_Workgroup__arr__struct_5_uint_3 = OpTypePointer Workgroup %_arr__struct_5_uint_3 + %_struct_10 = OpTypeStruct %uint %uint +%_arr__struct_10_uint_3 = OpTypeArray %_struct_10 %uint_3 +%_ptr_Workgroup__arr__struct_10_uint_3 = OpTypePointer Workgroup %_arr__struct_10_uint_3 + %14 = OpSpecConstant %uint 1 + %15 = OpSpecConstant %uint 1 + %16 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %14 %15 %16 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_22 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_22 = OpTypePointer StorageBuffer %_struct_22 + %void = OpTypeVoid + %27 = OpTypeFunction %void +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %bool = OpTypeBool + %uint_8 = OpConstant %uint 8 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %72 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %9 = OpVariable %_ptr_Workgroup__arr__struct_5_uint_3 Workgroup + %13 = OpVariable %_ptr_Workgroup__arr__struct_10_uint_3 Workgroup + %20 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %24 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %25 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %28 = OpFunction %void None %27 + %29 = OpLabel + %32 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_0 + OpStore %32 %uint_0 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %34 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_2 + OpStore %34 %uint_1 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %36 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_0 + OpStore %36 %uint_2 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %37 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_1 %uint_2 + OpStore %37 %uint_3 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %38 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_0 + OpStore %38 %uint_4 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %39 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_1 + OpStore %39 %uint_5 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %41 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_0 + OpStore %41 %uint_6 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %43 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_1 %uint_1 + OpStore %43 %uint_7 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + OpBranch %46 + %46 = OpLabel + %47 = OpPhi %uint %uint_0 %29 %68 %67 + %50 = OpULessThan %bool %47 %uint_8 + OpLoopMerge %71 %67 None + OpBranchConditional %50 %53 %67 + %53 = OpLabel + %54 = OpAccessChain %_ptr_Workgroup_uint %9 %uint_0 %uint_0 + %55 = OpPtrAccessChain %_ptr_Workgroup_uint %54 %47 + %56 = OpLoad %uint %55 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %58 = OpAccessChain %_ptr_StorageBuffer_uint %24 %uint_0 %47 + OpStore %58 %56 Aligned 4 + %59 = OpAccessChain %_ptr_Workgroup_uint %13 %uint_0 %uint_0 + %60 = OpPtrAccessChain %_ptr_Workgroup_uint %59 %47 + %61 = OpLoad %uint %60 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %62 = OpAccessChain %_ptr_StorageBuffer_uint %25 %uint_0 %47 + OpStore %62 %61 Aligned 4 + OpBranch %64 + %64 = OpLabel + %65 = OpIAdd %uint %47 %uint_1 + OpBranch %67 + %67 = OpLabel + %68 = OpPhi %uint %65 %64 %72 %46 + %69 = OpPhi %bool %false %64 %true %46 + OpBranchConditional %69 %71 %46 + %71 = OpLabel + OpReturn + OpFunctionEnd + %78 = OpExtInst %void %75 Kernel %28 %76 %uint_2 %uint_0 %77 + %80 = OpExtInst %void %75 ArgumentInfo %79 + %81 = OpExtInst %void %75 ArgumentStorageBuffer %78 %uint_0 %uint_0 %uint_0 %80 + %83 = OpExtInst %void %75 ArgumentInfo %82 + %84 = OpExtInst %void %75 ArgumentStorageBuffer %78 %uint_1 %uint_0 %uint_1 %83 + %85 = OpExtInst %void %75 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-pointer.spvasm new file mode 100644 index 0000000000..d180d7cbb6 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment3-struct-pointer.spvasm @@ -0,0 +1,126 @@ +; @Input: %12={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %13={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %14={{0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %15={{0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%12[0][0] == 0 and %12[0][2] == 1) +; @Output: forall (%12[0][4] == 2 and %12[0][6] == 3) +; @Output: forall (%13[0][0] == 4 and %13[0][1] == 5) +; @Output: forall (%13[0][2] == 6 and %13[0][3] == 7) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 81 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %64 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %18 "test" %8 %12 %13 %14 %15 + OpSource OpenCL_C 200 + %65 = OpString "test" + %66 = OpString "__kernel" + %68 = OpString "r_aligned" + %71 = OpString "r_unaligned" + %74 = OpString "aligned" + %77 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_10 0 Offset 0 + OpDecorate %_struct_10 Block + OpDecorate %12 DescriptorSet 0 + OpDecorate %12 Binding 0 + OpDecorate %13 DescriptorSet 0 + OpDecorate %13 Binding 1 + OpDecorate %14 DescriptorSet 0 + OpDecorate %14 Binding 2 + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 3 + OpDecorate %2 SpecId 0 + OpDecorate %3 SpecId 1 + OpDecorate %4 SpecId 2 + %uint = OpTypeInt 32 0 + %2 = OpSpecConstant %uint 1 + %3 = OpSpecConstant %uint 1 + %4 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %2 %3 %4 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_10 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_10 = OpTypePointer StorageBuffer %_struct_10 + %void = OpTypeVoid + %17 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_4 = OpConstant %uint 4 + %uint_6 = OpConstant %uint 6 + %uint_3 = OpConstant %uint 3 + %uint_5 = OpConstant %uint 5 + %uint_7 = OpConstant %uint 7 + %bool = OpTypeBool + %uint_8 = OpConstant %uint 8 + %61 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %8 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %12 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %13 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %14 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %15 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %18 = OpFunction %void None %17 + %19 = OpLabel + %22 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_0 + OpStore %22 %uint_0 Aligned 4 + %24 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_2 + OpStore %24 %uint_1 Aligned 4 + %27 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_4 + OpStore %27 %uint_2 Aligned 4 + %29 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_6 + OpStore %29 %uint_3 Aligned 4 + %31 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_0 + OpStore %31 %uint_4 Aligned 4 + %32 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_1 + OpStore %32 %uint_5 Aligned 4 + %34 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_2 + OpStore %34 %uint_6 Aligned 4 + %35 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_3 + OpStore %35 %uint_7 Aligned 4 + OpBranch %38 + %38 = OpLabel + %39 = OpPhi %uint %uint_0 %19 %57 %56 + %42 = OpULessThan %bool %39 %uint_8 + OpLoopMerge %60 %56 None + OpBranchConditional %42 %45 %56 + %45 = OpLabel + %46 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %39 + %47 = OpLoad %uint %46 Aligned 4 + %48 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %39 + OpStore %48 %47 Aligned 4 + %49 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %39 + %50 = OpLoad %uint %49 Aligned 4 + %51 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %39 + OpStore %51 %50 Aligned 4 + OpBranch %53 + %53 = OpLabel + %54 = OpIAdd %uint %39 %uint_1 + OpBranch %56 + %56 = OpLabel + %57 = OpPhi %uint %54 %53 %61 %38 + %58 = OpPhi %bool %false %53 %true %38 + OpBranchConditional %58 %60 %38 + %60 = OpLabel + OpReturn + OpFunctionEnd + %67 = OpExtInst %void %64 Kernel %18 %65 %uint_4 %uint_0 %66 + %69 = OpExtInst %void %64 ArgumentInfo %68 + %70 = OpExtInst %void %64 ArgumentStorageBuffer %67 %uint_0 %uint_0 %uint_0 %69 + %72 = OpExtInst %void %64 ArgumentInfo %71 + %73 = OpExtInst %void %64 ArgumentStorageBuffer %67 %uint_1 %uint_0 %uint_1 %72 + %75 = OpExtInst %void %64 ArgumentInfo %74 + %76 = OpExtInst %void %64 ArgumentStorageBuffer %67 %uint_2 %uint_0 %uint_2 %75 + %78 = OpExtInst %void %64 ArgumentInfo %77 + %79 = OpExtInst %void %64 ArgumentStorageBuffer %67 %uint_3 %uint_0 %uint_3 %78 + %80 = OpExtInst %void %64 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-local.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-local.spvasm new file mode 100644 index 0000000000..d998ca72dd --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-local.spvasm @@ -0,0 +1,154 @@ +; @Input: %26={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %27={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %11={{0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, {0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}} +; @Input: %15={{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}} +; @Output: forall (%26[0][0] == 0 and %26[0][2] == 1 and %26[0][4] == 2 and %26[0][8] == 3) +; @Output: forall (%26[0][12] == 4 and %26[0][14] == 5 and %26[0][16] == 6 and %26[0][20] == 7) +; @Output: forall (%27[0][0] == 8 and %27[0][1] == 9 and %27[0][2] == 10 and %27[0][3] == 11) +; @Output: forall (%27[0][4] == 12 and %27[0][5] == 13 and %27[0][6] == 14 and %27[0][7] == 15) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 103 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %92 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %30 "test" %11 %15 %22 %26 %27 + OpSource OpenCL_C 200 + %93 = OpString "test" + %94 = OpString "__kernel" + %96 = OpString "r_aligned" + %99 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_24 0 Offset 0 + OpDecorate %_struct_24 Block + OpDecorate %26 DescriptorSet 0 + OpDecorate %26 Binding 0 + OpDecorate %27 DescriptorSet 0 + OpDecorate %27 Binding 1 + OpDecorate %16 SpecId 0 + OpDecorate %17 SpecId 1 + OpDecorate %18 SpecId 2 + %uint = OpTypeInt 32 0 + %uchar = OpTypeInt 8 0 + %uint_4 = OpConstant %uint 4 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 + %uint_12 = OpConstant %uint 12 +%_arr_uchar_uint_12 = OpTypeArray %uchar %uint_12 + %_struct_7 = OpTypeStruct %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_4 %uint %_arr_uchar_uint_12 %uint %_arr_uchar_uint_12 + %uint_3 = OpConstant %uint 3 +%_arr__struct_7_uint_3 = OpTypeArray %_struct_7 %uint_3 +%_ptr_Workgroup__arr__struct_7_uint_3 = OpTypePointer Workgroup %_arr__struct_7_uint_3 + %_struct_12 = OpTypeStruct %uint %uint %uint %uint +%_arr__struct_12_uint_3 = OpTypeArray %_struct_12 %uint_3 +%_ptr_Workgroup__arr__struct_12_uint_3 = OpTypePointer Workgroup %_arr__struct_12_uint_3 + %16 = OpSpecConstant %uint 1 + %17 = OpSpecConstant %uint 1 + %18 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %16 %17 %18 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_24 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_24 = OpTypePointer StorageBuffer %_struct_24 + %void = OpTypeVoid + %29 = OpTypeFunction %void +%_ptr_Workgroup_uint = OpTypePointer Workgroup %uint + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_6 = OpConstant %uint 6 + %uint_5 = OpConstant %uint 5 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_14 = OpConstant %uint 14 + %uint_15 = OpConstant %uint 15 + %bool = OpTypeBool + %uint_24 = OpConstant %uint 24 +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %89 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %11 = OpVariable %_ptr_Workgroup__arr__struct_7_uint_3 Workgroup + %15 = OpVariable %_ptr_Workgroup__arr__struct_12_uint_3 Workgroup + %22 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %26 = OpVariable %_ptr_StorageBuffer__struct_24 StorageBuffer + %27 = OpVariable %_ptr_StorageBuffer__struct_24 StorageBuffer + %30 = OpFunction %void None %29 + %31 = OpLabel + %34 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_0 %uint_0 + OpStore %34 %uint_0 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %36 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_0 %uint_2 + OpStore %36 %uint_1 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %38 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_0 %uint_4 + OpStore %38 %uint_2 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %40 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_0 %uint_6 + OpStore %40 %uint_3 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %41 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_1 %uint_0 + OpStore %41 %uint_4 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %42 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_1 %uint_2 + OpStore %42 %uint_5 Aligned|MakePointerAvailable|NonPrivatePointer 8 %uint_2 + %44 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_1 %uint_4 + OpStore %44 %uint_6 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %45 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_1 %uint_6 + OpStore %45 %uint_7 Aligned|MakePointerAvailable|NonPrivatePointer 16 %uint_2 + %47 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_0 %uint_0 + OpStore %47 %uint_8 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %49 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_0 %uint_1 + OpStore %49 %uint_9 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %51 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_0 %uint_2 + OpStore %51 %uint_10 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %53 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_0 %uint_3 + OpStore %53 %uint_11 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %55 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_1 %uint_0 + OpStore %55 %uint_12 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %56 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_1 %uint_1 + OpStore %56 %uint_13 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %58 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_1 %uint_2 + OpStore %58 %uint_14 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %60 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_1 %uint_3 + OpStore %60 %uint_15 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + OpBranch %63 + %63 = OpLabel + %64 = OpPhi %uint %uint_0 %31 %85 %84 + %67 = OpULessThan %bool %64 %uint_24 + OpLoopMerge %88 %84 None + OpBranchConditional %67 %70 %84 + %70 = OpLabel + %71 = OpAccessChain %_ptr_Workgroup_uint %11 %uint_0 %uint_0 + %72 = OpPtrAccessChain %_ptr_Workgroup_uint %71 %64 + %73 = OpLoad %uint %72 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %75 = OpAccessChain %_ptr_StorageBuffer_uint %26 %uint_0 %64 + OpStore %75 %73 Aligned 4 + %76 = OpAccessChain %_ptr_Workgroup_uint %15 %uint_0 %uint_0 + %77 = OpPtrAccessChain %_ptr_Workgroup_uint %76 %64 + %78 = OpLoad %uint %77 Aligned|MakePointerVisible|NonPrivatePointer 4 %uint_2 + %79 = OpAccessChain %_ptr_StorageBuffer_uint %27 %uint_0 %64 + OpStore %79 %78 Aligned 4 + OpBranch %81 + %81 = OpLabel + %82 = OpIAdd %uint %64 %uint_1 + OpBranch %84 + %84 = OpLabel + %85 = OpPhi %uint %82 %81 %89 %63 + %86 = OpPhi %bool %false %81 %true %63 + OpBranchConditional %86 %88 %63 + %88 = OpLabel + OpReturn + OpFunctionEnd + %95 = OpExtInst %void %92 Kernel %30 %93 %uint_2 %uint_0 %94 + %97 = OpExtInst %void %92 ArgumentInfo %96 + %98 = OpExtInst %void %92 ArgumentStorageBuffer %95 %uint_0 %uint_0 %uint_0 %97 + %100 = OpExtInst %void %92 ArgumentInfo %99 + %101 = OpExtInst %void %92 ArgumentStorageBuffer %95 %uint_1 %uint_0 %uint_1 %100 + %102 = OpExtInst %void %92 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-pointer.spvasm new file mode 100644 index 0000000000..0a9671a59d --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment4-struct-pointer.spvasm @@ -0,0 +1,152 @@ +; @Input: %12={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %13={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %14={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %15={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%12[0][0] == 0 and %12[0][2] == 1 and %12[0][4] == 2 and %12[0][8] == 3) +; @Output: forall (%12[0][12] == 4 and %12[0][14] == 5 and %12[0][16] == 6 and %12[0][20] == 7) +; @Output: forall (%13[0][0] == 8 and %13[0][1] == 9 and %13[0][2] == 10 and %13[0][3] == 11) +; @Output: forall (%13[0][4] == 12 and %13[0][5] == 13 and %13[0][6] == 14 and %13[0][7] == 15) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 99 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %82 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %18 "test" %8 %12 %13 %14 %15 + OpSource OpenCL_C 200 + %83 = OpString "test" + %84 = OpString "__kernel" + %86 = OpString "r_aligned" + %89 = OpString "r_unaligned" + %92 = OpString "aligned" + %95 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_10 0 Offset 0 + OpDecorate %_struct_10 Block + OpDecorate %12 DescriptorSet 0 + OpDecorate %12 Binding 0 + OpDecorate %13 DescriptorSet 0 + OpDecorate %13 Binding 1 + OpDecorate %14 DescriptorSet 0 + OpDecorate %14 Binding 2 + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 3 + OpDecorate %2 SpecId 0 + OpDecorate %3 SpecId 1 + OpDecorate %4 SpecId 2 + %uint = OpTypeInt 32 0 + %2 = OpSpecConstant %uint 1 + %3 = OpSpecConstant %uint 1 + %4 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %2 %3 %4 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_10 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_10 = OpTypePointer StorageBuffer %_struct_10 + %void = OpTypeVoid + %17 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %uint_0 = OpConstant %uint 0 + %uint_2 = OpConstant %uint 2 + %uint_1 = OpConstant %uint 1 + %uint_4 = OpConstant %uint 4 + %uint_8 = OpConstant %uint 8 + %uint_3 = OpConstant %uint 3 + %uint_12 = OpConstant %uint 12 + %uint_14 = OpConstant %uint 14 + %uint_5 = OpConstant %uint 5 + %uint_16 = OpConstant %uint 16 + %uint_6 = OpConstant %uint 6 + %uint_20 = OpConstant %uint 20 + %uint_7 = OpConstant %uint 7 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %uint_13 = OpConstant %uint 13 + %uint_15 = OpConstant %uint 15 + %bool = OpTypeBool + %uint_24 = OpConstant %uint 24 + %79 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %8 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %12 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %13 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %14 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %15 = OpVariable %_ptr_StorageBuffer__struct_10 StorageBuffer + %18 = OpFunction %void None %17 + %19 = OpLabel + %22 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_0 + OpStore %22 %uint_0 Aligned 4 + %24 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_2 + OpStore %24 %uint_1 Aligned 4 + %27 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_4 + OpStore %27 %uint_2 Aligned 4 + %29 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_8 + OpStore %29 %uint_3 Aligned 4 + %32 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_12 + OpStore %32 %uint_4 Aligned 4 + %34 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_14 + OpStore %34 %uint_5 Aligned 4 + %37 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_16 + OpStore %37 %uint_6 Aligned 4 + %40 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %uint_20 + OpStore %40 %uint_7 Aligned 4 + %42 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_0 + OpStore %42 %uint_8 Aligned 4 + %43 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_1 + OpStore %43 %uint_9 Aligned 4 + %45 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_2 + OpStore %45 %uint_10 Aligned 4 + %47 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_3 + OpStore %47 %uint_11 Aligned 4 + %49 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_4 + OpStore %49 %uint_12 Aligned 4 + %50 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_5 + OpStore %50 %uint_13 Aligned 4 + %52 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_6 + OpStore %52 %uint_14 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %uint_7 + OpStore %53 %uint_15 Aligned 4 + OpBranch %56 + %56 = OpLabel + %57 = OpPhi %uint %uint_0 %19 %75 %74 + %60 = OpULessThan %bool %57 %uint_24 + OpLoopMerge %78 %74 None + OpBranchConditional %60 %63 %74 + %63 = OpLabel + %64 = OpAccessChain %_ptr_StorageBuffer_uint %14 %uint_0 %57 + %65 = OpLoad %uint %64 Aligned 4 + %66 = OpAccessChain %_ptr_StorageBuffer_uint %12 %uint_0 %57 + OpStore %66 %65 Aligned 4 + %67 = OpAccessChain %_ptr_StorageBuffer_uint %15 %uint_0 %57 + %68 = OpLoad %uint %67 Aligned 4 + %69 = OpAccessChain %_ptr_StorageBuffer_uint %13 %uint_0 %57 + OpStore %69 %68 Aligned 4 + OpBranch %71 + %71 = OpLabel + %72 = OpIAdd %uint %57 %uint_1 + OpBranch %74 + %74 = OpLabel + %75 = OpPhi %uint %72 %71 %79 %56 + %76 = OpPhi %bool %false %71 %true %56 + OpBranchConditional %76 %78 %56 + %78 = OpLabel + OpReturn + OpFunctionEnd + %85 = OpExtInst %void %82 Kernel %18 %83 %uint_4 %uint_0 %84 + %87 = OpExtInst %void %82 ArgumentInfo %86 + %88 = OpExtInst %void %82 ArgumentStorageBuffer %85 %uint_0 %uint_0 %uint_0 %87 + %90 = OpExtInst %void %82 ArgumentInfo %89 + %91 = OpExtInst %void %82 ArgumentStorageBuffer %85 %uint_1 %uint_0 %uint_1 %90 + %93 = OpExtInst %void %82 ArgumentInfo %92 + %94 = OpExtInst %void %82 ArgumentStorageBuffer %85 %uint_2 %uint_0 %uint_2 %93 + %96 = OpExtInst %void %82 ArgumentInfo %95 + %97 = OpExtInst %void %82 ArgumentStorageBuffer %85 %uint_3 %uint_0 %uint_3 %96 + %98 = OpExtInst %void %82 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-local.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-local.spvasm new file mode 100644 index 0000000000..32cb455f42 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-local.spvasm @@ -0,0 +1,195 @@ +; @Input: %25={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %26={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%25[0][0] == 0 and %25[0][1] == 1 and %25[0][2] == 2 and %25[0][3] == 3 and %25[0][4] == 4) +; @Output: forall (%25[0][8] == 5 and %25[0][9] == 6 and %25[0][10] == 7 and %25[0][11] == 8 and %25[0][12] == 9) +; @Output: forall (%26[0][0] == 10 and %26[0][1] == 11 and %26[0][2] == 12 and %26[0][3] == 13 and %26[0][4] == 14) +; @Output: forall (%26[0][5] == 15 and %26[0][6] == 16 and %26[0][7] == 17 and %26[0][8] == 18 and %26[0][9] == 19) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 142 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %131 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %29 "test" %10 %14 %21 %25 %26 + OpSource OpenCL_C 200 + %132 = OpString "test" + %133 = OpString "__kernel" + %135 = OpString "r_aligned" + %138 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uchar ArrayStride 1 + OpMemberDecorate %_struct_23 0 Offset 0 + OpDecorate %_struct_23 Block + OpDecorate %25 DescriptorSet 0 + OpDecorate %25 Binding 0 + OpDecorate %26 DescriptorSet 0 + OpDecorate %26 Binding 1 + OpDecorate %15 SpecId 0 + OpDecorate %16 SpecId 1 + OpDecorate %17 SpecId 2 + %uchar = OpTypeInt 8 0 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 + %uint_3 = OpConstant %uint 3 +%_arr_uchar_uint_3 = OpTypeArray %uchar %uint_3 + %_struct_7 = OpTypeStruct %uchar %_arr_uchar_uint_4 %_arr_uchar_uint_3 +%_arr__struct_7_uint_3 = OpTypeArray %_struct_7 %uint_3 +%_ptr_Workgroup__arr__struct_7_uint_3 = OpTypePointer Workgroup %_arr__struct_7_uint_3 + %_struct_11 = OpTypeStruct %uchar %_arr_uchar_uint_4 +%_arr__struct_11_uint_3 = OpTypeArray %_struct_11 %uint_3 +%_ptr_Workgroup__arr__struct_11_uint_3 = OpTypePointer Workgroup %_arr__struct_11_uint_3 + %15 = OpSpecConstant %uint 1 + %16 = OpSpecConstant %uint 1 + %17 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uchar = OpTypeRuntimeArray %uchar + %_struct_23 = OpTypeStruct %_runtimearr_uchar +%_ptr_StorageBuffer__struct_23 = OpTypePointer StorageBuffer %_struct_23 + %void = OpTypeVoid + %28 = OpTypeFunction %void +%_ptr_Workgroup_uchar = OpTypePointer Workgroup %uchar + %uint_0 = OpConstant %uint 0 + %uchar_0 = OpConstant %uchar 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uint_2 = OpConstant %uint 2 + %uchar_2 = OpConstant %uchar 2 + %uchar_3 = OpConstant %uchar 3 + %uchar_4 = OpConstant %uchar 4 + %uint_8 = OpConstant %uint 8 + %uchar_5 = OpConstant %uchar 5 + %uint_9 = OpConstant %uint 9 + %uchar_6 = OpConstant %uchar 6 + %uint_10 = OpConstant %uint 10 + %uchar_7 = OpConstant %uchar 7 + %uint_11 = OpConstant %uint 11 + %uchar_8 = OpConstant %uchar 8 + %uint_12 = OpConstant %uint 12 + %uchar_9 = OpConstant %uchar 9 + %uchar_10 = OpConstant %uchar 10 + %uchar_11 = OpConstant %uchar 11 + %uchar_12 = OpConstant %uchar 12 + %uchar_13 = OpConstant %uchar 13 + %uchar_14 = OpConstant %uchar 14 + %uint_5 = OpConstant %uint 5 + %uchar_15 = OpConstant %uchar 15 + %uint_6 = OpConstant %uint 6 + %uchar_16 = OpConstant %uchar 16 + %uint_7 = OpConstant %uint 7 + %uchar_17 = OpConstant %uchar 17 + %uchar_18 = OpConstant %uchar 18 + %uchar_19 = OpConstant %uchar 19 + %bool = OpTypeBool + %uint_16 = OpConstant %uint 16 +%_ptr_StorageBuffer_uchar = OpTypePointer StorageBuffer %uchar + %128 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %10 = OpVariable %_ptr_Workgroup__arr__struct_7_uint_3 Workgroup + %14 = OpVariable %_ptr_Workgroup__arr__struct_11_uint_3 Workgroup + %21 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %25 = OpVariable %_ptr_StorageBuffer__struct_23 StorageBuffer + %26 = OpVariable %_ptr_StorageBuffer__struct_23 StorageBuffer + %29 = OpFunction %void None %28 + %30 = OpLabel + %33 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + OpStore %33 %uchar_0 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %35 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %37 = OpPtrAccessChain %_ptr_Workgroup_uchar %35 %uint_1 + OpStore %37 %uchar_1 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %39 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %41 = OpPtrAccessChain %_ptr_Workgroup_uchar %39 %uint_2 + OpStore %41 %uchar_2 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %43 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %44 = OpPtrAccessChain %_ptr_Workgroup_uchar %43 %uint_3 + OpStore %44 %uchar_3 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %46 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %47 = OpPtrAccessChain %_ptr_Workgroup_uchar %46 %uint_4 + OpStore %47 %uchar_4 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %49 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %51 = OpPtrAccessChain %_ptr_Workgroup_uchar %49 %uint_8 + OpStore %51 %uchar_5 Aligned|MakePointerAvailable|NonPrivatePointer 4 %uint_2 + %53 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %55 = OpPtrAccessChain %_ptr_Workgroup_uchar %53 %uint_9 + OpStore %55 %uchar_6 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %57 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %59 = OpPtrAccessChain %_ptr_Workgroup_uchar %57 %uint_10 + OpStore %59 %uchar_7 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %61 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %63 = OpPtrAccessChain %_ptr_Workgroup_uchar %61 %uint_11 + OpStore %63 %uchar_8 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %65 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %67 = OpPtrAccessChain %_ptr_Workgroup_uchar %65 %uint_12 + OpStore %67 %uchar_9 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %69 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + OpStore %69 %uchar_10 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %71 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %72 = OpPtrAccessChain %_ptr_Workgroup_uchar %71 %uint_1 + OpStore %72 %uchar_11 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %74 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %75 = OpPtrAccessChain %_ptr_Workgroup_uchar %74 %uint_2 + OpStore %75 %uchar_12 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %77 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %78 = OpPtrAccessChain %_ptr_Workgroup_uchar %77 %uint_3 + OpStore %78 %uchar_13 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %80 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %81 = OpPtrAccessChain %_ptr_Workgroup_uchar %80 %uint_4 + OpStore %81 %uchar_14 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %83 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %85 = OpPtrAccessChain %_ptr_Workgroup_uchar %83 %uint_5 + OpStore %85 %uchar_15 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %87 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %89 = OpPtrAccessChain %_ptr_Workgroup_uchar %87 %uint_6 + OpStore %89 %uchar_16 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %91 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %93 = OpPtrAccessChain %_ptr_Workgroup_uchar %91 %uint_7 + OpStore %93 %uchar_17 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %95 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %96 = OpPtrAccessChain %_ptr_Workgroup_uchar %95 %uint_8 + OpStore %96 %uchar_18 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + %98 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %99 = OpPtrAccessChain %_ptr_Workgroup_uchar %98 %uint_9 + OpStore %99 %uchar_19 Aligned|MakePointerAvailable|NonPrivatePointer 1 %uint_2 + OpBranch %102 + %102 = OpLabel + %103 = OpPhi %uint %uint_0 %30 %124 %123 + %106 = OpULessThan %bool %103 %uint_16 + OpLoopMerge %127 %123 None + OpBranchConditional %106 %109 %123 + %109 = OpLabel + %110 = OpAccessChain %_ptr_Workgroup_uchar %10 %uint_0 %uint_0 + %111 = OpPtrAccessChain %_ptr_Workgroup_uchar %110 %103 + %112 = OpLoad %uchar %111 Aligned|MakePointerVisible|NonPrivatePointer 1 %uint_2 + %114 = OpAccessChain %_ptr_StorageBuffer_uchar %25 %uint_0 %103 + OpStore %114 %112 Aligned 1 + %115 = OpAccessChain %_ptr_Workgroup_uchar %14 %uint_0 %uint_0 + %116 = OpPtrAccessChain %_ptr_Workgroup_uchar %115 %103 + %117 = OpLoad %uchar %116 Aligned|MakePointerVisible|NonPrivatePointer 1 %uint_2 + %118 = OpAccessChain %_ptr_StorageBuffer_uchar %26 %uint_0 %103 + OpStore %118 %117 Aligned 1 + OpBranch %120 + %120 = OpLabel + %121 = OpIAdd %uint %103 %uint_1 + OpBranch %123 + %123 = OpLabel + %124 = OpPhi %uint %121 %120 %128 %102 + %125 = OpPhi %bool %false %120 %true %102 + OpBranchConditional %125 %127 %102 + %127 = OpLabel + OpReturn + OpFunctionEnd + %134 = OpExtInst %void %131 Kernel %29 %132 %uint_2 %uint_0 %133 + %136 = OpExtInst %void %131 ArgumentInfo %135 + %137 = OpExtInst %void %131 ArgumentStorageBuffer %134 %uint_0 %uint_0 %uint_0 %136 + %139 = OpExtInst %void %131 ArgumentInfo %138 + %140 = OpExtInst %void %131 ArgumentStorageBuffer %134 %uint_1 %uint_0 %uint_1 %139 + %141 = OpExtInst %void %131 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-pointer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-pointer.spvasm new file mode 100644 index 0000000000..8c01d22121 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/alignment5-struct-pointer.spvasm @@ -0,0 +1,177 @@ +; @Input: %13={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %14={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %15={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %16={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Output: forall (%13[0][0] == 0 and %13[0][1] == 1 and %13[0][2] == 2 and %13[0][3] == 3 and %13[0][4] == 4) +; @Output: forall (%13[0][8] == 5 and %13[0][9] == 6 and %13[0][10] == 7 and %13[0][11] == 8 and %13[0][12] == 9) +; @Output: forall (%14[0][0] == 10 and %14[0][1] == 11 and %14[0][2] == 12 and %14[0][3] == 13 and %14[0][4] == 14) +; @Output: forall (%14[0][5] == 15 and %14[0][6] == 16 and %14[0][7] == 17 and %14[0][8] == 18 and %14[0][9] == 19) +; SPIR-V +; Version: 1.6 +; Generator: Google Clspv; 0 +; Bound: 119 +; Schema: 0 + OpCapability Shader + OpCapability Int8 + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %102 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %19 "test" %8 %13 %14 %15 %16 + OpSource OpenCL_C 200 + %103 = OpString "test" + %104 = OpString "__kernel" + %106 = OpString "r_aligned" + %109 = OpString "r_unaligned" + %112 = OpString "aligned" + %115 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uchar ArrayStride 1 + OpMemberDecorate %_struct_11 0 Offset 0 + OpDecorate %_struct_11 Block + OpDecorate %13 DescriptorSet 0 + OpDecorate %13 Binding 0 + OpDecorate %14 DescriptorSet 0 + OpDecorate %14 Binding 1 + OpDecorate %15 DescriptorSet 0 + OpDecorate %15 Binding 2 + OpDecorate %16 DescriptorSet 0 + OpDecorate %16 Binding 3 + OpDecorate %2 SpecId 0 + OpDecorate %3 SpecId 1 + OpDecorate %4 SpecId 2 + %uint = OpTypeInt 32 0 + %2 = OpSpecConstant %uint 1 + %3 = OpSpecConstant %uint 1 + %4 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %2 %3 %4 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint + %uchar = OpTypeInt 8 0 +%_runtimearr_uchar = OpTypeRuntimeArray %uchar + %_struct_11 = OpTypeStruct %_runtimearr_uchar +%_ptr_StorageBuffer__struct_11 = OpTypePointer StorageBuffer %_struct_11 + %void = OpTypeVoid + %18 = OpTypeFunction %void +%_ptr_StorageBuffer_uchar = OpTypePointer StorageBuffer %uchar + %uint_0 = OpConstant %uint 0 + %uchar_0 = OpConstant %uchar 0 + %uint_1 = OpConstant %uint 1 + %uchar_1 = OpConstant %uchar 1 + %uint_2 = OpConstant %uint 2 + %uchar_2 = OpConstant %uchar 2 + %uint_3 = OpConstant %uint 3 + %uchar_3 = OpConstant %uchar 3 + %uint_4 = OpConstant %uint 4 + %uchar_4 = OpConstant %uchar 4 + %uint_8 = OpConstant %uint 8 + %uchar_5 = OpConstant %uchar 5 + %uint_9 = OpConstant %uint 9 + %uchar_6 = OpConstant %uchar 6 + %uint_10 = OpConstant %uint 10 + %uchar_7 = OpConstant %uchar 7 + %uint_11 = OpConstant %uint 11 + %uchar_8 = OpConstant %uchar 8 + %uint_12 = OpConstant %uint 12 + %uchar_9 = OpConstant %uchar 9 + %uchar_10 = OpConstant %uchar 10 + %uchar_11 = OpConstant %uchar 11 + %uchar_12 = OpConstant %uchar 12 + %uchar_13 = OpConstant %uchar 13 + %uchar_14 = OpConstant %uchar 14 + %uint_5 = OpConstant %uint 5 + %uchar_15 = OpConstant %uchar 15 + %uint_6 = OpConstant %uint 6 + %uchar_16 = OpConstant %uchar 16 + %uint_7 = OpConstant %uint 7 + %uchar_17 = OpConstant %uchar 17 + %uchar_18 = OpConstant %uchar 18 + %uchar_19 = OpConstant %uchar 19 + %bool = OpTypeBool + %uint_16 = OpConstant %uint 16 + %99 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %8 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %13 = OpVariable %_ptr_StorageBuffer__struct_11 StorageBuffer + %14 = OpVariable %_ptr_StorageBuffer__struct_11 StorageBuffer + %15 = OpVariable %_ptr_StorageBuffer__struct_11 StorageBuffer + %16 = OpVariable %_ptr_StorageBuffer__struct_11 StorageBuffer + %19 = OpFunction %void None %18 + %20 = OpLabel + %23 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_0 + %24 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_0 + OpStore %23 %uchar_0 Aligned 1 + %27 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_1 + OpStore %27 %uchar_1 Aligned 1 + %30 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_2 + OpStore %30 %uchar_2 Aligned 1 + %33 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_3 + OpStore %33 %uchar_3 Aligned 1 + %36 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_4 + OpStore %36 %uchar_4 Aligned 1 + %39 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_8 + OpStore %39 %uchar_5 Aligned 1 + %42 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_9 + OpStore %42 %uchar_6 Aligned 1 + %45 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_10 + OpStore %45 %uchar_7 Aligned 1 + %48 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_11 + OpStore %48 %uchar_8 Aligned 1 + %51 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %uint_12 + OpStore %51 %uchar_9 Aligned 1 + OpStore %24 %uchar_10 Aligned 1 + %54 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_1 + OpStore %54 %uchar_11 Aligned 1 + %56 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_2 + OpStore %56 %uchar_12 Aligned 1 + %58 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_3 + OpStore %58 %uchar_13 Aligned 1 + %60 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_4 + OpStore %60 %uchar_14 Aligned 1 + %63 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_5 + OpStore %63 %uchar_15 Aligned 1 + %66 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_6 + OpStore %66 %uchar_16 Aligned 1 + %69 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_7 + OpStore %69 %uchar_17 Aligned 1 + %71 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_8 + OpStore %71 %uchar_18 Aligned 1 + %73 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %uint_9 + OpStore %73 %uchar_19 Aligned 1 + OpBranch %76 + %76 = OpLabel + %77 = OpPhi %uint %uint_0 %20 %95 %94 + %80 = OpULessThan %bool %77 %uint_16 + OpLoopMerge %98 %94 None + OpBranchConditional %80 %83 %94 + %83 = OpLabel + %84 = OpAccessChain %_ptr_StorageBuffer_uchar %15 %uint_0 %77 + %85 = OpLoad %uchar %84 Aligned 1 + %86 = OpAccessChain %_ptr_StorageBuffer_uchar %13 %uint_0 %77 + OpStore %86 %85 Aligned 1 + %87 = OpAccessChain %_ptr_StorageBuffer_uchar %16 %uint_0 %77 + %88 = OpLoad %uchar %87 Aligned 1 + %89 = OpAccessChain %_ptr_StorageBuffer_uchar %14 %uint_0 %77 + OpStore %89 %88 Aligned 1 + OpBranch %91 + %91 = OpLabel + %92 = OpIAdd %uint %77 %uint_1 + OpBranch %94 + %94 = OpLabel + %95 = OpPhi %uint %92 %91 %99 %76 + %96 = OpPhi %bool %false %91 %true %76 + OpBranchConditional %96 %98 %76 + %98 = OpLabel + OpReturn + OpFunctionEnd + %105 = OpExtInst %void %102 Kernel %19 %103 %uint_4 %uint_0 %104 + %107 = OpExtInst %void %102 ArgumentInfo %106 + %108 = OpExtInst %void %102 ArgumentStorageBuffer %105 %uint_0 %uint_0 %uint_0 %107 + %110 = OpExtInst %void %102 ArgumentInfo %109 + %111 = OpExtInst %void %102 ArgumentStorageBuffer %105 %uint_1 %uint_0 %uint_1 %110 + %113 = OpExtInst %void %102 ArgumentInfo %112 + %114 = OpExtInst %void %102 ArgumentStorageBuffer %105 %uint_2 %uint_0 %uint_2 %113 + %116 = OpExtInst %void %102 ArgumentInfo %115 + %117 = OpExtInst %void %102 ArgumentStorageBuffer %105 %uint_3 %uint_0 %uint_3 %116 + %118 = OpExtInst %void %102 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-initializer.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-initializer.spvasm new file mode 100644 index 0000000000..d25edb9a51 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-initializer.spvasm @@ -0,0 +1,145 @@ +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 88 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr__arr_uint_uint_3_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_arr__arr_uint_uint_3_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %_arr_uint_uint_3 ArrayStride 4 + OpDecorate %22 SpecId 0 + OpDecorate %23 SpecId 1 + OpDecorate %24 SpecId 2 + %uint = OpTypeInt 32 0 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_3 = OpTypeArray %_arr_uint_uint_3 %uint_3 +%_arr__arr_uint_uint_3_uint_3_0 = OpTypeArray %_arr_uint_uint_3 %uint_3 + %_struct_16 = OpTypeStruct %_arr__arr_uint_uint_3_uint_3_0 + %_struct_18 = OpTypeStruct %_arr__arr_uint_uint_3_uint_3 + %39 = OpConstantComposite %_arr_uint_uint_3 %uint_0 %uint_1 %uint_2 + %40 = OpConstantComposite %_arr_uint_uint_3 %uint_3 %uint_4 %uint_5 + %41 = OpConstantComposite %_arr_uint_uint_3 %uint_0 %uint_0 %uint_0 + %42 = OpConstantComposite %_arr__arr_uint_uint_3_uint_3_0 %39 %40 %41 + %43 = OpConstantComposite %_struct_16 %42 + %44 = OpConstantComposite %_arr_uint_uint_3 %uint_6 %uint_7 %uint_8 + %45 = OpConstantComposite %_arr_uint_uint_3 %uint_9 %uint_10 %uint_11 + %46 = OpConstantComposite %_arr_uint_uint_3 %uint_0 %uint_0 %uint_0 + %47 = OpConstantComposite %_arr__arr_uint_uint_3_uint_3 %44 %45 %46 + %48 = OpConstantComposite %_struct_18 %47 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %22 %23 %24 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %54 = OpTypeFunction %void +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint + %56 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer %43 + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer %48 + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %54 + %61 = OpLabel + OpBranch %62 + %62 = OpLabel + %63 = OpPhi %uint %uint_0 %61 %64 %65 + %66 = OpULessThan %bool %63 %uint_8 + OpLoopMerge %67 %65 None + OpBranchConditional %66 %68 %65 + %68 = OpLabel + %69 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %63 + %70 = OpLoad %uint %69 Aligned 4 + %71 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %63 + OpStore %71 %70 Aligned 4 + %72 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %63 + %73 = OpLoad %uint %72 Aligned 4 + %74 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %63 + OpStore %74 %73 Aligned 4 + OpBranch %75 + %75 = OpLabel + %76 = OpIAdd %uint %63 %uint_1 + OpBranch %65 + %65 = OpLabel + %64 = OpPhi %uint %76 %75 %56 %62 + %77 = OpPhi %bool %false %75 %true %62 + OpBranchConditional %77 %67 %62 + %67 = OpLabel + OpReturn + OpFunctionEnd + %78 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %79 = OpExtInst %void %1 ArgumentInfo %10 + %80 = OpExtInst %void %1 ArgumentStorageBuffer %78 %uint_0 %uint_0 %uint_0 %79 + %81 = OpExtInst %void %1 ArgumentInfo %11 + %82 = OpExtInst %void %1 ArgumentStorageBuffer %78 %uint_1 %uint_0 %uint_1 %81 + %83 = OpExtInst %void %1 ArgumentInfo %12 + %84 = OpExtInst %void %1 ArgumentStorageBuffer %78 %uint_2 %uint_0 %uint_2 %83 + %85 = OpExtInst %void %1 ArgumentInfo %13 + %86 = OpExtInst %void %1 ArgumentStorageBuffer %78 %uint_3 %uint_0 %uint_3 %85 + %87 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-input.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-input.spvasm new file mode 100644 index 0000000000..27390ba607 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-input.spvasm @@ -0,0 +1,138 @@ +; @Input: %4={{{0, 1, 2}, {3, 4, 5}, {0, 0, 0}}} +; @Input: %5={{{6, 7, 8}, {9, 10, 11}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 78 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr__arr_uint_uint_3_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_arr__arr_uint_uint_3_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %_arr_uint_uint_3 ArrayStride 4 + OpDecorate %22 SpecId 0 + OpDecorate %23 SpecId 1 + OpDecorate %24 SpecId 2 + %uint = OpTypeInt 32 0 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_3 = OpTypeArray %_arr_uint_uint_3 %uint_3 +%_arr__arr_uint_uint_3_uint_3_0 = OpTypeArray %_arr_uint_uint_3 %uint_3 + %_struct_16 = OpTypeStruct %_arr__arr_uint_uint_3_uint_3_0 + %_struct_18 = OpTypeStruct %_arr__arr_uint_uint_3_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %22 %23 %24 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %44 = OpTypeFunction %void +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint + %46 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %44 + %51 = OpLabel + OpBranch %52 + %52 = OpLabel + %53 = OpPhi %uint %uint_0 %51 %54 %55 + %56 = OpULessThan %bool %53 %uint_8 + OpLoopMerge %57 %55 None + OpBranchConditional %56 %58 %55 + %58 = OpLabel + %59 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %53 + %60 = OpLoad %uint %59 Aligned 4 + %61 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %53 + OpStore %61 %60 Aligned 4 + %62 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %53 + %63 = OpLoad %uint %62 Aligned 4 + %64 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %53 + OpStore %64 %63 Aligned 4 + OpBranch %65 + %65 = OpLabel + %66 = OpIAdd %uint %53 %uint_1 + OpBranch %55 + %55 = OpLabel + %54 = OpPhi %uint %66 %65 %46 %52 + %67 = OpPhi %bool %false %65 %true %52 + OpBranchConditional %67 %57 %52 + %57 = OpLabel + OpReturn + OpFunctionEnd + %68 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %69 = OpExtInst %void %1 ArgumentInfo %10 + %70 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_0 %uint_0 %uint_0 %69 + %71 = OpExtInst %void %1 ArgumentInfo %11 + %72 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_1 %uint_0 %uint_1 %71 + %73 = OpExtInst %void %1 ArgumentInfo %12 + %74 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_2 %uint_0 %uint_2 %73 + %75 = OpExtInst %void %1 ArgumentInfo %13 + %76 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_3 %uint_0 %uint_3 %75 + %77 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-scalar.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-scalar.spvasm new file mode 100644 index 0000000000..e1dfb1de58 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-scalar.spvasm @@ -0,0 +1,162 @@ +; @Input: %4={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %5={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 90 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr__arr_uint_uint_3_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_arr__arr_uint_uint_3_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %_arr_uint_uint_3 ArrayStride 4 + OpDecorate %22 SpecId 0 + OpDecorate %23 SpecId 1 + OpDecorate %24 SpecId 2 + %uint = OpTypeInt 32 0 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_arr__arr_uint_uint_3_uint_3 = OpTypeArray %_arr_uint_uint_3 %uint_3 +%_arr__arr_uint_uint_3_uint_3_0 = OpTypeArray %_arr_uint_uint_3 %uint_3 + %_struct_16 = OpTypeStruct %_arr__arr_uint_uint_3_uint_3_0 + %_struct_18 = OpTypeStruct %_arr__arr_uint_uint_3_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %22 %23 %24 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %44 = OpTypeFunction %void +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint + %46 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %44 + %51 = OpLabel + %52 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %uint_0 + OpStore %52 %uint_0 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %uint_1 + OpStore %53 %uint_1 Aligned 4 + %54 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %uint_2 + OpStore %54 %uint_2 Aligned 4 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_1 %uint_0 + OpStore %55 %uint_3 Aligned 4 + %56 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_1 %uint_1 + OpStore %56 %uint_4 Aligned 4 + %57 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_1 %uint_2 + OpStore %57 %uint_5 Aligned 4 + %58 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %uint_0 + OpStore %58 %uint_6 Aligned 4 + %59 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %uint_1 + OpStore %59 %uint_7 Aligned 4 + %60 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %uint_2 + OpStore %60 %uint_8 Aligned 4 + %61 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_1 %uint_0 + OpStore %61 %uint_9 Aligned 4 + %62 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_1 %uint_1 + OpStore %62 %uint_10 Aligned 4 + %63 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_1 %uint_2 + OpStore %63 %uint_11 Aligned 4 + OpBranch %64 + %64 = OpLabel + %65 = OpPhi %uint %uint_0 %51 %66 %67 + %68 = OpULessThan %bool %65 %uint_8 + OpLoopMerge %69 %67 None + OpBranchConditional %68 %70 %67 + %70 = OpLabel + %71 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %65 + %72 = OpLoad %uint %71 Aligned 4 + %73 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %65 + OpStore %73 %72 Aligned 4 + %74 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %65 + %75 = OpLoad %uint %74 Aligned 4 + %76 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %65 + OpStore %76 %75 Aligned 4 + OpBranch %77 + %77 = OpLabel + %78 = OpIAdd %uint %65 %uint_1 + OpBranch %67 + %67 = OpLabel + %66 = OpPhi %uint %78 %77 %46 %64 + %79 = OpPhi %bool %false %77 %true %64 + OpBranchConditional %79 %69 %64 + %69 = OpLabel + OpReturn + OpFunctionEnd + %80 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %81 = OpExtInst %void %1 ArgumentInfo %10 + %82 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_0 %uint_0 %uint_0 %81 + %83 = OpExtInst %void %1 ArgumentInfo %11 + %84 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_1 %uint_0 %uint_1 %83 + %85 = OpExtInst %void %1 ArgumentInfo %12 + %86 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_2 %uint_0 %uint_2 %85 + %87 = OpExtInst %void %1 ArgumentInfo %13 + %88 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_3 %uint_0 %uint_3 %87 + %89 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-vector.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-vector.spvasm new file mode 100644 index 0000000000..db99739269 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-array-overwrite-vector.spvasm @@ -0,0 +1,148 @@ +; @Input: %4={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %5={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 85 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr_v3uint_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_arr_v3uint_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %21 SpecId 0 + OpDecorate %22 SpecId 1 + OpDecorate %23 SpecId 2 + %uint = OpTypeInt 32 0 + %21 = OpSpecConstant %uint 1 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 + %38 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2 + %39 = OpConstantComposite %v3uint %uint_3 %uint_4 %uint_5 + %40 = OpConstantComposite %v3uint %uint_6 %uint_7 %uint_8 + %41 = OpConstantComposite %v3uint %uint_9 %uint_10 %uint_11 +%_arr_v3uint_uint_3 = OpTypeArray %v3uint %uint_3 +%_arr_v3uint_uint_3_0 = OpTypeArray %v3uint %uint_3 + %_struct_16 = OpTypeStruct %_arr_v3uint_uint_3_0 + %_struct_18 = OpTypeStruct %_arr_v3uint_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %21 %22 %23 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %48 = OpTypeFunction %void + %49 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %48 + %54 = OpLabel + %55 = OpAccessChain %_ptr_StorageBuffer_v3uint %4 %uint_0 %uint_0 + OpStore %55 %38 Aligned 4 + %56 = OpAccessChain %_ptr_StorageBuffer_v3uint %4 %uint_0 %uint_1 + OpStore %56 %39 Aligned 4 + %57 = OpAccessChain %_ptr_StorageBuffer_v3uint %5 %uint_0 %uint_0 + OpStore %57 %40 Aligned 4 + %58 = OpAccessChain %_ptr_StorageBuffer_v3uint %5 %uint_0 %uint_1 + OpStore %58 %41 Aligned 4 + OpBranch %59 + %59 = OpLabel + %60 = OpPhi %uint %uint_0 %54 %61 %62 + %63 = OpULessThan %bool %60 %uint_8 + OpLoopMerge %64 %62 None + OpBranchConditional %63 %65 %62 + %65 = OpLabel + %66 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %60 + %67 = OpLoad %uint %66 Aligned 4 + %68 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %60 + OpStore %68 %67 Aligned 4 + %69 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %60 + %70 = OpLoad %uint %69 Aligned 4 + %71 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %60 + OpStore %71 %70 Aligned 4 + OpBranch %72 + %72 = OpLabel + %73 = OpIAdd %uint %60 %uint_1 + OpBranch %62 + %62 = OpLabel + %61 = OpPhi %uint %73 %72 %49 %59 + %74 = OpPhi %bool %false %72 %true %59 + OpBranchConditional %74 %64 %59 + %64 = OpLabel + OpReturn + OpFunctionEnd + %75 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %76 = OpExtInst %void %1 ArgumentInfo %10 + %77 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_0 %uint_0 %uint_0 %76 + %78 = OpExtInst %void %1 ArgumentInfo %11 + %79 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_1 %uint_0 %uint_1 %78 + %80 = OpExtInst %void %1 ArgumentInfo %12 + %81 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_2 %uint_0 %uint_2 %80 + %82 = OpExtInst %void %1 ArgumentInfo %13 + %83 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_3 %uint_0 %uint_3 %82 + %84 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-input.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-input.spvasm new file mode 100644 index 0000000000..f80126ce47 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-input.spvasm @@ -0,0 +1,138 @@ +; @Input: %4={{{0, 1, 2}, {3, 4, 5}, {0, 0, 0}}} +; @Input: %5={{{6, 7, 8}, {9, 10, 11}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 78 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtime__arr__arr_uint_uint_3_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_runtime__arr__arr_uint_uint_3_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %_arr_uint_uint_3 ArrayStride 4 + OpDecorate %22 SpecId 0 + OpDecorate %23 SpecId 1 + OpDecorate %24 SpecId 2 + %uint = OpTypeInt 32 0 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_runtime__arr__arr_uint_uint_3_uint_3 = OpTypeRuntimeArray %_arr_uint_uint_3 +%_runtime__arr__arr_uint_uint_3_uint_3_0 = OpTypeRuntimeArray %_arr_uint_uint_3 + %_struct_16 = OpTypeStruct %_runtime__arr__arr_uint_uint_3_uint_3_0 + %_struct_18 = OpTypeStruct %_runtime__arr__arr_uint_uint_3_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %22 %23 %24 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %44 = OpTypeFunction %void +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint + %46 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %44 + %51 = OpLabel + OpBranch %52 + %52 = OpLabel + %53 = OpPhi %uint %uint_0 %51 %54 %55 + %56 = OpULessThan %bool %53 %uint_8 + OpLoopMerge %57 %55 None + OpBranchConditional %56 %58 %55 + %58 = OpLabel + %59 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %53 + %60 = OpLoad %uint %59 Aligned 4 + %61 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %53 + OpStore %61 %60 Aligned 4 + %62 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %53 + %63 = OpLoad %uint %62 Aligned 4 + %64 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %53 + OpStore %64 %63 Aligned 4 + OpBranch %65 + %65 = OpLabel + %66 = OpIAdd %uint %53 %uint_1 + OpBranch %55 + %55 = OpLabel + %54 = OpPhi %uint %66 %65 %46 %52 + %67 = OpPhi %bool %false %65 %true %52 + OpBranchConditional %67 %57 %52 + %57 = OpLabel + OpReturn + OpFunctionEnd + %68 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %69 = OpExtInst %void %1 ArgumentInfo %10 + %70 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_0 %uint_0 %uint_0 %69 + %71 = OpExtInst %void %1 ArgumentInfo %11 + %72 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_1 %uint_0 %uint_1 %71 + %73 = OpExtInst %void %1 ArgumentInfo %12 + %74 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_2 %uint_0 %uint_2 %73 + %75 = OpExtInst %void %1 ArgumentInfo %13 + %76 = OpExtInst %void %1 ArgumentStorageBuffer %68 %uint_3 %uint_0 %uint_3 %75 + %77 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-scalar.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-scalar.spvasm new file mode 100644 index 0000000000..ba4484b0f9 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-scalar.spvasm @@ -0,0 +1,162 @@ +; @Input: %4={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %5={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 90 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr__arr_uint_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_runtimearr__arr_uint_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %_arr_uint_uint_3 ArrayStride 4 + OpDecorate %22 SpecId 0 + OpDecorate %23 SpecId 1 + OpDecorate %24 SpecId 2 + %uint = OpTypeInt 32 0 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_uint_uint_3 = OpTypeArray %uint %uint_3 +%_runtimearr__arr_uint_uint_3 = OpTypeRuntimeArray %_arr_uint_uint_3 +%_runtimearr__arr_uint_uint_3_0 = OpTypeRuntimeArray %_arr_uint_uint_3 + %_struct_16 = OpTypeStruct %_runtimearr__arr_uint_uint_3_0 + %_struct_18 = OpTypeStruct %_runtimearr__arr_uint_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %22 %23 %24 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %44 = OpTypeFunction %void +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint + %46 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %44 + %51 = OpLabel + %52 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %uint_0 + OpStore %52 %uint_0 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %uint_1 + OpStore %53 %uint_1 Aligned 4 + %54 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %uint_2 + OpStore %54 %uint_2 Aligned 4 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_1 %uint_0 + OpStore %55 %uint_3 Aligned 4 + %56 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_1 %uint_1 + OpStore %56 %uint_4 Aligned 4 + %57 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_1 %uint_2 + OpStore %57 %uint_5 Aligned 4 + %58 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %uint_0 + OpStore %58 %uint_6 Aligned 4 + %59 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %uint_1 + OpStore %59 %uint_7 Aligned 4 + %60 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %uint_2 + OpStore %60 %uint_8 Aligned 4 + %61 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_1 %uint_0 + OpStore %61 %uint_9 Aligned 4 + %62 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_1 %uint_1 + OpStore %62 %uint_10 Aligned 4 + %63 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_1 %uint_2 + OpStore %63 %uint_11 Aligned 4 + OpBranch %64 + %64 = OpLabel + %65 = OpPhi %uint %uint_0 %51 %66 %67 + %68 = OpULessThan %bool %65 %uint_8 + OpLoopMerge %69 %67 None + OpBranchConditional %68 %70 %67 + %70 = OpLabel + %71 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %65 + %72 = OpLoad %uint %71 Aligned 4 + %73 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %65 + OpStore %73 %72 Aligned 4 + %74 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %65 + %75 = OpLoad %uint %74 Aligned 4 + %76 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %65 + OpStore %76 %75 Aligned 4 + OpBranch %77 + %77 = OpLabel + %78 = OpIAdd %uint %65 %uint_1 + OpBranch %67 + %67 = OpLabel + %66 = OpPhi %uint %78 %77 %46 %64 + %79 = OpPhi %bool %false %77 %true %64 + OpBranchConditional %79 %69 %64 + %69 = OpLabel + OpReturn + OpFunctionEnd + %80 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %81 = OpExtInst %void %1 ArgumentInfo %10 + %82 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_0 %uint_0 %uint_0 %81 + %83 = OpExtInst %void %1 ArgumentInfo %11 + %84 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_1 %uint_0 %uint_1 %83 + %85 = OpExtInst %void %1 ArgumentInfo %12 + %86 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_2 %uint_0 %uint_2 %85 + %87 = OpExtInst %void %1 ArgumentInfo %13 + %88 = OpExtInst %void %1 ArgumentStorageBuffer %80 %uint_3 %uint_0 %uint_3 %87 + %89 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-vector.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-vector.spvasm new file mode 100644 index 0000000000..6dee37cfd2 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/array-stride-runtime-array-overwrite-vector.spvasm @@ -0,0 +1,148 @@ +; @Input: %4={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %5={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 85 +; Schema: 0 + OpCapability Shader + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtime_arr_v3uint_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_runtime_arr_v3uint_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpMemberDecorate %_struct_20 0 Offset 0 + OpDecorate %_struct_20 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %21 SpecId 0 + OpDecorate %22 SpecId 1 + OpDecorate %23 SpecId 2 + %uint = OpTypeInt 32 0 + %21 = OpSpecConstant %uint 1 + %22 = OpSpecConstant %uint 1 + %23 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 + %38 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2 + %39 = OpConstantComposite %v3uint %uint_3 %uint_4 %uint_5 + %40 = OpConstantComposite %v3uint %uint_6 %uint_7 %uint_8 + %41 = OpConstantComposite %v3uint %uint_9 %uint_10 %uint_11 +%_runtime_arr_v3uint_uint_3 = OpTypeRuntimeArray %v3uint +%_runtime_arr_v3uint_uint_3_0 = OpTypeRuntimeArray %v3uint + %_struct_16 = OpTypeStruct %_runtime_arr_v3uint_uint_3_0 + %_struct_18 = OpTypeStruct %_runtime_arr_v3uint_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %21 %22 %23 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_20 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_20 = OpTypePointer StorageBuffer %_struct_20 + %void = OpTypeVoid + %48 = OpTypeFunction %void + %49 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer + %2 = OpFunction %void None %48 + %54 = OpLabel + %55 = OpAccessChain %_ptr_StorageBuffer_v3uint %4 %uint_0 %uint_0 + OpStore %55 %38 Aligned 4 + %56 = OpAccessChain %_ptr_StorageBuffer_v3uint %4 %uint_0 %uint_1 + OpStore %56 %39 Aligned 4 + %57 = OpAccessChain %_ptr_StorageBuffer_v3uint %5 %uint_0 %uint_0 + OpStore %57 %40 Aligned 4 + %58 = OpAccessChain %_ptr_StorageBuffer_v3uint %5 %uint_0 %uint_1 + OpStore %58 %41 Aligned 4 + OpBranch %59 + %59 = OpLabel + %60 = OpPhi %uint %uint_0 %54 %61 %62 + %63 = OpULessThan %bool %60 %uint_8 + OpLoopMerge %64 %62 None + OpBranchConditional %63 %65 %62 + %65 = OpLabel + %66 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %60 + %67 = OpLoad %uint %66 Aligned 4 + %68 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %60 + OpStore %68 %67 Aligned 4 + %69 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %60 + %70 = OpLoad %uint %69 Aligned 4 + %71 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %60 + OpStore %71 %70 Aligned 4 + OpBranch %72 + %72 = OpLabel + %73 = OpIAdd %uint %60 %uint_1 + OpBranch %62 + %62 = OpLabel + %61 = OpPhi %uint %73 %72 %49 %59 + %74 = OpPhi %bool %false %72 %true %59 + OpBranchConditional %74 %64 %59 + %64 = OpLabel + OpReturn + OpFunctionEnd + %75 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %76 = OpExtInst %void %1 ArgumentInfo %10 + %77 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_0 %uint_0 %uint_0 %76 + %78 = OpExtInst %void %1 ArgumentInfo %11 + %79 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_1 %uint_0 %uint_1 %78 + %80 = OpExtInst %void %1 ArgumentInfo %12 + %81 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_2 %uint_0 %uint_2 %80 + %82 = OpExtInst %void %1 ArgumentInfo %13 + %83 = OpExtInst %void %1 ArgumentStorageBuffer %75 %uint_3 %uint_0 %uint_3 %82 + %84 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-scalar.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-scalar.spvasm new file mode 100644 index 0000000000..c8cdfccdce --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-scalar.spvasm @@ -0,0 +1,166 @@ +; @Input: %4={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %5={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 92 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr_v3uint_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_arr_v3uint_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpDecorate %_ptr_StorageBuffer_v3uint_0 ArrayStride 16 + OpDecorate %_ptr_StorageBuffer_v3uint ArrayStride 12 + OpMemberDecorate %_struct_22 0 Offset 0 + OpDecorate %_struct_22 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %23 SpecId 0 + OpDecorate %24 SpecId 1 + OpDecorate %25 SpecId 2 + %uint = OpTypeInt 32 0 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %25 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 +%_arr_v3uint_uint_3 = OpTypeArray %v3uint %uint_3 +%_arr_v3uint_uint_3_0 = OpTypeArray %v3uint %uint_3 + %_struct_16 = OpTypeStruct %_arr_v3uint_uint_3_0 + %_struct_18 = OpTypeStruct %_arr_v3uint_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %23 %24 %25 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint +%_ptr_StorageBuffer_v3uint_0 = OpTypePointer StorageBuffer %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_22 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_22 = OpTypePointer StorageBuffer %_struct_22 + %void = OpTypeVoid + %45 = OpTypeFunction %void + %46 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %2 = OpFunction %void None %45 + %51 = OpLabel + %52 = OpAccessChain %_ptr_StorageBuffer_v3uint_0 %4 %uint_0 %uint_0 + %53 = OpPtrAccessChain %_ptr_StorageBuffer_uint %52 %uint_0 %uint_0 + OpStore %53 %uint_0 Aligned 4 + %54 = OpPtrAccessChain %_ptr_StorageBuffer_uint %52 %uint_0 %uint_1 + OpStore %54 %uint_1 Aligned 4 + %55 = OpPtrAccessChain %_ptr_StorageBuffer_uint %52 %uint_0 %uint_2 + OpStore %55 %uint_2 Aligned 4 + %56 = OpPtrAccessChain %_ptr_StorageBuffer_uint %52 %uint_1 %uint_0 + OpStore %56 %uint_3 Aligned 4 + %57 = OpPtrAccessChain %_ptr_StorageBuffer_uint %52 %uint_1 %uint_1 + OpStore %57 %uint_4 Aligned 4 + %58 = OpPtrAccessChain %_ptr_StorageBuffer_uint %52 %uint_1 %uint_2 + OpStore %58 %uint_5 Aligned 4 + %59 = OpAccessChain %_ptr_StorageBuffer_v3uint %5 %uint_0 %uint_0 + %60 = OpPtrAccessChain %_ptr_StorageBuffer_uint %59 %uint_0 %uint_0 + OpStore %60 %uint_6 Aligned 4 + %61 = OpPtrAccessChain %_ptr_StorageBuffer_uint %59 %uint_0 %uint_1 + OpStore %61 %uint_7 Aligned 4 + %62 = OpPtrAccessChain %_ptr_StorageBuffer_uint %59 %uint_0 %uint_2 + OpStore %62 %uint_8 Aligned 4 + %63 = OpPtrAccessChain %_ptr_StorageBuffer_uint %59 %uint_1 %uint_0 + OpStore %63 %uint_9 Aligned 4 + %64 = OpPtrAccessChain %_ptr_StorageBuffer_uint %59 %uint_1 %uint_1 + OpStore %64 %uint_10 Aligned 4 + %65 = OpPtrAccessChain %_ptr_StorageBuffer_uint %59 %uint_1 %uint_2 + OpStore %65 %uint_11 Aligned 4 + OpBranch %66 + %66 = OpLabel + %67 = OpPhi %uint %uint_0 %51 %68 %69 + %70 = OpULessThan %bool %67 %uint_8 + OpLoopMerge %71 %69 None + OpBranchConditional %70 %72 %69 + %72 = OpLabel + %73 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %67 + %74 = OpLoad %uint %73 Aligned 4 + %75 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %67 + OpStore %75 %74 Aligned 4 + %76 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %67 + %77 = OpLoad %uint %76 Aligned 4 + %78 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %67 + OpStore %78 %77 Aligned 4 + OpBranch %79 + %79 = OpLabel + %80 = OpIAdd %uint %67 %uint_1 + OpBranch %69 + %69 = OpLabel + %68 = OpPhi %uint %80 %79 %46 %66 + %81 = OpPhi %bool %false %79 %true %66 + OpBranchConditional %81 %71 %66 + %71 = OpLabel + OpReturn + OpFunctionEnd + %82 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %83 = OpExtInst %void %1 ArgumentInfo %10 + %84 = OpExtInst %void %1 ArgumentStorageBuffer %82 %uint_0 %uint_0 %uint_0 %83 + %85 = OpExtInst %void %1 ArgumentInfo %11 + %86 = OpExtInst %void %1 ArgumentStorageBuffer %82 %uint_1 %uint_0 %uint_1 %85 + %87 = OpExtInst %void %1 ArgumentInfo %12 + %88 = OpExtInst %void %1 ArgumentStorageBuffer %82 %uint_2 %uint_0 %uint_2 %87 + %89 = OpExtInst %void %1 ArgumentInfo %13 + %90 = OpExtInst %void %1 ArgumentStorageBuffer %82 %uint_3 %uint_0 %uint_3 %89 + %91 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-vector.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-vector.spvasm new file mode 100644 index 0000000000..d391857585 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/pointer-stride-array-overwrite-vector.spvasm @@ -0,0 +1,152 @@ +; @Input: %4={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} +; @Input: %5={{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} + +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0}} + +; @Output: forall (%4[0][0][0] == 0 and %4[0][0][1] == 1 and %4[0][0][2] == 2) +; @Output: forall (%4[0][1][0] == 3 and %4[0][1][1] == 4 and %4[0][1][2] == 5) + +; @Output: forall (%5[0][0][0] == 6 and %5[0][0][1] == 7 and %5[0][0][2] == 8) +; @Output: forall (%5[0][1][0] == 9 and %5[0][1][1] == 10 and %5[0][1][2] == 11) + +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2) +; @Output: forall (%6[0][4] == 3 and %6[0][5] == 4 and %6[0][6] == 5) + +; @Output: forall (%7[0][0] == 6 and %7[0][1] == 7 and %7[0][2] == 8) +; @Output: forall (%7[0][3] == 9 and %7[0][4] == 10 and %7[0][5] == 11) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 86 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "aligned" + %11 = OpString "unaligned" + %12 = OpString "r_aligned" + %13 = OpString "r_unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr_v3uint_uint_3_0 ArrayStride 16 + OpMemberDecorate %_struct_16 0 Offset 0 + OpDecorate %_struct_16 Block + OpDecorate %_arr_v3uint_uint_3 ArrayStride 12 + OpMemberDecorate %_struct_18 0 Offset 0 + OpDecorate %_struct_18 Block + OpDecorate %_runtimearr_uint ArrayStride 4 + OpDecorate %_ptr_StorageBuffer_v3uint_0 ArrayStride 16 + OpDecorate %_ptr_StorageBuffer_v3uint ArrayStride 12 + OpMemberDecorate %_struct_22 0 Offset 0 + OpDecorate %_struct_22 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %23 SpecId 0 + OpDecorate %24 SpecId 1 + OpDecorate %25 SpecId 2 + %uint = OpTypeInt 32 0 + %23 = OpSpecConstant %uint 1 + %24 = OpSpecConstant %uint 1 + %25 = OpSpecConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %uint_8 = OpConstant %uint 8 + %uint_9 = OpConstant %uint 9 + %uint_10 = OpConstant %uint 10 + %uint_11 = OpConstant %uint 11 + %v3uint = OpTypeVector %uint 3 + %40 = OpConstantComposite %v3uint %uint_0 %uint_1 %uint_2 + %41 = OpConstantComposite %v3uint %uint_3 %uint_4 %uint_5 + %42 = OpConstantComposite %v3uint %uint_6 %uint_7 %uint_8 + %43 = OpConstantComposite %v3uint %uint_9 %uint_10 %uint_11 +%_arr_v3uint_uint_3 = OpTypeArray %v3uint %uint_3 +%_arr_v3uint_uint_3_0 = OpTypeArray %v3uint %uint_3 + %_struct_16 = OpTypeStruct %_arr_v3uint_uint_3_0 + %_struct_18 = OpTypeStruct %_arr_v3uint_uint_3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %23 %24 %25 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_ptr_StorageBuffer_v3uint = OpTypePointer StorageBuffer %v3uint +%_ptr_StorageBuffer_v3uint_0 = OpTypePointer StorageBuffer %v3uint +%_ptr_StorageBuffer__struct_16 = OpTypePointer StorageBuffer %_struct_16 +%_ptr_StorageBuffer__struct_18 = OpTypePointer StorageBuffer %_struct_18 +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_22 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_22 = OpTypePointer StorageBuffer %_struct_22 + %void = OpTypeVoid + %49 = OpTypeFunction %void + %50 = OpUndef %uint +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %bool = OpTypeBool + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_16 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_18 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_22 StorageBuffer + %2 = OpFunction %void None %49 + %55 = OpLabel + %56 = OpAccessChain %_ptr_StorageBuffer_v3uint_0 %4 %uint_0 %uint_0 + OpStore %56 %40 Aligned 4 + %57 = OpPtrAccessChain %_ptr_StorageBuffer_v3uint_0 %56 %uint_1 + OpStore %57 %41 Aligned 4 + %58 = OpAccessChain %_ptr_StorageBuffer_v3uint %5 %uint_0 %uint_0 + OpStore %58 %42 Aligned 4 + %59 = OpPtrAccessChain %_ptr_StorageBuffer_v3uint %58 %uint_1 + OpStore %59 %43 Aligned 4 + OpBranch %60 + %60 = OpLabel + %61 = OpPhi %uint %uint_0 %55 %62 %63 + %64 = OpULessThan %bool %61 %uint_8 + OpLoopMerge %65 %63 None + OpBranchConditional %64 %66 %63 + %66 = OpLabel + %67 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %uint_0 %61 + %68 = OpLoad %uint %67 Aligned 4 + %69 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %61 + OpStore %69 %68 Aligned 4 + %70 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %uint_0 %61 + %71 = OpLoad %uint %70 Aligned 4 + %72 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %61 + OpStore %72 %71 Aligned 4 + OpBranch %73 + %73 = OpLabel + %74 = OpIAdd %uint %61 %uint_1 + OpBranch %63 + %63 = OpLabel + %62 = OpPhi %uint %74 %73 %50 %60 + %75 = OpPhi %bool %false %73 %true %60 + OpBranchConditional %75 %65 %60 + %65 = OpLabel + OpReturn + OpFunctionEnd + %76 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %77 = OpExtInst %void %1 ArgumentInfo %10 + %78 = OpExtInst %void %1 ArgumentStorageBuffer %76 %uint_0 %uint_0 %uint_0 %77 + %79 = OpExtInst %void %1 ArgumentInfo %11 + %80 = OpExtInst %void %1 ArgumentStorageBuffer %76 %uint_1 %uint_0 %uint_1 %79 + %81 = OpExtInst %void %1 ArgumentInfo %12 + %82 = OpExtInst %void %1 ArgumentStorageBuffer %76 %uint_2 %uint_0 %uint_2 %81 + %83 = OpExtInst %void %1 ArgumentInfo %13 + %84 = OpExtInst %void %1 ArgumentStorageBuffer %76 %uint_3 %uint_0 %uint_3 %83 + %85 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-no-stride.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-no-stride.spvasm new file mode 100644 index 0000000000..25365b0b14 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-no-stride.spvasm @@ -0,0 +1,141 @@ +; @Input: %4={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %5={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} + +; scratchpad +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2 and %6[0][3] == 3) +; @Output: forall (%7[0][0] == 4 and %7[0][1] == 5 and %7[0][2] == 6 and %7[0][3] == 7) + +; result +; @Output: forall (%4[0][0] == 0 and %4[0][4] == 1 and %4[0][8] == 2 and %4[0][12] == 3) +; @Output: forall (%5[0][0] == 4 and %5[0][1] == 5 and %5[0][2] == 6 and %5[0][3] == 7) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 81 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "r_aligned" + %11 = OpString "r_unaligned" + %12 = OpString "aligned" + %13 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint_0 ArrayStride 16 + OpDecorate %_runtimearr_uint ArrayStride 4 + OpDecorate %_ptr_StorageBuffer_uint_0 ArrayStride 16 + OpDecorate %_ptr_StorageBuffer_uint ArrayStride 4 + OpMemberDecorate %_struct_19 0 Offset 0 + OpDecorate %_struct_19 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %20 SpecId 0 + OpDecorate %21 SpecId 1 + OpDecorate %22 SpecId 2 + %uint = OpTypeInt 32 0 + %20 = OpSpecConstant %uint 1 + %21 = OpSpecConstant %uint 1 + %22 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %20 %21 %22 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint +%_runtimearr_uint_0 = OpTypeRuntimeArray %uint + %_struct_26 = OpTypeStruct %_runtimearr_uint_0 + %_struct_19 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_26 = OpTypePointer StorageBuffer %_struct_26 +%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19 + %void = OpTypeVoid + %30 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %bool = OpTypeBool + %uint_16 = OpConstant %uint 16 + %41 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_26 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %2 = OpFunction %void None %30 + %44 = OpLabel + %45 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_0 + OpStore %45 %uint_0 Aligned 4 + %46 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_1 + OpStore %46 %uint_1 Aligned 4 + %47 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_2 + OpStore %47 %uint_2 Aligned 4 + %48 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_3 + OpStore %48 %uint_3 Aligned 4 + %49 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_0 + OpStore %49 %uint_4 Aligned 4 + %50 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_1 + OpStore %50 %uint_5 Aligned 4 + %51 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_2 + OpStore %51 %uint_6 Aligned 4 + %52 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_3 + OpStore %52 %uint_7 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %uint_0 + %54 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_0 + OpBranch %55 + %55 = OpLabel + %56 = OpPhi %uint %uint_0 %44 %57 %58 + %59 = OpULessThan %bool %56 %uint_16 + OpLoopMerge %60 %58 None + OpBranchConditional %59 %61 %58 + %61 = OpLabel + %62 = OpPtrAccessChain %_ptr_StorageBuffer_uint %53 %56 + %63 = OpLoad %uint %62 Aligned 4 + %64 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %56 + OpStore %64 %63 Aligned 4 + %65 = OpPtrAccessChain %_ptr_StorageBuffer_uint %54 %56 + %66 = OpLoad %uint %65 Aligned 4 + %67 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %56 + OpStore %67 %66 Aligned 4 + OpBranch %68 + %68 = OpLabel + %69 = OpIAdd %uint %56 %uint_1 + OpBranch %58 + %58 = OpLabel + %57 = OpPhi %uint %69 %68 %41 %55 + %70 = OpPhi %bool %false %68 %true %55 + OpBranchConditional %70 %60 %55 + %60 = OpLabel + OpReturn + OpFunctionEnd + %71 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %72 = OpExtInst %void %1 ArgumentInfo %10 + %73 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_0 %uint_0 %uint_0 %72 + %74 = OpExtInst %void %1 ArgumentInfo %11 + %75 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_1 %uint_0 %uint_1 %74 + %76 = OpExtInst %void %1 ArgumentInfo %12 + %77 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_2 %uint_0 %uint_2 %76 + %78 = OpExtInst %void %1 ArgumentInfo %13 + %79 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_3 %uint_0 %uint_3 %78 + %80 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-stride.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-stride.spvasm new file mode 100644 index 0000000000..03f581a7c2 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-scalar-overwrite-result-stride.spvasm @@ -0,0 +1,141 @@ +; @Input: %4={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %5={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %6={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} + +; scratchpad +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2 and %6[0][3] == 3) +; @Output: forall (%7[0][0] == 4 and %7[0][1] == 5 and %7[0][2] == 6 and %7[0][3] == 7) + +; result +; @Output: forall (%4[0][0] == 0 and %4[0][1] == 1 and %4[0][2] == 2 and %4[0][3] == 3) +; @Output: forall (%5[0][0] == 4 and %5[0][1] == 5 and %5[0][2] == 6 and %5[0][3] == 7) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 81 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "r_aligned" + %11 = OpString "r_unaligned" + %12 = OpString "aligned" + %13 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_runtimearr_uint_0 ArrayStride 16 + OpDecorate %_runtimearr_uint ArrayStride 4 + OpDecorate %_ptr_StorageBuffer_uint_0 ArrayStride 16 + OpDecorate %_ptr_StorageBuffer_uint ArrayStride 4 + OpMemberDecorate %_struct_19 0 Offset 0 + OpDecorate %_struct_19 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %20 SpecId 0 + OpDecorate %21 SpecId 1 + OpDecorate %22 SpecId 2 + %uint = OpTypeInt 32 0 + %20 = OpSpecConstant %uint 1 + %21 = OpSpecConstant %uint 1 + %22 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %20 %21 %22 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint +%_runtimearr_uint_0 = OpTypeRuntimeArray %uint + %_struct_26 = OpTypeStruct %_runtimearr_uint_0 + %_struct_19 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_26 = OpTypePointer StorageBuffer %_struct_26 +%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19 + %void = OpTypeVoid + %30 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 + %bool = OpTypeBool + %uint_16 = OpConstant %uint 16 + %41 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_26 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %2 = OpFunction %void None %30 + %44 = OpLabel + %45 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_0 + OpStore %45 %uint_0 Aligned 4 + %46 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_1 + OpStore %46 %uint_1 Aligned 4 + %47 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_2 + OpStore %47 %uint_2 Aligned 4 + %48 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_3 + OpStore %48 %uint_3 Aligned 4 + %49 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_0 + OpStore %49 %uint_4 Aligned 4 + %50 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_1 + OpStore %50 %uint_5 Aligned 4 + %51 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_2 + OpStore %51 %uint_6 Aligned 4 + %52 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_3 + OpStore %52 %uint_7 Aligned 4 + %53 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_0 + %54 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_0 + OpBranch %55 + %55 = OpLabel + %56 = OpPhi %uint %uint_0 %44 %57 %58 + %59 = OpULessThan %bool %56 %uint_16 + OpLoopMerge %60 %58 None + OpBranchConditional %59 %61 %58 + %61 = OpLabel + %62 = OpPtrAccessChain %_ptr_StorageBuffer_uint %53 %56 + %63 = OpLoad %uint %62 Aligned 4 + %64 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %56 + OpStore %64 %63 Aligned 4 + %65 = OpPtrAccessChain %_ptr_StorageBuffer_uint %54 %56 + %66 = OpLoad %uint %65 Aligned 4 + %67 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %56 + OpStore %67 %66 Aligned 4 + OpBranch %68 + %68 = OpLabel + %69 = OpIAdd %uint %56 %uint_1 + OpBranch %58 + %58 = OpLabel + %57 = OpPhi %uint %69 %68 %41 %55 + %70 = OpPhi %bool %false %68 %true %55 + OpBranchConditional %70 %60 %55 + %60 = OpLabel + OpReturn + OpFunctionEnd + %71 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %72 = OpExtInst %void %1 ArgumentInfo %10 + %73 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_0 %uint_0 %uint_0 %72 + %74 = OpExtInst %void %1 ArgumentInfo %11 + %75 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_1 %uint_0 %uint_1 %74 + %76 = OpExtInst %void %1 ArgumentInfo %12 + %77 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_2 %uint_0 %uint_2 %76 + %78 = OpExtInst %void %1 ArgumentInfo %13 + %79 = OpExtInst %void %1 ArgumentStorageBuffer %71 %uint_3 %uint_0 %uint_3 %78 + %80 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-no-stride.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-no-stride.spvasm new file mode 100644 index 0000000000..f51b5d6941 --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-no-stride.spvasm @@ -0,0 +1,136 @@ +; @Input: %4={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %5={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %6={{0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0}} + +; scratchpad +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2 and %6[0][3] == 3) +; @Output: forall (%7[0][0] == 4 and %7[0][1] == 5 and %7[0][2] == 6 and %7[0][3] == 7) + +; result +; @Output: forall (%4[0][0] == 0 and %4[0][4] == 1 and %4[0][8] == 2 and %4[0][12] == 3) +; @Output: forall (%5[0][0] == 4 and %5[0][1] == 5 and %5[0][2] == 6 and %5[0][3] == 7) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 82 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "r_aligned" + %11 = OpString "r_unaligned" + %12 = OpString "aligned" + %13 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr_uint_uint_4_0 ArrayStride 16 + OpDecorate %_arr_uint_uint_4 ArrayStride 4 + OpDecorate %_ptr_StorageBuffer_uint_0 ArrayStride 16 + OpDecorate %_ptr_StorageBuffer_uint ArrayStride 4 + OpMemberDecorate %_struct_19 0 Offset 0 + OpDecorate %_struct_19 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %20 SpecId 0 + OpDecorate %21 SpecId 1 + OpDecorate %22 SpecId 2 + %uint = OpTypeInt 32 0 + %20 = OpSpecConstant %uint 1 + %21 = OpSpecConstant %uint 1 + %22 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 +%_arr_uint_uint_4 = OpTypeArray %uint %uint_4 +%_arr_uint_uint_4_0 = OpTypeArray %uint %uint_4 + %33 = OpConstantComposite %_arr_uint_uint_4_0 %uint_0 %uint_1 %uint_2 %uint_3 + %34 = OpConstantComposite %_arr_uint_uint_4 %uint_4 %uint_5 %uint_6 %uint_7 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %20 %21 %22 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_37 = OpTypeStruct %_arr_uint_uint_4 + %_struct_38 = OpTypeStruct %_arr_uint_uint_4_0 + %_struct_19 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_37 = OpTypePointer StorageBuffer %_struct_37 +%_ptr_StorageBuffer__struct_38 = OpTypePointer StorageBuffer %_struct_38 +%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19 + %void = OpTypeVoid + %43 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint +%_ptr_StorageBuffer__arr_uint_uint_4 = OpTypePointer StorageBuffer %_arr_uint_uint_4 +%_ptr_StorageBuffer__arr_uint_uint_4_0 = OpTypePointer StorageBuffer %_arr_uint_uint_4_0 + %bool = OpTypeBool + %uint_16 = OpConstant %uint 16 + %48 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_38 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_37 StorageBuffer + %2 = OpFunction %void None %43 + %51 = OpLabel + %52 = OpAccessChain %_ptr_StorageBuffer__arr_uint_uint_4_0 %6 %uint_0 + OpStore %52 %33 Aligned 64 + %53 = OpAccessChain %_ptr_StorageBuffer__arr_uint_uint_4 %7 %uint_0 + OpStore %53 %34 Aligned 16 + %54 = OpAccessChain %_ptr_StorageBuffer_uint %6 %uint_0 %uint_0 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_0 + OpBranch %56 + %56 = OpLabel + %57 = OpPhi %uint %uint_0 %51 %58 %59 + %60 = OpULessThan %bool %57 %uint_16 + OpLoopMerge %61 %59 None + OpBranchConditional %60 %62 %59 + %62 = OpLabel + %63 = OpPtrAccessChain %_ptr_StorageBuffer_uint %54 %57 + %64 = OpLoad %uint %63 Aligned 4 + %65 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %57 + OpStore %65 %64 Aligned 4 + %66 = OpPtrAccessChain %_ptr_StorageBuffer_uint %55 %57 + %67 = OpLoad %uint %66 Aligned 4 + %68 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %57 + OpStore %68 %67 Aligned 4 + OpBranch %69 + %69 = OpLabel + %70 = OpIAdd %uint %57 %uint_1 + OpBranch %59 + %59 = OpLabel + %58 = OpPhi %uint %70 %69 %48 %56 + %71 = OpPhi %bool %false %69 %true %56 + OpBranchConditional %71 %61 %56 + %61 = OpLabel + OpReturn + OpFunctionEnd + %72 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %73 = OpExtInst %void %1 ArgumentInfo %10 + %74 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_0 %uint_0 %uint_0 %73 + %75 = OpExtInst %void %1 ArgumentInfo %11 + %76 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_1 %uint_0 %uint_1 %75 + %77 = OpExtInst %void %1 ArgumentInfo %12 + %78 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_2 %uint_0 %uint_2 %77 + %79 = OpExtInst %void %1 ArgumentInfo %13 + %80 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_3 %uint_0 %uint_3 %79 + %81 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-stride.spvasm b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-stride.spvasm new file mode 100644 index 0000000000..4aa2ea689b --- /dev/null +++ b/dartagnan/src/test/resources/spirv/vulkan/alignment/stride-vector-overwrite-result-stride.spvasm @@ -0,0 +1,136 @@ +; @Input: %4={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %5={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} +; @Input: %6={{0, 0, 0, 0}} +; @Input: %7={{0, 0, 0, 0}} + +; scratchpad +; @Output: forall (%6[0][0] == 0 and %6[0][1] == 1 and %6[0][2] == 2 and %6[0][3] == 3) +; @Output: forall (%7[0][0] == 4 and %7[0][1] == 5 and %7[0][2] == 6 and %7[0][3] == 7) + +; result +; @Output: forall (%4[0][0] == 0 and %4[0][1] == 1 and %4[0][2] == 2 and %4[0][3] == 3) +; @Output: forall (%5[0][0] == 4 and %5[0][1] == 5 and %5[0][2] == 6 and %5[0][3] == 7) + +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 82 +; Schema: 0 + OpCapability Shader + OpCapability VariablePointers + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_vulkan_memory_model" + %1 = OpExtInstImport "NonSemantic.ClspvReflection.5" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %2 "test" %3 %4 %5 %6 %7 + OpSource OpenCL_C 200 + %8 = OpString "test" + %9 = OpString "__kernel" + %10 = OpString "r_aligned" + %11 = OpString "r_unaligned" + %12 = OpString "aligned" + %13 = OpString "unaligned" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %_arr_uint_uint_4_0 ArrayStride 16 + OpDecorate %_arr_uint_uint_4 ArrayStride 4 + OpDecorate %_ptr_StorageBuffer_uint_0 ArrayStride 16 + OpDecorate %_ptr_StorageBuffer_uint ArrayStride 4 + OpMemberDecorate %_struct_19 0 Offset 0 + OpDecorate %_struct_19 Block + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpDecorate %20 SpecId 0 + OpDecorate %21 SpecId 1 + OpDecorate %22 SpecId 2 + %uint = OpTypeInt 32 0 + %20 = OpSpecConstant %uint 1 + %21 = OpSpecConstant %uint 1 + %22 = OpSpecConstant %uint 1 + %v3uint = OpTypeVector %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %uint_6 = OpConstant %uint 6 + %uint_7 = OpConstant %uint 7 +%_arr_uint_uint_4 = OpTypeArray %uint %uint_4 +%_arr_uint_uint_4_0 = OpTypeArray %uint %uint_4 + %33 = OpConstantComposite %_arr_uint_uint_4_0 %uint_0 %uint_1 %uint_2 %uint_3 + %34 = OpConstantComposite %_arr_uint_uint_4 %uint_4 %uint_5 %uint_6 %uint_7 +%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %20 %21 %22 +%_ptr_Private_v3uint = OpTypePointer Private %v3uint +%_runtimearr_uint = OpTypeRuntimeArray %uint + %_struct_37 = OpTypeStruct %_arr_uint_uint_4 + %_struct_38 = OpTypeStruct %_arr_uint_uint_4_0 + %_struct_19 = OpTypeStruct %_runtimearr_uint +%_ptr_StorageBuffer__struct_37 = OpTypePointer StorageBuffer %_struct_37 +%_ptr_StorageBuffer__struct_38 = OpTypePointer StorageBuffer %_struct_38 +%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19 + %void = OpTypeVoid + %43 = OpTypeFunction %void +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +%_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint +%_ptr_StorageBuffer__arr_uint_uint_4 = OpTypePointer StorageBuffer %_arr_uint_uint_4 +%_ptr_StorageBuffer__arr_uint_uint_4_0 = OpTypePointer StorageBuffer %_arr_uint_uint_4_0 + %bool = OpTypeBool + %uint_16 = OpConstant %uint 16 + %48 = OpUndef %uint + %false = OpConstantFalse %bool + %true = OpConstantTrue %bool + %3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize + %4 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %5 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer + %6 = OpVariable %_ptr_StorageBuffer__struct_38 StorageBuffer + %7 = OpVariable %_ptr_StorageBuffer__struct_37 StorageBuffer + %2 = OpFunction %void None %43 + %51 = OpLabel + %52 = OpAccessChain %_ptr_StorageBuffer__arr_uint_uint_4_0 %6 %uint_0 + OpStore %52 %33 Aligned 64 + %53 = OpAccessChain %_ptr_StorageBuffer__arr_uint_uint_4 %7 %uint_0 + OpStore %53 %34 Aligned 16 + %54 = OpAccessChain %_ptr_StorageBuffer_uint_0 %6 %uint_0 %uint_0 + %55 = OpAccessChain %_ptr_StorageBuffer_uint %7 %uint_0 %uint_0 + OpBranch %56 + %56 = OpLabel + %57 = OpPhi %uint %uint_0 %51 %58 %59 + %60 = OpULessThan %bool %57 %uint_16 + OpLoopMerge %61 %59 None + OpBranchConditional %60 %62 %59 + %62 = OpLabel + %63 = OpPtrAccessChain %_ptr_StorageBuffer_uint %54 %57 + %64 = OpLoad %uint %63 Aligned 4 + %65 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %57 + OpStore %65 %64 Aligned 4 + %66 = OpPtrAccessChain %_ptr_StorageBuffer_uint %55 %57 + %67 = OpLoad %uint %66 Aligned 4 + %68 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %57 + OpStore %68 %67 Aligned 4 + OpBranch %69 + %69 = OpLabel + %70 = OpIAdd %uint %57 %uint_1 + OpBranch %59 + %59 = OpLabel + %58 = OpPhi %uint %70 %69 %48 %56 + %71 = OpPhi %bool %false %69 %true %56 + OpBranchConditional %71 %61 %56 + %61 = OpLabel + OpReturn + OpFunctionEnd + %72 = OpExtInst %void %1 Kernel %2 %8 %uint_4 %uint_0 %9 + %73 = OpExtInst %void %1 ArgumentInfo %10 + %74 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_0 %uint_0 %uint_0 %73 + %75 = OpExtInst %void %1 ArgumentInfo %11 + %76 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_1 %uint_0 %uint_1 %75 + %77 = OpExtInst %void %1 ArgumentInfo %12 + %78 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_2 %uint_0 %uint_2 %77 + %79 = OpExtInst %void %1 ArgumentInfo %13 + %80 = OpExtInst %void %1 ArgumentStorageBuffer %72 %uint_3 %uint_0 %uint_3 %79 + %81 = OpExtInst %void %1 SpecConstantWorkgroupSize %uint_0 %uint_1 %uint_2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/basic/composite-extract.spvasm b/dartagnan/src/test/resources/spirv/vulkan/basic/composite-extract.spvasm index 7c686ce13d..de521a05d2 100644 --- a/dartagnan/src/test/resources/spirv/vulkan/basic/composite-extract.spvasm +++ b/dartagnan/src/test/resources/spirv/vulkan/basic/composite-extract.spvasm @@ -29,14 +29,14 @@ %uint_11 = OpConstant %uint 11 %vector = OpTypeVector %uint 3 - %vector2 = OpTypeVector %vector 2 + %array1 = OpTypeArray %vector %uint_2 %array = OpTypeArray %uint %uint_3 %array2 = OpTypeArray %array %uint_2 %output_type = OpTypeRuntimeArray %uint %v_vector1 = OpConstantComposite %vector %uint_0 %uint_1 %uint_2 %v_vector2 = OpConstantComposite %vector %uint_3 %uint_4 %uint_5 - %v_vector = OpConstantComposite %vector2 %v_vector1 %v_vector2 + %v_vector = OpConstantComposite %array1 %v_vector1 %v_vector2 %v_array1 = OpConstantComposite %array %uint_6 %uint_7 %uint_8 %v_array2 = OpConstantComposite %array %uint_9 %uint_10 %uint_11 %v_array = OpConstantComposite %array2 %v_array1 %v_array2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/basic/composite-initial.spvasm b/dartagnan/src/test/resources/spirv/vulkan/basic/composite-initial.spvasm index 8862c81d3d..23d2d33342 100644 --- a/dartagnan/src/test/resources/spirv/vulkan/basic/composite-initial.spvasm +++ b/dartagnan/src/test/resources/spirv/vulkan/basic/composite-initial.spvasm @@ -29,14 +29,14 @@ %uint_11 = OpConstant %uint 11 %vector = OpTypeVector %uint 3 - %vector2 = OpTypeVector %vector 2 + %array1 = OpTypeArray %vector %uint_2 %array = OpTypeArray %uint %uint_3 %array2 = OpTypeArray %array %uint_2 %output_type = OpTypeRuntimeArray %uint %v_vector1 = OpConstantComposite %vector %uint_0 %uint_0 %uint_0 %v_vector2 = OpConstantComposite %vector %uint_0 %uint_0 %uint_0 - %v_vector = OpConstantComposite %vector2 %v_vector1 %v_vector2 + %v_vector = OpConstantComposite %array1 %v_vector1 %v_vector2 %v_array1 = OpConstantComposite %array %uint_0 %uint_0 %uint_0 %v_array2 = OpConstantComposite %array %uint_0 %uint_0 %uint_0 %v_array = OpConstantComposite %array2 %v_array1 %v_array2 @@ -48,12 +48,12 @@ %main = OpFunction %void None %func %label = OpLabel - %0 = OpCompositeInsert %vector2 %uint_0 %v_vector 0 0 - %1 = OpCompositeInsert %vector2 %uint_1 %v_vector 0 1 - %2 = OpCompositeInsert %vector2 %uint_2 %v_vector 0 2 - %3 = OpCompositeInsert %vector2 %uint_3 %v_vector 1 0 - %4 = OpCompositeInsert %vector2 %uint_4 %v_vector 1 1 - %5 = OpCompositeInsert %vector2 %uint_5 %v_vector 1 2 + %0 = OpCompositeInsert %array1 %uint_0 %v_vector 0 0 + %1 = OpCompositeInsert %array1 %uint_1 %v_vector 0 1 + %2 = OpCompositeInsert %array1 %uint_2 %v_vector 0 2 + %3 = OpCompositeInsert %array1 %uint_3 %v_vector 1 0 + %4 = OpCompositeInsert %array1 %uint_4 %v_vector 1 1 + %5 = OpCompositeInsert %array1 %uint_5 %v_vector 1 2 %6 = OpCompositeInsert %array2 %uint_6 %v_array 0 0 %7 = OpCompositeInsert %array2 %uint_7 %v_array 0 1 %8 = OpCompositeInsert %array2 %uint_8 %v_array 0 2 diff --git a/dartagnan/src/test/resources/spirv/vulkan/basic/composite-insert.spvasm b/dartagnan/src/test/resources/spirv/vulkan/basic/composite-insert.spvasm index 11bb6b2f23..fa93743f42 100644 --- a/dartagnan/src/test/resources/spirv/vulkan/basic/composite-insert.spvasm +++ b/dartagnan/src/test/resources/spirv/vulkan/basic/composite-insert.spvasm @@ -29,14 +29,14 @@ %uint_11 = OpConstant %uint 11 %vector = OpTypeVector %uint 3 - %vector2 = OpTypeVector %vector 2 + %array1 = OpTypeArray %vector %uint_2 %array = OpTypeArray %uint %uint_3 %array2 = OpTypeArray %array %uint_2 %output_type = OpTypeRuntimeArray %uint %v_vector1 = OpConstantComposite %vector %uint_0 %uint_0 %uint_0 %v_vector2 = OpConstantComposite %vector %uint_0 %uint_0 %uint_0 - %v_vector = OpConstantComposite %vector2 %v_vector1 %v_vector2 + %v_vector = OpConstantComposite %array1 %v_vector1 %v_vector2 %v_array1 = OpConstantComposite %array %uint_0 %uint_0 %uint_0 %v_array2 = OpConstantComposite %array %uint_0 %uint_0 %uint_0 %v_array = OpConstantComposite %array2 %v_array1 %v_array2 @@ -48,12 +48,12 @@ %main = OpFunction %void None %func %label = OpLabel - %0 = OpCompositeInsert %vector2 %uint_0 %v_vector 0 0 - %1 = OpCompositeInsert %vector2 %uint_1 %v_vector 0 1 - %2 = OpCompositeInsert %vector2 %uint_2 %v_vector 0 2 - %3 = OpCompositeInsert %vector2 %uint_3 %v_vector 1 0 - %4 = OpCompositeInsert %vector2 %uint_4 %v_vector 1 1 - %5 = OpCompositeInsert %vector2 %uint_5 %v_vector 1 2 + %0 = OpCompositeInsert %array1 %uint_0 %v_vector 0 0 + %1 = OpCompositeInsert %array1 %uint_1 %v_vector 0 1 + %2 = OpCompositeInsert %array1 %uint_2 %v_vector 0 2 + %3 = OpCompositeInsert %array1 %uint_3 %v_vector 1 0 + %4 = OpCompositeInsert %array1 %uint_4 %v_vector 1 1 + %5 = OpCompositeInsert %array1 %uint_5 %v_vector 1 2 %6 = OpCompositeInsert %array2 %uint_6 %v_array 0 0 %7 = OpCompositeInsert %array2 %uint_7 %v_array 0 1 %8 = OpCompositeInsert %array2 %uint_8 %v_array 0 2