Skip to content

Commit

Permalink
Merged master:f233b92f92a into amd-gfx:0319e206077
Browse files Browse the repository at this point in the history
Local branch amd-gfx 0319e20 Merged master:d3849dddd26 into amd-gfx:e4688907c11
Remote branch master f233b92 [PGO][PGSO] Add profile guided size optimization to LegalizeDAG.
  • Loading branch information
Sw authored and Sw committed Jul 15, 2020
2 parents 0319e20 + f233b92 commit d4155ad
Show file tree
Hide file tree
Showing 31 changed files with 549 additions and 171 deletions.
60 changes: 60 additions & 0 deletions clang/test/CodeGen/ppc-aggregate-abi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -x c++ \
// RUN: -o - %s | FileCheck %s -check-prefix=CHECK-BE
// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm -x c++ \
// RUN: -o - %s | FileCheck %s -check-prefix=CHECK-LE

class agg_float_class { float a; };
// CHECK-BE-LABEL: define void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret align 4 %{{.*}}, float inreg %{{.*}})
// CHECK-LE-LABEL: define [1 x float] @_Z20pass_agg_float_class15agg_float_class(float inreg %{{.*}})
agg_float_class pass_agg_float_class(agg_float_class arg) { return arg; }

class agg_double_class { double a; };
// CHECK-BE-LABEL: define void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret align 8 %{{.*}}, double inreg %{{.*}})
// CHECK-LE-LABEL: define [1 x double] @_Z21pass_agg_double_class16agg_double_class(double inreg %{{.*}})
agg_double_class pass_agg_double_class(agg_double_class arg) { return arg; }

struct agg_float_cpp { float a; int : 0; };
// CHECK-BE-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, float inreg %{{.*}})
// CHECK-LE-LABEL: define [1 x float] @_Z18pass_agg_float_cpp13agg_float_cpp(float inreg %{{.*}})
agg_float_cpp pass_agg_float_cpp(agg_float_cpp arg) { return arg; }

struct empty { };
struct agg_nofloat_empty { float a; empty dummy; };
// CHECK-BE-LABEL: define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}})
// CHECK-LE-LABEL: define i64 @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(i64 %{{.*}})
agg_nofloat_empty pass_agg_nofloat_empty(agg_nofloat_empty arg) { return arg; }

struct agg_float_empty { float a; [[no_unique_address]] empty dummy; };
// CHECK-BE-LABEL: define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, float inreg %{{.*}})
// CHECK-LE-LABEL: define [1 x float] @_Z20pass_agg_float_empty15agg_float_empty(float inreg %{{.*}})
agg_float_empty pass_agg_float_empty(agg_float_empty arg) { return arg; }

struct agg_nofloat_emptyarray { float a; [[no_unique_address]] empty dummy[3]; };
// CHECK-BE-LABEL: define void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret align 4 %{{.*}}, i64 %{{.*}})
// CHECK-LE-LABEL: define i64 @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(i64 %{{.*}})
agg_nofloat_emptyarray pass_agg_nofloat_emptyarray(agg_nofloat_emptyarray arg) { return arg; }

struct noemptybase { empty dummy; };
struct agg_nofloat_emptybase : noemptybase { float a; };
// CHECK-BE-LABEL: define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}})
// CHECK-LE-LABEL: define i64 @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(i64 %{{.*}})
agg_nofloat_emptybase pass_agg_nofloat_emptybase(agg_nofloat_emptybase arg) { return arg; }

struct emptybase { [[no_unique_address]] empty dummy; };
struct agg_float_emptybase : emptybase { float a; };
// CHECK-BE-LABEL: define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, float inreg %{{.*}})
// CHECK-LE-LABEL: define [1 x float] @_Z24pass_agg_float_emptybase19agg_float_emptybase(float inreg %{{.*}})
agg_float_emptybase pass_agg_float_emptybase(agg_float_emptybase arg) { return arg; }

struct noemptybasearray { [[no_unique_address]] empty dummy[3]; };
struct agg_nofloat_emptybasearray : noemptybasearray { float a; };
// CHECK-BE-LABEL: define void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret align 4 %{{.*}}, i64 %{{.*}})
// CHECK-LE-LABEL: define i64 @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(i64 %{{.*}})
agg_nofloat_emptybasearray pass_agg_nofloat_emptybasearray(agg_nofloat_emptybasearray arg) { return arg; }

// CHECK-BE: call void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* sret align 4 %{{.*}}, float inreg %{{.*}})
// CHECK-LE: call [1 x float] @_Z24pass_agg_float_emptybase19agg_float_emptybase(float inreg %{{.*}})
void pass_agg_float_emptybase_ptr(agg_float_emptybase* arg) { pass_agg_float_emptybase(*arg); }
// CHECK-BE: call void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* sret align 4 %{{.*}}, i64 %{{.*}})
// CHECK-LE: call i64 @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(i64 %{{.*}})
void pass_agg_nofloat_emptybase_ptr(agg_nofloat_emptybase* arg) { pass_agg_nofloat_emptybase(*arg); }
8 changes: 4 additions & 4 deletions lldb/packages/Python/lldbsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
def find_lldb_root():
lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
while True:
lldb_root = os.path.dirname(lldb_root)
if lldb_root is None:
return None
parent = os.path.dirname(lldb_root)
if parent == lldb_root: # dirname('/') == '/'
raise Exception("use_lldb_suite_root.py not found")
lldb_root = parent

test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
if os.path.isfile(test_path):
return lldb_root
return None

# lldbsuite.lldb_root refers to the root of the git/svn source checkout
lldb_root = find_lldb_root()
Expand Down
27 changes: 0 additions & 27 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,6 @@ def setUp(self):
# List of spawned subproces.Popen objects
self.subprocesses = []

# List of forked process PIDs
self.forkedProcessPids = []

# List of log files produced by the current test.
self.log_files = []

Expand Down Expand Up @@ -892,13 +889,6 @@ def cleanupSubprocesses(self):
p.terminate()
del p
del self.subprocesses[:]
# Ensure any forked processes are cleaned up
for pid in self.forkedProcessPids:
try:
os.kill(pid, signal.SIGTERM)
except OSError:
pass
del self.forkedProcessPids[:]

def spawnSubprocess(self, executable, args=[], install_remote=True):
""" Creates a subprocess.Popen object with the specified executable and arguments,
Expand All @@ -910,23 +900,6 @@ def spawnSubprocess(self, executable, args=[], install_remote=True):
self.subprocesses.append(proc)
return proc

def forkSubprocess(self, executable, args=[]):
""" Fork a subprocess with its own group ID.
"""
child_pid = os.fork()
if child_pid == 0:
# If more I/O support is required, this can be beefed up.
fd = os.open(os.devnull, os.O_RDWR)
os.dup2(fd, 1)
os.dup2(fd, 2)
# This call causes the child to have its of group ID
os.setpgid(0, 0)
os.execvp(executable, [executable] + args)
# Give the child time to get through the execvp() call
time.sleep(0.1)
self.forkedProcessPids.append(child_pid)
return child_pid

def HideStdout(self):
"""Hide output to stdout from the user.
Expand Down
18 changes: 8 additions & 10 deletions lldb/scripts/use_lldb_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ def find_lldb_root():
while True:
parent = os.path.dirname(lldb_root)
if parent == lldb_root: # dirname('/') == '/'
break
raise Exception("use_lldb_suite_root.py not found")
lldb_root = parent

test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
if os.path.isfile(test_path):
return lldb_root
return None

lldb_root = find_lldb_root()
if lldb_root is not None:
import imp
fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
try:
imp.load_module("use_lldb_suite_root", fp, pathname, desc)
finally:
if fp:
fp.close()
import imp
fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
try:
imp.load_module("use_lldb_suite_root", fp, pathname, desc)
finally:
if fp:
fp.close()
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,6 @@ class CreateAfterAttachTestCase(TestBase):

mydir = TestBase.compute_mydir(__file__)

@skipIfFreeBSD # Hangs. May be the same as Linux issue llvm.org/pr16229 but
# not yet investigated. Revisit once required functionality
# is implemented for FreeBSD.
# Occasionally hangs on Windows, may be same as other issues.
@skipIfWindows
@skipIfiOSSimulator
@expectedFailureNetBSD
def test_create_after_attach_with_popen(self):
"""Test thread creation after process attach."""
self.build(dictionary=self.getBuildFlags(use_cpp11=False))
self.create_after_attach(use_fork=False)

@skipIfFreeBSD # Hangs. Revisit once required functionality is implemented
# for FreeBSD.
@skipIfRemote
@skipIfWindows # Windows doesn't have fork.
@skipIfiOSSimulator
@expectedFailureNetBSD
def test_create_after_attach_with_fork(self):
"""Test thread creation after process attach."""
self.build(dictionary=self.getBuildFlags(use_cpp11=False))
self.create_after_attach(use_fork=True)

def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
Expand All @@ -45,17 +22,21 @@ def setUp(self):
self.break_2 = line_number('main.cpp', '// Set second breakpoint here')
self.break_3 = line_number('main.cpp', '// Set third breakpoint here')

