[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-09 Thread Michael Kruse via cfe-commits


@@ -6033,6 +6034,52 @@ std::pair 
OpenMPIRBuilder::emitAtomicUpdate(
   Res.second = Res.first;
 else
   Res.second = emitRMWOpAsInstruction(Res.first, Expr, RMWOp);
+  } else if (RMWOp == llvm::AtomicRMWInst::BinOp::BAD_BINOP) {

Meinersbur wrote:

`BAD_BINOP`? Doesn't this implement `BinOp::Xchg`?

https://github.com/llvm/llvm-project/pull/92364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-09 Thread Michael Kruse via cfe-commits


@@ -6033,6 +6034,52 @@ std::pair 
OpenMPIRBuilder::emitAtomicUpdate(
   Res.second = Res.first;
 else
   Res.second = emitRMWOpAsInstruction(Res.first, Expr, RMWOp);
+  } else if (RMWOp == llvm::AtomicRMWInst::BinOp::BAD_BINOP) {
+LoadInst *OldVal =
+Builder.CreateLoad(XElemTy, X, X->getName() + ".atomic.load");
+OldVal->setAtomic(AO);
+const DataLayout  = OldVal->getModule()->getDataLayout();
+unsigned LoadSize =
+LoadDL.getTypeStoreSize(OldVal->getPointerOperand()->getType());
+OpenMPIRBuilder::AtomicInfo atomicInfo(, XElemTy, LoadSize * 8,
+   LoadSize * 8, OldVal->getAlign(),
+   OldVal->getAlign(), true, X);
+auto AtomicLoadRes = atomicInfo.EmitAtomicLoadLibcall(AO);
+BasicBlock *CurBB = Builder.GetInsertBlock();
+Instruction *CurBBTI = CurBB->getTerminator();
+CurBBTI = CurBBTI ? CurBBTI : Builder.CreateUnreachable();
+BasicBlock *ExitBB =
+CurBB->splitBasicBlock(CurBBTI, X->getName() + ".atomic.exit");
+BasicBlock *ContBB = CurBB->splitBasicBlock(CurBB->getTerminator(),
+X->getName() + ".atomic.cont");
+ContBB->getTerminator()->eraseFromParent();
+Builder.restoreIP(AllocaIP);
+AllocaInst *NewAtomicAddr = Builder.CreateAlloca(XElemTy);
+NewAtomicAddr->setName(X->getName() + "x.new.val");
+Builder.SetInsertPoint(ContBB);
+llvm::PHINode *PHI = Builder.CreatePHI(OldVal->getType(), 2);
+PHI->addIncoming(AtomicLoadRes.first, CurBB);
+Value *OldExprVal = PHI;
+Value *Upd = UpdateOp(OldExprVal, Builder);
+Builder.CreateStore(Upd, NewAtomicAddr);
+AtomicOrdering Failure =
+llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(AO);
+auto Result = atomicInfo.EmitAtomicCompareExchangeLibcall(
+AtomicLoadRes.second, NewAtomicAddr, AO, Failure);
+LoadInst *PHILoad = Builder.CreateLoad(XElemTy, Result.first);
+PHI->addIncoming(PHILoad, Builder.GetInsertBlock());
+Builder.CreateCondBr(Result.second, ExitBB, ContBB);
+OldVal->eraseFromParent();
+Res.first = OldExprVal;
+Res.second = Upd;
+
+if (UnreachableInst *ExitTI =
+dyn_cast(ExitBB->getTerminator())) {
+  CurBBTI->eraseFromParent();
+  Builder.SetInsertPoint(ExitBB);
+} else {
+  Builder.SetInsertPoint(ExitTI);

Meinersbur wrote:

Could you add some comment explaining the code+control flow that is generated 
here?

https://github.com/llvm/llvm-project/pull/92364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-09 Thread Michael Kruse via cfe-commits


@@ -6033,6 +6034,52 @@ std::pair 
OpenMPIRBuilder::emitAtomicUpdate(
   Res.second = Res.first;
 else
   Res.second = emitRMWOpAsInstruction(Res.first, Expr, RMWOp);
+  } else if (RMWOp == llvm::AtomicRMWInst::BinOp::BAD_BINOP) {
+LoadInst *OldVal =
+Builder.CreateLoad(XElemTy, X, X->getName() + ".atomic.load");
+OldVal->setAtomic(AO);
+const DataLayout  = OldVal->getModule()->getDataLayout();
+unsigned LoadSize =
+LoadDL.getTypeStoreSize(OldVal->getPointerOperand()->getType());
+OpenMPIRBuilder::AtomicInfo atomicInfo(, XElemTy, LoadSize * 8,
+   LoadSize * 8, OldVal->getAlign(),
+   OldVal->getAlign(), true, X);
+auto AtomicLoadRes = atomicInfo.EmitAtomicLoadLibcall(AO);
+BasicBlock *CurBB = Builder.GetInsertBlock();
+Instruction *CurBBTI = CurBB->getTerminator();
+CurBBTI = CurBBTI ? CurBBTI : Builder.CreateUnreachable();
+BasicBlock *ExitBB =
+CurBB->splitBasicBlock(CurBBTI, X->getName() + ".atomic.exit");
+BasicBlock *ContBB = CurBB->splitBasicBlock(CurBB->getTerminator(),
+X->getName() + ".atomic.cont");
+ContBB->getTerminator()->eraseFromParent();
+Builder.restoreIP(AllocaIP);
+AllocaInst *NewAtomicAddr = Builder.CreateAlloca(XElemTy);
+NewAtomicAddr->setName(X->getName() + "x.new.val");
+Builder.SetInsertPoint(ContBB);
+llvm::PHINode *PHI = Builder.CreatePHI(OldVal->getType(), 2);
+PHI->addIncoming(AtomicLoadRes.first, CurBB);
+Value *OldExprVal = PHI;
+Value *Upd = UpdateOp(OldExprVal, Builder);
+Builder.CreateStore(Upd, NewAtomicAddr);
+AtomicOrdering Failure =
+llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(AO);
+auto Result = atomicInfo.EmitAtomicCompareExchangeLibcall(

Meinersbur wrote:

```suggestion
auto Result = atomicInfo.EmitAtomicCompareExchange(
```
The decision of whether to to use libcall should be made by AtomicInfo itself.

https://github.com/llvm/llvm-project/pull/92364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-09 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/92364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-09 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur commented:

I see you squashed in my proposed refactoring of AtomicInfo. I think it should 
be its own PR. It also was just a sketch and needs to be completed 
(`check-clang` is failing) and needs some cleanup (`auto` -> type, 
`emitAtomicLibcalls2`). Ideally, it would be NFC for clang. I was hoping you 
would continue with my sketch, but I could work on it as well.

https://github.com/llvm/llvm-project/pull/92364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-07-08 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

@dpalermo I added fix as PR #98072

https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-07-08 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

Using git bisect, I tracked down Flang not working anymore on Windows to this 
PR:

```
> flang-new hello.f90 -o hello
flang-new version 19.0.0git
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\meinersbur\build\llvm-project\release\bin
Build config: +assertions
 "C:\\Users\\meinersbur\\build\\llvm-project\\release\\bin\\flang-new" -fc1 
-triple x86_64-pc-windows-msvc19.40.33811 -emit-obj -fcolor-diagnostics 
-mrelocation-model pic -pic-level 2 -target-cpu x86-64 
--dependent-lib=clang_rt.builtins-x86_64.lib -D_MT --dependent-lib=libcmt 
--dependent-lib=Fortran_main.static.lib 
--dependent-lib=FortranRuntime.static.lib 
--dependent-lib=FortranDecimal.static.lib -D_MSC_VER=1940 
-D_MSC_FULL_VER=194033811 -D_WIN32 -D_M_X64=100 -mframe-pointer=none -o 
"C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\hello-2ee671.o" -x f95-cpp-input 
hello.f90
 "C:\\Program Files\\Microsoft Visual 
Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.40.33807\\bin\\Hostx64\\x64\\link.exe"
 -out:hello "-libpath:C:\\Users\\meinersbur\\build\\llvm-project\\release\\lib" 
/WHOLEARCHIVE:Fortran_main.static.lib /subsystem:console 
"-libpath:C:\\Users\\meinersbur\\build\\llvm-project\\release\\lib\\clang\\19\\lib\\windows"
 -nologo "C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\hello-2ee671.o"
LINK : fatal error LNK1104: cannot open file 'clang_rt.builtins.lib'
flang-new: error: linker command failed with exit code 1104 (use -v to see 
invocation)
```

Before this commit, `/DEFAULTLIB:clang_rt.builtins-x86_64.lib` the linking 
directive, now it is `/DEFAULTLIB:clang_rt.builtins-x86_64.lib`. Turns out, 
`clang_rt.builtins-x86_64.lib` is actually shipped with the MSVC compiler 
(`C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\\lib\x64`, possibly for Sanitizer 
support in MSVC), which makes the former work, but not the latter.

With `-DLLVM_ENABLE_PROJECTS=compiler-rt`, the resource-dir 
`build\llvm-project\release\lib\clang\19\lib\windows` is filled with 
`clang_rt.builtins-x86_64.lib` et.al., but also changes it back to 
`/DEFAULTLIB:clang_rt.builtins-x86_64.lib`, and it works again.





https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)

2024-06-21 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

#92916 has been accepted, but waiting for this PR.

https://github.com/llvm/llvm-project/pull/92916
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-19 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,
+  //structArg)
+  //alwaysinline {
+  //   %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
+  //   offload_baseptrs = load(getelementptr structArg, 0, 0)
+  //   offload_ptrs = load(getelementptr structArg, 0, 1)
+  //   offload_mappers = load(getelementptr structArg, 0, 2)
+  //   ; setup kernel_args using offload_baseptrs, offload_ptrs and
+  //   ; offload_mappers
+  //   call i32 @__tgt_target_kernel(...,
+  // outlined_device_function,
+  // ptr %kernel_args)
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  //  *a = *b + *c
+  //   }
+  //
+  BasicBlock *TargetTaskBodyBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.body");
+  BasicBlock *TargetTaskAllocaBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca");
+
+  InsertPointTy TargetTaskAllocaIP =
+  InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin());
+  InsertPointTy TargetTaskBodyIP =
+  InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin());
+
+  OutlineInfo OI;
+  OI.EntryBB = 

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -681,7 +681,30 @@ convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase 
,
   ompLoc, bodyCB, numTeamsLower, numTeamsUpper, threadLimit, ifExpr));
   return bodyGenStatus;
 }
