Compare commits
No commits in common. "d2eafd26d8fb260370259215ad1a89bd83aab597" and "550a32921a01914ef92c1fab856565818a791de9" have entirely different histories.
d2eafd26d8
...
550a32921a
@ -1,72 +0,0 @@
|
|||||||
From 28e3fc80336935bc8bed372e78616ef5be9f4908 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Arthur Eubanks <aeubanks@google.com>
|
|
||||||
Date: Thu, 27 Jul 2023 13:27:58 -0700
|
|
||||||
Subject: [PATCH] Don't zero out noreg operands
|
|
||||||
|
|
||||||
A tail call may have $noreg operands.
|
|
||||||
|
|
||||||
Fixes a crash.
|
|
||||||
|
|
||||||
Reviewed By: xgupta
|
|
||||||
|
|
||||||
Differential Revision: https://reviews.llvm.org/D156485
|
|
||||||
---
|
|
||||||
llvm/lib/CodeGen/PrologEpilogInserter.cpp | 9 +++++++--
|
|
||||||
llvm/test/CodeGen/X86/zero-call-used-regs.ll | 14 ++++++++++++++
|
|
||||||
2 files changed, 21 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
|
|
||||||
index e323aaaeefaf..49047719fdaa 100644
|
|
||||||
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
|
|
||||||
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
|
|
||||||
@@ -1285,6 +1285,8 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
|
|
||||||
continue;
|
|
||||||
|
|
||||||
MCRegister Reg = MO.getReg();
|
|
||||||
+ if (!Reg)
|
|
||||||
+ continue;
|
|
||||||
|
|
||||||
// This picks up sibling registers (e.q. %al -> %ah).
|
|
||||||
for (MCRegUnit Unit : TRI.regunits(Reg))
|
|
||||||
@@ -1308,8 +1310,11 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
|
|
||||||
if (!MO.isReg())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
- for (const MCPhysReg &Reg :
|
|
||||||
- TRI.sub_and_superregs_inclusive(MO.getReg()))
|
|
||||||
+ MCRegister Reg = MO.getReg();
|
|
||||||
+ if (!Reg)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ for (const MCPhysReg Reg : TRI.sub_and_superregs_inclusive(Reg))
|
|
||||||
RegsToZero.reset(Reg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/llvm/test/CodeGen/X86/zero-call-used-regs.ll b/llvm/test/CodeGen/X86/zero-call-used-regs.ll
|
|
||||||
index 63d51c916bb9..97ad5ce9c8cb 100644
|
|
||||||
--- a/llvm/test/CodeGen/X86/zero-call-used-regs.ll
|
|
||||||
+++ b/llvm/test/CodeGen/X86/zero-call-used-regs.ll
|
|
||||||
@@ -241,6 +241,20 @@ entry:
|
|
||||||
ret i32 %x
|
|
||||||
}
|
|
||||||
|
|
||||||
+define dso_local void @tailcall(ptr %p) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" {
|
|
||||||
+; I386-LABEL: tailcall:
|
|
||||||
+; I386: # %bb.0:
|
|
||||||
+; I386-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
||||||
+; I386-NEXT: jmpl *(%eax) # TAILCALL
|
|
||||||
+;
|
|
||||||
+; X86-64-LABEL: tailcall:
|
|
||||||
+; X86-64: # %bb.0:
|
|
||||||
+; X86-64-NEXT: jmpq *(%rdi) # TAILCALL
|
|
||||||
+ %c = load ptr, ptr %p
|
|
||||||
+ tail call void %c()
|
|
||||||
+ ret void
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
; Don't emit zeroing registers in "main" function.
|
|
||||||
define dso_local i32 @main() local_unnamed_addr #1 {
|
|
||||||
; I386-LABEL: main:
|
|
||||||
--
|
|
||||||
2.43.0
|
|
||||||
|
|
||||||
@ -1,246 +0,0 @@
|
|||||||
From 60ff801d1ea96ab964039cc1ed42e1dca0a63d54 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Anton Sidorenko <anton.sidorenko@syntacore.com>
|
|
||||||
Date: Tue, 6 Feb 2024 12:02:06 +0300
|
|
||||||
Subject: [PATCH] [SimplifyLibCalls] Merge sqrt into the power of exp (#79146)
|
|
||||||
|
|
||||||
Under fast-math flags it's possible to convert `sqrt(exp(X)) `into
|
|
||||||
`exp(X * 0.5)`. I suppose that this transformation is always profitable.
|
|
||||||
This is similar to the optimization existing in GCC.
|
|
||||||
---
|
|
||||||
.../llvm/Transforms/Utils/SimplifyLibCalls.h | 1 +
|
|
||||||
.../lib/Transforms/Utils/SimplifyLibCalls.cpp | 67 ++++++++++
|
|
||||||
llvm/test/Transforms/InstCombine/sqrt.ll | 120 ++++++++++++++++++
|
|
||||||
3 files changed, 188 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
|
|
||||||
index eb10545ee149..1aad0b298845 100644
|
|
||||||
--- a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
|
|
||||||
+++ b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
|
|
||||||
@@ -201,6 +201,7 @@ private:
|
|
||||||
Value *optimizeFMinFMax(CallInst *CI, IRBuilderBase &B);
|
|
||||||
Value *optimizeLog(CallInst *CI, IRBuilderBase &B);
|
|
||||||
Value *optimizeSqrt(CallInst *CI, IRBuilderBase &B);
|
|
||||||
+ Value *mergeSqrtToExp(CallInst *CI, IRBuilderBase &B);
|
|
||||||
Value *optimizeSinCosPi(CallInst *CI, bool IsSin, IRBuilderBase &B);
|
|
||||||
Value *optimizeTan(CallInst *CI, IRBuilderBase &B);
|
|
||||||
// Wrapper for all floating point library call optimizations
|
|
||||||
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
|
|
||||||
index 3ad97613fe7a..dd5bbdaaf6d3 100644
|
|
||||||
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
|
|
||||||
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
|
|
||||||
@@ -2539,6 +2539,70 @@ Value *LibCallSimplifier::optimizeLog(CallInst *Log, IRBuilderBase &B) {
|
|
||||||
return Ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
+// sqrt(exp(X)) -> exp(X * 0.5)
|
|
||||||
+Value *LibCallSimplifier::mergeSqrtToExp(CallInst *CI, IRBuilderBase &B) {
|
|
||||||
+ if (!CI->hasAllowReassoc())
|
|
||||||
+ return nullptr;
|
|
||||||
+
|
|
||||||
+ Function *SqrtFn = CI->getCalledFunction();
|
|
||||||
+ CallInst *Arg = dyn_cast<CallInst>(CI->getArgOperand(0));
|
|
||||||
+ if (!Arg || !Arg->hasAllowReassoc() || !Arg->hasOneUse())
|
|
||||||
+ return nullptr;
|
|
||||||
+ Intrinsic::ID ArgID = Arg->getIntrinsicID();
|
|
||||||
+ LibFunc ArgLb = NotLibFunc;
|
|
||||||
+ TLI->getLibFunc(*Arg, ArgLb);
|
|
||||||
+
|
|
||||||
+ LibFunc SqrtLb, ExpLb, Exp2Lb, Exp10Lb;
|
|
||||||
+
|
|
||||||
+ if (TLI->getLibFunc(SqrtFn->getName(), SqrtLb))
|
|
||||||
+ switch (SqrtLb) {
|
|
||||||
+ case LibFunc_sqrtf:
|
|
||||||
+ ExpLb = LibFunc_expf;
|
|
||||||
+ Exp2Lb = LibFunc_exp2f;
|
|
||||||
+ Exp10Lb = LibFunc_exp10f;
|
|
||||||
+ break;
|
|
||||||
+ case LibFunc_sqrt:
|
|
||||||
+ ExpLb = LibFunc_exp;
|
|
||||||
+ Exp2Lb = LibFunc_exp2;
|
|
||||||
+ Exp10Lb = LibFunc_exp10;
|
|
||||||
+ break;
|
|
||||||
+ case LibFunc_sqrtl:
|
|
||||||
+ ExpLb = LibFunc_expl;
|
|
||||||
+ Exp2Lb = LibFunc_exp2l;
|
|
||||||
+ Exp10Lb = LibFunc_exp10l;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ return nullptr;
|
|
||||||
+ }
|
|
||||||
+ else if (SqrtFn->getIntrinsicID() == Intrinsic::sqrt) {
|
|
||||||
+ if (CI->getType()->getScalarType()->isFloatTy()) {
|
|
||||||
+ ExpLb = LibFunc_expf;
|
|
||||||
+ Exp2Lb = LibFunc_exp2f;
|
|
||||||
+ Exp10Lb = LibFunc_exp10f;
|
|
||||||
+ } else if (CI->getType()->getScalarType()->isDoubleTy()) {
|
|
||||||
+ ExpLb = LibFunc_exp;
|
|
||||||
+ Exp2Lb = LibFunc_exp2;
|
|
||||||
+ Exp10Lb = LibFunc_exp10;
|
|
||||||
+ } else
|
|
||||||
+ return nullptr;
|
|
||||||
+ } else
|
|
||||||
+ return nullptr;
|
|
||||||
+
|
|
||||||
+ if (ArgLb != ExpLb && ArgLb != Exp2Lb && ArgLb != Exp10Lb &&
|
|
||||||
+ ArgID != Intrinsic::exp && ArgID != Intrinsic::exp2)
|
|
||||||
+ return nullptr;
|
|
||||||
+
|
|
||||||
+ IRBuilderBase::InsertPointGuard Guard(B);
|
|
||||||
+ B.SetInsertPoint(Arg);
|
|
||||||
+ auto *ExpOperand = Arg->getOperand(0);
|
|
||||||
+ auto *FMul =
|
|
||||||
+ B.CreateFMulFMF(ExpOperand, ConstantFP::get(ExpOperand->getType(), 0.5),
|
|
||||||
+ CI, "merged.sqrt");
|
|
||||||
+
|
|
||||||
+ Arg->setOperand(0, FMul);
|
|
||||||
+ return Arg;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilderBase &B) {
|
|
||||||
Module *M = CI->getModule();
|
|
||||||
Function *Callee = CI->getCalledFunction();
|
|
||||||
@@ -2551,6 +2615,9 @@ Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilderBase &B) {
|
|
||||||
Callee->getIntrinsicID() == Intrinsic::sqrt))
|
|
||||||
Ret = optimizeUnaryDoubleFP(CI, B, TLI, true);
|
|
||||||
|
|
||||||
+ if (Value *Opt = mergeSqrtToExp(CI, B))
|
|
||||||
+ return Opt;
|
|
||||||
+
|
|
||||||
if (!CI->isFast())
|
|
||||||
return Ret;
|
|
||||||
|
|
||||||
diff --git a/llvm/test/Transforms/InstCombine/sqrt.ll b/llvm/test/Transforms/InstCombine/sqrt.ll
|
|
||||||
index 004df3e30c72..f72fe5a6a581 100644
|
|
||||||
--- a/llvm/test/Transforms/InstCombine/sqrt.ll
|
|
||||||
+++ b/llvm/test/Transforms/InstCombine/sqrt.ll
|
|
||||||
@@ -88,7 +88,127 @@ define float @sqrt_call_fabs_f32(float %x) {
|
|
||||||
ret float %sqrt
|
|
||||||
}
|
|
||||||
|
|
||||||
+define double @sqrt_exp(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc double [[X:%.*]], 5.000000e-01
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @llvm.exp.f64(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @llvm.exp.f64(double %x)
|
|
||||||
+ %res = call reassoc double @llvm.sqrt.f64(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define double @sqrt_exp_2(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_2(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc double [[X:%.*]], 5.000000e-01
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @exp(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @exp(double %x)
|
|
||||||
+ %res = call reassoc double @sqrt(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define double @sqrt_exp2(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp2(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc double [[X:%.*]], 5.000000e-01
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @exp2(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @exp2(double %x)
|
|
||||||
+ %res = call reassoc double @sqrt(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define double @sqrt_exp10(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp10(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc double [[X:%.*]], 5.000000e-01
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @exp10(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @exp10(double %x)
|
|
||||||
+ %res = call reassoc double @sqrt(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+; Negative test
|
|
||||||
+define double @sqrt_exp_nofast_1(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_nofast_1(
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call double @llvm.exp.f64(double [[X:%.*]])
|
|
||||||
+; CHECK-NEXT: [[RES:%.*]] = call reassoc double @llvm.sqrt.f64(double [[E]])
|
|
||||||
+; CHECK-NEXT: ret double [[RES]]
|
|
||||||
+;
|
|
||||||
+ %e = call double @llvm.exp.f64(double %x)
|
|
||||||
+ %res = call reassoc double @llvm.sqrt.f64(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+; Negative test
|
|
||||||
+define double @sqrt_exp_nofast_2(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_nofast_2(
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @llvm.exp.f64(double [[X:%.*]])
|
|
||||||
+; CHECK-NEXT: [[RES:%.*]] = call double @llvm.sqrt.f64(double [[E]])
|
|
||||||
+; CHECK-NEXT: ret double [[RES]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @llvm.exp.f64(double %x)
|
|
||||||
+ %res = call double @llvm.sqrt.f64(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define double @sqrt_exp_merge_constant(double %x, double %y) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_merge_constant(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc nsz double [[X:%.*]], 5.000000e+00
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @llvm.exp.f64(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %mul = fmul reassoc nsz double %x, 10.0
|
|
||||||
+ %e = call reassoc double @llvm.exp.f64(double %mul)
|
|
||||||
+ %res = call reassoc nsz double @llvm.sqrt.f64(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define double @sqrt_exp_intr_and_libcall(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_intr_and_libcall(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc double [[X:%.*]], 5.000000e-01
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @exp(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @exp(double %x)
|
|
||||||
+ %res = call reassoc double @llvm.sqrt.f64(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define double @sqrt_exp_intr_and_libcall_2(double %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_intr_and_libcall_2(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc double [[X:%.*]], 5.000000e-01
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc double @llvm.exp.f64(double [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret double [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc double @llvm.exp.f64(double %x)
|
|
||||||
+ %res = call reassoc double @sqrt(double %e)
|
|
||||||
+ ret double %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define <2 x float> @sqrt_exp_vec(<2 x float> %x) {
|
|
||||||
+; CHECK-LABEL: @sqrt_exp_vec(
|
|
||||||
+; CHECK-NEXT: [[MERGED_SQRT:%.*]] = fmul reassoc <2 x float> [[X:%.*]], <float 5.000000e-01, float 5.000000e-01>
|
|
||||||
+; CHECK-NEXT: [[E:%.*]] = call reassoc <2 x float> @llvm.exp.v2f32(<2 x float> [[MERGED_SQRT]])
|
|
||||||
+; CHECK-NEXT: ret <2 x float> [[E]]
|
|
||||||
+;
|
|
||||||
+ %e = call reassoc <2 x float> @llvm.exp.v2f32(<2 x float> %x)
|
|
||||||
+ %res = call reassoc <2 x float> @llvm.sqrt.v2f32(<2 x float> %e)
|
|
||||||
+ ret <2 x float> %res
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
declare i32 @foo(double)
|
|
||||||
declare double @sqrt(double) readnone
|
|
||||||
declare float @sqrtf(float)
|
|
||||||
declare float @llvm.fabs.f32(float)
|
|
||||||
+declare double @llvm.exp.f64(double)
|
|
||||||
+declare double @llvm.sqrt.f64(double)
|
|
||||||
+declare double @exp(double)
|
|
||||||
+declare double @exp2(double)
|
|
||||||
+declare double @exp10(double)
|
|
||||||
+declare <2 x float> @llvm.exp.v2f32(<2 x float>)
|
|
||||||
+declare <2 x float> @llvm.sqrt.v2f32(<2 x float>)
|
|
||||||
--
|
|
||||||
2.38.1.windows.1
|
|
||||||
|
|
||||||
@ -1,187 +0,0 @@
|
|||||||
From fdbf1bd9f1bdec32384eda47f419d895d11a1c50 Mon Sep 17 00:00:00 2001
|
|
||||||
From: XingYuShuai <1150775134@qq.com>
|
|
||||||
Date: Wed, 15 May 2024 14:42:27 +0800
|
|
||||||
Subject: [PATCH] [LICM] Solve runtime error caused by the signal function.
|
|
||||||
|
|
||||||
Using the option enable-signal to control whether to solve the
|
|
||||||
runtime error caused by the signal function when lto is turned on.
|
|
||||||
---
|
|
||||||
llvm/cmake/modules/HandleLLVMOptions.cmake | 8 ++++
|
|
||||||
llvm/lib/Transforms/Scalar/LICM.cpp | 47 +++++++++++++++++++
|
|
||||||
.../Transforms/LICM/signal-before-loop-2.ll | 25 ++++++++++
|
|
||||||
.../Transforms/LICM/signal-before-loop.ll | 25 ++++++++++
|
|
||||||
llvm/test/lit.site.cfg.py.in | 1 +
|
|
||||||
5 files changed, 106 insertions(+)
|
|
||||||
create mode 100644 llvm/test/Transforms/LICM/signal-before-loop-2.ll
|
|
||||||
create mode 100644 llvm/test/Transforms/LICM/signal-before-loop.ll
|
|
||||||
|
|
||||||
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
|
||||||
index b8e9dbe29d88..8be5d4ba52c2 100644
|
|
||||||
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
|
|
||||||
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
|
|
||||||
@@ -120,6 +120,14 @@ else()
|
|
||||||
set(LLVM_ENABLE_AUTOTUNER 0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
+option(LLVM_BUILD_FOR_COMMON "" ON)
|
|
||||||
+if(LLVM_BUILD_FOR_COMMON)
|
|
||||||
+ set(LLVM_BUILD_FOR_COMMON 1)
|
|
||||||
+ add_definitions( -DBUILD_FOR_COMMON )
|
|
||||||
+else()
|
|
||||||
+ set(LLVM_BUILD_FOR_COMMON 0)
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
if(LLVM_ENABLE_EXPENSIVE_CHECKS)
|
|
||||||
add_compile_definitions(EXPENSIVE_CHECKS)
|
|
||||||
|
|
||||||
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
|
|
||||||
index f8fab03f151d..2feec759f240 100644
|
|
||||||
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
|
|
||||||
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
|
|
||||||
@@ -44,6 +44,9 @@
|
|
||||||
#include "llvm/Analysis/AliasSetTracker.h"
|
|
||||||
#include "llvm/Analysis/AssumptionCache.h"
|
|
||||||
#include "llvm/Analysis/CaptureTracking.h"
|
|
||||||
+#ifdef BUILD_FOR_COMMON
|
|
||||||
+#include "llvm/Analysis/CFG.h"
|
|
||||||
+#endif // BUILD_FOR_COMMON
|
|
||||||
#include "llvm/Analysis/GuardUtils.h"
|
|
||||||
#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
|
|
||||||
#include "llvm/Analysis/Loads.h"
|
|
||||||
@@ -122,6 +125,13 @@ static cl::opt<bool>
|
|
||||||
SingleThread("licm-force-thread-model-single", cl::Hidden, cl::init(false),
|
|
||||||
cl::desc("Force thread model single in LICM pass"));
|
|
||||||
|
|
||||||
+#ifdef BUILD_FOR_COMMON
|
|
||||||
+static cl::opt<bool> DisableMovStoreInsOutsideOfLoopInSigFun(
|
|
||||||
+ "disable-move-store-ins-outside-of-loop",
|
|
||||||
+ cl::Hidden, cl::init(true), cl::desc("Disable move store instruction"
|
|
||||||
+ "outside of loop in signal function."));
|
|
||||||
+#endif // BUILD_FOR_COMMON
|
|
||||||
+
|
|
||||||
static cl::opt<uint32_t> MaxNumUsesTraversed(
|
|
||||||
"licm-max-num-uses-traversed", cl::Hidden, cl::init(8),
|
|
||||||
cl::desc("Max num uses visited for identifying load "
|
|
||||||
@@ -2075,8 +2085,45 @@ bool llvm::promoteLoopAccessesToScalars(
|
|
||||||
for (Use &U : ASIV->uses()) {
|
|
||||||
// Ignore instructions that are outside the loop.
|
|
||||||
Instruction *UI = dyn_cast<Instruction>(U.getUser());
|
|
||||||
+ #if defined(BUILD_FOR_COMMON)
|
|
||||||
+ if (DisableMovStoreInsOutsideOfLoopInSigFun) {
|
|
||||||
+ if (!UI)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ // In the following scenario, there will be a loop index store
|
|
||||||
+ // instruction that is moved outside the loop and when the termination
|
|
||||||
+ // loop is triggered by the signal function, the store instruction is not
|
|
||||||
+ // executed.However, the function registered by the signal will read the
|
|
||||||
+ // data sored in the store instruction, so the data read is incorrect.
|
|
||||||
+ // Solution: Prevent the store instruction form going outside the loop.
|
|
||||||
+ // NOTE: The sys_signal function takes the same arguments and performs
|
|
||||||
+ // the same task as signal. They all belong to glic.
|
|
||||||
+ if(StoreSafety == StoreSafe && !CurLoop->contains(UI)) {
|
|
||||||
+ if(LoadInst *NotCurLoopLoad = dyn_cast<LoadInst>(UI)) {
|
|
||||||
+ Function *NotCurLoopFun = UI->getParent()->getParent();
|
|
||||||
+ for (Use &UseFun : NotCurLoopFun->uses()) {
|
|
||||||
+ CallInst *Call = dyn_cast<CallInst>(UseFun.getUser());
|
|
||||||
+ if (Call && Call->getCalledFunction() &&
|
|
||||||
+ (Call->getCalledFunction()->getName() == "__sysv_signal" ||
|
|
||||||
+ Call->getCalledFunction()->getName() == "signal") &&
|
|
||||||
+ isPotentiallyReachable(Call->getParent(),
|
|
||||||
+ CurLoop->getLoopPreheader(),NULL,DT,
|
|
||||||
+ LI))
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!CurLoop->contains(UI))
|
|
||||||
+ continue;
|
|
||||||
+ } else {
|
|
||||||
+ if (!UI || !CurLoop->contains(UI))
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+#else
|
|
||||||
if (!UI || !CurLoop->contains(UI))
|
|
||||||
continue;
|
|
||||||
+#endif // BUILD_FOR_COMMON
|
|
||||||
|
|
||||||
// If there is an non-load/store instruction in the loop, we can't promote
|
|
||||||
// it.
|
|
||||||
diff --git a/llvm/test/Transforms/LICM/signal-before-loop-2.ll b/llvm/test/Transforms/LICM/signal-before-loop-2.ll
|
|
||||||
new file mode 100644
|
|
||||||
index 000000000000..da878c6c691b
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/llvm/test/Transforms/LICM/signal-before-loop-2.ll
|
|
||||||
@@ -0,0 +1,25 @@
|
|
||||||
+; REQUIRES: enable_build_for_common
|
|
||||||
+; RUN:opt -disable-move-store-ins-outside-of-loop=true -S < %s | FileCheck %s
|
|
||||||
+
|
|
||||||
+@Run_Index = external global i64
|
|
||||||
+
|
|
||||||
+declare ptr @signal(ptr)
|
|
||||||
+
|
|
||||||
+define void @report() {
|
|
||||||
+entry:
|
|
||||||
+ %0 = load i64, ptr @Run_Index, align 8
|
|
||||||
+ unreachable
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define i32 @main() {
|
|
||||||
+if.end:
|
|
||||||
+ %call.i4 = call ptr @signal(ptr @report)
|
|
||||||
+ br label %for.cond
|
|
||||||
+
|
|
||||||
+; CHECK-LABEL: for.cond
|
|
||||||
+; CHECK: store
|
|
||||||
+for.cond:
|
|
||||||
+ %0 = load i64, ptr @Run_Index, align 8
|
|
||||||
+ store i64 %0, ptr @Run_Index, align 8
|
|
||||||
+ br label %for.cond
|
|
||||||
+}
|
|
||||||
diff --git a/llvm/test/Transforms/LICM/signal-before-loop.ll b/llvm/test/Transforms/LICM/signal-before-loop.ll
|
|
||||||
new file mode 100644
|
|
||||||
index 000000000000..cfae4e87db56
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/llvm/test/Transforms/LICM/signal-before-loop.ll
|
|
||||||
@@ -0,0 +1,25 @@
|
|
||||||
+; REQUIRES: enable_build_for_common
|
|
||||||
+; RUN:opt -disable-move-store-ins-outside-of-loop=true -S < %s | FileCheck %s
|
|
||||||
+
|
|
||||||
+@Run_Index = external global i64
|
|
||||||
+
|
|
||||||
+declare ptr @__sysv_signal(ptr)
|
|
||||||
+
|
|
||||||
+define void @report() {
|
|
||||||
+entry:
|
|
||||||
+ %0 = load i64, ptr @Run_Index, align 8
|
|
||||||
+ unreachable
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+define i32 @main() {
|
|
||||||
+if.end:
|
|
||||||
+ %call.i4 = call ptr @__sysv_signal(ptr @report)
|
|
||||||
+ br label %for.cond
|
|
||||||
+
|
|
||||||
+; CHECK-LABEL: for.cond
|
|
||||||
+; CHECK: store
|
|
||||||
+for.cond:
|
|
||||||
+ %0 = load i64, ptr @Run_Index, align 8
|
|
||||||
+ store i64 %0, ptr @Run_Index, align 8
|
|
||||||
+ br label %for.cond
|
|
||||||
+}
|
|
||||||
diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
|
|
||||||
index 0e9396e3b014..20c1ecca1d43 100644
|
|
||||||
--- a/llvm/test/lit.site.cfg.py.in
|
|
||||||
+++ b/llvm/test/lit.site.cfg.py.in
|
|
||||||
@@ -63,6 +63,7 @@ config.dxil_tests = @LLVM_INCLUDE_DXIL_TESTS@
|
|
||||||
config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
|
|
||||||
config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@
|
|
||||||
config.enable_enable_autotuner = @LLVM_ENABLE_AUTOTUNER@
|
|
||||||
+config.enable_build_for_common = @LLVM_BUILD_FOR_COMMON@
|
|
||||||
|
|
||||||
import lit.llvm
|
|
||||||
lit.llvm.initialize(lit_config, config)
|
|
||||||
--
|
|
||||||
2.38.1.windows.1
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
|||||||
From d4cfa4fd4496735ea45afcd2b0cfb3607cadd1c9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: yinrun <lvyinrun@huawei.com>
|
|
||||||
Date: Thu, 17 Oct 2024 18:47:40 +0800
|
|
||||||
Subject: [PATCH] Find Python3 in default env PATH for ACPO
|
|
||||||
|
|
||||||
Enable the use of user python version, avoid the wrong version of python without AI infra.
|
|
||||||
---
|
|
||||||
llvm/lib/Analysis/ACPOMLInterface.cpp | 10 +++++++++-
|
|
||||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/llvm/lib/Analysis/ACPOMLInterface.cpp b/llvm/lib/Analysis/ACPOMLInterface.cpp
|
|
||||||
index f48eb46638e3..7d84bd5112d6 100644
|
|
||||||
--- a/llvm/lib/Analysis/ACPOMLInterface.cpp
|
|
||||||
+++ b/llvm/lib/Analysis/ACPOMLInterface.cpp
|
|
||||||
@@ -146,7 +146,15 @@ ACPOMLPythonInterface::ACPOMLPythonInterface() : NextID{0} {
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t PID = (int32_t) llvm::sys::Process::getProcessId();
|
|
||||||
- std::string ExecPython = "/usr/bin/python3";
|
|
||||||
+ std::string ExecPython;
|
|
||||||
+ llvm::ErrorOr<std::string> Res = llvm::sys::findProgramByName("python3");
|
|
||||||
+ if (std::error_code EC = Res.getError()) {
|
|
||||||
+ LLVM_DEBUG(dbgs() << "python3 could not be found, error_code " << EC.value() << "\n");
|
|
||||||
+ return;
|
|
||||||
+ } else {
|
|
||||||
+ ExecPython = Res.get();
|
|
||||||
+ LLVM_DEBUG(dbgs() << "python3 version found in " << ExecPython << "\n");
|
|
||||||
+ }
|
|
||||||
std::string
|
|
||||||
PythonScript = *Env + "/" + std::string(ACPO_ML_PYTHON_INTERFACE_PY);
|
|
||||||
std::string PIDStr = std::to_string(PID);
|
|
||||||
--
|
|
||||||
2.38.1.windows.1
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
34
llvm.spec
34
llvm.spec
@ -5,7 +5,6 @@
|
|||||||
%bcond_with classic_flang
|
%bcond_with classic_flang
|
||||||
%bcond_with toolchain_clang
|
%bcond_with toolchain_clang
|
||||||
%bcond_without bisheng_autotuner
|
%bcond_without bisheng_autotuner
|
||||||
%bcond_without ACPO
|
|
||||||
|
|
||||||
%if %{with toolchain_clang}
|
%if %{with toolchain_clang}
|
||||||
%global toolchain clang
|
%global toolchain clang
|
||||||
@ -47,7 +46,7 @@
|
|||||||
|
|
||||||
Name: %{pkg_name}
|
Name: %{pkg_name}
|
||||||
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
|
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
|
||||||
Release: 29
|
Release: 23
|
||||||
Summary: The Low Level Virtual Machine
|
Summary: The Low Level Virtual Machine
|
||||||
|
|
||||||
License: NCSA
|
License: NCSA
|
||||||
@ -85,13 +84,6 @@ Patch24: 0024-Backport-LoongArch-fix-and-add-some-new-support.patch
|
|||||||
Patch25: 0025-Backport-Simple-check-to-ignore-Inline-asm-fwait-insertion.patch
|
Patch25: 0025-Backport-Simple-check-to-ignore-Inline-asm-fwait-insertion.patch
|
||||||
Patch26: 0026-Add-arch-restriction-for-BiSheng-Autotuner.patch
|
Patch26: 0026-Add-arch-restriction-for-BiSheng-Autotuner.patch
|
||||||
Patch27: 0027-AArch64-Delete-hip09-macro.patch
|
Patch27: 0027-AArch64-Delete-hip09-macro.patch
|
||||||
Patch28: 0028-backport-Clang-Fix-crash-with-fzero-call-used-regs.patch
|
|
||||||
Patch29: 0029-SimplifyLibCalls-Merge-sqrt-into-the-power-of-exp-79.patch
|
|
||||||
Patch30: 0030-LICM-Solve-runtime-error-caused-by-the-signal-functi.patch
|
|
||||||
Patch31: 0031-ACPO-ACPO-Infrastructure.patch
|
|
||||||
Patch32: 0032-ACPO-Introduce-MLInliner-using-ACPO-infrastructure.patch
|
|
||||||
Patch33: 0033-Find-Python3-in-default-env-PATH-for-ACPO.patch
|
|
||||||
Patch34: 0034-AArch64-Support-HiSilicon-s-HIP09-sched-model.patch
|
|
||||||
|
|
||||||
BuildRequires: binutils-devel
|
BuildRequires: binutils-devel
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
@ -207,12 +199,6 @@ pathfix.py -i %{__python3} -pn \
|
|||||||
utils/update_cc_test_checks.py
|
utils/update_cc_test_checks.py
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%if %{with ACPO}
|
|
||||||
echo "enable ACPO"
|
|
||||||
export CFLAGS="-Wp,-DENABLE_ACPO ${CFLAGS}"
|
|
||||||
export CXXFLAGS="-Wp,-DENABLE_ACPO ${CXXFLAGS}"
|
|
||||||
%endif
|
|
||||||
|
|
||||||
%cmake -G Ninja \
|
%cmake -G Ninja \
|
||||||
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||||
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
|
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
|
||||||
@ -391,24 +377,6 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake
|
|||||||
%{install_includedir}/llvm-gmock
|
%{install_includedir}/llvm-gmock
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Fri Nov 22 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-29
|
|
||||||
- [AArch64] Support HiSilicon's HIP09 sched model
|
|
||||||
|
|
||||||
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-28
|
|
||||||
- Find Python3 in default env PATH for ACPO
|
|
||||||
|
|
||||||
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-27
|
|
||||||
- ACPO Infrastructure for ML integration into LLVM compiler
|
|
||||||
|
|
||||||
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-26
|
|
||||||
- [LICM] Solve runtime error caused by the signal function.
|
|
||||||
|
|
||||||
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-25
|
|
||||||
- [SimplifyLibCalls] Merge sqrt into the power of exp (#79146)
|
|
||||||
|
|
||||||
* Tue Nov 19 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-24
|
|
||||||
- [backport][Clang] Fix crash with -fzero-call-used-regs
|
|
||||||
|
|
||||||
* Mon Nov 18 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-23
|
* Mon Nov 18 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-23
|
||||||
- [AArch64] Delete hip09 macro
|
- [AArch64] Delete hip09 macro
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user