def create_after_attach(self, use_fork):
@skipIfFreeBSD # Hangs. May be the same as Linux issue llvm.org/pr16229 but
# not yet investigated. Revisit once required functionality
# is implemented for FreeBSD.
# Occasionally hangs on Windows, may be same as other issues.
@skipIfWindows
@skipIfiOSSimulator
@expectedFailureNetBSD
def test_create_after_attach(self):
"""Test thread creation after process attach."""

self.build(dictionary=self.getBuildFlags(use_cpp11=False))
exe = self.getBuildArtifact("a.out")

# Spawn a new process
if use_fork:
pid = self.forkSubprocess(exe)
else:
popen = self.spawnSubprocess(exe)
pid = popen.pid
popen = self.spawnSubprocess(exe)
pid = popen.pid

# Attach to the spawned process
self.runCmd("process attach -p " + str(pid))
Expand Down
24 changes: 12 additions & 12 deletions lldb/test/API/use_lldb_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ def find_lldb_root():
os.path.abspath(inspect.getfile(inspect.currentframe()))
)
while True:
lldb_root = os.path.dirname(lldb_root)
if lldb_root is None:
return None
parent = os.path.dirname(lldb_root)
if parent == lldb_root: # dirname('/') == '/'
raise Exception("use_lldb_suite_root.py not found")
lldb_root = parent

test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
if os.path.isfile(test_path):
return lldb_root
return None

lldb_root = find_lldb_root()
if lldb_root is not None:
import imp
fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
try:
imp.load_module("use_lldb_suite_root", fp, pathname, desc)
finally:
if fp:
fp.close()

import imp
fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
try:
imp.load_module("use_lldb_suite_root", fp, pathname, desc)
finally:
if fp:
fp.close()
12 changes: 8 additions & 4 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,12 @@ SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {
SmallVector<SDValue, 8> Stores;
unsigned TypeByteSize = MemVT.getSizeInBits() / 8;
assert(TypeByteSize > 0 && "Vector element type too small for stack store!");

// If the destination vector element type of a BUILD_VECTOR is narrower than
// the source element type, only store the bits necessary.
bool Truncate = isa<BuildVectorSDNode>(Node) &&
MemVT.bitsLT(Node->getOperand(0).getValueType());

// Store (in the right endianness) the elements to memory.
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
// Ignore undef elements.
Expand All @@ -1420,9 +1426,7 @@ SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {

SDValue Idx = DAG.getMemBasePlusOffset(FIPtr, Offset, dl);

// If the destination vector element type is narrower than the source
// element type, only store the bits necessary.
if (MemVT.bitsLT(Node->getOperand(i).getValueType()))
if (Truncate)
Stores.push_back(DAG.getTruncStore(DAG.getEntryNode(), dl,
Node->getOperand(i), Idx,
PtrInfo.getWithOffset(Offset), MemVT));
Expand Down Expand Up @@ -3315,7 +3319,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
// Check to see if this FP immediate is already legal.
// If this is a legal constant, turn it into a TargetConstantFP node.
if (!TLI.isFPImmLegal(CFP->getValueAPF(), Node->getValueType(0),
DAG.getMachineFunction().getFunction().hasOptSize()))
DAG.shouldOptForSize()))
Results.push_back(ExpandConstantFP(CFP, true));
break;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Passes/PassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ FUNCTION_PASS_WITH_PARAMS("print<stack-lifetime>",
LOOP_ANALYSIS("no-op-loop", NoOpLoopAnalysis())
LOOP_ANALYSIS("access-info", LoopAccessAnalysis())
LOOP_ANALYSIS("ddg", DDGAnalysis())
LOOP_ANALYSIS("ivusers", IVUsersAnalysis())
LOOP_ANALYSIS("iv-users", IVUsersAnalysis())
LOOP_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
#undef LOOP_ANALYSIS

Expand All @@ -338,7 +338,7 @@ LOOP_PASS("indvars", IndVarSimplifyPass())
LOOP_PASS("loop-unroll-full", LoopFullUnrollPass())
LOOP_PASS("print-access-info", LoopAccessInfoPrinterPass(dbgs()))
LOOP_PASS("print<ddg>", DDGAnalysisPrinterPass(dbgs()))
LOOP_PASS("print<ivusers>", IVUsersPrinterPass(dbgs()))
LOOP_PASS("print<iv-users>", IVUsersPrinterPass(dbgs()))
LOOP_PASS("print<loopnest>", LoopNestPrinterPass(dbgs()))
LOOP_PASS("print<loop-cache-cost>", LoopCachePrinterPass(dbgs()))
LOOP_PASS("loop-predication", LoopPredicationPass())
Expand Down
Loading

0 comments on commit d4155ad

Please sign in to comment.