-
+static void
+buildDependData(std::optional depends, OperandRange dependVars,
+LLVM::ModuleTranslation ,
+SmallVector ) {

Meinersbur wrote:

```suggestion
SmallVectorImpl ) {
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,
+  //structArg)
+  //alwaysinline {
+  //   %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
+  //   offload_baseptrs = load(getelementptr structArg, 0, 0)
+  //   offload_ptrs = load(getelementptr structArg, 0, 1)
+  //   offload_mappers = load(getelementptr structArg, 0, 2)
+  //   ; setup kernel_args using offload_baseptrs, offload_ptrs and
+  //   ; offload_mappers
+  //   call i32 @__tgt_target_kernel(...,
+  // outlined_device_function,
+  // ptr %kernel_args)
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  //  *a = *b + *c
+  //   }
+  //
+  BasicBlock *TargetTaskBodyBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.body");
+  BasicBlock *TargetTaskAllocaBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca");
+
+  InsertPointTy TargetTaskAllocaIP =
+  InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin());
+  InsertPointTy TargetTaskBodyIP =
+  InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin());
+
+  OutlineInfo OI;
+  OI.EntryBB = 

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,
+  //structArg)
+  //alwaysinline {
+  //   %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
+  //   offload_baseptrs = load(getelementptr structArg, 0, 0)
+  //   offload_ptrs = load(getelementptr structArg, 0, 1)
+  //   offload_mappers = load(getelementptr structArg, 0, 2)
+  //   ; setup kernel_args using offload_baseptrs, offload_ptrs and
+  //   ; offload_mappers
+  //   call i32 @__tgt_target_kernel(...,
+  // outlined_device_function,
+  // ptr %kernel_args)
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  //  *a = *b + *c
+  //   }
+  //
+  BasicBlock *TargetTaskBodyBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.body");
+  BasicBlock *TargetTaskAllocaBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca");
+
+  InsertPointTy TargetTaskAllocaIP =
+  InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin());
+  InsertPointTy TargetTaskBodyIP =
+  InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin());

Meinersbur wrote:


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,
+  //structArg)
+  //alwaysinline {
+  //   %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
+  //   offload_baseptrs = load(getelementptr structArg, 0, 0)
+  //   offload_ptrs = load(getelementptr structArg, 0, 1)
+  //   offload_mappers = load(getelementptr structArg, 0, 2)
+  //   ; setup kernel_args using offload_baseptrs, offload_ptrs and
+  //   ; offload_mappers
+  //   call i32 @__tgt_target_kernel(...,
+  // outlined_device_function,
+  // ptr %kernel_args)
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  //  *a = *b + *c
+  //   }
+  //
+  BasicBlock *TargetTaskBodyBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.body");
+  BasicBlock *TargetTaskAllocaBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca");
+
+  InsertPointTy TargetTaskAllocaIP =
+  InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin());
+  InsertPointTy TargetTaskBodyIP =
+  InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin());
+
+  OutlineInfo OI;
+  OI.EntryBB = 

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,
+  //structArg)
+  //alwaysinline {
+  //   %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
+  //   offload_baseptrs = load(getelementptr structArg, 0, 0)
+  //   offload_ptrs = load(getelementptr structArg, 0, 1)
+  //   offload_mappers = load(getelementptr structArg, 0, 2)
+  //   ; setup kernel_args using offload_baseptrs, offload_ptrs and
+  //   ; offload_mappers
+  //   call i32 @__tgt_target_kernel(...,
+  // outlined_device_function,
+  // ptr %kernel_args)
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  //  *a = *b + *c
+  //   }
+  //
+  BasicBlock *TargetTaskBodyBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.body");
+  BasicBlock *TargetTaskAllocaBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca");
+
+  InsertPointTy TargetTaskAllocaIP =
+  InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin());
+  InsertPointTy TargetTaskBodyIP =
+  InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin());
+
+  OutlineInfo OI;
+  OI.EntryBB = 

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -681,7 +681,30 @@ convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase 
,
   ompLoc, bodyCB, numTeamsLower, numTeamsUpper, threadLimit, ifExpr));
   return bodyGenStatus;
 }
-
+static void

Meinersbur wrote:

[nit]
```suggestion

static void
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5212,6 +5273,78 @@ static Function *createOutlinedFunction(
   return Func;
 }
 
+// Create an entry point for a target task with the following.
+// It'll have the following signature
+// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
+// This function is called from emitTargetTask once the
+// code to launch the target kernel has been outlined already.
+static Function *emitProxyTaskFunction(OpenMPIRBuilder ,
+   IRBuilderBase ,
+   CallInst *StaleCI) {
+  Module  = OMPBuilder.M;
+  // CalledFunction is the target launch function, i.e.
+  // the function that sets up kernel arguments and calls
+  // __tgt_target_kernel to launch the kernel on the device.
+  Function *CalledFunction = StaleCI->getCalledFunction();
+  OpenMPIRBuilder::InsertPointTy IP(StaleCI->getParent(),
+StaleCI->getIterator());
+  LLVMContext  = StaleCI->getParent()->getContext();
+  Type *ThreadIDTy = Type::getInt32Ty(Ctx);
+  Type *TaskPtrTy = OMPBuilder.TaskPtr;
+  Type *TaskTy = OMPBuilder.Task;
+  auto ProxyFnTy =
+  FunctionType::get(Builder.getVoidTy(), {ThreadIDTy, TaskPtrTy},
+/* isVarArg */ false);
+  auto ProxyFn = Function::Create(ProxyFnTy, GlobalValue::InternalLinkage,
+  ".omp_target_task_proxy_func",
+  Builder.GetInsertBlock()->getModule());
+
+  BasicBlock *EntryBB =
+  BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
+  Builder.SetInsertPoint(EntryBB);
+
+  bool HasShareds = StaleCI->arg_size() > 1;
+  // TODO: This is a temporary assert to prove to ourselves that
+  // the outlined target launch function is always going to have
+  // atmost two arguments if there is any data shared between
+  // host and device.
+  assert((!HasShareds || (StaleCI->arg_size() == 2)) &&
+ "StaleCI with shareds should have exactly two arguments.");
+  if (HasShareds) {
+AllocaInst *ArgStructAlloca =
+dyn_cast(StaleCI->getArgOperand(1));

Meinersbur wrote:

```suggestion
auto *ArgStructAlloca =
dyn_cast(StaleCI->getArgOperand(1));
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5212,6 +5273,78 @@ static Function *createOutlinedFunction(
   return Func;
 }
 
+// Create an entry point for a target task with the following.
+// It'll have the following signature
+// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
+// This function is called from emitTargetTask once the
+// code to launch the target kernel has been outlined already.

Meinersbur wrote:

Could be a Doxygen comment
```suggestion
/// Create an entry point for a target task with the following.
/// It'll have the following signature
/// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
/// This function is called from emitTargetTask once the
/// code to launch the target kernel has been outlined already.
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5212,6 +5273,78 @@ static Function *createOutlinedFunction(
   return Func;
 }
 
+// Create an entry point for a target task with the following.
+// It'll have the following signature
+// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
+// This function is called from emitTargetTask once the
+// code to launch the target kernel has been outlined already.
+static Function *emitProxyTaskFunction(OpenMPIRBuilder ,
+   IRBuilderBase ,
+   CallInst *StaleCI) {
+  Module  = OMPBuilder.M;
+  // CalledFunction is the target launch function, i.e.
+  // the function that sets up kernel arguments and calls
+  // __tgt_target_kernel to launch the kernel on the device.
+  Function *CalledFunction = StaleCI->getCalledFunction();
+  OpenMPIRBuilder::InsertPointTy IP(StaleCI->getParent(),
+StaleCI->getIterator());
+  LLVMContext  = StaleCI->getParent()->getContext();
+  Type *ThreadIDTy = Type::getInt32Ty(Ctx);
+  Type *TaskPtrTy = OMPBuilder.TaskPtr;
+  Type *TaskTy = OMPBuilder.Task;
+  auto ProxyFnTy =
+  FunctionType::get(Builder.getVoidTy(), {ThreadIDTy, TaskPtrTy},
+/* isVarArg */ false);
+  auto ProxyFn = Function::Create(ProxyFnTy, GlobalValue::InternalLinkage,
+  ".omp_target_task_proxy_func",
+  Builder.GetInsertBlock()->getModule());
+
+  BasicBlock *EntryBB =
+  BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
+  Builder.SetInsertPoint(EntryBB);
+
+  bool HasShareds = StaleCI->arg_size() > 1;
+  // TODO: This is a temporary assert to prove to ourselves that
+  // the outlined target launch function is always going to have
+  // atmost two arguments if there is any data shared between
+  // host and device.
+  assert((!HasShareds || (StaleCI->arg_size() == 2)) &&
+ "StaleCI with shareds should have exactly two arguments.");
+  if (HasShareds) {
+AllocaInst *ArgStructAlloca =
+dyn_cast(StaleCI->getArgOperand(1));
+assert(ArgStructAlloca &&
+   "Unable to find the alloca instruction corresponding to arguments "
+   "for extracted function");
+StructType *ArgStructType =
+dyn_cast(ArgStructAlloca->getAllocatedType());
+LLVM_DEBUG(dbgs() << "ArgStructType = " << *ArgStructType << "\n");
+
+AllocaInst *NewArgStructAlloca =
+Builder.CreateAlloca(ArgStructType, nullptr, "structArg");
+Value *TaskT = ProxyFn->getArg(1);
+Value *ThreadId = ProxyFn->getArg(0);
+LLVM_DEBUG(dbgs() << "TaskT = " << *TaskT << "\n");
+Value *SharedsSize =
+Builder.getInt64(M.getDataLayout().getTypeStoreSize(ArgStructType));
+
+Value *Shareds = Builder.CreateStructGEP(TaskTy, TaskT, 0);
+LoadInst *LoadShared =
+Builder.CreateLoad(PointerType::getUnqual(Ctx), Shareds);
+
+// TODO: Are these alignment values correct?

Meinersbur wrote:

I think `NewArgStructAlloca->getAlign()` shold be sufficient. If the 
alloca/load doesn't have the align set explicitly, `memcpy` should apply 
pointer alignment itself.

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5212,6 +5273,78 @@ static Function *createOutlinedFunction(
   return Func;
 }
 
+// Create an entry point for a target task with the following.
+// It'll have the following signature
+// void @.omp_target_task_proxy_func(i32 %thread.id, ptr %task)
+// This function is called from emitTargetTask once the
+// code to launch the target kernel has been outlined already.
+static Function *emitProxyTaskFunction(OpenMPIRBuilder ,
+   IRBuilderBase ,
+   CallInst *StaleCI) {
+  Module  = OMPBuilder.M;
+  // CalledFunction is the target launch function, i.e.
+  // the function that sets up kernel arguments and calls
+  // __tgt_target_kernel to launch the kernel on the device.
+  Function *CalledFunction = StaleCI->getCalledFunction();
+  OpenMPIRBuilder::InsertPointTy IP(StaleCI->getParent(),
+StaleCI->getIterator());
+  LLVMContext  = StaleCI->getParent()->getContext();
+  Type *ThreadIDTy = Type::getInt32Ty(Ctx);
+  Type *TaskPtrTy = OMPBuilder.TaskPtr;
+  Type *TaskTy = OMPBuilder.Task;
+  auto ProxyFnTy =
+  FunctionType::get(Builder.getVoidTy(), {ThreadIDTy, TaskPtrTy},
+/* isVarArg */ false);
+  auto ProxyFn = Function::Create(ProxyFnTy, GlobalValue::InternalLinkage,
+  ".omp_target_task_proxy_func",
+  Builder.GetInsertBlock()->getModule());
+
+  BasicBlock *EntryBB =
+  BasicBlock::Create(Builder.getContext(), "entry", ProxyFn);
+  Builder.SetInsertPoint(EntryBB);
+
+  bool HasShareds = StaleCI->arg_size() > 1;

Meinersbur wrote:

What is "Shareds"?

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur commented:

Conceptually, looks quite good. Just some style comments.

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,

Meinersbur wrote:

[nit] line break

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1762,6 +1762,26 @@ class OpenMPIRBuilder {
   EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
   Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP);
 
+  /// Generate a target-task for the target construct
+  ///
+  /// \param OutlinedFn The outlined device/target kernel function.
+  /// \param OutlinedFnID The ooulined function ID.
+  /// \param EmitTargetCallFallbackCB Call back function to generate host
+  ///fallback code.
+  /// \param Args Data structure holding information about the kernel 
arguments.
+  /// \param DeviceID Identifier for the device via the 'device' clause.
+  /// \param RTLoc Source location identifier
+  /// \param AllocaIP The insertion point to be used for alloca instructions.
+  /// \param Dependencies Vector of DependData objects holding information of
+  ///dependencies as specified by the 'depend' clause.
+  /// \param HasNoWait True if the target construct had 'nowait' on it, false
+  ///otherwise
+  InsertPointTy emitTargetTask(
+  Function *OutlinedFn, Value *OutlinedFnID,
+  EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+  Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP,
+  SmallVector , bool HasNoWait);

Meinersbur wrote:

```suggestion
  ArrayRef Dependencies, bool HasNoWait);
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const 
LocationDescription ) {
   emitTaskyieldImpl(Loc);
 }
 
+// Processes the dependencies in Dependencies and does the following
+// - Allocates space on the stack of an array of DependInfo objects
+// - Populates each DependInfo object with relevant information of
+//   the corresponding dependence.
+// - All code is inserted in the entry block of the current function.
+static Value *
+emitDepArray(OpenMPIRBuilder ,
+ SmallVector ) {
+  // Early return if we have no dependencies to process
+  if (!Dependencies.size())
+return nullptr;
+
+  IRBuilderBase  = OMPBuilder.Builder;
+  Type *DependInfo = OMPBuilder.DependInfo;
+  Module  = OMPBuilder.M;
+
+  Value *DepArray = nullptr;
+  if (Dependencies.size()) {
+OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
+Builder.SetInsertPoint(
+()->getParent()->getEntryBlock().back());

Meinersbur wrote:

```suggestion
Builder.SetInsertPoint(
()->getParent()->getEntryBlock().getTerminator());
```
just makes it more explicit. 
Did you consider explicitly passing the AllocaIP, could be needed with combined 
constructs.

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const 
LocationDescription ) {
   emitTaskyieldImpl(Loc);
 }
 
+// Processes the dependencies in Dependencies and does the following
+// - Allocates space on the stack of an array of DependInfo objects
+// - Populates each DependInfo object with relevant information of
+//   the corresponding dependence.
+// - All code is inserted in the entry block of the current function.
+static Value *
+emitDepArray(OpenMPIRBuilder ,
+ SmallVector ) {
+  // Early return if we have no dependencies to process
+  if (!Dependencies.size())
+return nullptr;
+
+  IRBuilderBase  = OMPBuilder.Builder;
+  Type *DependInfo = OMPBuilder.DependInfo;
+  Module  = OMPBuilder.M;
+
+  Value *DepArray = nullptr;
+  if (Dependencies.size()) {
+OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
+Builder.SetInsertPoint(
+()->getParent()->getEntryBlock().back());
+
+Type *DepArrayTy = ArrayType::get(DependInfo, Dependencies.size());
+DepArray = Builder.CreateAlloca(DepArrayTy, nullptr, ".dep.arr.addr");
+
+unsigned P = 0;
+for (const OpenMPIRBuilder::DependData  : Dependencies) {
+  Value *Base =
+  Builder.CreateConstInBoundsGEP2_64(DepArrayTy, DepArray, 0, P);
+  // Store the pointer to the variable
+  Value *Addr = Builder.CreateStructGEP(
+  DependInfo, Base,
+  static_cast(RTLDependInfoFields::BaseAddr));
+  Value *DepValPtr =
+  Builder.CreatePtrToInt(Dep.DepVal, Builder.getInt64Ty());
+  Builder.CreateStore(DepValPtr, Addr);
+  // Store the size of the variable
+  Value *Size = Builder.CreateStructGEP(
+  DependInfo, Base,
+  static_cast(RTLDependInfoFields::Len));
+  Builder.CreateStore(Builder.getInt64(M.getDataLayout().getTypeStoreSize(
+  Dep.DepValueType)),
+  Size);
+  // Store the dependency kind
+  Value *Flags = Builder.CreateStructGEP(
+  DependInfo, Base,
+  static_cast(RTLDependInfoFields::Flags));
+  Builder.CreateStore(
+  ConstantInt::get(Builder.getInt8Ty(),
+   static_cast(Dep.DepKind)),
+  Flags);

Meinersbur wrote:

Consider adding a comment with a mock source of what is generate here:
```
DepArray[P].BaseAddre = ...
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -2253,7 +2275,8 @@ class OpenMPIRBuilder {
  SmallVectorImpl ,
  GenMapInfoCallbackTy GenMapInfoCB,
  TargetBodyGenCallbackTy BodyGenCB,
- TargetGenArgAccessorsCallbackTy 
ArgAccessorFuncCB);
+ TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
+ SmallVector Dependencies = {});

Meinersbur wrote:

```suggestion
 ArrayRef Dependencies = {});
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits


@@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const 
LocationDescription ) {
   emitTaskyieldImpl(Loc);
 }
 
+// Processes the dependencies in Dependencies and does the following
+// - Allocates space on the stack of an array of DependInfo objects
+// - Populates each DependInfo object with relevant information of
+//   the corresponding dependence.
+// - All code is inserted in the entry block of the current function.
+static Value *
+emitDepArray(OpenMPIRBuilder ,
+ SmallVector ) {
+  // Early return if we have no dependencies to process
+  if (!Dependencies.size())

Meinersbur wrote:

```suggestion
  if (Dependencies.empty())
```

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur commented:

Not a full a review, but the first notes that I started with

https://github.com/llvm/llvm-project/pull/93977
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-05 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-05 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-05 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-05 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][OpenMP] Add -fopenmp-force-usm option to flang (PR #94359)

2024-06-04 Thread Michael Kruse via cfe-commits


@@ -172,13 +174,17 @@ struct OffloadModuleOpts {
   module.getOperation())) {
 offloadMod.setIsTargetDevice(Opts.OpenMPIsTargetDevice);
 offloadMod.setIsGPU(Opts.OpenMPIsGPU);
+if (Opts.OpenMPForceUSM) {
+  offloadMod.setRequires(mlir::omp::ClauseRequires::unified_shared_memory);
+}
 if (Opts.OpenMPIsTargetDevice) {
   offloadMod.setFlags(Opts.OpenMPTargetDebug, Opts.OpenMPTeamSubscription,
   Opts.OpenMPThreadSubscription, Opts.OpenMPNoThreadState,
   Opts.OpenMPNoNestedParallelism, Opts.OpenMPVersion, Opts.NoGPULib);
 
-  if (!Opts.OMPHostIRFile.empty())
+  if (!Opts.OMPHostIRFile.empty()) {

Meinersbur wrote:

[nit] unrelated change

https://github.com/llvm/llvm-project/pull/94359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][OpenMP] Add -fopenmp-force-usm option to flang (PR #94359)

2024-06-04 Thread Michael Kruse via cfe-commits


@@ -766,6 +766,8 @@ void Flang::ConstructJob(Compilation , const JobAction 
,
   Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
 
   // FIXME: Clang supports a whole bunch more flags here.

Meinersbur wrote:

The FIXME should stay behind all handled options

https://github.com/llvm/llvm-project/pull/94359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][OpenMP] Add -fopenmp-force-usm option to flang (PR #94359)

2024-06-04 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/94359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][OpenMP] Add -fopenmp-force-usm option to flang (PR #94359)

2024-06-04 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/94359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)

2024-06-04 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

@alexey-bataev ping

https://github.com/llvm/llvm-project/pull/92916
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-04 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-04 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-06-03 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur ready_for_review 
https://github.com/llvm/llvm-project/pull/93519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-05-28 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/93519

As discussed in #89743, when using the Visual Studio solution generators, 
object library projects are displayed as a collection of non-editable *.obj 
files. To look for the corresponding source files, one has to browse (or 
search) to the library's obj.libname project. This patch tries to avoid this as 
much as possible.

For Clang, there is already an exception for XCode. We handle MSVC_IDE the same 
way.

For MLIR, this is more complicated. There are explicit references to the 
obj.libname target that only work when there is an object library. This patch 
cleans up the reasons for why an object library is needed:

1. The obj.libname is modified in the calling CMakeLists.txt. Note that with 
use-only references, `add_library( ALIAS )` could have been used. 

2. An libMLIR.so (mlir-shlib) is also created. This works by adding linking the 
object libraries' object file into libMLIR.so (in addition to the library's own 
.so/.a). XCode is handled using the `-force_load` linker option instead. 
Windows is not even supported. This mechanism is different from LLVM's 
llvm-shlib that is created by linking static libraries with 
`-Wl,--whole-archive` (and `-Wl,-all_load` on MacOS).

3. The library might be added to an aggregate library. In-tree, the seems to be 
only libMLIR-C.so and the standalone example. It uses the object library and 
`-force_load` mechanism as above. Again, this is different from libLLVM-C.so. 

4. Build an object library whenever it was before this patch, except when 
generating a Visual Studio solution. This condition could be removed, but I am 
trying to avoid build breakages of whatever configurations others use.

This seem to not have worked with XCode because of the explicit references to 
obj.libname. I don't have access to XCode, but I tried to preserve the current 
working. IMHO there should be a common mechanism to build aggregate libraries 
for all LLVM projects instead of the 4 that we have now.

As far as I can see, this means for LLVM there are the following changes on 
whether object libraries are created:

1. An object library is created even in XCode if FORCE_OBJECT_LIBRARY is set. I 
do not know how XCode handles it, but I also know CMake will abort otherwise.

2. An object library is created even for explicitly SHARED libraries for 
building libMLIR.so. Again, mlir-shlib does not work otherwise. libMLIR.so 
itself is created using SHARED so this is marking it as EXCLUDE_FROM_LIBMLIR.

3. For the second condition, it is now sensitive to whether the mlir-shlib is 
built at all (LLVM_BUILD_LLVM_DYLIB). However, an object library is still built 
using the fourth condition unless using the MSVC solution generator. That is, 
except with MSVC_IDE, when an object library was built before, it will also be 
an object library now.

>From a08815e3b5e204c4f7eccbfbfcdb04d00ab7f895 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 28 May 2024 09:50:21 +0200
Subject: [PATCH] Avoid object libraries in the VS IDE

---
 clang/cmake/modules/AddClang.cmake   |  6 ++-
 clang/lib/Support/CMakeLists.txt |  2 +-
 flang/cmake/modules/AddFlang.cmake   | 21 +++---
 mlir/cmake/modules/AddMLIR.cmake | 62 +++-
 mlir/lib/Dialect/GPU/CMakeLists.txt  |  2 +
 mlir/lib/Target/LLVM/CMakeLists.txt  |  4 ++
 mlir/tools/mlir-shlib/CMakeLists.txt |  1 +
 7 files changed, 70 insertions(+), 28 deletions(-)

diff --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index a5ef639187d9d..9d09be1936847 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -96,8 +96,12 @@ macro(add_clang_library name)
 else()
   set(LIBTYPE STATIC)
 endif()
-if(NOT XCODE)
+if(NOT XCODE AND NOT MSVC_IDE)
   # The Xcode generator doesn't handle object libraries correctly.
+  # The Visual Studio CMake generator does handle object libraries
+  # correctly, but it is preferable to list the libraries with their
+  # source files (instead of the object files and the source files in
+  # a separate target in the "Object Libraries" folder)
   list(APPEND LIBTYPE OBJECT)
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
diff --git a/clang/lib/Support/CMakeLists.txt b/clang/lib/Support/CMakeLists.txt
index 8ea5620052ed8..de06271e914ae 100644
--- a/clang/lib/Support/CMakeLists.txt
+++ b/clang/lib/Support/CMakeLists.txt
@@ -15,7 +15,7 @@ set(clangSupport_sources
 
 add_clang_library(clangSupport ${clangSupport_sources})
 
-if (NOT XCODE)
+if (TARGET obj.clangSupport)
   add_library(clangSupport_tablegen ALIAS obj.clangSupport)
 elseif (NOT LLVM_LINK_LLVM_DYLIB)
   add_library(clangSupport_tablegen ALIAS clangSupport)
diff --git a/flang/cmake/modules/AddFlang.cmake 
b/flang/cmake/modules/AddFlang.cmake
index 3a5119b83831f..aeb4d862cf780 100644
--- 

[clang-tools-extra] 5fb3830 - [clang-tools-extra] Remove redundant FOLDER property. NFC.

2024-05-27 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2024-05-27T17:42:32+02:00
New Revision: 5fb38307f372555cd22fd09ace86c3b1ccd2abb9

URL: 
https://github.com/llvm/llvm-project/commit/5fb38307f372555cd22fd09ace86c3b1ccd2abb9
DIFF: 
https://github.com/llvm/llvm-project/commit/5fb38307f372555cd22fd09ace86c3b1ccd2abb9.diff

LOG: [clang-tools-extra] Remove redundant FOLDER property. NFC.

This should have been removed from #89744 to address a review comment.

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index 0583671910526..35e29b9a7d136 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -52,7 +52,6 @@ add_clang_library(clangTidyMiscModule
   genconfusable
   ClangDriverOptions
   )
-set_target_properties(clangTidyMiscModule PROPERTIES FOLDER "Clang Tools 
Extra/Libraries")
 
 clang_target_link_libraries(clangTidyMiscModule
   PRIVATE



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-05-25 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

> This is basically names passed as FOLDER property are very generic. 

They are a little more specific than before (especially when considering 
Compiler-RT which put everything into "Compiler-RT/Misc"). Being more 
contextual would also require more maintenance, e.g. adding the right folder 
name for new artifacts. Only users of CMake's XCode or Visual Studio generators 
even see then, other would not even know something is off when this is not 
done. Hence the goal was to reduce maintenance, i.e. `add_clang_library` 
selects the folder name itself. It only has the type of the target available 
(here: library), so that's what it is restricted to.

> Then this change is +- fine.

Thank you


https://github.com/llvm/llvm-project/pull/89744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/89744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-05-25 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

> For me this entire change doesn't make sense.

Could you elaborate on why?

https://github.com/llvm/llvm-project/pull/89744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/89744

>From 6f39beb9ee58d7c377dce6ba8ce69e71da5b8e09 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 12:55:15 +0200
Subject: [PATCH 1/6] [llvm] Revise IDE folder structure

---
 llvm/CMakeLists.txt   | 12 ++-
 llvm/cmake/modules/AddLLVM.cmake  | 83 ++-
 llvm/cmake/modules/AddOCaml.cmake |  5 +-
 llvm/cmake/modules/AddSphinxTarget.cmake  |  3 +
 llvm/cmake/modules/CrossCompile.cmake |  4 +
 .../modules/LLVMDistributionSupport.cmake |  8 ++
 .../modules/LLVMExternalProjectUtils.cmake| 25 +-
 llvm/cmake/modules/TableGen.cmake |  7 +-
 llvm/docs/CMakeLists.txt  |  1 +
 llvm/examples/Kaleidoscope/CMakeLists.txt |  2 +-
 llvm/include/llvm/Support/CMakeLists.txt  |  2 +-
 llvm/lib/Support/BLAKE3/CMakeLists.txt|  1 +
 llvm/runtimes/CMakeLists.txt  | 23 +
 llvm/test/CMakeLists.txt  |  6 +-
 llvm/tools/opt-viewer/CMakeLists.txt  |  1 +
 .../InlineAdvisorPlugin/CMakeLists.txt|  3 +-
 .../Analysis/InlineOrderPlugin/CMakeLists.txt |  2 +-
 llvm/unittests/CMakeLists.txt |  2 +-
 llvm/unittests/DebugInfo/BTF/CMakeLists.txt   |  2 -
 .../DebugInfo/CodeView/CMakeLists.txt |  2 -
 llvm/unittests/DebugInfo/DWARF/CMakeLists.txt |  2 -
 llvm/unittests/DebugInfo/GSYM/CMakeLists.txt  |  2 -
 llvm/unittests/DebugInfo/MSF/CMakeLists.txt   |  2 -
 llvm/unittests/DebugInfo/PDB/CMakeLists.txt   |  2 -
 llvm/unittests/ExecutionEngine/CMakeLists.txt |  2 -
 .../ExecutionEngine/JITLink/CMakeLists.txt|  2 -
 .../ExecutionEngine/MCJIT/CMakeLists.txt  |  2 -
 .../ExecutionEngine/Orc/CMakeLists.txt|  2 -
 .../Support/CommandLineInit/CMakeLists.txt|  4 -
 .../Support/DynamicLibrary/CMakeLists.txt |  4 +-
 llvm/unittests/Target/AArch64/CMakeLists.txt  |  2 -
 llvm/unittests/Target/AMDGPU/CMakeLists.txt   |  2 -
 llvm/unittests/Target/ARM/CMakeLists.txt  |  2 -
 llvm/unittests/Target/CMakeLists.txt  |  3 -
 .../unittests/Target/LoongArch/CMakeLists.txt |  2 -
 llvm/unittests/Target/PowerPC/CMakeLists.txt  |  2 -
 llvm/unittests/Target/RISCV/CMakeLists.txt|  2 -
 .../Target/WebAssembly/CMakeLists.txt |  2 -
 llvm/unittests/Target/X86/CMakeLists.txt  |  2 -
 .../Transforms/Coroutines/CMakeLists.txt  |  2 -
 llvm/unittests/Transforms/IPO/CMakeLists.txt  |  2 -
 .../Transforms/Scalar/CMakeLists.txt  |  2 -
 .../unittests/Transforms/Utils/CMakeLists.txt |  2 -
 .../Transforms/Vectorize/CMakeLists.txt   |  2 -
 .../tools/llvm-cfi-verify/CMakeLists.txt  |  2 -
 .../tools/llvm-exegesis/CMakeLists.txt|  2 -
 llvm/unittests/tools/llvm-mca/CMakeLists.txt  |  2 -
 .../tools/llvm-profdata/CMakeLists.txt|  2 -
 .../tools/llvm-profgen/CMakeLists.txt |  2 -
 llvm/utils/LLVMVisualizers/CMakeLists.txt |  2 +-
 llvm/utils/TableGen/Basic/CMakeLists.txt  |  1 -
 llvm/utils/TableGen/CMakeLists.txt|  2 -
 llvm/utils/TableGen/Common/CMakeLists.txt |  1 -
 llvm/utils/lit/CMakeLists.txt |  4 +-
 llvm/utils/llvm-locstats/CMakeLists.txt   |  2 +-
 llvm/utils/mlgo-utils/CMakeLists.txt  |  2 +-
 56 files changed, 159 insertions(+), 112 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 43181af3bc195..48a6ab7d21f48 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1124,7 +1124,7 @@ configure_file(
 add_custom_target(srpm
   COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B 
${LLVM_SRPM_DIR}/SOURCES
   COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' 
${LLVM_SRPM_BINARY_SPECFILE})
-set_target_properties(srpm PROPERTIES FOLDER "Misc")
+set_target_properties(srpm PROPERTIES FOLDER "LLVM/Misc")
 
 if(APPLE AND DARWIN_LTO_LIBRARY)
   set(CMAKE_EXE_LINKER_FLAGS
@@ -1222,7 +1222,9 @@ if( LLVM_INCLUDE_UTILS )
   add_subdirectory(utils/split-file)
   add_subdirectory(utils/mlgo-utils)
   if( LLVM_INCLUDE_TESTS )
+set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
 add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest 
${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+set(LLVM_SUBPROJECT_TITLE) 
   endif()
 else()
   if ( LLVM_INCLUDE_TESTS )
@@ -1286,7 +1288,7 @@ if( LLVM_INCLUDE_TESTS )
   if(LLVM_ALL_LIT_DEPENDS OR LLVM_ALL_ADDITIONAL_TEST_DEPENDS)
 add_dependencies(test-depends ${LLVM_ALL_LIT_DEPENDS} 
${LLVM_ALL_ADDITIONAL_TEST_DEPENDS})
   endif()
-  set_target_properties(test-depends PROPERTIES FOLDER "Tests")
+  set_target_properties(test-depends PROPERTIES FOLDER "LLVM/Tests")
   add_dependencies(check-all test-depends)
 endif()
 
@@ -1343,7 +1345,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   # Installing the headers needs to depend on generating any public
   # tablegen'd headers.
   add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen)
-  

[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-05-25 Thread Michael Kruse via cfe-commits


@@ -51,6 +52,7 @@ add_clang_library(clangTidyMiscModule
   genconfusable
   ClangDriverOptions
   )
+set_target_properties(clangTidyMiscModule PROPERTIES FOLDER "Clang Tools 
Extra/Libraries")

Meinersbur wrote:

This `set_target_properties` is redundant here, the same folder is already set 
by `add_clang_library` in #89741. This must be a leftover from cleaning up when 
I changed `add_clang_library` to set the folder instead of each of them 
individually. Thanks for noticing.

https://github.com/llvm/llvm-project/pull/89744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/89153
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/89755
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/89755

>From 6f39beb9ee58d7c377dce6ba8ce69e71da5b8e09 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 12:55:15 +0200
Subject: [PATCH 1/6] [llvm] Revise IDE folder structure

---
 llvm/CMakeLists.txt   | 12 ++-
 llvm/cmake/modules/AddLLVM.cmake  | 83 ++-
 llvm/cmake/modules/AddOCaml.cmake |  5 +-
 llvm/cmake/modules/AddSphinxTarget.cmake  |  3 +
 llvm/cmake/modules/CrossCompile.cmake |  4 +
 .../modules/LLVMDistributionSupport.cmake |  8 ++
 .../modules/LLVMExternalProjectUtils.cmake| 25 +-
 llvm/cmake/modules/TableGen.cmake |  7 +-
 llvm/docs/CMakeLists.txt  |  1 +
 llvm/examples/Kaleidoscope/CMakeLists.txt |  2 +-
 llvm/include/llvm/Support/CMakeLists.txt  |  2 +-
 llvm/lib/Support/BLAKE3/CMakeLists.txt|  1 +
 llvm/runtimes/CMakeLists.txt  | 23 +
 llvm/test/CMakeLists.txt  |  6 +-
 llvm/tools/opt-viewer/CMakeLists.txt  |  1 +
 .../InlineAdvisorPlugin/CMakeLists.txt|  3 +-
 .../Analysis/InlineOrderPlugin/CMakeLists.txt |  2 +-
 llvm/unittests/CMakeLists.txt |  2 +-
 llvm/unittests/DebugInfo/BTF/CMakeLists.txt   |  2 -
 .../DebugInfo/CodeView/CMakeLists.txt |  2 -
 llvm/unittests/DebugInfo/DWARF/CMakeLists.txt |  2 -
 llvm/unittests/DebugInfo/GSYM/CMakeLists.txt  |  2 -
 llvm/unittests/DebugInfo/MSF/CMakeLists.txt   |  2 -
 llvm/unittests/DebugInfo/PDB/CMakeLists.txt   |  2 -
 llvm/unittests/ExecutionEngine/CMakeLists.txt |  2 -
 .../ExecutionEngine/JITLink/CMakeLists.txt|  2 -
 .../ExecutionEngine/MCJIT/CMakeLists.txt  |  2 -
 .../ExecutionEngine/Orc/CMakeLists.txt|  2 -
 .../Support/CommandLineInit/CMakeLists.txt|  4 -
 .../Support/DynamicLibrary/CMakeLists.txt |  4 +-
 llvm/unittests/Target/AArch64/CMakeLists.txt  |  2 -
 llvm/unittests/Target/AMDGPU/CMakeLists.txt   |  2 -
 llvm/unittests/Target/ARM/CMakeLists.txt  |  2 -
 llvm/unittests/Target/CMakeLists.txt  |  3 -
 .../unittests/Target/LoongArch/CMakeLists.txt |  2 -
 llvm/unittests/Target/PowerPC/CMakeLists.txt  |  2 -
 llvm/unittests/Target/RISCV/CMakeLists.txt|  2 -
 .../Target/WebAssembly/CMakeLists.txt |  2 -
 llvm/unittests/Target/X86/CMakeLists.txt  |  2 -
 .../Transforms/Coroutines/CMakeLists.txt  |  2 -
 llvm/unittests/Transforms/IPO/CMakeLists.txt  |  2 -
 .../Transforms/Scalar/CMakeLists.txt  |  2 -
 .../unittests/Transforms/Utils/CMakeLists.txt |  2 -
 .../Transforms/Vectorize/CMakeLists.txt   |  2 -
 .../tools/llvm-cfi-verify/CMakeLists.txt  |  2 -
 .../tools/llvm-exegesis/CMakeLists.txt|  2 -
 llvm/unittests/tools/llvm-mca/CMakeLists.txt  |  2 -
 .../tools/llvm-profdata/CMakeLists.txt|  2 -
 .../tools/llvm-profgen/CMakeLists.txt |  2 -
 llvm/utils/LLVMVisualizers/CMakeLists.txt |  2 +-
 llvm/utils/TableGen/Basic/CMakeLists.txt  |  1 -
 llvm/utils/TableGen/CMakeLists.txt|  2 -
 llvm/utils/TableGen/Common/CMakeLists.txt |  1 -
 llvm/utils/lit/CMakeLists.txt |  4 +-
 llvm/utils/llvm-locstats/CMakeLists.txt   |  2 +-
 llvm/utils/mlgo-utils/CMakeLists.txt  |  2 +-
 56 files changed, 159 insertions(+), 112 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 43181af3bc195..48a6ab7d21f48 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1124,7 +1124,7 @@ configure_file(
 add_custom_target(srpm
   COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B 
${LLVM_SRPM_DIR}/SOURCES
   COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' 
${LLVM_SRPM_BINARY_SPECFILE})
-set_target_properties(srpm PROPERTIES FOLDER "Misc")
+set_target_properties(srpm PROPERTIES FOLDER "LLVM/Misc")
 
 if(APPLE AND DARWIN_LTO_LIBRARY)
   set(CMAKE_EXE_LINKER_FLAGS
@@ -1222,7 +1222,9 @@ if( LLVM_INCLUDE_UTILS )
   add_subdirectory(utils/split-file)
   add_subdirectory(utils/mlgo-utils)
   if( LLVM_INCLUDE_TESTS )
+set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
 add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest 
${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
+set(LLVM_SUBPROJECT_TITLE) 
   endif()
 else()
   if ( LLVM_INCLUDE_TESTS )
@@ -1286,7 +1288,7 @@ if( LLVM_INCLUDE_TESTS )
   if(LLVM_ALL_LIT_DEPENDS OR LLVM_ALL_ADDITIONAL_TEST_DEPENDS)
 add_dependencies(test-depends ${LLVM_ALL_LIT_DEPENDS} 
${LLVM_ALL_ADDITIONAL_TEST_DEPENDS})
   endif()
-  set_target_properties(test-depends PROPERTIES FOLDER "Tests")
+  set_target_properties(test-depends PROPERTIES FOLDER "LLVM/Tests")
   add_dependencies(check-all test-depends)
 endif()
 
@@ -1343,7 +1345,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   # Installing the headers needs to depend on generating any public
   # tablegen'd headers.
   add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen)
-  

[libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89755
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] [llvm] [libclc] Revise IDE folder structure (PR #89746)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89746
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Revise IDE folder structure (PR #89743)

2024-05-25 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

Sorry for the notification noise. For some reason, when committing the parent 
PR, it closed this one.

https://github.com/llvm/llvm-project/pull/89743
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Revise IDE folder structure (PR #89743)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/89743
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89744
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Revise IDE folder structure (PR #89743)

2024-05-25 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89743
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)

2024-05-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/92916
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-22 Thread Michael Kruse via cfe-commits


@@ -156,9 +156,9 @@ extern "C" void body(...) {}
 // IR-EMPTY:
 // IR-NEXT:  [[FOR_INC]]:
 // IR-NEXT:%[[TMP34:.+]] = load i32, ptr %[[DOTTILE_0_IV_I]], align 4
-// IR-NEXT:%[[INC:.+]] = add nsw i32 %[[TMP34]], 1
+// IR-NEXT:%[[INC:.+]] = add i32 %[[TMP34]], 1

Meinersbur wrote:

`nuw` would be an idea for a Clang extension in the footsteps of [vector 
extensions](https://releases.llvm.org/18.1.1/tools/clang/docs/LanguageExtensions.html#vectors-and-extended-vectors)
 or 
[`_ExtInt`](http://blog.llvm.org/2020/04/the-new-clang-extint-feature-provides.html)
 which also exposed a feature that LLVM always supported. E.g. 
```
typedef unsigned nowrap_unsigned_t __attribute__((ext_no_wrap));
for (nowrap_unsigned_t i = 0; i < n; ++i)
```
or
```
int [[clang::]]
```
However, the language consequences are immense.

https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-22 Thread Michael Kruse via cfe-commits


@@ -156,9 +156,9 @@ extern "C" void body(...) {}
 // IR-EMPTY:
 // IR-NEXT:  [[FOR_INC]]:
 // IR-NEXT:%[[TMP34:.+]] = load i32, ptr %[[DOTTILE_0_IV_I]], align 4
-// IR-NEXT:%[[INC:.+]] = add nsw i32 %[[TMP34]], 1
+// IR-NEXT:%[[INC:.+]] = add i32 %[[TMP34]], 1

Meinersbur wrote:

This is due to the change of using the type of `LoopHelper.NumIterations` (an 
unsigned integer) as the new loop's induction variable (instead of the original 
loop's iteration variable type). In iterator-based loops that type would be 
incompatible with `LoopHelper.NumIterations` which remains an integer.

Even if the original loop variable is a signed integer (it could be a 
(`std::iota_view`)[https://en.cppreference.com/w/cpp/ranges/iota_view] over the 
same range), using and unsigned type is more correct as long as we start 
counting at 0. For instance, the loop
```
#pragma omp tile sizes(2)
for (int i = INT_MIN; i < INT_MAX; ++i)
```
would overflow the `nsw` flag.

The "most correct" fix would be to add the `nuw` flag. Unfortunately there is 
no AST expression we could create that would make CodeGen generate one. 
Alternatively, I could make generated loops start counting at `INT_MIN`.

https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-21 Thread Michael Kruse via cfe-commits


@@ -182,17 +182,34 @@ class OMPLoopScope : public 
CodeGenFunction::RunCleanupsScope {
 }
 return false;
   });
-  PreInits = cast_or_null(LD->getPreInits());
+  PreInits = LD->getPreInits();
 } else if (const auto *Tile = dyn_cast()) {
-  PreInits = cast_or_null(Tile->getPreInits());
+  PreInits = Tile->getPreInits();
 } else if (const auto *Unroll = dyn_cast()) {
-  PreInits = cast_or_null(Unroll->getPreInits());
+  PreInits = Unroll->getPreInits();
 } else {
   llvm_unreachable("Unknown loop-based directive kind.");
 }
 if (PreInits) {
-  for (const auto *I : PreInits->decls())
-CGF.EmitVarDecl(cast(*I));
+  // CompoundStmts and DeclStmts are used as lists of PreInit statements 
and
+  // declarations. Since declarations must be visible in the the following
+  // that they initialize, unpack the ComboundStmt they are nested in.
+  SmallVector PreInitStmts;
+  if (auto *PreInitCompound = dyn_cast(PreInits))
+llvm::append_range(PreInitStmts, PreInitCompound->body());
+  else
+PreInitStmts.push_back(PreInits);
+
+  for (const Stmt *S : PreInitStmts) {
+// EmitStmt skips any OMPCapturedExprDecls, but needs to be emitted
+// here.
+if (auto *PreInitDecl = dyn_cast(S)) {

Meinersbur wrote:

Everything else is emitted in `CGF.EmitStmt(S);` at line 211.

`CGF.EmitStmt(S)` does itself call `CGF.EmitVarDecl(S)` if passed a DeclStmts, 
so this special handling should not be necessary. It includes, however, an 
exception for `OMPCapturedExprDecl` (subclass of `VarDecl`) that are NOT 
emitted so we need to do this explicitly here. Otherwise, lines 203-212 would 
be just a single `CGF.EmitStmt(S)`.

https://github.com/llvm/llvm-project/blob/a15b685c2d868eaf408d05baa50baa3c9f5cc740/clang/lib/CodeGen/CGDecl.cpp#L129

https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-13 Thread Michael Kruse via cfe-commits


@@ -182,17 +182,34 @@ class OMPLoopScope : public 
CodeGenFunction::RunCleanupsScope {
 }
 return false;
   });
-  PreInits = cast_or_null(LD->getPreInits());
+  PreInits = LD->getPreInits();
 } else if (const auto *Tile = dyn_cast()) {
-  PreInits = cast_or_null(Tile->getPreInits());
+  PreInits = Tile->getPreInits();
 } else if (const auto *Unroll = dyn_cast()) {
-  PreInits = cast_or_null(Unroll->getPreInits());
+  PreInits = Unroll->getPreInits();
 } else {
   llvm_unreachable("Unknown loop-based directive kind.");
 }
 if (PreInits) {
-  for (const auto *I : PreInits->decls())
-CGF.EmitVarDecl(cast(*I));
+  // CompoundStmts and DeclStmts are used as lists of PreInit statements 
and
+  // declarations. Since declarations must be visible in the the following
+  // that they initialize, unpack the ComboundStmt they are nested in.
+  SmallVector PreInitStmts;
+  if (auto *PreInitCompound = dyn_cast(PreInits))

Meinersbur wrote:

This is explained in the summary. In essence, the init-statement for a C++20 
foreach-loop does not need to be a DeclStmt, but can be an arbitrary Stmt.

https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-05-13 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

@jakeegan  Sorry, didn't see you comment over an extended weekend.

https://github.com/llvm/llvm-project/pull/88948
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)

2024-05-13 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/91345
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)

2024-05-13 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/91459
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)

2024-05-13 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/91345

>From 855a84814eb8d263427bce7837af61e67eb2db95 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 7 May 2024 14:47:45 +0200
Subject: [PATCH 1/6] Make unique instances

---
 clang/lib/Sema/SemaOpenMP.cpp | 75 +++
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cf5447f223d45..fff4c7350f0f7 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15109,6 +15109,8 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 SourceLocation StartLoc,
 SourceLocation EndLoc) {
   ASTContext  = getASTContext();
+  Scope *CurScope = SemaRef.getCurScope();
+
   auto SizesClauses =
   OMPExecutableDirective::getClausesOfKind(Clauses);
   if (SizesClauses.empty()) {
@@ -15137,6 +15139,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 NumLoops, AStmt, nullptr, nullptr);
 
   SmallVector PreInits;
+  CaptureVars CopyTransformer(SemaRef);
 
   // Create iteration variables for the generated loops.
   SmallVector FloorIndVars;
@@ -15200,19 +15203,30 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 Expr *NumIterations = LoopHelper.NumIterations;
 auto *OrigCntVar = cast(LoopHelper.Counters[0]);
 QualType CntTy = OrigCntVar->getType();
-Expr *DimTileSize = SizesClause->getSizesRefs()[I];
-Scope *CurScope = SemaRef.getCurScope();
 
-// Commonly used variables.
-DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
-   OrigCntVar->getExprLoc());
-DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
-OrigCntVar->getExprLoc());
+// Commonly used variables. One of the constraints of an AST is that every
+// node object must appear at most once, hence we define lamdas that create
+// a new AST node at every use.
+auto MakeDimTileSize = [ = this->SemaRef, , I,
+SizesClause]() -> Expr * {
+  Expr *DimTileSize = SizesClause->getSizesRefs()[I];
+  return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize));
+};
+auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy,
+  OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
+auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy,
+   OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
 
 // For init-statement: auto .tile.iv = .floor.iv
-SemaRef.AddInitializerToDecl(TileIndVars[I],
- 
SemaRef.DefaultLvalueConversion(FloorIV).get(),
- /*DirectInit=*/false);
+SemaRef.AddInitializerToDecl(
+TileIndVars[I], 
SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
+/*DirectInit=*/false);
 Decl *CounterDecl = TileIndVars[I];
 StmtResult InitStmt = new (Context)
 DeclStmt(DeclGroupRef::Create(Context, , 1),
@@ -15220,10 +15234,11 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 if (!InitStmt.isUsable())
   return StmtError();
 
-// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize,
-// NumIterations)
-ExprResult EndOfTile = SemaRef.BuildBinOp(
-CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize);
+// For cond-expression:
+//   .tile.iv < min(.floor.iv + DimTileSize, NumIterations)
+ExprResult EndOfTile =
+SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
+   MakeFloorIVRef(), MakeDimTileSize());
 if (!EndOfTile.isUsable())
   return StmtError();
 ExprResult IsPartialTile =
@@ -15238,25 +15253,28 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
   return StmtError();
 ExprResult CondExpr =
 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
-   TileIV, MinTileAndIterSpace.get());
+   MakeTileIVRef(), MinTileAndIterSpace.get());
 if (!CondExpr.isUsable())
   return StmtError();
 
 // For incr-statement: ++.tile.iv
 ExprResult IncrStmt = SemaRef.BuildUnaryOp(
-CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV);
+CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef());
 if (!IncrStmt.isUsable())
   return StmtError();
 
 // Statements to set the original iteration variable's value from the
 // logical iteration 

[clang] f059058 - [Clang][OpenMP] Fix unused lambda capture warning.

2024-05-13 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2024-05-13T14:55:34+02:00
New Revision: f0590581aa01944a3bb502a622a412617d1efcbb

URL: 
https://github.com/llvm/llvm-project/commit/f0590581aa01944a3bb502a622a412617d1efcbb
DIFF: 
https://github.com/llvm/llvm-project/commit/f0590581aa01944a3bb502a622a412617d1efcbb.diff

LOG: [Clang][OpenMP] Fix unused lambda capture warning.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index fff4c7350f0f7..2475f962fd0df 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15207,8 +15207,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 // Commonly used variables. One of the constraints of an AST is that every
 // node object must appear at most once, hence we define lamdas that create
 // a new AST node at every use.
-auto MakeDimTileSize = [ = this->SemaRef, , I,
-SizesClause]() -> Expr * {
+auto MakeDimTileSize = [, I, SizesClause]() -> Expr * {
   Expr *DimTileSize = SizesClause->getSizesRefs()[I];
   return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize));
 };
@@ -15298,8 +15297,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 QualType CntTy = OrigCntVar->getType();
 
 // Commonly used variables.
-auto MakeDimTileSize = [ = this->SemaRef, , I,
-SizesClause]() -> Expr * {
+auto MakeDimTileSize = [, I, SizesClause]() -> Expr * {
   Expr *DimTileSize = SizesClause->getSizesRefs()[I];
   return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize));
 };



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-13 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/91325
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Clang][OpenMP][Tile] Allow non-constant tile sizes. (PR #91345)

2024-05-13 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/91345
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-08 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur ready_for_review 
https://github.com/llvm/llvm-project/pull/91325
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-08 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

Test failure is from unrelated test `DataFlowSanitizer-x86_64 :: 
release_shadow_space.c`

https://github.com/llvm/llvm-project/pull/91325
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/91325

>From 855a84814eb8d263427bce7837af61e67eb2db95 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 7 May 2024 14:47:45 +0200
Subject: [PATCH] Make unique instances

---
 clang/lib/Sema/SemaOpenMP.cpp | 75 +++
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cf5447f223d450..fff4c7350f0f75 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15109,6 +15109,8 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 SourceLocation StartLoc,
 SourceLocation EndLoc) {
   ASTContext  = getASTContext();
+  Scope *CurScope = SemaRef.getCurScope();
+
   auto SizesClauses =
   OMPExecutableDirective::getClausesOfKind(Clauses);
   if (SizesClauses.empty()) {
@@ -15137,6 +15139,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 NumLoops, AStmt, nullptr, nullptr);
 
   SmallVector PreInits;
+  CaptureVars CopyTransformer(SemaRef);
 
   // Create iteration variables for the generated loops.
   SmallVector FloorIndVars;
@@ -15200,19 +15203,30 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 Expr *NumIterations = LoopHelper.NumIterations;
 auto *OrigCntVar = cast(LoopHelper.Counters[0]);
 QualType CntTy = OrigCntVar->getType();
-Expr *DimTileSize = SizesClause->getSizesRefs()[I];
-Scope *CurScope = SemaRef.getCurScope();
 
-// Commonly used variables.
-DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
-   OrigCntVar->getExprLoc());
-DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
-OrigCntVar->getExprLoc());
+// Commonly used variables. One of the constraints of an AST is that every
+// node object must appear at most once, hence we define lamdas that create
+// a new AST node at every use.
+auto MakeDimTileSize = [ = this->SemaRef, , I,
+SizesClause]() -> Expr * {
+  Expr *DimTileSize = SizesClause->getSizesRefs()[I];
+  return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize));
+};
+auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy,
+  OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
+auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy,
+   OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
 
 // For init-statement: auto .tile.iv = .floor.iv
-SemaRef.AddInitializerToDecl(TileIndVars[I],
- 
SemaRef.DefaultLvalueConversion(FloorIV).get(),
- /*DirectInit=*/false);
+SemaRef.AddInitializerToDecl(
+TileIndVars[I], 
SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
+/*DirectInit=*/false);
 Decl *CounterDecl = TileIndVars[I];
 StmtResult InitStmt = new (Context)
 DeclStmt(DeclGroupRef::Create(Context, , 1),
@@ -15220,10 +15234,11 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 if (!InitStmt.isUsable())
   return StmtError();
 
-// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize,
-// NumIterations)
-ExprResult EndOfTile = SemaRef.BuildBinOp(
-CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize);
+// For cond-expression:
+//   .tile.iv < min(.floor.iv + DimTileSize, NumIterations)
+ExprResult EndOfTile =
+SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
+   MakeFloorIVRef(), MakeDimTileSize());
 if (!EndOfTile.isUsable())
   return StmtError();
 ExprResult IsPartialTile =
@@ -15238,25 +15253,28 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
   return StmtError();
 ExprResult CondExpr =
 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
-   TileIV, MinTileAndIterSpace.get());
+   MakeTileIVRef(), MinTileAndIterSpace.get());
 if (!CondExpr.isUsable())
   return StmtError();
 
 // For incr-statement: ++.tile.iv
 ExprResult IncrStmt = SemaRef.BuildUnaryOp(
-CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV);
+CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef());
 if (!IncrStmt.isUsable())
   return StmtError();
 
 // Statements to set the original iteration variable's value from the
 // logical iteration 

[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/91325

>From 42b1e6d435acaf8283ce7a0246f076a367ca876c Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 7 May 2024 14:47:45 +0200
Subject: [PATCH 1/2] Make unique instances

---
 clang/lib/Sema/SemaOpenMP.cpp | 75 +++
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cf5447f223d45..1cffe051e5377 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15109,6 +15109,8 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 SourceLocation StartLoc,
 SourceLocation EndLoc) {
   ASTContext  = getASTContext();
+  Scope *CurScope = SemaRef.getCurScope();
+
   auto SizesClauses =
   OMPExecutableDirective::getClausesOfKind(Clauses);
   if (SizesClauses.empty()) {
@@ -15137,6 +15139,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 NumLoops, AStmt, nullptr, nullptr);
 
   SmallVector PreInits;
+  CaptureVars CopyTransformer(SemaRef);
 
   // Create iteration variables for the generated loops.
   SmallVector FloorIndVars;
@@ -15200,19 +15203,30 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 Expr *NumIterations = LoopHelper.NumIterations;
 auto *OrigCntVar = cast(LoopHelper.Counters[0]);
 QualType CntTy = OrigCntVar->getType();
-Expr *DimTileSize = SizesClause->getSizesRefs()[I];
-Scope *CurScope = SemaRef.getCurScope();
 
-// Commonly used variables.
-DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
-   OrigCntVar->getExprLoc());
-DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
-OrigCntVar->getExprLoc());
+// Commonly used variables. One of the constraints of an AST is that every
+// node object must appear at most once, hence we define lamdas that create
+// a new AST node at every use.
+auto MakeDimTileSize = [ = this->SemaRef, , I,
+SizesClause]() -> Expr * {
+  Expr *DimTileSize = SizesClause->getSizesRefs()[I];
+  return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize));
+};
+auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy,
+  OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
+auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy,
+   OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
 
 // For init-statement: auto .tile.iv = .floor.iv
-SemaRef.AddInitializerToDecl(TileIndVars[I],
- 
SemaRef.DefaultLvalueConversion(FloorIV).get(),
- /*DirectInit=*/false);
+SemaRef.AddInitializerToDecl(
+TileIndVars[I], 
SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
+/*DirectInit=*/false);
 Decl *CounterDecl = TileIndVars[I];
 StmtResult InitStmt = new (Context)
 DeclStmt(DeclGroupRef::Create(Context, , 1),
@@ -15220,10 +15234,11 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 if (!InitStmt.isUsable())
   return StmtError();
 
-// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize,
-// NumIterations)
-ExprResult EndOfTile = SemaRef.BuildBinOp(
-CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize);
+// For cond-expression:
+//   .tile.iv < min(.floor.iv + DimTileSize, NumIterations)
+ExprResult EndOfTile =
+SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
+   MakeFloorIVRef(), MakeDimTileSize());
 if (!EndOfTile.isUsable())
   return StmtError();
 ExprResult IsPartialTile =
@@ -15238,25 +15253,28 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
   return StmtError();
 ExprResult CondExpr =
 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
-   TileIV, MinTileAndIterSpace.get());
+   MakeTileIVRef(), MinTileAndIterSpace.get());
 if (!CondExpr.isUsable())
   return StmtError();
 
 // For incr-statement: ++.tile.iv
 ExprResult IncrStmt = SemaRef.BuildUnaryOp(
-CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV);
+CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef());
 if (!IncrStmt.isUsable())
   return StmtError();
 
 // Statements to set the original iteration variable's value from the
 // logical iteration 

[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/91325

>From 42b1e6d435acaf8283ce7a0246f076a367ca876c Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 7 May 2024 14:47:45 +0200
Subject: [PATCH] Make unique instances

---
 clang/lib/Sema/SemaOpenMP.cpp | 75 +++
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cf5447f223d45..1cffe051e5377 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15109,6 +15109,8 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 SourceLocation StartLoc,
 SourceLocation EndLoc) {
   ASTContext  = getASTContext();
+  Scope *CurScope = SemaRef.getCurScope();
+
   auto SizesClauses =
   OMPExecutableDirective::getClausesOfKind(Clauses);
   if (SizesClauses.empty()) {
@@ -15137,6 +15139,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 NumLoops, AStmt, nullptr, nullptr);
 
   SmallVector PreInits;
+  CaptureVars CopyTransformer(SemaRef);
 
   // Create iteration variables for the generated loops.
   SmallVector FloorIndVars;
@@ -15200,19 +15203,30 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 Expr *NumIterations = LoopHelper.NumIterations;
 auto *OrigCntVar = cast(LoopHelper.Counters[0]);
 QualType CntTy = OrigCntVar->getType();
-Expr *DimTileSize = SizesClause->getSizesRefs()[I];
-Scope *CurScope = SemaRef.getCurScope();
 
-// Commonly used variables.
-DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
-   OrigCntVar->getExprLoc());
-DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
-OrigCntVar->getExprLoc());
+// Commonly used variables. One of the constraints of an AST is that every
+// node object must appear at most once, hence we define lamdas that create
+// a new AST node at every use.
+auto MakeDimTileSize = [ = this->SemaRef, , I,
+SizesClause]() -> Expr * {
+  Expr *DimTileSize = SizesClause->getSizesRefs()[I];
+  return AssertSuccess(CopyTransformer.TransformExpr(DimTileSize));
+};
+auto MakeTileIVRef = [ = this->SemaRef, , I, CntTy,
+  OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
+auto MakeFloorIVRef = [ = this->SemaRef, , I, CntTy,
+   OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
+  OrigCntVar->getExprLoc());
+};
 
 // For init-statement: auto .tile.iv = .floor.iv
-SemaRef.AddInitializerToDecl(TileIndVars[I],
- 
SemaRef.DefaultLvalueConversion(FloorIV).get(),
- /*DirectInit=*/false);
+SemaRef.AddInitializerToDecl(
+TileIndVars[I], 
SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
+/*DirectInit=*/false);
 Decl *CounterDecl = TileIndVars[I];
 StmtResult InitStmt = new (Context)
 DeclStmt(DeclGroupRef::Create(Context, , 1),
@@ -15220,10 +15234,11 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 if (!InitStmt.isUsable())
   return StmtError();
 
-// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize,
-// NumIterations)
-ExprResult EndOfTile = SemaRef.BuildBinOp(
-CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize);
+// For cond-expression:
+//   .tile.iv < min(.floor.iv + DimTileSize, NumIterations)
+ExprResult EndOfTile =
+SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
+   MakeFloorIVRef(), MakeDimTileSize());
 if (!EndOfTile.isUsable())
   return StmtError();
 ExprResult IsPartialTile =
@@ -15238,25 +15253,28 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
   return StmtError();
 ExprResult CondExpr =
 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
-   TileIV, MinTileAndIterSpace.get());
+   MakeTileIVRef(), MinTileAndIterSpace.get());
 if (!CondExpr.isUsable())
   return StmtError();
 
 // For incr-statement: ++.tile.iv
 ExprResult IncrStmt = SemaRef.BuildUnaryOp(
-CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, TileIV);
+CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc, MakeTileIVRef());
 if (!IncrStmt.isUsable())
   return StmtError();
 
 // Statements to set the original iteration variable's value from the
 // logical iteration 

[clang] [Clang][OpenMP][Tile] Ensure AST node uniqueness. (PR #91325)

2024-05-07 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/91325

One of the constraints of an AST is that every node object must appear at most 
once, hence we define lamdas that create a new AST node at every use.

>From 1c1910b6885cd5be18cb15e364569f2a2f662955 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 7 May 2024 14:47:45 +0200
Subject: [PATCH] Make unique instances

---
 clang/lib/Sema/SemaOpenMP.cpp |  77 ++--
 clang/test/OpenMP/tile_codegen.cpp|  58 +--
 .../OpenMP/tile_codegen_for_dependent.cpp | 326 +++--
 clang/test/OpenMP/tile_codegen_tile_for.cpp   | 435 +-
 4 files changed, 447 insertions(+), 449 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cf5447f223d45..ba86bd4e62786 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15109,6 +15109,8 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 SourceLocation StartLoc,
 SourceLocation EndLoc) {
   ASTContext  = getASTContext();
+  Scope *CurScope = SemaRef.getCurScope();
+
   auto SizesClauses =
   OMPExecutableDirective::getClausesOfKind(Clauses);
   if (SizesClauses.empty()) {
@@ -15137,6 +15139,7 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 NumLoops, AStmt, nullptr, nullptr);
 
   SmallVector PreInits;
+  CaptureVars CopyTransformer(SemaRef);
 
   // Create iteration variables for the generated loops.
   SmallVector FloorIndVars;
@@ -15194,25 +15197,37 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
   // Once the original iteration values are set, append the innermost body.
   Stmt *Inner = Body;
 
+  auto MakeDimTileSize = [ = this->SemaRef, , ,
+  SizesClause, CurScope](int I) -> Expr * {
+Expr *DimTileSizeExpr = SizesClause->getSizesRefs()[I];
+return AssertSuccess(CopyTransformer.TransformExpr(DimTileSizeExpr));
+  };
+
   // Create tile loops from the inside to the outside.
   for (int I = NumLoops - 1; I >= 0; --I) {
 OMPLoopBasedDirective::HelperExprs  = LoopHelpers[I];
 Expr *NumIterations = LoopHelper.NumIterations;
 auto *OrigCntVar = cast(LoopHelper.Counters[0]);
-QualType CntTy = OrigCntVar->getType();
-Expr *DimTileSize = SizesClause->getSizesRefs()[I];
-Scope *CurScope = SemaRef.getCurScope();
-
-// Commonly used variables.
-DeclRefExpr *TileIV = buildDeclRefExpr(SemaRef, TileIndVars[I], CntTy,
-   OrigCntVar->getExprLoc());
-DeclRefExpr *FloorIV = buildDeclRefExpr(SemaRef, FloorIndVars[I], CntTy,
-OrigCntVar->getExprLoc());
+QualType IVTy = NumIterations->getType();
+
+// Commonly used variables. One of the constraints of an AST is that every
+// node object must appear at most once, hence we define lamdas that create
+// a new AST node at every use.
+auto MakeTileIVRef = [ = this->SemaRef, , I, IVTy,
+  OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, TileIndVars[I], IVTy,
+  OrigCntVar->getExprLoc());
+};
+auto MakeFloorIVRef = [ = this->SemaRef, , I, IVTy,
+   OrigCntVar]() {
+  return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy,
+  OrigCntVar->getExprLoc());
+};
 
 // For init-statement: auto .tile.iv = .floor.iv
-SemaRef.AddInitializerToDecl(TileIndVars[I],
- 
SemaRef.DefaultLvalueConversion(FloorIV).get(),
- /*DirectInit=*/false);
+SemaRef.AddInitializerToDecl(
+TileIndVars[I], 
SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
+/*DirectInit=*/false);
 Decl *CounterDecl = TileIndVars[I];
 StmtResult InitStmt = new (Context)
 DeclStmt(DeclGroupRef::Create(Context, , 1),
@@ -15220,10 +15235,11 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
 if (!InitStmt.isUsable())
   return StmtError();
 
-// For cond-expression: .tile.iv < min(.floor.iv + DimTileSize,
-// NumIterations)
-ExprResult EndOfTile = SemaRef.BuildBinOp(
-CurScope, LoopHelper.Cond->getExprLoc(), BO_Add, FloorIV, DimTileSize);
+// For cond-expression:
+//   .tile.iv < min(.floor.iv + DimTileSize, NumIterations)
+ExprResult EndOfTile =
+SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
+   MakeFloorIVRef(), MakeDimTileSize(I));
 if (!EndOfTile.isUsable())
   return StmtError();
 ExprResult IsPartialTile =
@@ -15238,25 +15254,28 @@ StmtResult 
SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses,
   return StmtError();
 ExprResult CondExpr =
 

[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-05-06 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/88948
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-04-30 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

I accidentally pushed a Foxtrot merge. Will push once the pre-merge bot is 
happy.

Thanks for the review.

https://github.com/llvm/llvm-project/pull/88948
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-04-30 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/88948

>From d2cd62082b6967215e6fb7eb975377a01052b79a Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 16 Apr 2024 19:50:35 +0200
Subject: [PATCH 1/2] Do not warn about unused plugin flags.

Plugins are not loaded without the -cc1 phase. Do not report them when
running on a assembly file or when linking. Many build tools add these
options to all driver invocations. See GH #88173.
---
 clang/include/clang/Driver/Options.td | 6 +++---
 clang/test/Driver/clang-s-plugin.s| 5 +
 2 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Driver/clang-s-plugin.s

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 086aedefc11878..73ad01f2be8861 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3645,14 +3645,14 @@ defm rwpi : BoolFOption<"rwpi",
   "Generate read-write position independent code (ARM only)">,
   NegFlag>;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group,
-  Flags<[NoXarchOption]>, MetaVarName<"">,
+  Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
 def fplugin_arg : Joined<["-"], "fplugin-arg-">,
-  MetaVarName<"-">,
+  MetaVarName<"-">, Flags<[NoArgumentUnused]>,
   HelpText<"Pass  to plugin ">;
 def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
   Group, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  MetaVarName<"">,
+  MetaVarName<"">, Flags<[NoArgumentUnused]>,
   HelpText<"Load pass plugin from a dynamic shared object file (only with new 
pass manager).">,
   MarshallingInfoStringVector>;
 defm tocdata : BoolOption<"m","tocdata",
diff --git a/clang/test/Driver/clang-s-plugin.s 
b/clang/test/Driver/clang-s-plugin.s
new file mode 100644
index 00..81169b7bc5bbc8
--- /dev/null
+++ b/clang/test/Driver/clang-s-plugin.s
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so 
-fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s
+
+// Plugins are only relevant for the -cc1 phase. No warning should be raised
+// when applied to assembly files. See GH #88173.
+// CHECK-NOT: argument unused during compilation

>From 6e22e57300eba3ba8506c056c091d19d4c249bc5 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 30 Apr 2024 14:56:57 +0200
Subject: [PATCH 2/2] Address reviewer comment

---
 clang/test/Driver/clang-s-plugin.s   | 5 -
 clang/test/Driver/plugin-driver-args.cpp | 5 +
 2 files changed, 5 insertions(+), 5 deletions(-)
 delete mode 100644 clang/test/Driver/clang-s-plugin.s

diff --git a/clang/test/Driver/clang-s-plugin.s 
b/clang/test/Driver/clang-s-plugin.s
deleted file mode 100644
index 81169b7bc5bbc8..00
--- a/clang/test/Driver/clang-s-plugin.s
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so 
-fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s
-
-// Plugins are only relevant for the -cc1 phase. No warning should be raised
-// when applied to assembly files. See GH #88173.
-// CHECK-NOT: argument unused during compilation
diff --git a/clang/test/Driver/plugin-driver-args.cpp 
b/clang/test/Driver/plugin-driver-args.cpp
index d6475b4b3d733a..6f0e6e2ba75251 100644
--- a/clang/test/Driver/plugin-driver-args.cpp
+++ b/clang/test/Driver/plugin-driver-args.cpp
@@ -20,3 +20,8 @@
 
 // RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext 
-fplugin-arg-testname- -fsyntax-only %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-PLUGIN-ARG2
 // CHECK-NO-PLUGIN-ARG2: missing plugin argument for plugin testname in 
-fplugin-arg-testname-
+
+// Plugins are only relevant for the -cc1 phase. No warning should be raised
+// when only using the assembler. See GH #88173.
+// RUN: %clang -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option 
-Werror -x assembler %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PLUGIN-ASM
+// CHECK-PLUGIN-ASM-NOT: argument unused during compilation

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-23 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

As suggested, I split the patch into per-subproject patches:

[LLVM](https://github.com/llvm/llvm-project/pull/89741) (dependency of the 
other patches)
[BOLT](https://github.com/llvm/llvm-project/pull/89742)
[Clang](https://github.com/llvm/llvm-project/pull/89743)
[Clang-Tools-Extra](https://github.com/llvm/llvm-project/pull/89744)
[Compiler-RT](https://github.com/llvm/llvm-project/pull/89753)
[Flang](https://github.com/llvm/llvm-project/pull/89745)
[libclc](https://github.com/llvm/llvm-project/pull/89746)
[LLD](https://github.com/llvm/llvm-project/pull/89747)
[LLDB](https://github.com/llvm/llvm-project/pull/89748)
[MLIR](https://github.com/llvm/llvm-project/pull/89749)
[OpenMP](https://github.com/llvm/llvm-project/pull/89750)
[Polly](https://github.com/llvm/llvm-project/pull/89752)
[Misc](https://github.com/llvm/llvm-project/pull/89755)

https://github.com/llvm/llvm-project/pull/89153
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-23 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89153
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-22 Thread Michael Kruse via cfe-commits


@@ -406,5 +426,13 @@ function(llvm_ExternalProject_Add name source_dir)
   WORKING_DIRECTORY ${BINARY_DIR}
   VERBATIM
   USES_TERMINAL)
+if (ARG_FOLDER)
+  set_target_properties(${target} PROPERTIES FOLDER "${ARG_FOLDER}")
+endif ()
   endforeach()
+
+  #set_target_folder(
+  #  TARGETS ${name} install-${name} ${name}-clobber ${name}-clear 
${name}-clean ${ARG_EXTRA_TARGETS}
+  #  FOLDER "${ARG_FOLDE}"
+  #)

Meinersbur wrote:

thanks

https://github.com/llvm/llvm-project/pull/89153
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-22 Thread Michael Kruse via cfe-commits


@@ -56,11 +56,13 @@ endfunction()
 # Use provided strip tool instead of the default one.
 #   TARGET_TRIPLE triple
 # Optional target triple to pass to the compiler
+#   FOLDER
+# For IDEs, the Folder to put the targets into.=

Meinersbur wrote:

It's already called FOLDER in 
https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/AddLLVM.cmake#L2080-L2083.
 I would prefer to keep it consistent.

https://github.com/llvm/llvm-project/pull/89153
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur ready_for_review 
https://github.com/llvm/llvm-project/pull/89153
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)

2024-04-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur closed 
https://github.com/llvm/llvm-project/pull/88932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)

2024-04-22 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

> IIRC it was unnecessary for the documentation because it gets built multiple 
> times, for the driver it's built once so it has to include all possible 
> variants the first time.
> 
> I have no preference for how it's done, if the `%Program` thing works then 
> fine. We only need a `ForVariants` if it's something people see when 
> interacting with Flang itself I think.

I didn't know this and experimented a bit. Indeed `%Program` in `HelpText` gets 
emitted as "Clang" in `flang-new --help`. `DocBrief` and `HelpText` are "Flang" 
for `FlangCommandLineReference.rst`.

So `DocBriefForVariant` would not add new functionality, but might be useful so 
`DocBrief[ForVariant]` and `HelpText[ForVariant]` can use the same syntax and 
avoid confusion. I will merge this patch and work on `DocBriefForVariant` after 
that.

https://github.com/llvm/llvm-project/pull/88932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-04-22 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur ready_for_review 
https://github.com/llvm/llvm-project/pull/88948
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)

2024-04-17 Thread Michael Kruse via cfe-commits


@@ -807,8 +807,12 @@ def gcc_install_dir_EQ : Joined<["--"], 
"gcc-install-dir=">,
   "Note: executables (e.g. ld) used by the compiler are not overridden by the 
selected GCC installation">;
 def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, FlangOption]>,
-  HelpText<"Specify a directory where Clang can find 'include' and 
'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
-  "Clang will use the GCC installation with the largest version">;
+  HelpText<
+"Specify a directory where Clang can find 'include' and 
'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
+"Clang will use the GCC installation with the largest version">,
+  HelpTextForVariants<[FlangOption],
+"Specify a directory where Flang can find 
'lib{,32,64}/gcc{,-cross}/$triple/$version'. "

Meinersbur wrote:

Even though flang has a (non-standard) preprocessor, it doesn't add `-isystem` 
includes from gcc's dir. Hence referencing `include` could be confusing.

https://github.com/llvm/llvm-project/pull/88932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)

2024-04-17 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

> Do you mean that this PR fixes this, or that you noticed this problem while 
> working on this?

I noticed this when working on the patch, .i.e that 
https://flang.llvm.org/docs/FlangCommandLineReference.html still mentioned 
Clang in several places and since it was common, I didn't want to fix it only 
for `--gcc-toolchain`. `HelpTextForVariants` was introduced later, reducing the 
number of "Clang" in FlangCommandLineReference already. This fixes 
`--gcc-toolchain`, but there is no list of warnings supported by Flang, so I 
don't have anything beyond what #81726  already did.

> If it's the latter it may be as @banach-space mentioned to me, that the 
> `docbrief` is still shared between Flang and Clang. This could be solved in a 
> similar, albeit tedious way to what I did for the help text.

The docbrief strings already use `%Program`/`GlobalDocumentation.Program` which 
seems to work and made me think that `HelpTextForVariants` was actually 
unnecessary. Would you like me to introduce `DocBriefForVariants`?


> @Meinersbur Could you share an example? If it's a problem specific to 
> diagnostics then we should possibly just start separating Clang and Flang 
> diagnostics. That could mean a bit of duplication, but not too much, so I'm 
> not worried.

```
def Diag_Group : OptionGroup<"">, Group,
 DocName<"Diagnostic options">,
 DocBrief.str,
   !cond(!eq(GlobalDocumentation.Program, "Clang"):
   "See the :doc:`full list of warning and remark flags 
`.",
 true:
   "See Clang's Diagnostic Reference for a full list of 
warning and remark flags."
   )
 )>;
```


https://github.com/llvm/llvm-project/pull/88932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)

2024-04-17 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur ready_for_review 
https://github.com/llvm/llvm-project/pull/88932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Avoid mentions of Clang in Flang's command line reference. (PR #88932)

2024-04-16 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/88932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-04-16 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/88948
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >