From 1f6a6086aedbb08e6cd788de5ee85c7ac99c7175 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Wed, 22 Jan 2014 18:32:35 +0000 Subject: Fix inline assembly that switches between ARM and Thumb modes This patch restores the ARM mode if the user's inline assembly does not. In the object streamer, it ensures that instructions following the inline assembly are encoded correctly and that correct mapping symbols are emitted. For the asm streamer, it emits a .arm or .thumb directive. This patch does not ensure that the inline assembly contains the ADR instruction to switch modes at runtime. The problem we need to solve is code like this: int foo(int a, int b) { int r = a + b; asm volatile( ".align 2 \n" ".arm \n" "add r0,r0,r0 \n" : : "r"(r)); return r+1; } If we compile this function in thumb mode then the inline assembly will switch to arm mode. We need to make sure that we switch back to thumb mode after emitting the inline assembly or we will incorrectly encode the instructions that follow (i.e. the assembly instructions for return r+1). Based on patch by David Peixotto Change-Id: Ib57f6d2d78a22afad5de8693fba6230ff56ba48b llvm-svn: 199818 --- llvm/lib/MC/MCStreamer.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'llvm/lib/MC') diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 11b9c58957e..5ba28d2099d 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -25,7 +25,6 @@ using namespace llvm; // Pin the vtables to this file. MCTargetStreamer::~MCTargetStreamer() {} void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {} -void ARMTargetStreamer::anchor() {} MCStreamer::MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer) : Context(Ctx), TargetStreamer(TargetStreamer), EmitEHFrame(true), -- cgit v1.2.3