From 80629c85f1041df41b5158ebb03a4725af6ecd90 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 19 Oct 2007 21:09:55 +0000 Subject: [PATCH] Don't branch fold inline asm statements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43191 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/BranchFolding.cpp | 3 ++- test/CFrontend/2007-10-15-VoidPtr.c | 3 +-- .../2007-10-19-InlineAsmDirectives.ll | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 test/Transforms/BranchFolding/2007-10-19-InlineAsmDirectives.ll diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 055302f153a..d523bf585ae 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -271,7 +271,8 @@ static unsigned ComputeCommonTailLength(MachineBasicBlock *MBB1, unsigned TailLen = 0; while (I1 != MBB1->begin() && I2 != MBB2->begin()) { --I1; --I2; - if (!I1->isIdenticalTo(I2)) { + if (!I1->isIdenticalTo(I2) || + I1->getOpcode() == TargetInstrInfo::INLINEASM) { ++I1; ++I2; break; } diff --git a/test/CFrontend/2007-10-15-VoidPtr.c b/test/CFrontend/2007-10-15-VoidPtr.c index 80eebdca447..c5948b93e16 100644 --- a/test/CFrontend/2007-10-15-VoidPtr.c +++ b/test/CFrontend/2007-10-15-VoidPtr.c @@ -1,5 +1,4 @@ -// RUN: llvm-gcc -S %s -o /dev/null +// RUN: %llvmgcc -S %s -o /dev/null void bork(void **data) { (*(unsigned short *) (&(data[37])[927]) = 0); } - diff --git a/test/Transforms/BranchFolding/2007-10-19-InlineAsmDirectives.ll b/test/Transforms/BranchFolding/2007-10-19-InlineAsmDirectives.ll new file mode 100644 index 00000000000..8afdcae50ae --- /dev/null +++ b/test/Transforms/BranchFolding/2007-10-19-InlineAsmDirectives.ll @@ -0,0 +1,18 @@ +; RUN: llvm-as < %s | opt -std-compile-opts -o - | llc -o - | grep bork_directive | wc -l | grep 2 + +;; We don't want branch folding to fold asm directives. + +define void @bork(i32 %param) { +entry: + %tmp = icmp eq i32 %param, 0 + br i1 %tmp, label %cond_true, label %cond_false + +cond_true: + call void asm sideeffect ".bork_directive /* ${0:c}:${1:c} */", "i,i,~{dirflag},~{fpsr},~{flags}"( i32 37, i32 927 ) + ret void + +cond_false: + call void asm sideeffect ".foo_directive ${0:c}:${1:c}", "i,i,~{dirflag},~{fpsr},~{flags}"( i32 37, i32 927 ) + call void asm sideeffect ".bork_directive /* ${0:c}:${1:c} */", "i,i,~{dirflag},~{fpsr},~{flags}"( i32 37, i32 927 ) + ret void +} -- 2.34.1